survey-react 1.12.65 → 1.12.67

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/survey.react.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - Survey JavaScript library v1.12.65
2
+ * surveyjs - Survey JavaScript library v1.12.67
3
3
  * Copyright (c) 2015-2026 Devsoft Baltic OÜ - http://surveyjs.io/
4
4
  * License: MIT (http://www.opensource.org/licenses/mit-license.php)
5
5
  */
@@ -5622,24 +5622,17 @@ function dateDiff(params) {
5622
5622
  if (!Array.isArray(params) || params.length < 2 || !params[0] || !params[1])
5623
5623
  return null;
5624
5624
  var type = (params.length > 2 ? params[2] : "") || "days";
5625
- var isHours = type === "hours" || type === "minutes";
5626
- var dType = isHours ? "days" : type;
5627
- var days = dateDiffMonths(params[0], params[1], dType);
5628
- if (isHours) {
5629
- var date1 = createDate("function-dateDiffMonths", params[0]);
5630
- var date2 = createDate("function-dateDiffMonths", params[1]);
5631
- if (date2.getHours() > date1.getHours() || (type !== "hours" && date2.getHours() === date1.getHours() && date2.getMinutes() > date1.getMinutes())) {
5632
- days -= 1;
5633
- }
5634
- var hours = days * 24 + date2.getHours() - date1.getHours();
5625
+ if (type === "hours" || type === "minutes" || type === "seconds") {
5626
+ var date1 = createDate("function-dateDiff", params[0]);
5627
+ var date2 = createDate("function-dateDiff", params[1]);
5628
+ var diffMs = Math.abs(date2 - date1);
5635
5629
  if (type === "hours")
5636
- return hours;
5637
- if (date2.getMinutes() < date1.getMinutes()) {
5638
- hours -= 1;
5639
- }
5640
- return hours * 60 + date2.getMinutes() - date1.getMinutes();
5630
+ return Math.ceil(diffMs / (1000 * 60 * 60));
5631
+ if (type === "minutes")
5632
+ return Math.ceil(diffMs / (1000 * 60));
5633
+ return Math.ceil(diffMs / 1000);
5641
5634
  }
5642
- return days;
5635
+ return dateDiffMonths(params[0], params[1], type);
5643
5636
  }
5644
5637
  functionsfactory_FunctionFactory.Instance.register("dateDiff", dateDiff);
5645
5638
  function dateAdd(params) {
@@ -21376,9 +21369,7 @@ var question_Question = /** @class */ (function (_super) {
21376
21369
  * @see SurveyModel.getQuizQuestions
21377
21370
  */
21378
21371
  get: function () {
21379
- if (this.isVisible &&
21380
- this.hasInput &&
21381
- !this.isValueEmpty(this.correctAnswer))
21372
+ if (this.isVisible && this.hasInput && this.hasCorrectAnswerValue())
21382
21373
  return this.getQuizQuestionCount();
21383
21374
  return 0;
21384
21375
  },
@@ -21387,13 +21378,16 @@ var question_Question = /** @class */ (function (_super) {
21387
21378
  });
21388
21379
  Object.defineProperty(Question.prototype, "correctAnswerCount", {
21389
21380
  get: function () {
21390
- if (!this.isEmpty() && !this.isValueEmpty(this.correctAnswer))
21381
+ if (!this.isEmpty() && this.hasCorrectAnswerValue())
21391
21382
  return this.getCorrectAnswerCount();
21392
21383
  return 0;
21393
21384
  },
21394
21385
  enumerable: false,
21395
21386
  configurable: true
21396
21387
  });
21388
+ Question.prototype.hasCorrectAnswerValue = function () {
21389
+ return !this.isValueEmpty(this.correctAnswer);
21390
+ };
21397
21391
  Question.prototype.getQuizQuestionCount = function () {
21398
21392
  return 1;
21399
21393
  };
@@ -60577,10 +60571,8 @@ var question_ranking_QuestionRankingModel = /** @class */ (function (_super) {
60577
60571
  _this.updateRankingChoices();
60578
60572
  return;
60579
60573
  }
60580
- if (_this.visibleChoices.length > _this.value.length)
60581
- _this.addToValueByVisibleChoices();
60582
- if (_this.visibleChoices.length < _this.value.length)
60583
- _this.removeFromValueByVisibleChoices();
60574
+ _this.syncDefaultValueWithVisibleChoices();
60575
+ _this.syncValueWithVisibleChoices();
60584
60576
  _this.updateRankingChoices();
60585
60577
  };
60586
60578
  _this.localeChanged = function () {
@@ -60779,11 +60771,14 @@ var question_ranking_QuestionRankingModel = /** @class */ (function (_super) {
60779
60771
  _super.prototype.onSurveyValueChanged.call(this, newValue);
60780
60772
  if (this.isLoadingFromJson)
60781
60773
  return;
60774
+ this.syncValueWithVisibleChoices();
60782
60775
  this.updateRankingChoices();
60783
60776
  };
60784
60777
  QuestionRankingModel.prototype.onSurveyLoad = function () {
60785
60778
  this.blockAnimations();
60786
60779
  _super.prototype.onSurveyLoad.call(this);
60780
+ this.syncDefaultValueWithVisibleChoices();
60781
+ this.syncValueWithVisibleChoices();
60787
60782
  this.updateRankingChoices();
60788
60783
  this.releaseAnimations();
60789
60784
  };
@@ -60792,24 +60787,41 @@ var question_ranking_QuestionRankingModel = /** @class */ (function (_super) {
60792
60787
  if (newValue)
60793
60788
  this.isValueSetByUser = true;
60794
60789
  };
60795
- QuestionRankingModel.prototype.addToValueByVisibleChoices = function () {
60796
- var newValue = this.value.slice();
60797
- this.visibleChoices.forEach(function (choice) {
60798
- if (newValue.indexOf(choice.value) === -1) {
60799
- newValue.push(choice.value);
60790
+ QuestionRankingModel.prototype.getRankedValueByVisibleChoices = function (value) {
60791
+ var _this = this;
60792
+ var res = [];
60793
+ var filteredVisibleChoices = this.visibleChoices.filter(function (choice) { return _this.isItemInList(choice); });
60794
+ (Array.isArray(value) ? value : []).forEach(function (valueItem) {
60795
+ if (!!itemvalue_ItemValue.getItemByValue(filteredVisibleChoices, valueItem) && res.indexOf(valueItem) < 0) {
60796
+ res.push(valueItem);
60800
60797
  }
60801
60798
  });
60802
- this.value = newValue;
60803
- };
60804
- QuestionRankingModel.prototype.removeFromValueByVisibleChoices = function () {
60805
- var newValue = this.value.slice();
60806
- var choices = this.visibleChoices;
60807
- for (var i = this.value.length - 1; i >= 0; i--) {
60808
- if (!itemvalue_ItemValue.getItemByValue(choices, this.value[i])) {
60809
- newValue.splice(i, 1);
60799
+ filteredVisibleChoices.forEach(function (choice) {
60800
+ if (res.indexOf(choice.value) < 0) {
60801
+ res.push(choice.value);
60810
60802
  }
60803
+ });
60804
+ return res;
60805
+ };
60806
+ QuestionRankingModel.prototype.syncValueWithVisibleChoices = function () {
60807
+ if (this.selectToRankEnabled || this.isEmpty())
60808
+ return;
60809
+ var newValue = this.getRankedValueByVisibleChoices(this.value);
60810
+ if (!this.isTwoValueEquals(this.value, newValue)) {
60811
+ this.value = newValue;
60812
+ }
60813
+ };
60814
+ // the defaultValue should contain all choices as the question value does, otherwise a user sees a part of choices in the designer
60815
+ QuestionRankingModel.prototype.syncDefaultValueWithVisibleChoices = function () {
60816
+ if (!this.isDesignMode || this.isLoadingFromJson || this.selectToRankEnabled)
60817
+ return;
60818
+ var defaultValue = this.defaultValue;
60819
+ if (!Array.isArray(defaultValue) || defaultValue.length === 0)
60820
+ return;
60821
+ var newValue = this.getRankedValueByVisibleChoices(defaultValue);
60822
+ if (!this.isTwoValueEquals(defaultValue, newValue)) {
60823
+ this.defaultValue = newValue;
60811
60824
  }
60812
- this.value = newValue;
60813
60825
  };
60814
60826
  QuestionRankingModel.prototype.getChoicesAnimationOptions = function (isRankingChoices) {
60815
60827
  var _this = this;
@@ -60929,6 +60941,11 @@ var question_ranking_QuestionRankingModel = /** @class */ (function (_super) {
60929
60941
  newRankingChoices.push(choice);
60930
60942
  });
60931
60943
  });
60944
+ this.visibleChoices.forEach(function (choice) {
60945
+ if (newRankingChoices.indexOf(choice) < 0) {
60946
+ newRankingChoices.push(choice);
60947
+ }
60948
+ });
60932
60949
  this.rankingChoices = newRankingChoices;
60933
60950
  };
60934
60951
  QuestionRankingModel.prototype.updateUnRankingChoices = function (newRankingChoices) {
@@ -69060,6 +69077,34 @@ var question_paneldynamic_QuestionPanelDynamicModel = /** @class */ (function (_
69060
69077
  QuestionPanelDynamicModel.prototype.getProgressInfo = function () {
69061
69078
  return survey_element_SurveyElement.getProgressInfoByElements(this.visiblePanelsCore, this.isRequired);
69062
69079
  };
69080
+ QuestionPanelDynamicModel.prototype.hasCorrectAnswerValue = function () {
69081
+ return this.getQuizQuestionsInPanels().length > 0 || _super.prototype.hasCorrectAnswerValue.call(this);
69082
+ };
69083
+ QuestionPanelDynamicModel.prototype.getQuizQuestionCount = function () {
69084
+ var _this = this;
69085
+ return this.calcQuizCountInPanels(function (q) { return q.quizQuestionCount; }, function () { return _super.prototype.getQuizQuestionCount.call(_this); });
69086
+ };
69087
+ QuestionPanelDynamicModel.prototype.getCorrectAnswerCount = function () {
69088
+ var _this = this;
69089
+ return this.calcQuizCountInPanels(function (q) { return q.correctAnswerCount; }, function () { return _super.prototype.getCorrectAnswerCount.call(_this); });
69090
+ };
69091
+ QuestionPanelDynamicModel.prototype.calcQuizCountInPanels = function (getCount, getDefault) {
69092
+ var questions = this.getQuizQuestionsInPanels();
69093
+ return questions.length === 0
69094
+ ? getDefault()
69095
+ : questions.reduce(function (res, q) { return res + getCount(q); }, 0);
69096
+ };
69097
+ QuestionPanelDynamicModel.prototype.getQuizQuestionsInPanels = function () {
69098
+ var res = [];
69099
+ this.visiblePanels.forEach(function (panel) {
69100
+ panel.questions.forEach(function (q) {
69101
+ if (q.quizQuestionCount > 0) {
69102
+ res.push(q);
69103
+ }
69104
+ });
69105
+ });
69106
+ return res;
69107
+ };
69063
69108
  QuestionPanelDynamicModel.prototype.isRowEmpty = function (val) {
69064
69109
  for (var prop in val) {
69065
69110
  if (val.hasOwnProperty(prop))
@@ -73404,9 +73449,9 @@ Serializer.addClass("currencymask", [
73404
73449
 
73405
73450
  var Version;
73406
73451
  var ReleaseDate;
73407
- Version = "" + "1.12.65";
73452
+ Version = "" + "1.12.67";
73408
73453
  settings.version = Version;
73409
- ReleaseDate = "" + "2026-07-20";
73454
+ ReleaseDate = "" + "2026-08-04";
73410
73455
  function checkLibraryVersion(ver, libraryName) {
73411
73456
  if (Version != ver) {
73412
73457
  var str = "survey-core has version '" + Version + "' and " + libraryName