-
Notifications
You must be signed in to change notification settings - Fork 473
/
NestedList.js
766 lines (700 loc) · 24.4 KB
/
NestedList.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = require("react");
var _react2 = _interopRequireDefault(_react);
var _classnames = require("classnames");
var _classnames2 = _interopRequireDefault(_classnames);
var _reactivemaps = require("@appbaseio/reactivemaps");
var _StaticSearch = require("../addons/StaticSearch");
var _StaticSearch2 = _interopRequireDefault(_StaticSearch);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /* eslint max-lines: 0 */
var _ = require("lodash");
var NestedList = function (_Component) {
_inherits(NestedList, _Component);
function NestedList(props) {
_classCallCheck(this, NestedList);
var _this = _possibleConstructorReturn(this, (NestedList.__proto__ || Object.getPrototypeOf(NestedList)).call(this, props));
_this.state = {
items: [],
storedItems: [],
rawData: {
hits: {
hits: []
}
},
subItems: [],
selectedValues: []
};
_this.nested = ["nestedParentaggs"];
_this.sortObj = {
aggSort: _this.props.sortBy
};
_this.channelId = null;
_this.channelListener = null;
_this.urlParams = props.URLParams ? _reactivemaps.AppbaseSensorHelper.URLParams.get(props.componentId) : null;
_this.urlParams = _this.urlParams ? _this.urlParams.split("/") : null;
_this.filterBySearch = _this.filterBySearch.bind(_this);
_this.onItemSelect = _this.onItemSelect.bind(_this);
_this.onItemClick = _this.onItemClick.bind(_this);
_this.customQuery = _this.customQuery.bind(_this);
_this.handleSelect = _this.handleSelect.bind(_this);
_this.nestedAggQuery = _this.nestedAggQuery.bind(_this);
_this.type = "term";
return _this;
}
// Get the items from Appbase when component is mounted
_createClass(NestedList, [{
key: "componentWillMount",
value: function componentWillMount() {
this.previousQuery = null; // initial value for onQueryChange
this.setReact(this.props);
this.setQueryInfo();
this.createChannel();
}
}, {
key: "componentDidMount",
value: function componentDidMount() {
setTimeout(this.checkDefault.bind(this, this.props), 100);
this.listenFilter();
}
}, {
key: "componentWillReceiveProps",
value: function componentWillReceiveProps(nextProps) {
if (!_.isEqual(this.props.defaultSelected, nextProps.defaultSelected)) {
this.changeValue(nextProps.defaultSelected);
}
if (!_.isEqual(this.props.react, nextProps.react)) {
this.setReact(nextProps);
_reactivemaps.AppbaseChannelManager.update(this.channelId, this.react, nextProps.size, 0, false);
}
}
// stop streaming request and remove listener when component will unmount
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
if (this.channelId) {
_reactivemaps.AppbaseChannelManager.stopStream(this.channelId);
}
if (this.channelListener) {
this.channelListener.remove();
}
if (this.loadListenerParent) {
this.loadListenerParent.remove();
}
if (this.loadListenerChild) {
this.loadListenerChild.remove();
}
if (this.filterListener) {
this.filterListener.remove();
}
}
}, {
key: "listenFilter",
value: function listenFilter() {
var _this2 = this;
this.filterListener = _reactivemaps.AppbaseSensorHelper.sensorEmitter.addListener("clearFilter", function (data) {
if (data === _this2.props.componentId) {
_this2.changeValue(null);
}
});
}
}, {
key: "checkDefault",
value: function checkDefault(props) {
this.urlParams = props.URLParams ? _reactivemaps.AppbaseSensorHelper.URLParams.get(props.componentId) : null;
this.urlParams = this.urlParams ? this.urlParams.split("/") : null;
var defaultValue = this.urlParams !== null ? this.urlParams : props.defaultSelected;
this.changeValue(defaultValue);
}
}, {
key: "changeValue",
value: function changeValue(defaultValue) {
var _this3 = this;
if (!_.isEqual(this.defaultSelected, defaultValue)) {
this.defaultSelected = defaultValue;
var items = this.state.items;
items = items.map(function (subitems) {
subitems = Array.isArray(subitems) ? subitems.map(function (item) {
item.key = item && item.key ? item.key.toString() : null;
item.status = !!(_this3.defaultSelected && _this3.defaultSelected.length && _this3.defaultSelected.indexOf(item.key) > -1);
return item;
}) : null;
return subitems;
});
this.setState({
items: items,
storedItems: items
});
this.handleSelect(this.defaultSelected);
}
if (this.sortBy !== this.props.sortBy) {
this.sortBy = this.props.sortBy;
this.handleSortSelect();
}
}
}, {
key: "handleSelect",
value: function handleSelect(defaultSelected) {
var _this4 = this;
if (defaultSelected) {
this.defaultSelected.forEach(function (value, index) {
var customValue = defaultSelected.filter(function (item, subindex) {
return subindex <= index;
});
_this4.onItemSelect(customValue);
});
// this.onItemSelect(this.defaultSelected);
} else if (this.defaultSelected === null) {
this.onItemSelect(null);
}
}
// build query for this sensor only
}, {
key: "customQuery",
value: function customQuery(record) {
var query = null;
function generateRangeQuery(dataField) {
return record.map(function (singleRecord, index) {
return {
term: _defineProperty({}, dataField[index], singleRecord)
};
});
}
if (record && record[0] !== null) {
query = {
bool: {
must: generateRangeQuery(this.props.dataField)
}
};
}
return query;
}
// set the query type and input data
}, {
key: "setQueryInfo",
value: function setQueryInfo() {
var _this5 = this;
var getQuery = function getQuery(value) {
var currentQuery = _this5.props.customQuery ? _this5.props.customQuery(value) : _this5.customQuery(value);
if (_this5.props.onQueryChange && JSON.stringify(_this5.previousQuery) !== JSON.stringify(currentQuery)) {
_this5.props.onQueryChange(_this5.previousQuery, currentQuery);
}
_this5.previousQuery = currentQuery;
return currentQuery;
};
var obj = {
key: this.props.componentId,
value: {
queryType: this.type,
inputData: this.props.dataField[0],
customQuery: getQuery,
reactiveId: this.context.reactiveId,
showFilter: this.props.showFilter,
filterLabel: this.props.filterLabel ? this.props.filterLabel : this.props.componentId,
component: "NestedList",
defaultSelected: this.urlParams !== null ? this.urlParams : this.props.defaultSelected
}
};
_reactivemaps.AppbaseSensorHelper.selectedSensor.setSensorInfo(obj);
var nestedObj = {
key: "nestedSelectedValues-" + this.props.componentId,
value: {
queryType: this.type,
inputData: this.props.dataField[0],
customQuery: function customQuery() {}
}
};
_reactivemaps.AppbaseSensorHelper.selectedSensor.setSensorInfo(nestedObj);
}
}, {
key: "includeAggQuery",
value: function includeAggQuery() {
var _this6 = this;
this.nested.forEach(function (name) {
var obj = {
key: name,
value: _this6.sortObj
};
_reactivemaps.AppbaseSensorHelper.selectedSensor.setSortInfo(obj);
});
}
}, {
key: "handleSortSelect",
value: function handleSortSelect() {
var _this7 = this;
this.sortObj = {
aggSort: this.props.sortBy
};
this.nested.forEach(function (name) {
var obj = {
key: name,
value: _this7.sortObj
};
_reactivemaps.AppbaseSensorHelper.selectedSensor.set(obj, true, "sortChange");
});
}
}, {
key: "nestedAggQuery",
value: function nestedAggQuery() {
var _this8 = this;
var query = null;
var level = Array.isArray(this.state.selectedValues) && this.state.selectedValues.length ? this.state.selectedValues.length : 0;
var field = this.props.dataField[level];
var orderType = this.props.sortBy === "count" ? "_count" : "_term";
var sortBy = this.props.sortBy === "count" ? "desc" : this.props.sortBy;
var createTermQuery = function createTermQuery(index) {
return {
term: _defineProperty({}, _this8.props.dataField[index], _this8.state.selectedValues[index])
};
};
var createFilterQuery = function createFilterQuery(level) {
var filterMust = [];
if (level > 0) {
for (var i = 0; i <= level - 1; i++) {
filterMust.push(createTermQuery(i));
}
}
return {
bool: {
must: filterMust
}
};
};
var init = function init(field, level) {
return _defineProperty({}, field + "-" + level, {
filter: createFilterQuery(level),
aggs: _defineProperty({}, field, {
terms: {
field: field,
size: _this8.props.size,
order: _defineProperty({}, orderType, sortBy)
}
})
});
};
if (Array.isArray(this.state.selectedValues) && this.state.selectedValues.length < this.props.dataField.length) {
query = init(field, level);
}
return query;
}
}, {
key: "setReact",
value: function setReact(props) {
var react = Object.assign({}, props.react);
react.aggs = {
key: props.dataField[0],
sort: props.sortBy,
size: props.size,
customQuery: this.nestedAggQuery
};
var reactAnd = [this.nested[0], "nestedSelectedValues-" + props.componentId];
this.react = _reactivemaps.AppbaseSensorHelper.setupReact(react, reactAnd);
}
// Create a channel which passes the react and receive results whenever react changes
}, {
key: "createChannel",
value: function createChannel() {
var _this9 = this;
this.includeAggQuery();
// create a channel and listen the changes
var channelObj = _reactivemaps.AppbaseChannelManager.create(this.context.appbaseRef, this.context.type, this.react, 100, 0, false, this.props.componentId);
this.channelId = channelObj.channelId;
this.channelListener = channelObj.emitter.addListener(this.channelId, function (res) {
if (res.error) {
_this9.setState({
queryStart: false
});
}
if (res.appliedQuery && Object.keys(res.appliedQuery).length) {
_this9.queryLevel = _this9.getQueryLevel(res.appliedQuery);
_this9.setState({
queryStart: false,
rawData: res.data
});
_this9.setData(res.data, _this9.queryLevel);
}
});
this.listenLoadingChannel(channelObj, "loadListenerParent");
}
}, {
key: "getQueryLevel",
value: function getQueryLevel(appliedQuery) {
var level = 0;
try {
var field = Object.keys(appliedQuery.body.aggs)[0];
if (field) {
var appliedField = field.split("-")[0];
level = this.props.dataField.indexOf(appliedField);
level = level > -1 ? level : 0;
}
} catch (e) {
console.log(e);
}
return level;
}
}, {
key: "listenLoadingChannel",
value: function listenLoadingChannel(channelObj, listener) {
var _this10 = this;
this[listener] = channelObj.emitter.addListener(channelObj.channelId + "-query", function (res) {
if (res.appliedQuery) {
_this10.setState({
queryStart: res.queryState
});
}
});
}
}, {
key: "setData",
value: function setData(data, level) {
var fieldLevel = this.props.dataField[level] + "-" + level;
if (data && data.aggregations && data.aggregations[fieldLevel] && data.aggregations[fieldLevel][this.props.dataField[level]] && data.aggregations[fieldLevel][this.props.dataField[level]].buckets) {
this.addItemsToList(data.aggregations[fieldLevel][this.props.dataField[level]].buckets, level);
}
}
}, {
key: "addItemsToList",
value: function addItemsToList(newItems, level) {
var _this11 = this;
newItems = newItems.map(function (item) {
item.key = item.key.toString();
item.status = !!(_this11.defaultSelected && _this11.defaultSelected.indexOf(item.key) > -1);
return item;
});
var items = this.state.items;
items[level] = newItems;
this.setState({
items: items,
storedItems: items
});
}
// set value
}, {
key: "setValue",
value: function setValue(value) {
var _this12 = this;
var isExecuteQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var changeNestedValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
value = value && value.length ? value : null;
var obj = {
key: this.props.componentId,
value: value
};
var nestedObj = {
key: "nestedSelectedValues-" + this.props.componentId,
value: value
};
_reactivemaps.AppbaseSensorHelper.selectedSensor.set(nestedObj, changeNestedValue);
var execQuery = function execQuery() {
if (_this12.props.onValueChange) {
_this12.props.onValueChange(obj.value);
}
var paramValue = value && value.length ? value.join("/") : null;
if (_this12.props.URLParams) {
_reactivemaps.AppbaseSensorHelper.URLParams.update(_this12.props.componentId, paramValue, _this12.props.URLParams);
}
_reactivemaps.AppbaseSensorHelper.selectedSensor.set(obj, isExecuteQuery);
};
if (this.props.beforeValueChange) {
this.props.beforeValueChange(obj.value).then(function () {
execQuery();
}).catch(function (e) {
console.warn(_this12.props.componentId + " - beforeValueChange rejected the promise with", e);
});
} else {
execQuery();
}
}
// filter
}, {
key: "filterBySearch",
value: function filterBySearch(value) {
if (value) {
var items = this.state.storedItems[0].filter(function (item) {
return item.key && item.key.toLowerCase().indexOf(value.toLowerCase()) > -1;
});
this.setState({
items: [items]
});
} else {
this.setState({
items: this.state.storedItems
});
}
}
}, {
key: "onItemClick",
value: function onItemClick(selectedValues, level) {
selectedValues = selectedValues.split("@rbc@");
if (this.state.selectedValues && selectedValues[level] === this.state.selectedValues[level]) {
selectedValues = this.state.selectedValues.filter(function (item, index) {
return index < level;
});
var items = this.state.items;
items[level + 1] = null;
this.setState({
items: items,
selectedValues: selectedValues
}, this.setValue.bind(this, selectedValues, true, false));
} else {
this.onItemSelect(selectedValues);
}
}
}, {
key: "onItemSelect",
value: function onItemSelect(selectedValues) {
var items = this.state.items;
if (selectedValues === null) {
items = [items[0]];
} else {
items[selectedValues.length] = null;
}
this.defaultSelected = selectedValues;
this.setState({
selectedValues: selectedValues,
items: items
}, this.setValue.bind(this, selectedValues, true));
}
}, {
key: "renderChevron",
value: function renderChevron(level) {
return level < this.props.dataField.length - 1 ? _react2.default.createElement("i", { className: "fa fa-chevron-right" }) : "";
}
}, {
key: "countRender",
value: function countRender(docCount) {
var count = void 0;
if (this.props.showCount) {
count = _react2.default.createElement(
"span",
{ className: "rbc-count" },
" ",
docCount
);
}
return count;
}
}, {
key: "renderItems",
value: function renderItems(items) {
var _this13 = this;
var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var level = prefix.length;
items = items.filter(function (item) {
return item.key;
});
return items.map(function (item, index) {
item.value = prefix.concat([item.key]);
var cx = (0, _classnames2.default)({
"rbc-item-active": Array.isArray(_this13.state.selectedValues) && item.key === _this13.state.selectedValues[level],
"rbc-item-inactive": !(Array.isArray(_this13.state.selectedValues) && item.key === _this13.state.selectedValues[level])
});
if (Array.isArray(_this13.state.selectedValues) && _this13.state.selectedValues.length) {
if (item.key === _this13.state.selectedValues[level] || _this13.state.selectedValues.length === level) {
return _react2.default.createElement(
"li",
{
key: index,
className: "rbc-list-container col s12 col-xs-12"
},
_react2.default.createElement(
"button",
{ className: "rbc-list-item " + cx, onClick: function onClick() {
return _this13.onItemClick(item.value.join("@rbc@"), level);
} },
_react2.default.createElement(
"span",
{ className: "rbc-label" },
item.key,
" ",
_this13.countRender(item.doc_count)
),
_this13.renderChevron(level)
),
Array.isArray(_this13.state.selectedValues) && _this13.state.selectedValues[level] === item.key && _this13.state.items[level + 1] ? _react2.default.createElement(
"ul",
{ className: "rbc-list-container col s12 col-xs-12" },
_this13.renderItems(_this13.state.items[level + 1], item.value)
) : null
);
}
return null;
} else {
return _react2.default.createElement(
"li",
{
key: index,
className: "rbc-list-container col s12 col-xs-12"
},
_react2.default.createElement(
"button",
{ className: "rbc-list-item " + cx, onClick: function onClick() {
return _this13.onItemClick(item.value.join("@rbc@"), level);
} },
_react2.default.createElement(
"span",
{ className: "rbc-label" },
item.key,
" ",
_this13.countRender(item.doc_count)
),
_this13.renderChevron(level)
),
Array.isArray(_this13.state.selectedValues) && _this13.state.selectedValues[level] === item.key && _this13.state.items[level + 1] ? _react2.default.createElement(
"ul",
{ className: "rbc-list-container col s12 col-xs-12" },
_this13.renderItems(_this13.state.items[level + 1], item.value)
) : null
);
}
});
}
}, {
key: "renderList",
value: function renderList(key, level) {
var list = void 0;
if (key === this.state.selectedValues[level] && level === 0) {
list = _react2.default.createElement(
"ul",
{ className: "rbc-sublist-container rbc-indent col s12 col-xs-12" },
this.renderItems(this.state.subItems, 1)
);
}
return list;
}
}, {
key: "render",
value: function render() {
var searchComponent = null,
title = null;
if (this.state.storedItems.length === 0 || this.state.storedItems.length && Array.isArray(this.state.storedItems[0]) && this.state.storedItems[0].length === 0) {
return null;
}
var listComponent = this.state.items[0] ? _react2.default.createElement(
"ul",
{ className: "row rbc-list-container" },
this.renderItems(this.state.items[0], [])
) : null;
// set static search
if (this.props.showSearch) {
searchComponent = _react2.default.createElement(_StaticSearch2.default, {
placeholder: this.props.placeholder,
changeCallback: this.filterBySearch
});
}
if (this.props.title) {
title = _react2.default.createElement(
"h4",
{ className: "rbc-title col s12 col-xs-12" },
this.props.title
);
}
var cx = (0, _classnames2.default)({
"rbc-search-active": this.props.showSearch,
"rbc-search-inactive": !this.props.showSearch,
"rbc-title-active": this.props.title,
"rbc-title-inactive": !this.props.title,
"rbc-placeholder-active": this.props.placeholder,
"rbc-placeholder-inactive": !this.props.placeholder,
"rbc-count-active": this.props.showCount,
"rbc-count-inactive": !this.props.showCount,
"rbc-initialloader-active": this.props.initialLoader,
"rbc-initialloader-inactive": !this.props.initialLoader
});
return _react2.default.createElement(
"div",
{ className: "rbc rbc-nestedlist-container card thumbnail col s12 col-xs-12 " + (this.props.className ? this.props.className : ""), style: this.props.style },
_react2.default.createElement(
"div",
{ className: "rbc rbc-nestedlist col s12 col-xs-12 " + cx },
title,
searchComponent,
listComponent
),
this.props.initialLoader && this.state.queryStart ? _react2.default.createElement(_reactivemaps.InitialLoader, { defaultText: this.props.initialLoader }) : null
);
}
}]);
return NestedList;
}(_react.Component);
exports.default = NestedList;
var NestedingValidation = function NestedingValidation(props, propName) {
var err = null;
if (!props[propName]) {
err = new Error("dataField is required prop!");
} else if (!Array.isArray(props[propName])) {
err = new Error("dataField should be an array!");
} else if (props[propName].length === 0) {
err = new Error("dataField should not have an empty array.");
} else if (props[propName].length > 9) {
err = new Error("dataField can have maximum 10 fields.");
}
return err;
};
NestedList.propTypes = {
componentId: _react2.default.PropTypes.string.isRequired,
dataField: NestedingValidation,
title: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.string, _react2.default.PropTypes.element]),
showCount: _react2.default.PropTypes.bool,
showSearch: _react2.default.PropTypes.bool,
sortBy: _react2.default.PropTypes.oneOf(["count", "asc", "desc"]),
size: _reactivemaps.AppbaseSensorHelper.sizeValidation,
defaultSelected: _react2.default.PropTypes.array,
customQuery: _react2.default.PropTypes.func,
placeholder: _react2.default.PropTypes.string,
initialLoader: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.string, _react2.default.PropTypes.element]),
react: _react2.default.PropTypes.object,
beforeValueChange: _react2.default.PropTypes.func,
onValueChange: _react2.default.PropTypes.func,
style: _react2.default.PropTypes.object,
URLParams: _react2.default.PropTypes.bool,
showFilter: _react2.default.PropTypes.bool,
filterLabel: _react2.default.PropTypes.string,
className: _react2.default.PropTypes.string,
onQueryChange: _react2.default.PropTypes.func
};
// Default props value
NestedList.defaultProps = {
showCount: true,
sortBy: "count",
size: 100,
showSearch: true,
title: null,
placeholder: "Search",
style: {},
URLParams: false,
showFilter: true
};
// context type
NestedList.contextTypes = {
appbaseRef: _react2.default.PropTypes.any.isRequired,
type: _react2.default.PropTypes.any.isRequired,
reactiveId: _react2.default.PropTypes.number
};
NestedList.types = {
componentId: _reactivemaps.TYPES.STRING,
dataField: _reactivemaps.TYPES.ARRAY,
dataFieldType: _reactivemaps.TYPES.STRING,
title: _reactivemaps.TYPES.STRING,
placeholder: _reactivemaps.TYPES.STRING,
react: _reactivemaps.TYPES.OBJECT,
size: _reactivemaps.TYPES.NUMBER,
sortBy: _reactivemaps.TYPES.STRING,
showCount: _reactivemaps.TYPES.BOOLEAN,
showSearch: _reactivemaps.TYPES.BOOLEAN,
defaultSelected: _reactivemaps.TYPES.ARRAY,
customQuery: _reactivemaps.TYPES.FUNCTION,
initialLoader: _reactivemaps.TYPES.OBJECT,
URLParams: _reactivemaps.TYPES.BOOLEAN,
showFilter: _reactivemaps.TYPES.BOOLEAN,
filterLabel: _reactivemaps.TYPES.STRING,
className: _reactivemaps.TYPES.STRING,
onQueryChange: _reactivemaps.TYPES.FUNCTION
};