@veloceapps/sdk 5.0.1 → 5.0.2

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.
@@ -953,6 +953,12 @@
953
953
  }
954
954
  return true;
955
955
  };
956
+ function flattenElements(elements) {
957
+ return lodash.flatten(elements.map(function (el) { return __spreadArray([el], __read(flattenElements(el.children))); }));
958
+ }
959
+ function isSharedElement(el) {
960
+ return Boolean(el.isShared) && el.type !== 'REFERENCE';
961
+ }
956
962
 
957
963
  var ElementContextService = /** @class */ (function () {
958
964
  function ElementContextService() {
@@ -1034,11 +1040,15 @@
1034
1040
  };
1035
1041
  ElementRendererComponent.prototype.processChildren = function (children) {
1036
1042
  var _this = this;
1037
- var refs = children.reduce(function (acc, data) {
1043
+ var refs = children.reduce(function (acc, data, index) {
1038
1044
  var _c;
1039
1045
  var _a;
1040
1046
  var key = String((_a = data === null || data === void 0 ? void 0 : data.id) !== null && _a !== void 0 ? _a : core.UUID.UUID());
1041
- var ref = _this.refs[key] ? _this.updateComponent(key, data) : _this.createComponent(data);
1047
+ var existingRef = _this.refs[key];
1048
+ var ref = existingRef !== null && existingRef !== void 0 ? existingRef : _this.createComponent(data, index);
1049
+ if (existingRef) {
1050
+ _this.updateComponent(existingRef, data, index);
1051
+ }
1042
1052
  return ref ? Object.assign(Object.assign({}, acc), (_c = {}, _c[key] = ref, _c)) : acc;
1043
1053
  }, {});
1044
1054
  var existingKeys = Object.keys(this.refs);
@@ -1057,12 +1067,12 @@
1057
1067
  var parentModel$ = parentRef === null || parentRef === void 0 ? void 0 : parentRef.instance.model$;
1058
1068
  return parentModel$ !== null && parentModel$ !== void 0 ? parentModel$ : this.configurationService.get();
1059
1069
  };
1060
- ElementRendererComponent.prototype.createComponent = function (data) {
1070
+ ElementRendererComponent.prototype.createComponent = function (data, index) {
1061
1071
  var _a, _b;
1062
1072
  if (!this.factory) {
1063
1073
  return;
1064
1074
  }
1065
- var componentRef = (_a = this.el) === null || _a === void 0 ? void 0 : _a.createComponent(this.factory);
1075
+ var componentRef = (_a = this.el) === null || _a === void 0 ? void 0 : _a.createComponent(this.factory, index);
1066
1076
  if (componentRef) {
1067
1077
  componentRef.location.nativeElement.setAttribute('name', this.meta.name);
1068
1078
  componentRef.location.nativeElement.setAttribute('path', this.meta.path);
@@ -1070,10 +1080,11 @@
1070
1080
  }
1071
1081
  return componentRef;
1072
1082
  };
1073
- ElementRendererComponent.prototype.updateComponent = function (key, data) {
1074
- var ref = this.refs[key];
1075
- ref === null || ref === void 0 ? void 0 : ref.instance.model$.next(data);
1076
- return ref;
1083
+ ElementRendererComponent.prototype.updateComponent = function (ref, data, index) {
1084
+ ref.instance.model$.next(data);
1085
+ if (this.el && this.el.indexOf(ref.hostView) !== index) {
1086
+ this.el.move(ref.hostView, index);
1087
+ }
1077
1088
  };
1078
1089
  ElementRendererComponent.prototype.destroyComponent = function (key) {
1079
1090
  var _a;
@@ -1858,8 +1869,10 @@
1858
1869
  exports.extendElementMetadata = extendElementMetadata;
1859
1870
  exports.extractElementMetadata = extractElementMetadata;
1860
1871
  exports.findElementByModule = findElementByModule;
1872
+ exports.flattenElements = flattenElements;
1861
1873
  exports.getAbsolutePath = getAbsolutePath;
1862
1874
  exports.getElementConfig = getElementConfig;
1875
+ exports.isSharedElement = isSharedElement;
1863
1876
  exports.isValidScript = isValidScript;
1864
1877
  exports.metadataToElement = metadataToElement;
1865
1878
  exports.normalizeElementMetadata = normalizeElementMetadata;