@splunk/visualizations 24.3.1 → 24.3.4
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.
- package/.loki/reference/chrome_docker_PureVisualizations_PureMap_Tooltip_Dark.png +0 -0
- package/.loki/reference/chrome_docker_PureVisualizations_PureMap_basic.png +0 -0
- package/.loki/reference/chrome_docker_PureVisualizations_PureMap_bubble_layer_geostats_by.png +0 -0
- package/.loki/reference/chrome_docker_PureVisualizations_PureMap_scale_off.png +0 -0
- package/.loki/reference/chrome_docker_PureVisualizations_PureMap_scale_unit_metric.png +0 -0
- package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Map_Editor.png +0 -0
- package/.loki/reference/chrome_docker_Visualizations_Map_Map_Bubble_Layer_Geostats_By_Additional_Cases.png +0 -0
- package/.loki/reference/chrome_docker_Visualizations_Map_Map_Bubble_Layer_Geostats_By_Internal_Fields.png +0 -0
- package/.loki/reference/chrome_docker_Visualizations_Map_Map_Bubble_Layer_Geostats_By_Mostly_null.png +0 -0
- package/.loki/reference/chrome_docker_Visualizations_Map_Map_Restricted_Zoom.png +0 -0
- package/.loki/reference/chrome_docker_Visualizations_Map_Map_Set_Map_tiles.png +0 -0
- package/.loki/reference/chrome_docker_Visualizations_Markdown_Markdown_Markdown_with_number_as_DSL.png +0 -0
- package/Area.js +121 -65
- package/Area.js.map +1 -1
- package/Bar.js +121 -65
- package/Bar.js.map +1 -1
- package/Bubble.js +121 -65
- package/Bubble.js.map +1 -1
- package/ChoroplethSvg.js +142 -73
- package/ChoroplethSvg.js.map +1 -1
- package/Column.js +121 -65
- package/Column.js.map +1 -1
- package/Ellipse.js +121 -65
- package/Ellipse.js.map +1 -1
- package/FillerGauge.js +121 -65
- package/FillerGauge.js.map +1 -1
- package/Image.js +125 -69
- package/Image.js.map +1 -1
- package/Line.js +121 -65
- package/Line.js.map +1 -1
- package/LinkGraph.js +121 -65
- package/LinkGraph.js.map +1 -1
- package/Map.config.js +16 -6
- package/Map.config.js.map +1 -1
- package/Map.js +430 -126
- package/Map.js.map +1 -1
- package/Markdown.js +136 -78
- package/Markdown.js.map +1 -1
- package/MarkerGauge.js +135 -79
- package/MarkerGauge.js.map +1 -1
- package/ParallelCoordinates.js +140 -83
- package/ParallelCoordinates.js.map +1 -1
- package/Pie.js +133 -77
- package/Pie.js.map +1 -1
- package/Punchcard.js +144 -87
- package/Punchcard.js.map +1 -1
- package/Rectangle.js +129 -73
- package/Rectangle.js.map +1 -1
- package/Sankey.js +204 -148
- package/Sankey.js.map +1 -1
- package/Scatter.js +131 -75
- package/Scatter.js.map +1 -1
- package/SingleValue.js +160 -104
- package/SingleValue.js.map +1 -1
- package/SingleValueIcon.js +135 -78
- package/SingleValueIcon.js.map +1 -1
- package/SingleValueRadial.js +202 -146
- package/SingleValueRadial.js.map +1 -1
- package/Table.js +236 -180
- package/Table.js.map +1 -1
- package/common/utils/hocUtils.js +65 -9
- package/common/utils/hocUtils.js.map +1 -1
- package/common/withDashboardViz.js +68 -12
- package/common/withDashboardViz.js.map +1 -1
- package/package.json +10 -10
package/Markdown.js
CHANGED
|
@@ -87,7 +87,7 @@ module.exports =
|
|
|
87
87
|
/******/
|
|
88
88
|
/******/
|
|
89
89
|
/******/ // Load entry module and return exports
|
|
90
|
-
/******/ return __webpack_require__(__webpack_require__.s =
|
|
90
|
+
/******/ return __webpack_require__(__webpack_require__.s = 201);
|
|
91
91
|
/******/ })
|
|
92
92
|
/************************************************************************/
|
|
93
93
|
/******/ ({
|
|
@@ -195,7 +195,7 @@ var withFixedSizeContainer = function withFixedSizeContainer(Viz) {
|
|
|
195
195
|
|
|
196
196
|
return React.createElement(FixSizeItem, {
|
|
197
197
|
"data-test": "fix-size-item",
|
|
198
|
-
"data-splunk-visualization-version": "24.3.
|
|
198
|
+
"data-splunk-visualization-version": "24.3.4 - fa50e80e6",
|
|
199
199
|
width: width,
|
|
200
200
|
height: height,
|
|
201
201
|
backgroundColor: backgroundColor
|
|
@@ -234,17 +234,17 @@ var React = __webpack_require__(1);
|
|
|
234
234
|
|
|
235
235
|
var style_1 = __webpack_require__(13);
|
|
236
236
|
|
|
237
|
-
var Markdown_1 = __webpack_require__(
|
|
237
|
+
var Markdown_1 = __webpack_require__(202);
|
|
238
238
|
|
|
239
239
|
var styled_components_1 = __webpack_require__(4);
|
|
240
240
|
|
|
241
241
|
var T = __webpack_require__(0);
|
|
242
242
|
|
|
243
|
-
var config_1 = __webpack_require__(
|
|
243
|
+
var config_1 = __webpack_require__(203);
|
|
244
244
|
|
|
245
245
|
exports.config = config_1.default;
|
|
246
246
|
|
|
247
|
-
var withDashboardViz_1 = __webpack_require__(
|
|
247
|
+
var withDashboardViz_1 = __webpack_require__(28); // startsWithHeader is a prop that can be
|
|
248
248
|
// falsy if the markdown text begins with text
|
|
249
249
|
// or the number of heading level;
|
|
250
250
|
// casting heading level below 4 to 4
|
|
@@ -274,8 +274,10 @@ var MarkdownVisualization = function MarkdownVisualization(_ref2) {
|
|
|
274
274
|
backgroundColor = _ref2.backgroundColor,
|
|
275
275
|
fontColor = _ref2.fontColor;
|
|
276
276
|
|
|
277
|
-
var _a;
|
|
277
|
+
var _a; // because DSL evaluation is not guaranteed to return string data if `markdown` is powered by DSL, we do a typecast here
|
|
278
278
|
|
|
279
|
+
|
|
280
|
+
var stringifiedMarkdown = "".concat(markdown);
|
|
279
281
|
return React.createElement(Container, {
|
|
280
282
|
"data-testid": "markdown-container",
|
|
281
283
|
padding: [5, 5, 5, 5],
|
|
@@ -283,9 +285,9 @@ var MarkdownVisualization = function MarkdownVisualization(_ref2) {
|
|
|
283
285
|
height: height,
|
|
284
286
|
backgroundColor: backgroundColor,
|
|
285
287
|
fontColor: fontColor,
|
|
286
|
-
startsWithHeader: (_a =
|
|
288
|
+
startsWithHeader: (_a = stringifiedMarkdown.trim().match(/^#+/)) === null || _a === void 0 ? void 0 : _a[0].length
|
|
287
289
|
}, React.createElement(Markdown_1.default, {
|
|
288
|
-
text:
|
|
290
|
+
text: stringifiedMarkdown
|
|
289
291
|
}));
|
|
290
292
|
};
|
|
291
293
|
|
|
@@ -357,7 +359,7 @@ module.exports = require("@babel/runtime/helpers/typeof");
|
|
|
357
359
|
|
|
358
360
|
/***/ }),
|
|
359
361
|
|
|
360
|
-
/***/
|
|
362
|
+
/***/ 201:
|
|
361
363
|
/***/ (function(module, exports, __webpack_require__) {
|
|
362
364
|
|
|
363
365
|
"use strict";
|
|
@@ -400,14 +402,14 @@ Object.defineProperty(exports, "default", {
|
|
|
400
402
|
|
|
401
403
|
/***/ }),
|
|
402
404
|
|
|
403
|
-
/***/
|
|
405
|
+
/***/ 202:
|
|
404
406
|
/***/ (function(module, exports) {
|
|
405
407
|
|
|
406
408
|
module.exports = require("@splunk/react-ui/Markdown");
|
|
407
409
|
|
|
408
410
|
/***/ }),
|
|
409
411
|
|
|
410
|
-
/***/
|
|
412
|
+
/***/ 203:
|
|
411
413
|
/***/ (function(module, exports, __webpack_require__) {
|
|
412
414
|
|
|
413
415
|
"use strict";
|
|
@@ -427,7 +429,7 @@ var schemaUtils_1 = __webpack_require__(14);
|
|
|
427
429
|
|
|
428
430
|
var VizBehavior_1 = __webpack_require__(5);
|
|
429
431
|
|
|
430
|
-
var VizCategory_1 = __webpack_require__(
|
|
432
|
+
var VizCategory_1 = __webpack_require__(27);
|
|
431
433
|
|
|
432
434
|
var configUtils_1 = __webpack_require__(6);
|
|
433
435
|
|
|
@@ -555,7 +557,7 @@ var T = __webpack_require__(0);
|
|
|
555
557
|
|
|
556
558
|
var lodash_1 = __webpack_require__(2);
|
|
557
559
|
|
|
558
|
-
var DataSource_1 = __webpack_require__(
|
|
560
|
+
var DataSource_1 = __webpack_require__(34);
|
|
559
561
|
|
|
560
562
|
exports.SortParamsPropTypes = T.shape({
|
|
561
563
|
currentSortKey: T.string,
|
|
@@ -680,6 +682,40 @@ exports.getPaginationParams = getPaginationParams;
|
|
|
680
682
|
"use strict";
|
|
681
683
|
|
|
682
684
|
|
|
685
|
+
Object.defineProperty(exports, "__esModule", {
|
|
686
|
+
value: true
|
|
687
|
+
});
|
|
688
|
+
exports.pickFieldFromJSONSchema = void 0;
|
|
689
|
+
|
|
690
|
+
var lodash_1 = __webpack_require__(2);
|
|
691
|
+
|
|
692
|
+
var pickFieldFromJSONSchema = function pickFieldFromJSONSchema(optionsSchema) {
|
|
693
|
+
var fieldName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
|
|
694
|
+
return Object.keys(optionsSchema).reduce(function (accum, k) {
|
|
695
|
+
if (lodash_1.has(optionsSchema[k], fieldName)) {
|
|
696
|
+
accum[k] = optionsSchema[k][fieldName];
|
|
697
|
+
} else if (lodash_1.get(optionsSchema, [k, 'type']) === 'object' && lodash_1.has(optionsSchema[k], 'properties')) {
|
|
698
|
+
var nestedSchema = exports.pickFieldFromJSONSchema(optionsSchema[k].properties, fieldName);
|
|
699
|
+
|
|
700
|
+
if (!lodash_1.isEmpty(nestedSchema)) {
|
|
701
|
+
accum[k] = nestedSchema;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
return accum;
|
|
706
|
+
}, {});
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
exports.pickFieldFromJSONSchema = pickFieldFromJSONSchema;
|
|
710
|
+
|
|
711
|
+
/***/ }),
|
|
712
|
+
|
|
713
|
+
/***/ 26:
|
|
714
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
715
|
+
|
|
716
|
+
"use strict";
|
|
717
|
+
|
|
718
|
+
|
|
683
719
|
Object.defineProperty(exports, "__esModule", {
|
|
684
720
|
value: true
|
|
685
721
|
});
|
|
@@ -763,7 +799,7 @@ exports.default = FixedSizeContainer_1.default(IconPlaceholder);
|
|
|
763
799
|
|
|
764
800
|
/***/ }),
|
|
765
801
|
|
|
766
|
-
/***/
|
|
802
|
+
/***/ 27:
|
|
767
803
|
/***/ (function(module, exports, __webpack_require__) {
|
|
768
804
|
|
|
769
805
|
"use strict";
|
|
@@ -792,7 +828,7 @@ var VizCategory;
|
|
|
792
828
|
|
|
793
829
|
/***/ }),
|
|
794
830
|
|
|
795
|
-
/***/
|
|
831
|
+
/***/ 28:
|
|
796
832
|
/***/ (function(module, exports, __webpack_require__) {
|
|
797
833
|
|
|
798
834
|
"use strict";
|
|
@@ -806,15 +842,15 @@ var React = __webpack_require__(1);
|
|
|
806
842
|
|
|
807
843
|
var lodash_1 = __webpack_require__(2);
|
|
808
844
|
|
|
809
|
-
var getSettingsFromThemedProps_1 = __webpack_require__(
|
|
845
|
+
var getSettingsFromThemedProps_1 = __webpack_require__(29);
|
|
810
846
|
|
|
811
|
-
var Options_1 = __webpack_require__(
|
|
847
|
+
var Options_1 = __webpack_require__(30);
|
|
812
848
|
|
|
813
|
-
var SanitizeProps_1 = __webpack_require__(
|
|
849
|
+
var SanitizeProps_1 = __webpack_require__(31);
|
|
814
850
|
|
|
815
851
|
var styled_components_1 = __webpack_require__(4);
|
|
816
852
|
|
|
817
|
-
var SplunkVisualization_1 = __webpack_require__(
|
|
853
|
+
var SplunkVisualization_1 = __webpack_require__(32);
|
|
818
854
|
|
|
819
855
|
var VizBehavior_1 = __webpack_require__(5);
|
|
820
856
|
|
|
@@ -822,9 +858,9 @@ var getSorting_1 = __webpack_require__(23);
|
|
|
822
858
|
|
|
823
859
|
var getPagination_1 = __webpack_require__(24);
|
|
824
860
|
|
|
825
|
-
var useDeepMemo_1 = __webpack_require__(
|
|
861
|
+
var useDeepMemo_1 = __webpack_require__(35);
|
|
826
862
|
|
|
827
|
-
var JSONSchemaUtils_1 = __webpack_require__(
|
|
863
|
+
var JSONSchemaUtils_1 = __webpack_require__(25);
|
|
828
864
|
|
|
829
865
|
var MissingPropsMessage_1 = __webpack_require__(36);
|
|
830
866
|
|
|
@@ -886,7 +922,7 @@ var withDashboardViz = function withDashboardViz(opts) {
|
|
|
886
922
|
try {
|
|
887
923
|
return Options_1.Options.evaluate({
|
|
888
924
|
context: lodash_1.defaultsDeep({}, context, vizConfig.defaultContext),
|
|
889
|
-
options: hocUtils_1.
|
|
925
|
+
options: hocUtils_1.deepMergeWithArrayPrimitiveOverrides({}, options, defaultOptions)
|
|
890
926
|
}, dataSources, themeFunc);
|
|
891
927
|
} catch (e) {
|
|
892
928
|
// eslint-disable-next-line no-console
|
|
@@ -1017,35 +1053,35 @@ exports.default = withDashboardViz;
|
|
|
1017
1053
|
|
|
1018
1054
|
/***/ }),
|
|
1019
1055
|
|
|
1020
|
-
/***/
|
|
1056
|
+
/***/ 29:
|
|
1021
1057
|
/***/ (function(module, exports) {
|
|
1022
1058
|
|
|
1023
1059
|
module.exports = require("@splunk/themes/getSettingsFromThemedProps");
|
|
1024
1060
|
|
|
1025
1061
|
/***/ }),
|
|
1026
1062
|
|
|
1027
|
-
/***/
|
|
1063
|
+
/***/ 3:
|
|
1028
1064
|
/***/ (function(module, exports) {
|
|
1029
1065
|
|
|
1030
|
-
module.exports = require("@splunk/
|
|
1066
|
+
module.exports = require("@splunk/ui-utils/i18n");
|
|
1031
1067
|
|
|
1032
1068
|
/***/ }),
|
|
1033
1069
|
|
|
1034
|
-
/***/
|
|
1070
|
+
/***/ 30:
|
|
1035
1071
|
/***/ (function(module, exports) {
|
|
1036
1072
|
|
|
1037
|
-
module.exports = require("@splunk/
|
|
1073
|
+
module.exports = require("@splunk/visualization-encoding/Options");
|
|
1038
1074
|
|
|
1039
1075
|
/***/ }),
|
|
1040
1076
|
|
|
1041
|
-
/***/
|
|
1077
|
+
/***/ 31:
|
|
1042
1078
|
/***/ (function(module, exports) {
|
|
1043
1079
|
|
|
1044
1080
|
module.exports = require("@splunk/visualizations-shared/SanitizeProps");
|
|
1045
1081
|
|
|
1046
1082
|
/***/ }),
|
|
1047
1083
|
|
|
1048
|
-
/***/
|
|
1084
|
+
/***/ 32:
|
|
1049
1085
|
/***/ (function(module, exports, __webpack_require__) {
|
|
1050
1086
|
|
|
1051
1087
|
"use strict";
|
|
@@ -1063,7 +1099,7 @@ var T = __webpack_require__(0);
|
|
|
1063
1099
|
|
|
1064
1100
|
var lodash_1 = __webpack_require__(2);
|
|
1065
1101
|
|
|
1066
|
-
var VizActionHandler_1 = __webpack_require__(
|
|
1102
|
+
var VizActionHandler_1 = __webpack_require__(33); // this is identical to the initial height and width we use in BaseVisualization in dashboard-visualizations
|
|
1067
1103
|
|
|
1068
1104
|
|
|
1069
1105
|
exports.INITIAL_WIDTH = 250;
|
|
@@ -1197,7 +1233,7 @@ exports.default = SplunkVisualization;
|
|
|
1197
1233
|
|
|
1198
1234
|
/***/ }),
|
|
1199
1235
|
|
|
1200
|
-
/***/
|
|
1236
|
+
/***/ 33:
|
|
1201
1237
|
/***/ (function(module, exports, __webpack_require__) {
|
|
1202
1238
|
|
|
1203
1239
|
"use strict";
|
|
@@ -1235,7 +1271,7 @@ exports.DefaultVizActionHandler = DefaultVizActionHandler;
|
|
|
1235
1271
|
|
|
1236
1272
|
/***/ }),
|
|
1237
1273
|
|
|
1238
|
-
/***/
|
|
1274
|
+
/***/ 34:
|
|
1239
1275
|
/***/ (function(module, exports, __webpack_require__) {
|
|
1240
1276
|
|
|
1241
1277
|
"use strict";
|
|
@@ -1249,7 +1285,7 @@ exports.validSortDirs = ['asc', 'desc', 'none'];
|
|
|
1249
1285
|
|
|
1250
1286
|
/***/ }),
|
|
1251
1287
|
|
|
1252
|
-
/***/
|
|
1288
|
+
/***/ 35:
|
|
1253
1289
|
/***/ (function(module, exports, __webpack_require__) {
|
|
1254
1290
|
|
|
1255
1291
|
"use strict";
|
|
@@ -1295,40 +1331,6 @@ exports.useDeepMemo = useDeepMemo;
|
|
|
1295
1331
|
|
|
1296
1332
|
/***/ }),
|
|
1297
1333
|
|
|
1298
|
-
/***/ 35:
|
|
1299
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1300
|
-
|
|
1301
|
-
"use strict";
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
Object.defineProperty(exports, "__esModule", {
|
|
1305
|
-
value: true
|
|
1306
|
-
});
|
|
1307
|
-
exports.pickFieldFromJSONSchema = void 0;
|
|
1308
|
-
|
|
1309
|
-
var lodash_1 = __webpack_require__(2);
|
|
1310
|
-
|
|
1311
|
-
var pickFieldFromJSONSchema = function pickFieldFromJSONSchema(optionsSchema) {
|
|
1312
|
-
var fieldName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
|
|
1313
|
-
return Object.keys(optionsSchema).reduce(function (accum, k) {
|
|
1314
|
-
if (lodash_1.has(optionsSchema[k], fieldName)) {
|
|
1315
|
-
accum[k] = optionsSchema[k][fieldName];
|
|
1316
|
-
} else if (lodash_1.get(optionsSchema, [k, 'type']) === 'object' && lodash_1.has(optionsSchema[k], 'properties')) {
|
|
1317
|
-
var nestedSchema = exports.pickFieldFromJSONSchema(optionsSchema[k].properties, fieldName);
|
|
1318
|
-
|
|
1319
|
-
if (!lodash_1.isEmpty(nestedSchema)) {
|
|
1320
|
-
accum[k] = nestedSchema;
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
|
-
return accum;
|
|
1325
|
-
}, {});
|
|
1326
|
-
};
|
|
1327
|
-
|
|
1328
|
-
exports.pickFieldFromJSONSchema = pickFieldFromJSONSchema;
|
|
1329
|
-
|
|
1330
|
-
/***/ }),
|
|
1331
|
-
|
|
1332
1334
|
/***/ 36:
|
|
1333
1335
|
/***/ (function(module, exports, __webpack_require__) {
|
|
1334
1336
|
|
|
@@ -1431,7 +1433,7 @@ var Cover = styled_components_1.default.div.withConfig({
|
|
|
1431
1433
|
componentId: "sc-1gsbnxb-0"
|
|
1432
1434
|
})(["position:absolute;left:0;right:0;top:0;bottom:0;"]);
|
|
1433
1435
|
var Blocker = styled_components_1.default.div.attrs({
|
|
1434
|
-
'data-splunk-visualization-version': "24.3.
|
|
1436
|
+
'data-splunk-visualization-version': "24.3.4 - fa50e80e6"
|
|
1435
1437
|
}).withConfig({
|
|
1436
1438
|
displayName: "withEditModeCover__Blocker",
|
|
1437
1439
|
componentId: "sc-1gsbnxb-1"
|
|
@@ -1477,7 +1479,7 @@ var React = __webpack_require__(1);
|
|
|
1477
1479
|
|
|
1478
1480
|
var colorUtils_1 = __webpack_require__(11);
|
|
1479
1481
|
|
|
1480
|
-
var IconPlaceholder_1 = __webpack_require__(
|
|
1482
|
+
var IconPlaceholder_1 = __webpack_require__(26);
|
|
1481
1483
|
|
|
1482
1484
|
var VizBehavior_1 = __webpack_require__(5);
|
|
1483
1485
|
|
|
@@ -1809,7 +1811,7 @@ var _typeof = __webpack_require__(20);
|
|
|
1809
1811
|
Object.defineProperty(exports, "__esModule", {
|
|
1810
1812
|
value: true
|
|
1811
1813
|
});
|
|
1812
|
-
exports.
|
|
1814
|
+
exports.findClosestMatchFromDefaultList = exports.deepMergeWithArrayPrimitiveOverrides = exports.extendStaticWrapperProps = void 0;
|
|
1813
1815
|
|
|
1814
1816
|
var lodash_1 = __webpack_require__(2);
|
|
1815
1817
|
/**
|
|
@@ -1835,17 +1837,19 @@ var extendStaticWrapperProps = function extendStaticWrapperProps(_ref) {
|
|
|
1835
1837
|
exports.extendStaticWrapperProps = extendStaticWrapperProps;
|
|
1836
1838
|
/**
|
|
1837
1839
|
* helper to deeply merge objects while preserving arrays in earlier source objects
|
|
1838
|
-
* deeply nested primitive keys are merged similarly to lodash's defaultsDeep, while keys with arrays will be preserved if already present in the resultant merged object
|
|
1839
|
-
* this prevents default arrays from appending values to user-defined arrays (this occurs if the default array is longer than the user-defined one)
|
|
1840
|
+
* deeply nested primitive keys are merged similarly to lodash's defaultsDeep, while keys with arrays of primitives will be preserved if already present in the resultant merged object
|
|
1841
|
+
* this prevents default arrays of primitives from appending values to user-defined arrays (this occurs if the default array is longer than the user-defined one).
|
|
1842
|
+
* Array of objects gets merged with the defaults, where the defaults can be an array of objects. Closest matching default object from the defaults list based on key - value pair
|
|
1843
|
+
* will be used for merging defaults for each object in the array. If no closest match found, first object in default array list used for merging.
|
|
1840
1844
|
*
|
|
1841
|
-
* @method
|
|
1845
|
+
* @method deepMergeWithArrayPrimitiveOverrides
|
|
1842
1846
|
* @param {Object} initial - target object to merge values into
|
|
1843
1847
|
* @param {Object[]} sources - other default options to be merged into the resultant object if no explicit value is provided, with earlier args taking precedence over later ones
|
|
1844
1848
|
*
|
|
1845
1849
|
* @returns {Object}
|
|
1846
1850
|
*/
|
|
1847
1851
|
|
|
1848
|
-
var
|
|
1852
|
+
var deepMergeWithArrayPrimitiveOverrides = function deepMergeWithArrayPrimitiveOverrides(initial) {
|
|
1849
1853
|
var clone = lodash_1.cloneDeep(initial);
|
|
1850
1854
|
|
|
1851
1855
|
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
@@ -1856,18 +1860,72 @@ var deepMergeWithArrayOverrides = function deepMergeWithArrayOverrides(initial)
|
|
|
1856
1860
|
Object.keys(sourceToApply).forEach(function (sourceKey) {
|
|
1857
1861
|
if (!Object.prototype.hasOwnProperty.call(clone, sourceKey)) {
|
|
1858
1862
|
clone[sourceKey] = lodash_1.cloneDeep(sourceToApply[sourceKey]);
|
|
1859
|
-
}
|
|
1860
|
-
|
|
1863
|
+
}
|
|
1861
1864
|
|
|
1862
1865
|
if (clone[sourceKey] && _typeof(clone[sourceKey]) === 'object' && !Array.isArray(clone[sourceKey]) && _typeof(sourceToApply[sourceKey]) === 'object') {
|
|
1863
|
-
clone[sourceKey] = exports.
|
|
1866
|
+
clone[sourceKey] = exports.deepMergeWithArrayPrimitiveOverrides(clone[sourceKey], sourceToApply[sourceKey]);
|
|
1867
|
+
} else if (Array.isArray(clone[sourceKey]) && _typeof(clone[sourceKey][0]) === 'object' && !Array.isArray(clone[sourceKey][0])) {
|
|
1868
|
+
// If option is an array of objects
|
|
1869
|
+
for (var i = 0; i < clone[sourceKey].length; i += 1) {
|
|
1870
|
+
if (_typeof(clone[sourceKey][i]) === 'object') {
|
|
1871
|
+
var closestMatchIdx = exports.findClosestMatchFromDefaultList(sourceToApply[sourceKey], clone[sourceKey][i]);
|
|
1872
|
+
|
|
1873
|
+
if (closestMatchIdx > -1) {
|
|
1874
|
+
clone[sourceKey][i] = exports.deepMergeWithArrayPrimitiveOverrides(clone[sourceKey][i], sourceToApply[sourceKey][closestMatchIdx]);
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1864
1878
|
}
|
|
1865
1879
|
});
|
|
1866
1880
|
});
|
|
1867
1881
|
return clone;
|
|
1868
1882
|
};
|
|
1869
1883
|
|
|
1870
|
-
exports.
|
|
1884
|
+
exports.deepMergeWithArrayPrimitiveOverrides = deepMergeWithArrayPrimitiveOverrides;
|
|
1885
|
+
/**
|
|
1886
|
+
* Finds the closest matching object from the list, which has the max same key value pairs.
|
|
1887
|
+
* Returns the index of match if found, or -1
|
|
1888
|
+
* For eg :-
|
|
1889
|
+
const list = [{
|
|
1890
|
+
type: "marker",
|
|
1891
|
+
lat: "value1"
|
|
1892
|
+
}, {
|
|
1893
|
+
type: "bubble",
|
|
1894
|
+
size: "value2"
|
|
1895
|
+
}];
|
|
1896
|
+
|
|
1897
|
+
const obj = {
|
|
1898
|
+
type: 'bubble'
|
|
1899
|
+
};
|
|
1900
|
+
|
|
1901
|
+
findClosestMatch(list, obj) -> returns index 1.
|
|
1902
|
+
*/
|
|
1903
|
+
|
|
1904
|
+
var findClosestMatchFromDefaultList = function findClosestMatchFromDefaultList(searchList, inputObj) {
|
|
1905
|
+
if (!Array.isArray(searchList) || searchList.length === 0) {
|
|
1906
|
+
return -1;
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
var keys = Object.keys(inputObj);
|
|
1910
|
+
var maxMatchCnt = 0;
|
|
1911
|
+
var maxMatchIdx = 0;
|
|
1912
|
+
searchList.forEach(function (item, idx) {
|
|
1913
|
+
var matchCnt = 0;
|
|
1914
|
+
keys.forEach(function (key) {
|
|
1915
|
+
if (item[key] === inputObj[key]) {
|
|
1916
|
+
matchCnt += 1;
|
|
1917
|
+
}
|
|
1918
|
+
});
|
|
1919
|
+
|
|
1920
|
+
if (Math.max(maxMatchCnt, matchCnt) > maxMatchCnt) {
|
|
1921
|
+
maxMatchCnt = matchCnt;
|
|
1922
|
+
maxMatchIdx = idx;
|
|
1923
|
+
}
|
|
1924
|
+
});
|
|
1925
|
+
return maxMatchIdx;
|
|
1926
|
+
};
|
|
1927
|
+
|
|
1928
|
+
exports.findClosestMatchFromDefaultList = findClosestMatchFromDefaultList;
|
|
1871
1929
|
|
|
1872
1930
|
/***/ }),
|
|
1873
1931
|
|