survey-js-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-js-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",
@@ -23,7 +23,7 @@
23
23
  "typings": "./typings/src/entries/js-ui.d.ts",
24
24
  "dependencies": {},
25
25
  "peerDependencies": {
26
- "survey-core": "1.11.13",
26
+ "survey-core": "1.12.1",
27
27
  "@types/react-dom": "*",
28
28
  "@types/react": "*"
29
29
  }
package/survey-js-ui.js CHANGED
@@ -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
  */
@@ -446,6 +446,7 @@ var reactquestion_element_SurveyElementBase = /** @class */ (function (_super) {
446
446
  function SurveyElementBase(props) {
447
447
  var _this = _super.call(this, props) || this;
448
448
  _this._allowComponentUpdate = true;
449
+ _this.prevStateElements = [];
449
450
  return _this;
450
451
  }
451
452
  SurveyElementBase.renderLocString = function (locStr, style, key) {
@@ -465,9 +466,14 @@ var reactquestion_element_SurveyElementBase = /** @class */ (function (_super) {
465
466
  };
466
467
  SurveyElementBase.prototype.componentWillUnmount = function () {
467
468
  this.unMakeBaseElementsReact();
469
+ this.disableStateElementsRerenderEvent(this.getStateElements());
468
470
  };
469
471
  SurveyElementBase.prototype.componentDidUpdate = function (prevProps, prevState) {
472
+ var _a;
470
473
  this.makeBaseElementsReact();
474
+ var stateElements = this.getStateElements();
475
+ this.disableStateElementsRerenderEvent(((_a = this.prevStateElements) !== null && _a !== void 0 ? _a : []).filter(function (el) { return !stateElements.includes(el); }));
476
+ this.prevStateElements = [];
471
477
  this.getStateElements().forEach(function (el) {
472
478
  el.afterRerender();
473
479
  });
@@ -482,6 +488,7 @@ var reactquestion_element_SurveyElementBase = /** @class */ (function (_super) {
482
488
  SurveyElementBase.prototype.shouldComponentUpdate = function (nextProps, nextState) {
483
489
  if (this._allowComponentUpdate) {
484
490
  this.unMakeBaseElementsReact();
491
+ this.prevStateElements = this.getStateElements();
485
492
  }
486
493
  return this._allowComponentUpdate;
487
494
  };
@@ -549,10 +556,14 @@ var reactquestion_element_SurveyElementBase = /** @class */ (function (_super) {
549
556
  SurveyElementBase.prototype.unMakeBaseElementsReact = function () {
550
557
  var els = this.getStateElements();
551
558
  for (var i = 0; i < els.length; i++) {
552
- els[i].disableOnElementRenderedEvent();
553
559
  this.unMakeBaseElementReact(els[i]);
554
560
  }
555
561
  };
562
+ SurveyElementBase.prototype.disableStateElementsRerenderEvent = function (els) {
563
+ els.forEach(function (el) {
564
+ el.disableOnElementRenderedEvent();
565
+ });
566
+ };
556
567
  SurveyElementBase.prototype.getStateElements = function () {
557
568
  var el = this.getStateElement();
558
569
  return !!el ? [el] : [];
@@ -1337,7 +1348,7 @@ var action_bar_item_SurveyActionBarItem = /** @class */ (function (_super) {
1337
1348
  var title = this.item.tooltip || this.item.title;
1338
1349
  var buttonContent = this.renderButtonContent();
1339
1350
  var tabIndex = this.item.disableTabStop ? -1 : undefined;
1340
- var button = attachKey2click(Rn.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 });
1351
+ var button = attachKey2click(Rn.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 });
1341
1352
  return button;
1342
1353
  };
1343
1354
  return SurveyActionBarItem;
@@ -3693,7 +3704,7 @@ var reactquestion_checkbox_SurveyQuestionCheckbox = /** @class */ (function (_su
3693
3704
  var _this = this;
3694
3705
  if (this.question.hasHeadItems) {
3695
3706
  return this.question.headItems.map(function (item, ii) {
3696
- return _this.renderItem("item_h" + ii, item, false, _this.question.cssClasses);
3707
+ return _this.renderItem(item, false, _this.question.cssClasses);
3697
3708
  });
3698
3709
  }
3699
3710
  };
@@ -3701,7 +3712,7 @@ var reactquestion_checkbox_SurveyQuestionCheckbox = /** @class */ (function (_su
3701
3712
  var _this = this;
3702
3713
  if (this.question.hasFootItems) {
3703
3714
  return this.question.footItems.map(function (item, ii) {
3704
- return _this.renderItem("item_f" + ii, item, false, _this.question.cssClasses);
3715
+ return _this.renderItem(item, false, _this.question.cssClasses);
3705
3716
  });
3706
3717
  }
3707
3718
  };
@@ -3712,7 +3723,7 @@ var reactquestion_checkbox_SurveyQuestionCheckbox = /** @class */ (function (_su
3712
3723
  var _this = this;
3713
3724
  return this.question.columns.map(function (column, ci) {
3714
3725
  var items = column.map(function (item, ii) {
3715
- return _this.renderItem("item" + ii, item, ci === 0 && ii === 0, cssClasses, "" + ci + ii);
3726
+ return _this.renderItem(item, ci === 0 && ii === 0, cssClasses, "" + ci + ii);
3716
3727
  });
3717
3728
  return (preact_module_("div", { key: "column" + ci + _this.question.getItemsColumnKey(column), className: _this.question.getColumnClass(), role: "presentation" }, items));
3718
3729
  });
@@ -3728,8 +3739,8 @@ var reactquestion_checkbox_SurveyQuestionCheckbox = /** @class */ (function (_su
3728
3739
  var renderedItems = [];
3729
3740
  for (var i = 0; i < choices.length; i++) {
3730
3741
  var item = choices[i];
3731
- var key = "item" + i;
3732
- var renderedItem = this.renderItem(key, item, i == 0, cssClasses, "" + i);
3742
+ var key = "item" + item.value;
3743
+ var renderedItem = this.renderItem(item, i == 0, cssClasses, "" + i);
3733
3744
  if (!!renderedItem) {
3734
3745
  renderedItems.push(renderedItem);
3735
3746
  }
@@ -3748,9 +3759,9 @@ var reactquestion_checkbox_SurveyQuestionCheckbox = /** @class */ (function (_su
3748
3759
  return (preact_module_("div", { className: this.question.getCommentAreaCss(true) },
3749
3760
  preact_module_(SurveyQuestionOtherValueItem, { question: this.question, otherCss: cssClasses.other, cssClasses: cssClasses, isDisplayMode: this.isDisplayMode })));
3750
3761
  };
3751
- SurveyQuestionCheckbox.prototype.renderItem = function (key, item, isFirst, cssClasses, index) {
3762
+ SurveyQuestionCheckbox.prototype.renderItem = function (item, isFirst, cssClasses, index) {
3752
3763
  var renderedItem = ReactElementFactory.Instance.createElement(this.question.itemComponent, {
3753
- key: key,
3764
+ key: item.value,
3754
3765
  question: this.question,
3755
3766
  cssClasses: cssClasses,
3756
3767
  isDisplayMode: this.isDisplayMode,
@@ -3776,6 +3787,7 @@ var reactquestion_checkbox_SurveyQuestionCheckboxItem = /** @class */ (function
3776
3787
  _this.handleOnChange = function (event) {
3777
3788
  _this.question.clickItemHandler(_this.item, event.target.checked);
3778
3789
  };
3790
+ _this.rootRef = m();
3779
3791
  return _this;
3780
3792
  }
3781
3793
  SurveyQuestionCheckboxItem.prototype.getStateElement = function () {
@@ -3823,11 +3835,20 @@ var reactquestion_checkbox_SurveyQuestionCheckboxItem = /** @class */ (function
3823
3835
  enumerable: false,
3824
3836
  configurable: true
3825
3837
  });
3838
+ SurveyQuestionCheckboxItem.prototype.componentDidUpdate = function (prevProps, prevState) {
3839
+ _super.prototype.componentDidUpdate.call(this, prevProps, prevState);
3840
+ if (prevProps.item !== this.props.item && !this.question.isDesignMode) {
3841
+ if (this.props.item) {
3842
+ this.props.item.setRootElement(this.rootRef.current);
3843
+ }
3844
+ if (prevProps.item) {
3845
+ prevProps.item.setRootElement(undefined);
3846
+ }
3847
+ }
3848
+ };
3826
3849
  SurveyQuestionCheckboxItem.prototype.shouldComponentUpdate = function (nextProps, nextState) {
3827
3850
  if (!_super.prototype.shouldComponentUpdate.call(this, nextProps, nextState))
3828
3851
  return false;
3829
- if (!this.question)
3830
- return false;
3831
3852
  return (!this.question.customWidget ||
3832
3853
  !!this.question.customWidgetData.isNeedRender ||
3833
3854
  !!this.question.customWidget.widgetJson.isDefaultRender ||
@@ -3852,7 +3873,7 @@ var reactquestion_checkbox_SurveyQuestionCheckboxItem = /** @class */ (function
3852
3873
  var itemClass = this.question.getItemClass(this.item);
3853
3874
  var labelClass = this.question.getLabelClass(this.item);
3854
3875
  var itemLabel = !this.hideCaption ? preact_module_("span", { className: this.cssClasses.controlLabel }, this.renderLocString(this.item.locText, this.textStyle)) : null;
3855
- return (preact_module_("div", { className: itemClass, role: "presentation" },
3876
+ return (preact_module_("div", { className: itemClass, role: "presentation", ref: this.rootRef },
3856
3877
  preact_module_("label", { className: labelClass },
3857
3878
  preact_module_("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() }),
3858
3879
  this.cssClasses.materialDecorator ?
@@ -3864,6 +3885,18 @@ var reactquestion_checkbox_SurveyQuestionCheckboxItem = /** @class */ (function
3864
3885
  itemLabel),
3865
3886
  otherItem));
3866
3887
  };
3888
+ SurveyQuestionCheckboxItem.prototype.componentDidMount = function () {
3889
+ _super.prototype.componentDidMount.call(this);
3890
+ if (!this.question.isDesignMode) {
3891
+ this.item.setRootElement(this.rootRef.current);
3892
+ }
3893
+ };
3894
+ SurveyQuestionCheckboxItem.prototype.componentWillUnmount = function () {
3895
+ _super.prototype.componentWillUnmount.call(this);
3896
+ if (!this.question.isDesignMode) {
3897
+ this.item.setRootElement(undefined);
3898
+ }
3899
+ };
3867
3900
  return SurveyQuestionCheckboxItem;
3868
3901
  }(ReactSurveyElement));
3869
3902
 
@@ -4388,10 +4421,10 @@ var tagbox_filter_TagboxFilterString = /** @class */ (function (_super) {
4388
4421
  this.model.inputKeyHandler(e);
4389
4422
  };
4390
4423
  TagboxFilterString.prototype.onBlur = function (e) {
4391
- this.model.onBlur(e);
4424
+ this.question.onBlur(e);
4392
4425
  };
4393
4426
  TagboxFilterString.prototype.onFocus = function (e) {
4394
- this.model.onFocus(e);
4427
+ this.question.onFocus(e);
4395
4428
  };
4396
4429
  TagboxFilterString.prototype.getStateElement = function () {
4397
4430
  return this.model;
@@ -5606,7 +5639,7 @@ var reactquestion_radiogroup_SurveyQuestionRadiogroup = /** @class */ (function
5606
5639
  var _this = this;
5607
5640
  if (this.question.hasFootItems) {
5608
5641
  return this.question.footItems.map(function (item, ii) {
5609
- return _this.renderItem("item_f" + ii, item, false, _this.question.cssClasses);
5642
+ return _this.renderItem(item, false, _this.question.cssClasses);
5610
5643
  });
5611
5644
  }
5612
5645
  };
@@ -5618,7 +5651,7 @@ var reactquestion_radiogroup_SurveyQuestionRadiogroup = /** @class */ (function
5618
5651
  var value = this.getStateValue();
5619
5652
  return this.question.columns.map(function (column, ci) {
5620
5653
  var items = column.map(function (item, ii) {
5621
- return _this.renderItem("item" + ci + ii, item, value, cssClasses, "" + ci + ii);
5654
+ return _this.renderItem(item, value, cssClasses, "" + ci + ii);
5622
5655
  });
5623
5656
  return (preact_module_("div", { key: "column" + ci + _this.question.getItemsColumnKey(column), className: _this.question.getColumnClass(), role: "presentation" }, items));
5624
5657
  });
@@ -5635,7 +5668,7 @@ var reactquestion_radiogroup_SurveyQuestionRadiogroup = /** @class */ (function
5635
5668
  var value = this.getStateValue();
5636
5669
  for (var i = 0; i < choices.length; i++) {
5637
5670
  var item = choices[i];
5638
- var renderedItem = this.renderItem("item" + i, item, value, cssClasses, "" + i);
5671
+ var renderedItem = this.renderItem(item, value, cssClasses, "" + i);
5639
5672
  items.push(renderedItem);
5640
5673
  }
5641
5674
  return items;
@@ -5651,9 +5684,9 @@ var reactquestion_radiogroup_SurveyQuestionRadiogroup = /** @class */ (function
5651
5684
  return (preact_module_("div", { className: this.question.getCommentAreaCss(true) },
5652
5685
  preact_module_(SurveyQuestionOtherValueItem, { question: this.question, otherCss: cssClasses.other, cssClasses: cssClasses, isDisplayMode: this.isDisplayMode })));
5653
5686
  };
5654
- SurveyQuestionRadiogroup.prototype.renderItem = function (key, item, value, cssClasses, index) {
5687
+ SurveyQuestionRadiogroup.prototype.renderItem = function (item, value, cssClasses, index) {
5655
5688
  var renderedItem = ReactElementFactory.Instance.createElement(this.question.itemComponent, {
5656
- key: key,
5689
+ key: item.value,
5657
5690
  question: this.question,
5658
5691
  cssClasses: cssClasses,
5659
5692
  isDisplayMode: this.isDisplayMode,
@@ -5679,6 +5712,7 @@ var reactquestion_radiogroup_SurveyQuestionRadioItem = /** @class */ (function (
5679
5712
  reactquestion_radiogroup_extends(SurveyQuestionRadioItem, _super);
5680
5713
  function SurveyQuestionRadioItem(props) {
5681
5714
  var _this = _super.call(this, props) || this;
5715
+ _this.rootRef = m();
5682
5716
  _this.handleOnChange = _this.handleOnChange.bind(_this);
5683
5717
  _this.handleOnMouseDown = _this.handleOnMouseDown.bind(_this);
5684
5718
  return _this;
@@ -5747,12 +5781,23 @@ var reactquestion_radiogroup_SurveyQuestionRadioItem = /** @class */ (function (
5747
5781
  SurveyQuestionRadioItem.prototype.canRender = function () {
5748
5782
  return !!this.question && !!this.item;
5749
5783
  };
5784
+ SurveyQuestionRadioItem.prototype.componentDidUpdate = function (prevProps, prevState) {
5785
+ _super.prototype.componentDidUpdate.call(this, prevProps, prevState);
5786
+ if (prevProps.item !== this.props.item && !this.question.isDesignMode) {
5787
+ if (this.props.item) {
5788
+ this.props.item.setRootElement(this.rootRef.current);
5789
+ }
5790
+ if (prevProps.item) {
5791
+ prevProps.item.setRootElement(undefined);
5792
+ }
5793
+ }
5794
+ };
5750
5795
  SurveyQuestionRadioItem.prototype.renderElement = function () {
5751
5796
  var itemClass = this.question.getItemClass(this.item);
5752
5797
  var labelClass = this.question.getLabelClass(this.item);
5753
5798
  var controlLabelClass = this.question.getControlLabelClass(this.item);
5754
5799
  var itemLabel = !this.hideCaption ? preact_module_("span", { className: controlLabelClass }, this.renderLocString(this.item.locText, this.textStyle)) : null;
5755
- return (preact_module_("div", { className: itemClass, role: "presentation" },
5800
+ return (preact_module_("div", { className: itemClass, role: "presentation", ref: this.rootRef },
5756
5801
  preact_module_("label", { onMouseDown: this.handleOnMouseDown, className: labelClass },
5757
5802
  preact_module_("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 }),
5758
5803
  this.cssClasses.materialDecorator ?
@@ -5763,6 +5808,18 @@ var reactquestion_radiogroup_SurveyQuestionRadioItem = /** @class */ (function (
5763
5808
  null,
5764
5809
  itemLabel)));
5765
5810
  };
5811
+ SurveyQuestionRadioItem.prototype.componentDidMount = function () {
5812
+ _super.prototype.componentDidMount.call(this);
5813
+ if (!this.question.isDesignMode) {
5814
+ this.item.setRootElement(this.rootRef.current);
5815
+ }
5816
+ };
5817
+ SurveyQuestionRadioItem.prototype.componentWillUnmount = function () {
5818
+ _super.prototype.componentWillUnmount.call(this);
5819
+ if (!this.question.isDesignMode) {
5820
+ this.item.setRootElement(undefined);
5821
+ }
5822
+ };
5766
5823
  return SurveyQuestionRadioItem;
5767
5824
  }(ReactSurveyElement));
5768
5825
 
@@ -6220,6 +6277,9 @@ var drag_drop_icon_SurveyQuestionMatrixDynamicDragDropIcon = /** @class */ (func
6220
6277
  configurable: true
6221
6278
  });
6222
6279
  SurveyQuestionMatrixDynamicDragDropIcon.prototype.renderElement = function () {
6280
+ return Rn.createElement("div", null, this.renderIcon());
6281
+ };
6282
+ SurveyQuestionMatrixDynamicDragDropIcon.prototype.renderIcon = function () {
6223
6283
  if (this.question.iconDragElement) {
6224
6284
  return (Rn.createElement("svg", { className: this.question.cssClasses.dragElementDecorator },
6225
6285
  Rn.createElement("use", { xlinkHref: this.question.iconDragElement })));
@@ -6850,7 +6910,7 @@ var paneldynamic_add_btn_SurveyQuestionPanelDynamicAddButton = /** @class */ (fu
6850
6910
  if (!this.question.canAddPanel)
6851
6911
  return null;
6852
6912
  var btnText = this.renderLocString(this.question.locPanelAddText);
6853
- return (Rn.createElement("button", { type: "button", className: this.question.getAddButtonCss(), onClick: this.handleClick },
6913
+ return (Rn.createElement("button", { type: "button", id: this.question.addButtonId, className: this.question.getAddButtonCss(), onClick: this.handleClick },
6854
6914
  Rn.createElement("span", { className: this.question.cssClasses.buttonAddText }, btnText)));
6855
6915
  };
6856
6916
  return SurveyQuestionPanelDynamicAddButton;
@@ -7422,7 +7482,7 @@ var list_item_ListItem = /** @class */ (function (_super) {
7422
7482
  paddingInlineStart: this.model.getItemIndent(this.item)
7423
7483
  };
7424
7484
  var className = this.model.getItemClass(this.item);
7425
- var itemContent = this.item.component || "sv-list-item-content";
7485
+ var itemContent = this.item.component || this.model.itemComponent;
7426
7486
  var newElement = ReactElementFactory.Instance.createElement(itemContent, { item: this.item, key: this.item.id, model: this.model });
7427
7487
  var contentWrap = Rn.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);
7428
7488
  var separator = this.item.needSeparator ? Rn.createElement("div", { className: this.model.cssClasses.itemSeparator }) : null;
@@ -9337,7 +9397,7 @@ var preact = compat_module_namespaceObject;
9337
9397
 
9338
9398
 
9339
9399
 
9340
- Object(external_root_Survey_commonjs2_survey_core_commonjs_survey_core_amd_survey_core_["checkLibraryVersion"])("" + "1.11.13", "survey-js-ui");
9400
+ Object(external_root_Survey_commonjs2_survey_core_commonjs_survey_core_amd_survey_core_["checkLibraryVersion"])("" + "1.12.1", "survey-js-ui");
9341
9401
 
9342
9402
 
9343
9403
  /***/ }),