@kepler.gl/reducers 3.3.0-alpha.27 → 3.3.0-alpha.28

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.
@@ -816,6 +816,20 @@ function mergeEffects(state, effects, fromConfig) {
816
816
  })
817
817
  });
818
818
  }
819
+ function replaceAnnotationDatasetIds(annotations, dataId, dataIdToUse) {
820
+ var replaced = annotations === null || annotations === void 0 ? void 0 : annotations.filter(function (annotation) {
821
+ var _annotation$readout;
822
+ return ((_annotation$readout = annotation.readout) === null || _annotation$readout === void 0 ? void 0 : _annotation$readout.type) === 'count' && annotation.readout.dataId === dataId;
823
+ }).map(function (annotation) {
824
+ return _objectSpread(_objectSpread({}, annotation), {}, {
825
+ readout: {
826
+ type: 'count',
827
+ dataId: dataIdToUse
828
+ }
829
+ });
830
+ });
831
+ return replaced !== null && replaced !== void 0 && replaced.length ? replaced : null;
832
+ }
819
833
 
820
834
  /**
821
835
  * Merge annotations with saved config
@@ -828,13 +842,13 @@ function mergeAnnotations(state, annotations) {
828
842
  return a.id;
829
843
  }));
830
844
  var validAnnotations = annotations.filter(function (a) {
831
- return a && a.id && !existingIds.has(a.id) && (0, _constants.isAnnotationKind)(a.kind) && Array.isArray(a.anchorPoint) && (a.anchorPoint.length === 2 || a.anchorPoint.length === 3) && a.anchorPoint.every(function (value) {
845
+ return a && a.id && !existingIds.has(a.id) && (0, _constants.isAnnotationKind)(a.kind) && (a.viewport == null || a.kind === _constants.AnnotationKind.TEXT && (0, _utils.normalizeAnnotationViewport)(a.viewport)) && (a.readout == null || a.viewport && (0, _utils.normalizeAnnotationReadout)(a.readout)) && (a.viewport && a.anchorPoint == null || Array.isArray(a.anchorPoint) && (a.anchorPoint.length === 2 || a.anchorPoint.length === 3) && a.anchorPoint.every(function (value) {
832
846
  return Number.isFinite(value);
833
- }) && (a.kind !== _constants.AnnotationKind.RULER || Array.isArray(a.endPoint) && (a.endPoint.length === 2 || a.endPoint.length === 3) && a.endPoint.every(function (value) {
847
+ })) && (a.kind !== _constants.AnnotationKind.RULER || Array.isArray(a.endPoint) && (a.endPoint.length === 2 || a.endPoint.length === 3) && a.endPoint.every(function (value) {
834
848
  return Number.isFinite(value);
835
849
  }));
836
850
  }).map(function (a) {
837
- var _a$showCustomText, _a$showDistance;
851
+ var _a$showCustomText, _a$showDistance, _a$anchorPoint;
838
852
  var annotation = _objectSpread(_objectSpread({
839
853
  isVisible: true,
840
854
  autoSize: true,
@@ -848,6 +862,10 @@ function mergeAnnotations(state, annotations) {
848
862
  showCustomText: (_a$showCustomText = a.showCustomText) !== null && _a$showCustomText !== void 0 ? _a$showCustomText : true,
849
863
  showDistance: (_a$showDistance = a.showDistance) !== null && _a$showDistance !== void 0 ? _a$showDistance : true
850
864
  } : {});
865
+ annotation.anchorPoint = (_a$anchorPoint = a.anchorPoint) !== null && _a$anchorPoint !== void 0 ? _a$anchorPoint : [0, 0];
866
+ delete annotation.viewport;
867
+ delete annotation.readout;
868
+ Object.assign(annotation, (0, _utils.normalizeAnnotationCaption)(a));
851
869
  var propertyTransitions = (0, _utils.normalizeLayerPropertyTransitions)(a.propertyTransitions);
852
870
  if (propertyTransitions === undefined) delete annotation.propertyTransitions;else annotation.propertyTransitions = propertyTransitions;
853
871
  return annotation;
@@ -856,7 +874,10 @@ function mergeAnnotations(state, annotations) {
856
874
  return state;
857
875
  }
858
876
  return _objectSpread(_objectSpread({}, state), {}, {
859
- annotations: [].concat((0, _toConsumableArray2["default"])(state.annotations), (0, _toConsumableArray2["default"])(validAnnotations))
877
+ annotations: validAnnotations.reduce(function (merged, annotation) {
878
+ var _state$preserveAnnota;
879
+ return insertItemBasedOnPreservedOrder(merged, [annotation], state.preserveAnnotationOrder, (_state$preserveAnnota = state.preserveAnnotationOrder) === null || _state$preserveAnnota === void 0 ? void 0 : _state$preserveAnnota.includes(annotation.id));
880
+ }, state.annotations)
860
881
  });
861
882
  }
862
883
 
@@ -1411,7 +1432,9 @@ var VIS_STATE_MERGERS = exports.VIS_STATE_MERGERS = [{
1411
1432
  }, {
1412
1433
  merge: mergeAnnotations,
1413
1434
  prop: 'annotations',
1414
- toMergeProp: 'annotationsToBeMerged'
1435
+ toMergeProp: 'annotationsToBeMerged',
1436
+ preserveOrder: 'preserveAnnotationOrder',
1437
+ replaceParentDatasetIds: replaceAnnotationDatasetIds
1415
1438
  }, {
1416
1439
  merge: mergeInteractions,
1417
1440
  prop: 'interactionConfig',