@yoobic/yobi 7.7.23 → 7.7.24

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.
@@ -123933,7 +123933,11 @@ const YooFormDynamicComponent = class {
123933
123933
  }
123934
123934
  updateData() {
123935
123935
  this.currentData = this.data || {};
123936
- this.updateState();
123936
+ setTimeout(() => {
123937
+ this.updateState().then(() => {
123938
+ this.updateSteps();
123939
+ });
123940
+ }, 300);
123937
123941
  }
123938
123942
  updateSlides() {
123939
123943
  if (this.isLivePreview() && this.hasLoaded) {
@@ -88,6 +88,17 @@ const YooFormChoiceComponent = class {
88
88
  !hasDuplicatedValues && this.updateChoices();
89
89
  }
90
90
  }
91
+ onValueChange(newValue, oldValue) {
92
+ if (!isEqual.isEqual(newValue, oldValue)) {
93
+ this.selection = [];
94
+ const values = rrule.compact([].concat(this.value));
95
+ values.forEach((v) => {
96
+ if (!this.selection || this.selection.indexOf(v) < 0) {
97
+ this.onItemSelect(v, true);
98
+ }
99
+ });
100
+ }
101
+ }
91
102
  componentWillLoad() {
92
103
  var _a;
93
104
  formInputHelpers.setValidator(this);
@@ -149,7 +160,7 @@ const YooFormChoiceComponent = class {
149
160
  formInputHelpers.setValueAndValidateInput(this.multiple ? this.selection : this.selection.length > 0 ? this.selection[0] : null, this);
150
161
  this.updateShowOther();
151
162
  }
152
- onItemSelect(item) {
163
+ onItemSelect(item, preventSetValue = false) {
153
164
  if (this.customEvent) {
154
165
  this.choiceSelected.emit(item);
155
166
  }
@@ -167,7 +178,9 @@ const YooFormChoiceComponent = class {
167
178
  else {
168
179
  this.selection = index < 0 ? [item] : [];
169
180
  }
170
- formInputHelpers.setValueAndValidateInput(this.multiple ? this.selection : this.selection.length > 0 ? this.selection[0] : null, this);
181
+ if (!preventSetValue) {
182
+ formInputHelpers.setValueAndValidateInput(this.multiple ? this.selection : this.selection.length > 0 ? this.selection[0] : null, this);
183
+ }
171
184
  this.setShowOther(false);
172
185
  }
173
186
  }
@@ -338,7 +351,8 @@ const YooFormChoiceComponent = class {
338
351
  index.h("div", { class: "outer-container", ref: el => this.outerContainerElement = el }, this.livePreview && this.renderAlertBanner(), this.choices && this.renderEditable());
339
352
  }
340
353
  static get watchers() { return {
341
- "values": ["onValuesChanged"]
354
+ "values": ["onValuesChanged"],
355
+ "value": ["onValueChange"]
342
356
  }; }
343
357
  };
344
358
  YooFormChoiceComponent.style = formChoiceCss;
@@ -1,7 +1,7 @@
1
1
  import { translate, translateMulti } from '@shared/utils';
2
2
  import { Component, Event, h, Prop, State, Watch } from '@stencil/core';
3
3
  import { hasDuplicates, setColorSVG, setValidator, setValueAndValidateInput, showSlidesMedia, showWarningAlert } from '@utils';
4
- import { findIndex, isEqual, isString, shuffle } from 'lodash-es';
4
+ import { compact, findIndex, isEqual, isString, shuffle } from 'lodash-es';
5
5
  export class YooFormChoiceComponent {
6
6
  constructor() {
7
7
  this.animated = true;
@@ -21,6 +21,17 @@ export class YooFormChoiceComponent {
21
21
  !hasDuplicatedValues && this.updateChoices();
22
22
  }
23
23
  }
24
+ onValueChange(newValue, oldValue) {
25
+ if (!isEqual(newValue, oldValue)) {
26
+ this.selection = [];
27
+ const values = compact([].concat(this.value));
28
+ values.forEach((v) => {
29
+ if (!this.selection || this.selection.indexOf(v) < 0) {
30
+ this.onItemSelect(v, true);
31
+ }
32
+ });
33
+ }
34
+ }
24
35
  componentWillLoad() {
25
36
  var _a;
26
37
  setValidator(this);
@@ -82,7 +93,7 @@ export class YooFormChoiceComponent {
82
93
  setValueAndValidateInput(this.multiple ? this.selection : this.selection.length > 0 ? this.selection[0] : null, this);
83
94
  this.updateShowOther();
84
95
  }
85
- onItemSelect(item) {
96
+ onItemSelect(item, preventSetValue = false) {
86
97
  if (this.customEvent) {
87
98
  this.choiceSelected.emit(item);
88
99
  }
@@ -100,7 +111,9 @@ export class YooFormChoiceComponent {
100
111
  else {
101
112
  this.selection = index < 0 ? [item] : [];
102
113
  }
103
- setValueAndValidateInput(this.multiple ? this.selection : this.selection.length > 0 ? this.selection[0] : null, this);
114
+ if (!preventSetValue) {
115
+ setValueAndValidateInput(this.multiple ? this.selection : this.selection.length > 0 ? this.selection[0] : null, this);
116
+ }
104
117
  this.setShowOther(false);
105
118
  }
106
119
  }
@@ -831,5 +844,8 @@ export class YooFormChoiceComponent {
831
844
  static get watchers() { return [{
832
845
  "propName": "values",
833
846
  "methodName": "onValuesChanged"
847
+ }, {
848
+ "propName": "value",
849
+ "methodName": "onValueChange"
834
850
  }]; }
835
851
  }
@@ -89,7 +89,11 @@ export class YooFormDynamicComponent {
89
89
  }
90
90
  updateData() {
91
91
  this.currentData = this.data || {};
92
- this.updateState();
92
+ setTimeout(() => {
93
+ this.updateState().then(() => {
94
+ this.updateSteps();
95
+ });
96
+ }, 300);
93
97
  }
94
98
  updateSlides() {
95
99
  if (this.isLivePreview() && this.hasLoaded) {