survey-react-ui 1.9.126 → 1.9.127

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "survey-react-ui",
3
- "version": "1.9.126",
3
+ "version": "1.9.127",
4
4
  "description": "survey.js is a JavaScript Survey Library. It is a modern way to add a survey to your website. It uses JSON for survey metadata and results.",
5
5
  "keywords": [
6
6
  "Survey",
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - Survey JavaScript library v1.9.126
2
+ * surveyjs - Survey JavaScript library v1.9.127
3
3
  * Copyright (c) 2015-2024 Devsoft Baltic OÜ - http://surveyjs.io/
4
4
  * License: MIT (http://www.opensource.org/licenses/mit-license.php)
5
5
  */
@@ -561,8 +561,8 @@ var Base = /** @class */ (function () {
561
561
  * Returns a JSON object that corresponds to the current SurveyJS object.
562
562
  * @see fromJSON
563
563
  */
564
- Base.prototype.toJSON = function () {
565
- return new _jsonobject__WEBPACK_IMPORTED_MODULE_2__["JsonObject"]().toJsonObject(this);
564
+ Base.prototype.toJSON = function (options) {
565
+ return new _jsonobject__WEBPACK_IMPORTED_MODULE_2__["JsonObject"]().toJsonObject(this, options);
566
566
  };
567
567
  /**
568
568
  * Assigns a new configuration to the current SurveyJS object. This configuration is taken from a passed JSON object.
@@ -2620,7 +2620,7 @@ __webpack_require__.r(__webpack_exports__);
2620
2620
 
2621
2621
 
2622
2622
 
2623
- Object(survey_core__WEBPACK_IMPORTED_MODULE_2__["checkLibraryVersion"])("" + "1.9.126", "survey-react-ui");
2623
+ Object(survey_core__WEBPACK_IMPORTED_MODULE_2__["checkLibraryVersion"])("" + "1.9.127", "survey-react-ui");
2624
2624
 
2625
2625
 
2626
2626
  /***/ }),
@@ -7235,6 +7235,27 @@ var Helpers = /** @class */ (function () {
7235
7235
  }
7236
7236
  return val;
7237
7237
  };
7238
+ Helpers.compareVerions = function (ver1, ver2) {
7239
+ if (!ver1 && !ver2)
7240
+ return 0;
7241
+ var ver1Ar = ver1.split(".");
7242
+ var ver2Ar = ver2.split(".");
7243
+ var len1 = ver1Ar.length;
7244
+ var len2 = ver2Ar.length;
7245
+ for (var i = 0; i < len1 && i < len2; i++) {
7246
+ var str1 = ver1Ar[i];
7247
+ var str2 = ver2Ar[i];
7248
+ if (str1.length === str2.length) {
7249
+ if (str1 !== str2) {
7250
+ return str1 < str2 ? -1 : 1;
7251
+ }
7252
+ }
7253
+ else {
7254
+ return str1.length < str2.length ? -1 : 1;
7255
+ }
7256
+ }
7257
+ return len1 === len2 ? 0 : (len1 < len2 ? -1 : 1);
7258
+ };
7238
7259
  return Helpers;
7239
7260
  }());
7240
7261
 
@@ -7694,6 +7715,21 @@ var JsonObjectProperty = /** @class */ (function () {
7694
7715
  enumerable: false,
7695
7716
  configurable: true
7696
7717
  });
7718
+ JsonObjectProperty.prototype.isAvailableInVersion = function (ver) {
7719
+ if (!!this.alternativeName)
7720
+ return true;
7721
+ return this.isAvailableInVersionCore(ver);
7722
+ };
7723
+ JsonObjectProperty.prototype.getSerializedName = function (ver) {
7724
+ if (!this.alternativeName)
7725
+ return this.name;
7726
+ return this.isAvailableInVersionCore(ver) ? this.name : this.alternativeName;
7727
+ };
7728
+ JsonObjectProperty.prototype.isAvailableInVersionCore = function (ver) {
7729
+ if (!ver || !this.version)
7730
+ return true;
7731
+ return _helpers__WEBPACK_IMPORTED_MODULE_2__["Helpers"].compareVerions(this.version, ver) <= 0;
7732
+ };
7697
7733
  Object.defineProperty(JsonObjectProperty.prototype, "isLocalizable", {
7698
7734
  get: function () {
7699
7735
  return this.isLocalizableValue != null ? this.isLocalizableValue : false;
@@ -7774,6 +7810,7 @@ var JsonObjectProperty = /** @class */ (function () {
7774
7810
  "className",
7775
7811
  "alternativeName",
7776
7812
  "layout",
7813
+ "version",
7777
7814
  "classNamePart",
7778
7815
  "baseClassName",
7779
7816
  "defaultValue",
@@ -8222,6 +8259,9 @@ var JsonMetadataClass = /** @class */ (function () {
8222
8259
  if (propInfo.layout) {
8223
8260
  prop.layout = propInfo.layout;
8224
8261
  }
8262
+ if (propInfo.version) {
8263
+ prop.version = propInfo.version;
8264
+ }
8225
8265
  if (propInfo.dependsOn) {
8226
8266
  this.addDependsOnProperties(prop, propInfo.dependsOn);
8227
8267
  }
@@ -8366,36 +8406,54 @@ var JsonMetadata = /** @class */ (function () {
8366
8406
  JsonMetadata.prototype.getPropertiesByObj = function (obj) {
8367
8407
  if (!obj || !obj.getType)
8368
8408
  return [];
8369
- var res = {};
8370
8409
  var props = this.getProperties(obj.getType());
8371
- for (var i = 0; i < props.length; i++) {
8372
- res[props[i].name] = props[i];
8373
- }
8374
- var dynamicProps = !!obj.getDynamicType
8375
- ? this.getProperties(obj.getDynamicType())
8376
- : null;
8377
- if (dynamicProps && dynamicProps.length > 0) {
8378
- for (var i = 0; i < dynamicProps.length; i++) {
8379
- var dProp = dynamicProps[i];
8380
- if (!!res[dProp.name])
8381
- continue;
8382
- res[dProp.name] = dProp;
8410
+ var dynamicProps = this.getDynamicPropertiesByObj(obj);
8411
+ return [].concat(props).concat(dynamicProps);
8412
+ };
8413
+ JsonMetadata.prototype.addDynamicPropertiesIntoObj = function (dest, src, props) {
8414
+ var _this = this;
8415
+ props.forEach(function (prop) {
8416
+ _this.addDynamicPropertyIntoObj(dest, src, prop.name, false);
8417
+ if (prop.serializationProperty) {
8418
+ _this.addDynamicPropertyIntoObj(dest, src, prop.serializationProperty, true);
8383
8419
  }
8420
+ if (prop.alternativeName) {
8421
+ _this.addDynamicPropertyIntoObj(dest, src, prop.alternativeName, false);
8422
+ }
8423
+ });
8424
+ };
8425
+ JsonMetadata.prototype.addDynamicPropertyIntoObj = function (dest, src, propName, isReadOnly) {
8426
+ var desc = {
8427
+ configurable: true,
8428
+ get: function () {
8429
+ return src[propName];
8430
+ },
8431
+ };
8432
+ if (!isReadOnly) {
8433
+ desc["set"] = function (v) {
8434
+ src[propName] = v;
8435
+ };
8384
8436
  }
8385
- return Object.keys(res).map(function (key) { return res[key]; });
8437
+ Object.defineProperty(dest, propName, desc);
8386
8438
  };
8387
8439
  JsonMetadata.prototype.getDynamicPropertiesByObj = function (obj, dynamicType) {
8388
8440
  if (dynamicType === void 0) { dynamicType = null; }
8389
- if (!obj || !obj.getType || (!obj.getDynamicType && !dynamicType))
8441
+ if (!obj || !obj.getType)
8442
+ return [];
8443
+ if (!!obj.getDynamicProperties)
8444
+ return obj.getDynamicProperties();
8445
+ if (!obj.getDynamicType && !dynamicType)
8390
8446
  return [];
8391
- var objType = obj.getType();
8392
8447
  var dType = !!dynamicType ? dynamicType : obj.getDynamicType();
8393
- if (!dType)
8448
+ return this.getDynamicPropertiesByTypes(obj.getType(), dType);
8449
+ };
8450
+ JsonMetadata.prototype.getDynamicPropertiesByTypes = function (objType, dynamicType, invalidNames) {
8451
+ if (!dynamicType)
8394
8452
  return [];
8395
- var cacheType = dType + "-" + objType;
8453
+ var cacheType = dynamicType + "-" + objType;
8396
8454
  if (this.dynamicPropsCache[cacheType])
8397
8455
  return this.dynamicPropsCache[cacheType];
8398
- var dynamicProps = this.getProperties(dType);
8456
+ var dynamicProps = this.getProperties(dynamicType);
8399
8457
  if (!dynamicProps || dynamicProps.length == 0)
8400
8458
  return [];
8401
8459
  var hash = {};
@@ -8404,9 +8462,11 @@ var JsonMetadata = /** @class */ (function () {
8404
8462
  hash[props[i].name] = props[i];
8405
8463
  }
8406
8464
  var res = [];
8407
- for (var i = 0; i < dynamicProps.length; i++) {
8408
- var dProp = dynamicProps[i];
8409
- if (!hash[dProp.name]) {
8465
+ if (!invalidNames)
8466
+ invalidNames = [];
8467
+ for (var i_1 = 0; i_1 < dynamicProps.length; i_1++) {
8468
+ var dProp = dynamicProps[i_1];
8469
+ if (!hash[dProp.name] && invalidNames.indexOf(dProp.name) < 0) {
8410
8470
  res.push(dProp);
8411
8471
  }
8412
8472
  }
@@ -8901,9 +8961,8 @@ var JsonObject = /** @class */ (function () {
8901
8961
  enumerable: false,
8902
8962
  configurable: true
8903
8963
  });
8904
- JsonObject.prototype.toJsonObject = function (obj, storeDefaults) {
8905
- if (storeDefaults === void 0) { storeDefaults = false; }
8906
- return this.toJsonObjectCore(obj, null, storeDefaults);
8964
+ JsonObject.prototype.toJsonObject = function (obj, options) {
8965
+ return this.toJsonObjectCore(obj, null, options);
8907
8966
  };
8908
8967
  JsonObject.prototype.toObject = function (jsonObj, obj, options) {
8909
8968
  this.toObjectCore(jsonObj, obj, options);
@@ -8952,8 +9011,7 @@ var JsonObject = /** @class */ (function () {
8952
9011
  obj.endLoadingFromJson();
8953
9012
  }
8954
9013
  };
8955
- JsonObject.prototype.toJsonObjectCore = function (obj, property, storeDefaults) {
8956
- if (storeDefaults === void 0) { storeDefaults = false; }
9014
+ JsonObject.prototype.toJsonObjectCore = function (obj, property, options) {
8957
9015
  if (!obj || !obj.getType)
8958
9016
  return obj;
8959
9017
  if (typeof obj.getData === "function")
@@ -8962,61 +9020,67 @@ var JsonObject = /** @class */ (function () {
8962
9020
  if (property != null && !property.className) {
8963
9021
  result[JsonObject.typePropertyName] = property.getObjType(obj.getType());
8964
9022
  }
8965
- this.propertiesToJson(obj, Serializer.getProperties(obj.getType()), result, storeDefaults);
8966
- this.propertiesToJson(obj, this.getDynamicProperties(obj), result, storeDefaults);
9023
+ var storeDefaults = options === true;
9024
+ if (!options || options === true) {
9025
+ options = {};
9026
+ }
9027
+ if (storeDefaults) {
9028
+ options.storeDefaults = storeDefaults;
9029
+ }
9030
+ this.propertiesToJson(obj, Serializer.getProperties(obj.getType()), result, options);
9031
+ this.propertiesToJson(obj, this.getDynamicProperties(obj), result, options);
8967
9032
  return result;
8968
9033
  };
8969
9034
  JsonObject.prototype.getDynamicProperties = function (obj) {
8970
9035
  return Serializer.getDynamicPropertiesByObj(obj);
8971
9036
  };
8972
- JsonObject.prototype.addDynamicProperties = function (obj, jsonObj, properties) {
8973
- if (!obj.getDynamicPropertyName)
8974
- return properties;
8975
- var dynamicPropName = obj.getDynamicPropertyName();
8976
- if (!dynamicPropName)
8977
- return properties;
8978
- if (jsonObj[dynamicPropName]) {
8979
- obj[dynamicPropName] = jsonObj[dynamicPropName];
8980
- }
8981
- var dynamicProperties = this.getDynamicProperties(obj);
8982
- var res = [];
8983
- for (var i = 0; i < properties.length; i++) {
8984
- res.push(properties[i]);
8985
- }
8986
- for (var i = 0; i < dynamicProperties.length; i++) {
8987
- res.push(dynamicProperties[i]);
9037
+ JsonObject.prototype.addDynamicProperties = function (obj, jsonObj, props) {
9038
+ if (!obj.getDynamicPropertyName && !obj.getDynamicProperties)
9039
+ return props;
9040
+ if (obj.getDynamicPropertyName) {
9041
+ var dynamicPropName = obj.getDynamicPropertyName();
9042
+ if (!dynamicPropName)
9043
+ return props;
9044
+ if (dynamicPropName && jsonObj[dynamicPropName]) {
9045
+ obj[dynamicPropName] = jsonObj[dynamicPropName];
9046
+ }
8988
9047
  }
8989
- return res;
9048
+ var dynamicProps = this.getDynamicProperties(obj);
9049
+ return dynamicProps.length === 0 ? props : [].concat(props).concat(dynamicProps);
8990
9050
  };
8991
- JsonObject.prototype.propertiesToJson = function (obj, properties, json, storeDefaults) {
8992
- if (storeDefaults === void 0) { storeDefaults = false; }
9051
+ JsonObject.prototype.propertiesToJson = function (obj, properties, json, options) {
8993
9052
  for (var i = 0; i < properties.length; i++) {
8994
- this.valueToJson(obj, json, properties[i], storeDefaults);
9053
+ this.valueToJson(obj, json, properties[i], options);
8995
9054
  }
8996
9055
  };
8997
- JsonObject.prototype.valueToJson = function (obj, result, property, storeDefaults) {
8998
- if (storeDefaults === void 0) { storeDefaults = false; }
8999
- if (property.isSerializable === false ||
9000
- (property.isLightSerializable === false && this.lightSerializing))
9056
+ JsonObject.prototype.valueToJson = function (obj, result, prop, options) {
9057
+ if (!options)
9058
+ options = {};
9059
+ if (prop.isSerializable === false || (prop.isLightSerializable === false && this.lightSerializing))
9060
+ return;
9061
+ if (options.version && !prop.isAvailableInVersion(options.version))
9001
9062
  return;
9002
- var value = property.getSerializableValue(obj);
9003
- if (!storeDefaults && property.isDefaultValueByObj(obj, value))
9063
+ var value = prop.getSerializableValue(obj);
9064
+ if (!options.storeDefaults && prop.isDefaultValueByObj(obj, value))
9004
9065
  return;
9005
9066
  if (this.isValueArray(value)) {
9006
9067
  var arrValue = [];
9007
9068
  for (var i = 0; i < value.length; i++) {
9008
- arrValue.push(this.toJsonObjectCore(value[i], property, storeDefaults));
9069
+ arrValue.push(this.toJsonObjectCore(value[i], prop, options));
9009
9070
  }
9010
9071
  value = arrValue.length > 0 ? arrValue : null;
9011
9072
  }
9012
9073
  else {
9013
- value = this.toJsonObjectCore(value, property, storeDefaults);
9074
+ value = this.toJsonObjectCore(value, prop, options);
9014
9075
  }
9076
+ if (value === undefined || value === null)
9077
+ return;
9078
+ var name = prop.getSerializedName(options.version);
9015
9079
  var hasValue = typeof obj["getPropertyValue"] === "function" &&
9016
- obj["getPropertyValue"](property.name, null) !== null;
9017
- if ((storeDefaults && hasValue) || !property.isDefaultValueByObj(obj, value)) {
9018
- if (!Serializer.onSerializingProperty || !Serializer.onSerializingProperty(obj, property, value, result)) {
9019
- result[property.name] = value;
9080
+ obj["getPropertyValue"](name, null) !== null;
9081
+ if ((options.storeDefaults && hasValue) || !prop.isDefaultValueByObj(obj, value)) {
9082
+ if (!Serializer.onSerializingProperty || !Serializer.onSerializingProperty(obj, prop, value, result)) {
9083
+ result[name] = this.removePosOnValueToJson(prop, value);
9020
9084
  }
9021
9085
  }
9022
9086
  };
@@ -9056,6 +9120,14 @@ var JsonObject = /** @class */ (function () {
9056
9120
  }
9057
9121
  }
9058
9122
  };
9123
+ JsonObject.prototype.removePosOnValueToJson = function (property, value) {
9124
+ if (!property.isCustom || !value)
9125
+ return value;
9126
+ if (!!value[JsonObject.positionPropertyName]) {
9127
+ delete value[JsonObject.positionPropertyName];
9128
+ }
9129
+ return value;
9130
+ };
9059
9131
  JsonObject.prototype.removePos = function (property, value) {
9060
9132
  if (!property || !property.type || property.type.indexOf("value") < 0)
9061
9133
  return;
@@ -10176,7 +10248,7 @@ var SurveyQuestionBoolean = /** @class */ (function (_super) {
10176
10248
  react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("label", { className: itemClass, onClick: this.handleOnClick },
10177
10249
  react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("input", { ref: this.checkRef, type: "checkbox", name: this.question.name, value: this.question.booleanValue === null
10178
10250
  ? ""
10179
- : this.question.booleanValue, id: this.question.inputId, className: cssClasses.control, disabled: this.isDisplayMode, checked: this.question.booleanValue || false, onChange: this.handleOnChange, "aria-required": this.question.ariaRequired, "aria-label": this.question.ariaLabel, "aria-invalid": this.question.ariaInvalid, "aria-describedby": this.question.ariaDescribedBy }),
10251
+ : this.question.booleanValue, id: this.question.inputId, className: cssClasses.control, disabled: this.isDisplayMode, checked: this.question.booleanValue || false, onChange: this.handleOnChange, role: this.question.a11y_input_ariaRole, "aria-required": this.question.a11y_input_ariaRequired, "aria-label": this.question.a11y_input_ariaLabel, "aria-labelledby": this.question.a11y_input_ariaLabelledBy, "aria-invalid": this.question.a11y_input_ariaInvalid, "aria-describedby": this.question.a11y_input_ariaDescribedBy }),
10180
10252
  react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("div", { className: cssClasses.sliderGhost, onClick: function (event) { return _this.handleOnLabelClick(event, false); } },
10181
10253
  react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("span", { className: this.question.getLabelCss(false) }, this.renderLocString(this.question.locLabelFalse))),
10182
10254
  react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("div", { className: cssClasses.switch, onClick: this.handleOnSwitchClick },
@@ -19506,7 +19578,7 @@ var SurveyQuestionSignaturePad = /** @class */ (function (_super) {
19506
19578
  react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("div", { className: cssClasses.placeholder, style: { display: this.question.needShowPlaceholder() ? "" : "none" } }, this.renderLocString(this.question.locPlaceholder)),
19507
19579
  react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("div", null,
19508
19580
  this.renderBackgroundImage(),
19509
- react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("canvas", { tabIndex: 0, className: this.question.cssClasses.canvas, onBlur: this.question.onBlur })),
19581
+ react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("canvas", { tabIndex: -1, className: this.question.cssClasses.canvas, onBlur: this.question.onBlur })),
19510
19582
  clearButton,
19511
19583
  loadingIndicator));
19512
19584
  };
@@ -20413,8 +20485,8 @@ var settings = {
20413
20485
  * @param message A message to be displayed in the confirm dialog window.
20414
20486
  * @param callback A callback function that should be called with `true` if a user confirms an action or `false` otherwise.
20415
20487
  */
20416
- confirmActionAsync: function (message, callback, applyTitle) {
20417
- return Object(_utils_utils__WEBPACK_IMPORTED_MODULE_0__["showConfirmDialog"])(message, callback, applyTitle);
20488
+ confirmActionAsync: function (message, callback, applyTitle, locale) {
20489
+ return Object(_utils_utils__WEBPACK_IMPORTED_MODULE_0__["showConfirmDialog"])(message, callback, applyTitle, locale);
20418
20490
  },
20419
20491
  /**
20420
20492
  * A minimum width value for all survey elements.
@@ -21022,7 +21094,7 @@ function confirmAction(message) {
21022
21094
  return _settings__WEBPACK_IMPORTED_MODULE_1__["settings"].confirmActionFunc(message);
21023
21095
  return confirm(message);
21024
21096
  }
21025
- function confirmActionAsync(message, funcOnYes, funcOnNo) {
21097
+ function confirmActionAsync(message, funcOnYes, funcOnNo, locale) {
21026
21098
  var callbackFunc = function (res) {
21027
21099
  if (res)
21028
21100
  funcOnYes();
@@ -21030,7 +21102,7 @@ function confirmActionAsync(message, funcOnYes, funcOnNo) {
21030
21102
  funcOnNo();
21031
21103
  };
21032
21104
  if (!!_settings__WEBPACK_IMPORTED_MODULE_1__["settings"] && !!_settings__WEBPACK_IMPORTED_MODULE_1__["settings"].confirmActionAsync) {
21033
- if (_settings__WEBPACK_IMPORTED_MODULE_1__["settings"].confirmActionAsync(message, callbackFunc))
21105
+ if (_settings__WEBPACK_IMPORTED_MODULE_1__["settings"].confirmActionAsync(message, callbackFunc, undefined, locale))
21034
21106
  return;
21035
21107
  }
21036
21108
  callbackFunc(confirmAction(message));
@@ -21379,7 +21451,7 @@ var Logger = /** @class */ (function () {
21379
21451
  return Logger;
21380
21452
  }());
21381
21453
 
21382
- function showConfirmDialog(message, callback, applyTitle) {
21454
+ function showConfirmDialog(message, callback, applyTitle, locale) {
21383
21455
  var locStr = new _localizablestring__WEBPACK_IMPORTED_MODULE_0__["LocalizableString"](undefined);
21384
21456
  var popupViewModel = _settings__WEBPACK_IMPORTED_MODULE_1__["settings"].showDialog({
21385
21457
  componentName: "sv-string-viewer",
@@ -21400,9 +21472,9 @@ function showConfirmDialog(message, callback, applyTitle) {
21400
21472
  var toolbar = popupViewModel.footerToolbar;
21401
21473
  var applyBtn = toolbar.getActionById("apply");
21402
21474
  var cancelBtn = toolbar.getActionById("cancel");
21403
- cancelBtn.title = _surveyStrings__WEBPACK_IMPORTED_MODULE_2__["surveyLocalization"].getString("cancel");
21475
+ cancelBtn.title = _surveyStrings__WEBPACK_IMPORTED_MODULE_2__["surveyLocalization"].getString("cancel", locale);
21404
21476
  cancelBtn.innerCss = "sv-popup__body-footer-item sv-popup__button sd-btn sd-btn--small";
21405
- applyBtn.title = applyTitle || _surveyStrings__WEBPACK_IMPORTED_MODULE_2__["surveyLocalization"].getString("ok");
21477
+ applyBtn.title = applyTitle || _surveyStrings__WEBPACK_IMPORTED_MODULE_2__["surveyLocalization"].getString("ok", locale);
21406
21478
  applyBtn.innerCss = "sv-popup__body-footer-item sv-popup__button sv-popup__button--danger sd-btn sd-btn--small sd-btn--danger";
21407
21479
  popupViewModel.width = "452px";
21408
21480
  return true;