survey-react-ui 1.11.13 → 1.12.1

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.11.13",
3
+ "version": "1.12.1",
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": "./typings/src/entries/react-ui.d.ts",
23
23
  "peerDependencies": {
24
- "survey-core": "1.11.13",
24
+ "survey-core": "1.12.1",
25
25
  "react": "^16.5.0 || ^17.0.1 || ^18.2.0",
26
26
  "react-dom": "^16.5.0 || ^17.0.1 || ^18.2.0"
27
27
  }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - Survey JavaScript library v1.11.13
2
+ * surveyjs - Survey JavaScript library v1.12.1
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
  */
@@ -345,6 +345,7 @@ var reactquestion_element_SurveyElementBase = /** @class */ (function (_super) {
345
345
  function SurveyElementBase(props) {
346
346
  var _this = _super.call(this, props) || this;
347
347
  _this._allowComponentUpdate = true;
348
+ _this.prevStateElements = [];
348
349
  return _this;
349
350
  }
350
351
  SurveyElementBase.renderLocString = function (locStr, style, key) {
@@ -364,9 +365,14 @@ var reactquestion_element_SurveyElementBase = /** @class */ (function (_super) {
364
365
  };
365
366
  SurveyElementBase.prototype.componentWillUnmount = function () {
366
367
  this.unMakeBaseElementsReact();
368
+ this.disableStateElementsRerenderEvent(this.getStateElements());
367
369
  };
368
370
  SurveyElementBase.prototype.componentDidUpdate = function (prevProps, prevState) {
371
+ var _a;
369
372
  this.makeBaseElementsReact();
373
+ var stateElements = this.getStateElements();
374
+ this.disableStateElementsRerenderEvent(((_a = this.prevStateElements) !== null && _a !== void 0 ? _a : []).filter(function (el) { return !stateElements.includes(el); }));
375
+ this.prevStateElements = [];
370
376
  this.getStateElements().forEach(function (el) {
371
377
  el.afterRerender();
372
378
  });
@@ -381,6 +387,7 @@ var reactquestion_element_SurveyElementBase = /** @class */ (function (_super) {
381
387
  SurveyElementBase.prototype.shouldComponentUpdate = function (nextProps, nextState) {
382
388
  if (this._allowComponentUpdate) {
383
389
  this.unMakeBaseElementsReact();
390
+ this.prevStateElements = this.getStateElements();
384
391
  }
385
392
  return this._allowComponentUpdate;
386
393
  };
@@ -448,10 +455,14 @@ var reactquestion_element_SurveyElementBase = /** @class */ (function (_super) {
448
455
  SurveyElementBase.prototype.unMakeBaseElementsReact = function () {
449
456
  var els = this.getStateElements();
450
457
  for (var i = 0; i < els.length; i++) {
451
- els[i].disableOnElementRenderedEvent();
452
458
  this.unMakeBaseElementReact(els[i]);
453
459
  }
454
460
  };
461
+ SurveyElementBase.prototype.disableStateElementsRerenderEvent = function (els) {
462
+ els.forEach(function (el) {
463
+ el.disableOnElementRenderedEvent();
464
+ });
465
+ };
455
466
  SurveyElementBase.prototype.getStateElements = function () {
456
467
  var el = this.getStateElement();
457
468
  return !!el ? [el] : [];
@@ -1236,7 +1247,7 @@ var action_bar_item_SurveyActionBarItem = /** @class */ (function (_super) {
1236
1247
  var title = this.item.tooltip || this.item.title;
1237
1248
  var buttonContent = this.renderButtonContent();
1238
1249
  var tabIndex = this.item.disableTabStop ? -1 : undefined;
1239
- var button = attachKey2click(external_root_React_commonjs2_react_commonjs_react_amd_react_default.a.createElement("button", { className: className, type: "button", disabled: this.item.disabled, onMouseDown: function () { return _this.item.doMouseDown(); }, onFocus: function (args) { return _this.item.doFocus(args); }, onClick: function (args) { return _this.item.doAction(args); }, title: title, tabIndex: tabIndex, "aria-checked": this.item.ariaChecked, "aria-expanded": this.item.ariaExpanded, role: this.item.ariaRole }, buttonContent), this.item, { processEsc: false });
1250
+ var button = attachKey2click(external_root_React_commonjs2_react_commonjs_react_amd_react_default.a.createElement("button", { className: className, type: "button", disabled: this.item.disabled, onMouseDown: function (args) { return _this.item.doMouseDown(args); }, onFocus: function (args) { return _this.item.doFocus(args); }, onClick: function (args) { return _this.item.doAction(args); }, title: title, tabIndex: tabIndex, "aria-checked": this.item.ariaChecked, "aria-expanded": this.item.ariaExpanded, role: this.item.ariaRole }, buttonContent), this.item, { processEsc: false });
1240
1251
  return button;
1241
1252
  };
1242
1253
  return SurveyActionBarItem;
@@ -3596,7 +3607,7 @@ var reactquestion_checkbox_SurveyQuestionCheckbox = /** @class */ (function (_su
3596
3607
  var _this = this;
3597
3608
  if (this.question.hasHeadItems) {
3598
3609
  return this.question.headItems.map(function (item, ii) {
3599
- return _this.renderItem("item_h" + ii, item, false, _this.question.cssClasses);
3610
+ return _this.renderItem(item, false, _this.question.cssClasses);
3600
3611
  });
3601
3612
  }
3602
3613
  };
@@ -3604,7 +3615,7 @@ var reactquestion_checkbox_SurveyQuestionCheckbox = /** @class */ (function (_su
3604
3615
  var _this = this;
3605
3616
  if (this.question.hasFootItems) {
3606
3617
  return this.question.footItems.map(function (item, ii) {
3607
- return _this.renderItem("item_f" + ii, item, false, _this.question.cssClasses);
3618
+ return _this.renderItem(item, false, _this.question.cssClasses);
3608
3619
  });
3609
3620
  }
3610
3621
  };
@@ -3615,7 +3626,7 @@ var reactquestion_checkbox_SurveyQuestionCheckbox = /** @class */ (function (_su
3615
3626
  var _this = this;
3616
3627
  return this.question.columns.map(function (column, ci) {
3617
3628
  var items = column.map(function (item, ii) {
3618
- return _this.renderItem("item" + ii, item, ci === 0 && ii === 0, cssClasses, "" + ci + ii);
3629
+ return _this.renderItem(item, ci === 0 && ii === 0, cssClasses, "" + ci + ii);
3619
3630
  });
3620
3631
  return (external_root_React_commonjs2_react_commonjs_react_amd_react_["createElement"]("div", { key: "column" + ci + _this.question.getItemsColumnKey(column), className: _this.question.getColumnClass(), role: "presentation" }, items));
3621
3632
  });
@@ -3631,8 +3642,8 @@ var reactquestion_checkbox_SurveyQuestionCheckbox = /** @class */ (function (_su
3631
3642
  var renderedItems = [];
3632
3643
  for (var i = 0; i < choices.length; i++) {
3633
3644
  var item = choices[i];
3634
- var key = "item" + i;
3635
- var renderedItem = this.renderItem(key, item, i == 0, cssClasses, "" + i);
3645
+ var key = "item" + item.value;
3646
+ var renderedItem = this.renderItem(item, i == 0, cssClasses, "" + i);
3636
3647
  if (!!renderedItem) {
3637
3648
  renderedItems.push(renderedItem);
3638
3649
  }
@@ -3651,9 +3662,9 @@ var reactquestion_checkbox_SurveyQuestionCheckbox = /** @class */ (function (_su
3651
3662
  return (external_root_React_commonjs2_react_commonjs_react_amd_react_["createElement"]("div", { className: this.question.getCommentAreaCss(true) },
3652
3663
  external_root_React_commonjs2_react_commonjs_react_amd_react_["createElement"](SurveyQuestionOtherValueItem, { question: this.question, otherCss: cssClasses.other, cssClasses: cssClasses, isDisplayMode: this.isDisplayMode })));
3653
3664
  };
3654
- SurveyQuestionCheckbox.prototype.renderItem = function (key, item, isFirst, cssClasses, index) {
3665
+ SurveyQuestionCheckbox.prototype.renderItem = function (item, isFirst, cssClasses, index) {
3655
3666
  var renderedItem = ReactElementFactory.Instance.createElement(this.question.itemComponent, {
3656
- key: key,
3667
+ key: item.value,
3657
3668
  question: this.question,
3658
3669
  cssClasses: cssClasses,
3659
3670
  isDisplayMode: this.isDisplayMode,
@@ -3679,6 +3690,7 @@ var reactquestion_checkbox_SurveyQuestionCheckboxItem = /** @class */ (function
3679
3690
  _this.handleOnChange = function (event) {
3680
3691
  _this.question.clickItemHandler(_this.item, event.target.checked);
3681
3692
  };
3693
+ _this.rootRef = external_root_React_commonjs2_react_commonjs_react_amd_react_["createRef"]();
3682
3694
  return _this;
3683
3695
  }
3684
3696
  SurveyQuestionCheckboxItem.prototype.getStateElement = function () {
@@ -3726,11 +3738,20 @@ var reactquestion_checkbox_SurveyQuestionCheckboxItem = /** @class */ (function
3726
3738
  enumerable: false,
3727
3739
  configurable: true
3728
3740
  });
3741
+ SurveyQuestionCheckboxItem.prototype.componentDidUpdate = function (prevProps, prevState) {
3742
+ _super.prototype.componentDidUpdate.call(this, prevProps, prevState);
3743
+ if (prevProps.item !== this.props.item && !this.question.isDesignMode) {
3744
+ if (this.props.item) {
3745
+ this.props.item.setRootElement(this.rootRef.current);
3746
+ }
3747
+ if (prevProps.item) {
3748
+ prevProps.item.setRootElement(undefined);
3749
+ }
3750
+ }
3751
+ };
3729
3752
  SurveyQuestionCheckboxItem.prototype.shouldComponentUpdate = function (nextProps, nextState) {
3730
3753
  if (!_super.prototype.shouldComponentUpdate.call(this, nextProps, nextState))
3731
3754
  return false;
3732
- if (!this.question)
3733
- return false;
3734
3755
  return (!this.question.customWidget ||
3735
3756
  !!this.question.customWidgetData.isNeedRender ||
3736
3757
  !!this.question.customWidget.widgetJson.isDefaultRender ||
@@ -3755,7 +3776,7 @@ var reactquestion_checkbox_SurveyQuestionCheckboxItem = /** @class */ (function
3755
3776
  var itemClass = this.question.getItemClass(this.item);
3756
3777
  var labelClass = this.question.getLabelClass(this.item);
3757
3778
  var itemLabel = !this.hideCaption ? external_root_React_commonjs2_react_commonjs_react_amd_react_["createElement"]("span", { className: this.cssClasses.controlLabel }, this.renderLocString(this.item.locText, this.textStyle)) : null;
3758
- return (external_root_React_commonjs2_react_commonjs_react_amd_react_["createElement"]("div", { className: itemClass, role: "presentation" },
3779
+ return (external_root_React_commonjs2_react_commonjs_react_amd_react_["createElement"]("div", { className: itemClass, role: "presentation", ref: this.rootRef },
3759
3780
  external_root_React_commonjs2_react_commonjs_react_amd_react_["createElement"]("label", { className: labelClass },
3760
3781
  external_root_React_commonjs2_react_commonjs_react_amd_react_["createElement"]("input", { className: this.cssClasses.itemControl, type: "checkbox", name: this.question.name + this.item.id, value: this.item.value, id: id, style: this.inputStyle, disabled: !this.question.getItemEnabled(this.item), readOnly: this.question.isReadOnlyAttr, checked: isChecked, onChange: this.handleOnChange, required: this.question.hasRequiredError() }),
3761
3782
  this.cssClasses.materialDecorator ?
@@ -3767,6 +3788,18 @@ var reactquestion_checkbox_SurveyQuestionCheckboxItem = /** @class */ (function
3767
3788
  itemLabel),
3768
3789
  otherItem));
3769
3790
  };
3791
+ SurveyQuestionCheckboxItem.prototype.componentDidMount = function () {
3792
+ _super.prototype.componentDidMount.call(this);
3793
+ if (!this.question.isDesignMode) {
3794
+ this.item.setRootElement(this.rootRef.current);
3795
+ }
3796
+ };
3797
+ SurveyQuestionCheckboxItem.prototype.componentWillUnmount = function () {
3798
+ _super.prototype.componentWillUnmount.call(this);
3799
+ if (!this.question.isDesignMode) {
3800
+ this.item.setRootElement(undefined);
3801
+ }
3802
+ };
3770
3803
  return SurveyQuestionCheckboxItem;
3771
3804
  }(ReactSurveyElement));
3772
3805
 
@@ -4291,10 +4324,10 @@ var tagbox_filter_TagboxFilterString = /** @class */ (function (_super) {
4291
4324
  this.model.inputKeyHandler(e);
4292
4325
  };
4293
4326
  TagboxFilterString.prototype.onBlur = function (e) {
4294
- this.model.onBlur(e);
4327
+ this.question.onBlur(e);
4295
4328
  };
4296
4329
  TagboxFilterString.prototype.onFocus = function (e) {
4297
- this.model.onFocus(e);
4330
+ this.question.onFocus(e);
4298
4331
  };
4299
4332
  TagboxFilterString.prototype.getStateElement = function () {
4300
4333
  return this.model;
@@ -5509,7 +5542,7 @@ var reactquestion_radiogroup_SurveyQuestionRadiogroup = /** @class */ (function
5509
5542
  var _this = this;
5510
5543
  if (this.question.hasFootItems) {
5511
5544
  return this.question.footItems.map(function (item, ii) {
5512
- return _this.renderItem("item_f" + ii, item, false, _this.question.cssClasses);
5545
+ return _this.renderItem(item, false, _this.question.cssClasses);
5513
5546
  });
5514
5547
  }
5515
5548
  };
@@ -5521,7 +5554,7 @@ var reactquestion_radiogroup_SurveyQuestionRadiogroup = /** @class */ (function
5521
5554
  var value = this.getStateValue();
5522
5555
  return this.question.columns.map(function (column, ci) {
5523
5556
  var items = column.map(function (item, ii) {
5524
- return _this.renderItem("item" + ci + ii, item, value, cssClasses, "" + ci + ii);
5557
+ return _this.renderItem(item, value, cssClasses, "" + ci + ii);
5525
5558
  });
5526
5559
  return (external_root_React_commonjs2_react_commonjs_react_amd_react_["createElement"]("div", { key: "column" + ci + _this.question.getItemsColumnKey(column), className: _this.question.getColumnClass(), role: "presentation" }, items));
5527
5560
  });
@@ -5538,7 +5571,7 @@ var reactquestion_radiogroup_SurveyQuestionRadiogroup = /** @class */ (function
5538
5571
  var value = this.getStateValue();
5539
5572
  for (var i = 0; i < choices.length; i++) {
5540
5573
  var item = choices[i];
5541
- var renderedItem = this.renderItem("item" + i, item, value, cssClasses, "" + i);
5574
+ var renderedItem = this.renderItem(item, value, cssClasses, "" + i);
5542
5575
  items.push(renderedItem);
5543
5576
  }
5544
5577
  return items;
@@ -5554,9 +5587,9 @@ var reactquestion_radiogroup_SurveyQuestionRadiogroup = /** @class */ (function
5554
5587
  return (external_root_React_commonjs2_react_commonjs_react_amd_react_["createElement"]("div", { className: this.question.getCommentAreaCss(true) },
5555
5588
  external_root_React_commonjs2_react_commonjs_react_amd_react_["createElement"](SurveyQuestionOtherValueItem, { question: this.question, otherCss: cssClasses.other, cssClasses: cssClasses, isDisplayMode: this.isDisplayMode })));
5556
5589
  };
5557
- SurveyQuestionRadiogroup.prototype.renderItem = function (key, item, value, cssClasses, index) {
5590
+ SurveyQuestionRadiogroup.prototype.renderItem = function (item, value, cssClasses, index) {
5558
5591
  var renderedItem = ReactElementFactory.Instance.createElement(this.question.itemComponent, {
5559
- key: key,
5592
+ key: item.value,
5560
5593
  question: this.question,
5561
5594
  cssClasses: cssClasses,
5562
5595
  isDisplayMode: this.isDisplayMode,
@@ -5582,6 +5615,7 @@ var reactquestion_radiogroup_SurveyQuestionRadioItem = /** @class */ (function (
5582
5615
  reactquestion_radiogroup_extends(SurveyQuestionRadioItem, _super);
5583
5616
  function SurveyQuestionRadioItem(props) {
5584
5617
  var _this = _super.call(this, props) || this;
5618
+ _this.rootRef = external_root_React_commonjs2_react_commonjs_react_amd_react_["createRef"]();
5585
5619
  _this.handleOnChange = _this.handleOnChange.bind(_this);
5586
5620
  _this.handleOnMouseDown = _this.handleOnMouseDown.bind(_this);
5587
5621
  return _this;
@@ -5650,12 +5684,23 @@ var reactquestion_radiogroup_SurveyQuestionRadioItem = /** @class */ (function (
5650
5684
  SurveyQuestionRadioItem.prototype.canRender = function () {
5651
5685
  return !!this.question && !!this.item;
5652
5686
  };
5687
+ SurveyQuestionRadioItem.prototype.componentDidUpdate = function (prevProps, prevState) {
5688
+ _super.prototype.componentDidUpdate.call(this, prevProps, prevState);
5689
+ if (prevProps.item !== this.props.item && !this.question.isDesignMode) {
5690
+ if (this.props.item) {
5691
+ this.props.item.setRootElement(this.rootRef.current);
5692
+ }
5693
+ if (prevProps.item) {
5694
+ prevProps.item.setRootElement(undefined);
5695
+ }
5696
+ }
5697
+ };
5653
5698
  SurveyQuestionRadioItem.prototype.renderElement = function () {
5654
5699
  var itemClass = this.question.getItemClass(this.item);
5655
5700
  var labelClass = this.question.getLabelClass(this.item);
5656
5701
  var controlLabelClass = this.question.getControlLabelClass(this.item);
5657
5702
  var itemLabel = !this.hideCaption ? external_root_React_commonjs2_react_commonjs_react_amd_react_["createElement"]("span", { className: controlLabelClass }, this.renderLocString(this.item.locText, this.textStyle)) : null;
5658
- return (external_root_React_commonjs2_react_commonjs_react_amd_react_["createElement"]("div", { className: itemClass, role: "presentation" },
5703
+ return (external_root_React_commonjs2_react_commonjs_react_amd_react_["createElement"]("div", { className: itemClass, role: "presentation", ref: this.rootRef },
5659
5704
  external_root_React_commonjs2_react_commonjs_react_amd_react_["createElement"]("label", { onMouseDown: this.handleOnMouseDown, className: labelClass },
5660
5705
  external_root_React_commonjs2_react_commonjs_react_amd_react_["createElement"]("input", { "aria-errormessage": this.question.ariaErrormessage, className: this.cssClasses.itemControl, id: this.question.getItemId(this.item), type: "radio", name: this.question.questionName, checked: this.isChecked, value: this.item.value, disabled: !this.question.getItemEnabled(this.item), readOnly: this.question.isReadOnlyAttr, onChange: this.handleOnChange }),
5661
5706
  this.cssClasses.materialDecorator ?
@@ -5666,6 +5711,18 @@ var reactquestion_radiogroup_SurveyQuestionRadioItem = /** @class */ (function (
5666
5711
  null,
5667
5712
  itemLabel)));
5668
5713
  };
5714
+ SurveyQuestionRadioItem.prototype.componentDidMount = function () {
5715
+ _super.prototype.componentDidMount.call(this);
5716
+ if (!this.question.isDesignMode) {
5717
+ this.item.setRootElement(this.rootRef.current);
5718
+ }
5719
+ };
5720
+ SurveyQuestionRadioItem.prototype.componentWillUnmount = function () {
5721
+ _super.prototype.componentWillUnmount.call(this);
5722
+ if (!this.question.isDesignMode) {
5723
+ this.item.setRootElement(undefined);
5724
+ }
5725
+ };
5669
5726
  return SurveyQuestionRadioItem;
5670
5727
  }(ReactSurveyElement));
5671
5728
 
@@ -6123,6 +6180,9 @@ var drag_drop_icon_SurveyQuestionMatrixDynamicDragDropIcon = /** @class */ (func
6123
6180
  configurable: true
6124
6181
  });
6125
6182
  SurveyQuestionMatrixDynamicDragDropIcon.prototype.renderElement = function () {
6183
+ return external_root_React_commonjs2_react_commonjs_react_amd_react_default.a.createElement("div", null, this.renderIcon());
6184
+ };
6185
+ SurveyQuestionMatrixDynamicDragDropIcon.prototype.renderIcon = function () {
6126
6186
  if (this.question.iconDragElement) {
6127
6187
  return (external_root_React_commonjs2_react_commonjs_react_amd_react_default.a.createElement("svg", { className: this.question.cssClasses.dragElementDecorator },
6128
6188
  external_root_React_commonjs2_react_commonjs_react_amd_react_default.a.createElement("use", { xlinkHref: this.question.iconDragElement })));
@@ -6753,7 +6813,7 @@ var paneldynamic_add_btn_SurveyQuestionPanelDynamicAddButton = /** @class */ (fu
6753
6813
  if (!this.question.canAddPanel)
6754
6814
  return null;
6755
6815
  var btnText = this.renderLocString(this.question.locPanelAddText);
6756
- return (external_root_React_commonjs2_react_commonjs_react_amd_react_default.a.createElement("button", { type: "button", className: this.question.getAddButtonCss(), onClick: this.handleClick },
6816
+ return (external_root_React_commonjs2_react_commonjs_react_amd_react_default.a.createElement("button", { type: "button", id: this.question.addButtonId, className: this.question.getAddButtonCss(), onClick: this.handleClick },
6757
6817
  external_root_React_commonjs2_react_commonjs_react_amd_react_default.a.createElement("span", { className: this.question.cssClasses.buttonAddText }, btnText)));
6758
6818
  };
6759
6819
  return SurveyQuestionPanelDynamicAddButton;
@@ -7325,7 +7385,7 @@ var list_item_ListItem = /** @class */ (function (_super) {
7325
7385
  paddingInlineStart: this.model.getItemIndent(this.item)
7326
7386
  };
7327
7387
  var className = this.model.getItemClass(this.item);
7328
- var itemContent = this.item.component || "sv-list-item-content";
7388
+ var itemContent = this.item.component || this.model.itemComponent;
7329
7389
  var newElement = ReactElementFactory.Instance.createElement(itemContent, { item: this.item, key: this.item.id, model: this.model });
7330
7390
  var contentWrap = external_root_React_commonjs2_react_commonjs_react_amd_react_default.a.createElement("div", { style: contentWrapStyle, className: this.model.cssClasses.itemBody, title: this.item.locTitle.calculatedText, onMouseOver: function (event) { _this.model.onItemHover(_this.item); }, onMouseLeave: function (event) { _this.model.onItemLeave(_this.item); } }, newElement);
7331
7391
  var separator = this.item.needSeparator ? external_root_React_commonjs2_react_commonjs_react_amd_react_default.a.createElement("div", { className: this.model.cssClasses.itemSeparator }) : null;
@@ -9168,7 +9228,7 @@ ReactElementFactory.Instance.registerElement(external_root_Survey_commonjs2_surv
9168
9228
 
9169
9229
 
9170
9230
 
9171
- Object(external_root_Survey_commonjs2_survey_core_commonjs_survey_core_amd_survey_core_["checkLibraryVersion"])("" + "1.11.13", "survey-react-ui");
9231
+ Object(external_root_Survey_commonjs2_survey_core_commonjs_survey_core_amd_survey_core_["checkLibraryVersion"])("" + "1.12.1", "survey-react-ui");
9172
9232
 
9173
9233
 
9174
9234
  /***/ }),