survey-react-ui 1.9.117 → 1.9.118

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.117",
3
+ "version": "1.9.118",
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",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "typings": "survey-react-ui.d.ts",
23
23
  "dependencies": {
24
- "survey-core": "1.9.117",
24
+ "survey-core": "1.9.118",
25
25
  "react": "^16.5.0 || ^17.0.1 || ^18.1.0",
26
26
  "react-dom": "^16.5.0 || ^17.0.1 || ^18.1.0"
27
27
  }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - Survey JavaScript library v1.9.117
2
+ * surveyjs - Survey JavaScript library v1.9.118
3
3
  * Copyright (c) 2015-2023 Devsoft Baltic OÜ - http://surveyjs.io/
4
4
  * License: MIT (http://www.opensource.org/licenses/mit-license.php)
5
5
  */
@@ -2564,7 +2564,7 @@ __webpack_require__.r(__webpack_exports__);
2564
2564
 
2565
2565
 
2566
2566
 
2567
- Object(survey_core__WEBPACK_IMPORTED_MODULE_2__["checkLibraryVersion"])("" + "1.9.117", "survey-react-ui");
2567
+ Object(survey_core__WEBPACK_IMPORTED_MODULE_2__["checkLibraryVersion"])("" + "1.9.118", "survey-react-ui");
2568
2568
 
2569
2569
 
2570
2570
  /***/ }),
@@ -7510,6 +7510,11 @@ var JsonObjectProperty = /** @class */ (function () {
7510
7510
  return ((value === false && (this.type == "boolean" || this.type == "switch")) ||
7511
7511
  value === "" || _helpers__WEBPACK_IMPORTED_MODULE_2__["Helpers"].isValueEmpty(value));
7512
7512
  };
7513
+ JsonObjectProperty.prototype.getSerializableValue = function (obj) {
7514
+ if (!!this.onSerializeValue)
7515
+ return this.onSerializeValue(obj);
7516
+ return this.getValue(obj);
7517
+ };
7513
7518
  JsonObjectProperty.prototype.getValue = function (obj) {
7514
7519
  if (this.onGetValue)
7515
7520
  return this.onGetValue(obj);
@@ -8101,6 +8106,9 @@ var JsonMetadataClass = /** @class */ (function () {
8101
8106
  if (!!propInfo.baseValue) {
8102
8107
  prop.setBaseValue(propInfo.baseValue);
8103
8108
  }
8109
+ if (propInfo.onSerializeValue) {
8110
+ prop.onSerializeValue = propInfo.onSerializeValue;
8111
+ }
8104
8112
  if (propInfo.onGetValue) {
8105
8113
  prop.onGetValue = propInfo.onGetValue;
8106
8114
  }
@@ -8895,7 +8903,7 @@ var JsonObject = /** @class */ (function () {
8895
8903
  if (property.isSerializable === false ||
8896
8904
  (property.isLightSerializable === false && this.lightSerializing))
8897
8905
  return;
8898
- var value = property.getValue(obj);
8906
+ var value = property.getSerializableValue(obj);
8899
8907
  if (!storeDefaults && property.isDefaultValueByObj(obj, value))
8900
8908
  return;
8901
8909
  if (this.isValueArray(value)) {
@@ -9736,8 +9744,8 @@ var englishStrings = {
9736
9744
  textMaxLength: "Please enter no more than {0} character(s).",
9737
9745
  textMinMaxLength: "Please enter at least {0} and no more than {1} characters.",
9738
9746
  minRowCountError: "Please fill in at least {0} row(s).",
9739
- minSelectError: "Please select at least {0} variant(s).",
9740
- maxSelectError: "Please select no more than {0} variant(s).",
9747
+ minSelectError: "Please select at least {0} option(s).",
9748
+ maxSelectError: "Please select no more than {0} option(s).",
9741
9749
  numericMinMax: "The '{0}' should be at least {1} and at most {2}",
9742
9750
  numericMin: "The '{0}' should be at least {1}",
9743
9751
  numericMax: "The '{0}' should be at most {1}",
@@ -15999,8 +16007,10 @@ __webpack_require__.r(__webpack_exports__);
15999
16007
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
16000
16008
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
16001
16009
  /* harmony import */ var _reactquestion_element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./reactquestion_element */ "./src/react/reactquestion_element.tsx");
16002
- /* harmony import */ var _reactquestion_factory__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./reactquestion_factory */ "./src/react/reactquestion_factory.tsx");
16003
- /* harmony import */ var _components_character_counter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./components/character-counter */ "./src/react/components/character-counter.tsx");
16010
+ /* harmony import */ var survey_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! survey-core */ "survey-core");
16011
+ /* harmony import */ var survey_core__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(survey_core__WEBPACK_IMPORTED_MODULE_2__);
16012
+ /* harmony import */ var _reactquestion_factory__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./reactquestion_factory */ "./src/react/reactquestion_factory.tsx");
16013
+ /* harmony import */ var _components_character_counter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./components/character-counter */ "./src/react/components/character-counter.tsx");
16004
16014
  var __extends = (undefined && undefined.__extends) || (function () {
16005
16015
  var extendStatics = function (d, b) {
16006
16016
  extendStatics = Object.setPrototypeOf ||
@@ -16020,6 +16030,7 @@ var __extends = (undefined && undefined.__extends) || (function () {
16020
16030
 
16021
16031
 
16022
16032
 
16033
+
16023
16034
  var SurveyQuestionComment = /** @class */ (function (_super) {
16024
16035
  __extends(SurveyQuestionComment, _super);
16025
16036
  function SurveyQuestionComment(props) {
@@ -16042,7 +16053,7 @@ var SurveyQuestionComment = /** @class */ (function (_super) {
16042
16053
  if (this.question.isReadOnlyRenderDiv()) {
16043
16054
  return react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("div", null, this.question.value);
16044
16055
  }
16045
- var counter = !!this.question.getMaxLength() ? (react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_components_character_counter__WEBPACK_IMPORTED_MODULE_3__["CharacterCounterComponent"], { counter: this.question.characterCounter, remainingCharacterCounter: this.question.cssClasses.remainingCharacterCounter })) : null;
16056
+ var counter = !!this.question.getMaxLength() ? (react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_components_character_counter__WEBPACK_IMPORTED_MODULE_4__["CharacterCounterComponent"], { counter: this.question.characterCounter, remainingCharacterCounter: this.question.cssClasses.remainingCharacterCounter })) : null;
16046
16057
  return (react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react__WEBPACK_IMPORTED_MODULE_0__["Fragment"], null,
16047
16058
  react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("textarea", { id: this.question.inputId, className: this.question.className, disabled: this.question.isInputReadOnly, readOnly: this.question.isInputReadOnly, ref: function (textarea) { return (_this.setControl(textarea)); }, maxLength: this.question.getMaxLength(), placeholder: placeholder, onBlur: onBlur, onInput: onInput, onKeyDown: function (event) { _this.question.onKeyDown(event); }, cols: this.question.cols, rows: this.question.rows, "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, style: { resize: this.question.resizeStyle } }),
16048
16059
  counter));
@@ -16052,9 +16063,19 @@ var SurveyQuestionComment = /** @class */ (function (_super) {
16052
16063
 
16053
16064
  var SurveyQuestionCommentItem = /** @class */ (function (_super) {
16054
16065
  __extends(SurveyQuestionCommentItem, _super);
16055
- function SurveyQuestionCommentItem() {
16056
- return _super !== null && _super.apply(this, arguments) || this;
16066
+ function SurveyQuestionCommentItem(props) {
16067
+ var _this = _super.call(this, props) || this;
16068
+ _this.state = { comment: _this.getComment() || "" };
16069
+ return _this;
16057
16070
  }
16071
+ SurveyQuestionCommentItem.prototype.getStateComment = function () {
16072
+ var comment = this.getComment();
16073
+ var stateComment = this.state.comment;
16074
+ if (stateComment !== undefined && stateComment.trim() !== comment) {
16075
+ stateComment = comment;
16076
+ }
16077
+ return stateComment !== undefined ? stateComment : comment || "";
16078
+ };
16058
16079
  SurveyQuestionCommentItem.prototype.canRender = function () {
16059
16080
  return !!this.props.question;
16060
16081
  };
@@ -16064,12 +16085,12 @@ var SurveyQuestionCommentItem = /** @class */ (function (_super) {
16064
16085
  SurveyQuestionCommentItem.prototype.onCommentInput = function (event) {
16065
16086
  this.props.question.onCommentInput(event);
16066
16087
  };
16067
- SurveyQuestionCommentItem.prototype.onCommentCompositionUpdate = function (event) {
16068
- this.props.question.onCompositionUpdateComment(event);
16069
- };
16070
16088
  SurveyQuestionCommentItem.prototype.getComment = function () {
16071
16089
  return this.props.question.comment;
16072
16090
  };
16091
+ SurveyQuestionCommentItem.prototype.setComment = function (value) {
16092
+ this.props.question.comment = value;
16093
+ };
16073
16094
  SurveyQuestionCommentItem.prototype.getId = function () {
16074
16095
  return this.props.question.commentId;
16075
16096
  };
@@ -16082,18 +16103,16 @@ var SurveyQuestionCommentItem = /** @class */ (function (_super) {
16082
16103
  var className = this.props.otherCss || this.cssClasses.comment;
16083
16104
  var handleOnChange = function (event) {
16084
16105
  _this.setState({ comment: event.target.value });
16085
- _this.onCommentChange(event);
16106
+ // https://github.com/surveyjs/survey-library/issues/7252
16107
+ if (!survey_core__WEBPACK_IMPORTED_MODULE_2__["Helpers"].isTwoValueEquals(_this.getComment(), event.target.value, false, true, false)) {
16108
+ _this.setComment(event.target.value);
16109
+ }
16086
16110
  };
16087
- var questionComment = this.getComment();
16088
- var stateComment = !!this.state ? this.state.comment : undefined;
16089
- if (stateComment !== undefined && stateComment.trim() !== questionComment) {
16090
- stateComment = questionComment;
16091
- }
16092
- var comment = stateComment !== undefined ? stateComment : questionComment || "";
16111
+ var comment = this.getStateComment();
16093
16112
  if (question.isReadOnlyRenderDiv()) {
16094
16113
  return react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("div", null, comment);
16095
16114
  }
16096
- return (react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("textarea", { id: this.getId(), className: className, value: comment, disabled: this.isDisplayMode, maxLength: question.getOthersMaxLength(), placeholder: this.getPlaceholder(), onChange: handleOnChange, onBlur: function (e) { _this.onCommentChange(e); handleOnChange(e); }, onInput: function (e) { return _this.onCommentInput(e); }, onCompositionUpdate: function (e) { return _this.onCommentCompositionUpdate(e); }, "aria-required": question.isRequired || question.a11y_input_ariaRequired, "aria-label": question.ariaLabel || question.a11y_input_ariaLabel, style: { resize: question.resizeStyle } }));
16115
+ return (react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("textarea", { id: this.getId(), className: className, value: comment, disabled: this.isDisplayMode, maxLength: question.getOthersMaxLength(), placeholder: this.getPlaceholder(), onChange: handleOnChange, onBlur: function (e) { _this.onCommentChange(e); handleOnChange(e); }, onInput: function (e) { return _this.onCommentInput(e); }, "aria-required": question.isRequired || question.a11y_input_ariaRequired, "aria-label": question.ariaLabel || question.a11y_input_ariaLabel, style: { resize: question.resizeStyle } }));
16097
16116
  };
16098
16117
  return SurveyQuestionCommentItem;
16099
16118
  }(_reactquestion_element__WEBPACK_IMPORTED_MODULE_1__["ReactSurveyElement"]));
@@ -16109,12 +16128,12 @@ var SurveyQuestionOtherValueItem = /** @class */ (function (_super) {
16109
16128
  SurveyQuestionOtherValueItem.prototype.onCommentInput = function (event) {
16110
16129
  this.props.question.onOtherValueInput(event);
16111
16130
  };
16112
- SurveyQuestionOtherValueItem.prototype.onCommentCompositionUpdate = function (event) {
16113
- this.props.question.onCompositionUpdateOtherValue(event);
16114
- };
16115
16131
  SurveyQuestionOtherValueItem.prototype.getComment = function () {
16116
16132
  return this.props.question.otherValue;
16117
16133
  };
16134
+ SurveyQuestionOtherValueItem.prototype.setComment = function (value) {
16135
+ this.props.question.otherValue = value;
16136
+ };
16118
16137
  SurveyQuestionOtherValueItem.prototype.getId = function () {
16119
16138
  return this.props.question.otherId;
16120
16139
  };
@@ -16124,7 +16143,7 @@ var SurveyQuestionOtherValueItem = /** @class */ (function (_super) {
16124
16143
  return SurveyQuestionOtherValueItem;
16125
16144
  }(SurveyQuestionCommentItem));
16126
16145
 
16127
- _reactquestion_factory__WEBPACK_IMPORTED_MODULE_2__["ReactQuestionFactory"].Instance.registerQuestion("comment", function (props) {
16146
+ _reactquestion_factory__WEBPACK_IMPORTED_MODULE_3__["ReactQuestionFactory"].Instance.registerQuestion("comment", function (props) {
16128
16147
  return react__WEBPACK_IMPORTED_MODULE_0__["createElement"](SurveyQuestionComment, props);
16129
16148
  });
16130
16149
 
@@ -17171,7 +17190,7 @@ var SurveyQuestionMatrixRow = /** @class */ (function (_super) {
17171
17190
  else {
17172
17191
  td = (react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("td", { key: key, "data-responsive-title": column.locText.renderedHtml, className: this.question.cssClasses.cell },
17173
17192
  react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("label", { onMouseDown: this.handleOnMouseDown, className: itemClass },
17174
- react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("input", { id: inputId, type: "radio", className: this.cssClasses.itemValue, name: row.fullName, value: column.value, disabled: this.isDisplayMode, checked: isChecked, onChange: this.handleOnChange, "aria-required": this.question.ariaRequired, "aria-label": this.question.getCellAriaLabel(row.locText.renderedHtml, column.locText.renderedHtml), "aria-invalid": this.question.ariaInvalid, "aria-describedby": this.question.ariaDescribedBy }),
17193
+ react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("input", { id: inputId, type: "radio", className: this.cssClasses.itemValue, name: row.fullName, value: column.value, disabled: this.isDisplayMode, checked: isChecked, onChange: this.handleOnChange, "aria-required": this.question.a11y_input_ariaRequired, "aria-label": this.question.getCellAriaLabel(row.locText.renderedHtml, column.locText.renderedHtml), "aria-invalid": this.question.a11y_input_ariaInvalid, "aria-describedby": this.question.a11y_input_ariaDescribedBy }),
17175
17194
  react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("span", { className: this.question.cssClasses.materialDecorator }, this.question.itemSvgIcon ?
17176
17195
  react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("svg", { className: this.cssClasses.itemDecorator },
17177
17196
  react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("use", { xlinkHref: this.question.itemSvgIcon })) :
@@ -20167,6 +20186,27 @@ var settings = {
20167
20186
  * Default value: `"none"`
20168
20187
  */
20169
20188
  noneItemValue: "none",
20189
+ /**
20190
+ * An object whose properties specify the order of the special choice items (None, Other, Select All) in select-based questions.
20191
+ *
20192
+ * Default value: `{ selectAllItem: [-1], noneItem: [1], otherItem: [2] }`
20193
+ *
20194
+ * Use this object to reorder special choices. Each property accepts an array of integer numbers. Negative numbers place a special choice item above regular choice items, positive numbers place it below them. For instance, the code below specifies the following order of choices: None, Select All, regular choices, Other.
20195
+ *
20196
+ * ```js
20197
+ * import { settings } from "survey-core";
20198
+ *
20199
+ * settings.specialChoicesOrder.noneItem = [-2];
20200
+ * settings.specialChoicesOrder.selectAllItem = [-1];
20201
+ * settings.specialChoicesOrder.otherItem = [1];
20202
+ * ```
20203
+ *
20204
+ * If you want to duplicate a special choice item above and below other choices, add two numbers to the corresponding array:
20205
+ *
20206
+ * ```js
20207
+ * settings.specialChoicesOrder.selectAllItem = [-1, 3] // Displays Select All above and below other choices
20208
+ * ```
20209
+ */
20170
20210
  specialChoicesOrder: {
20171
20211
  selectAllItem: [-1],
20172
20212
  noneItem: [1],
@@ -20534,19 +20574,36 @@ var ResponsivityManager = /** @class */ (function () {
20534
20574
  configurable: true
20535
20575
  });
20536
20576
  ResponsivityManager.prototype.process = function () {
20537
- var _a;
20577
+ var _this = this;
20538
20578
  if (this.isContainerVisible && !this.model.isResponsivenessDisabled) {
20539
20579
  if (!this.isInitialized) {
20540
20580
  this.model.setActionsMode("large");
20541
- this.calcItemsSizes();
20542
- this.isInitialized = true;
20581
+ var recalcItemSizes = function () {
20582
+ _this.calcItemsSizes();
20583
+ _this.isInitialized = true;
20584
+ };
20585
+ if (queueMicrotask) {
20586
+ queueMicrotask(recalcItemSizes);
20587
+ }
20588
+ else {
20589
+ recalcItemSizes();
20590
+ }
20543
20591
  }
20544
- var dotsItemSize = this.dotsItemSize;
20545
- if (!this.dotsItemSize) {
20546
- var dotsItemElement = (_a = this.container) === null || _a === void 0 ? void 0 : _a.querySelector(".sv-dots");
20547
- dotsItemSize = dotsItemElement && this.calcItemSize(dotsItemElement) || this.dotsSizeConst;
20592
+ var processResponsiveness = function () {
20593
+ var _a;
20594
+ var dotsItemSize = _this.dotsItemSize;
20595
+ if (!_this.dotsItemSize) {
20596
+ var dotsItemElement = (_a = _this.container) === null || _a === void 0 ? void 0 : _a.querySelector(".sv-dots");
20597
+ dotsItemSize = dotsItemElement && _this.calcItemSize(dotsItemElement) || _this.dotsSizeConst;
20598
+ }
20599
+ _this.model.fit(_this.getAvailableSpace(), dotsItemSize);
20600
+ };
20601
+ if (queueMicrotask) {
20602
+ queueMicrotask(processResponsiveness);
20603
+ }
20604
+ else {
20605
+ processResponsiveness();
20548
20606
  }
20549
- this.model.fit(this.getAvailableSpace(), dotsItemSize);
20550
20607
  }
20551
20608
  };
20552
20609
  ResponsivityManager.prototype.dispose = function () {
@@ -20968,6 +21025,9 @@ function findParentByClassNames(element, classNames) {
20968
21025
  function sanitizeEditableContent(element) {
20969
21026
  if (window.getSelection && document.createRange && element.childNodes.length > 0) {
20970
21027
  var selection = document.getSelection();
21028
+ if (selection.rangeCount == 0) {
21029
+ return;
21030
+ }
20971
21031
  var range = selection.getRangeAt(0);
20972
21032
  range.setStart(range.endContainer, range.endOffset);
20973
21033
  range.setEndAfter(element.lastChild);