@synerise/ds-condition 0.17.3 → 0.17.6

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/CHANGELOG.md CHANGED
@@ -3,6 +3,33 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.17.6](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.17.5...@synerise/ds-condition@0.17.6) (2022-06-15)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-condition
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.17.5](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.17.4...@synerise/ds-condition@0.17.5) (2022-06-10)
15
+
16
+ **Note:** Version bump only for package @synerise/ds-condition
17
+
18
+
19
+
20
+
21
+
22
+ ## [0.17.4](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.17.3...@synerise/ds-condition@0.17.4) (2022-06-03)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **condition:** validation value ([3e202bc](https://github.com/Synerise/synerise-design/commit/3e202bcbadd18cafc7463dcbe96a6bb9ca2542f3))
28
+
29
+
30
+
31
+
32
+
6
33
  ## [0.17.3](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.17.2...@synerise/ds-condition@0.17.3) (2022-05-31)
7
34
 
8
35
 
package/dist/Condition.js CHANGED
@@ -86,10 +86,6 @@ var Condition = function Condition(props) {
86
86
  currentField = _React$useState3[0],
87
87
  setCurrentField = _React$useState3[1];
88
88
 
89
- var _React$useState4 = React.useState(''),
90
- errorId = _React$useState4[0],
91
- setErrorId = _React$useState4[1];
92
-
93
89
  var prevSteps = usePrevious(steps);
94
90
  React.useEffect(function () {
95
91
  if (autoOpenedComponent && steps.length && steps[0].conditions[0].operator && steps[0].conditions[0].operator.value === undefined) {
@@ -216,32 +212,13 @@ var Condition = function Condition(props) {
216
212
  setCurrentField(SUBJECT);
217
213
  }
218
214
  }, [addStep]);
219
- var returnLast = React.useCallback(function (arr) {
220
- return arr[arr.length - 1];
221
- }, []);
222
- var testPrevValueElement = React.useCallback(function () {
223
- return steps == null ? void 0 : steps.map(function (step) {
224
- var _returnLast, _returnLast2;
225
-
226
- return !((_returnLast = returnLast(step.conditions)) != null && _returnLast.factor.value) && setErrorId((_returnLast2 = returnLast(step.conditions)) == null ? void 0 : _returnLast2.id);
227
- });
228
- }, [steps, returnLast]);
229
215
  var handleAddCondition = React.useMemo(function () {
230
- var lastStep = returnLast(steps);
231
- var lastCondition = returnLast(lastStep.conditions);
232
-
233
216
  if (!addCondition) {
234
217
  return undefined;
235
218
  }
236
219
 
237
220
  return function (stepId) {
238
- var newConditionId;
239
-
240
- if (addCondition && lastCondition != null && lastCondition.factor.value || (lastStep == null ? void 0 : lastStep.conditions.length) === 0) {
241
- newConditionId = addCondition(stepId);
242
- }
243
-
244
- testPrevValueElement();
221
+ var newConditionId = addCondition ? addCondition(stepId) : undefined;
245
222
 
246
223
  if (newConditionId) {
247
224
  setCurrentConditionId(newConditionId);
@@ -249,7 +226,7 @@ var Condition = function Condition(props) {
249
226
  setCurrentField(PARAMETER);
250
227
  }
251
228
  };
252
- }, [addCondition, steps, testPrevValueElement, returnLast]);
229
+ }, [addCondition]);
253
230
  var handleClearActiveCondition = React.useCallback(function () {
254
231
  setCurrentConditionId(DEFAULT_CONDITION);
255
232
  setCurrentStepId(DEFAULT_STEP);
@@ -292,8 +269,7 @@ var Condition = function Condition(props) {
292
269
  setCurrentStep: setCurrentStepId,
293
270
  onDeactivate: handleClearActiveCondition,
294
271
  showSuffix: showSuffix,
295
- hoverDisabled: hoverDisabled || currentStepId !== step.id && currentStepId !== undefined,
296
- errorId: errorId
272
+ hoverDisabled: hoverDisabled || currentStepId !== step.id && currentStepId !== undefined
297
273
  });
298
274
  })), addStep && /*#__PURE__*/React.createElement(S.AddStepButton, null, /*#__PURE__*/React.createElement(Button, {
299
275
  type: "ghost",
@@ -302,7 +278,7 @@ var Condition = function Condition(props) {
302
278
  }, /*#__PURE__*/React.createElement(Icon, {
303
279
  component: /*#__PURE__*/React.createElement(Add3M, null)
304
280
  }), text.addStep)), renderAddStep && /*#__PURE__*/React.createElement(S.AddStepButton, null, renderAddStep()));
305
- }, [steps, onChangeOrder, addStep, handleAddStep, text, renderAddStep, currentStepId, getPopupContainerOverride, draggableEnabled, selectOperator, selectParameter, selectContext, selectSubject, onUpdateStepName, duplicateStep, removeStep, minConditionsLength, maxConditionsLength, setStepConditionFactorType, setStepConditionFactorValue, currentConditionId, currentField, removeCondition, handleAddCondition, handleClearActiveCondition, showSuffix, hoverDisabled, errorId]);
281
+ }, [steps, onChangeOrder, addStep, handleAddStep, text, renderAddStep, currentStepId, getPopupContainerOverride, draggableEnabled, selectOperator, selectParameter, selectContext, selectSubject, onUpdateStepName, duplicateStep, removeStep, minConditionsLength, maxConditionsLength, setStepConditionFactorType, setStepConditionFactorValue, currentConditionId, currentField, removeCondition, handleAddCondition, handleClearActiveCondition, showSuffix, hoverDisabled]);
306
282
  };
307
283
 
308
284
  export default Condition;
@@ -48,8 +48,7 @@ export var ConditionStep = function ConditionStep(_ref) {
48
48
  setCurrentStep = _ref.setCurrentStep,
49
49
  onDeactivate = _ref.onDeactivate,
50
50
  showSuffix = _ref.showSuffix,
51
- hoverDisabled = _ref.hoverDisabled,
52
- errorId = _ref.errorId;
51
+ hoverDisabled = _ref.hoverDisabled;
53
52
 
54
53
  var _useIntl = useIntl(),
55
54
  formatMessage = _useIntl.formatMessage;
@@ -168,10 +167,9 @@ export var ConditionStep = function ConditionStep(_ref) {
168
167
  setStepConditionFactorValue: setStepConditionFactorValue,
169
168
  texts: text,
170
169
  stepType: (_step$context2 = step.context) == null ? void 0 : _step$context2.type,
171
- onDeactivate: onDeactivate,
172
- error: errorId === condition.id && !condition.factor.value && true
170
+ onDeactivate: onDeactivate
173
171
  });
174
- }, [step.id, step.conditions.length, step.context, hasPriority, currentConditionId, addCondition, removeCondition, minConditionsLength, maxConditionsLength, currentStepId, currentField, selectParameter, selectOperator, getPopupContainerOverride, setStepConditionFactorType, setStepConditionFactorValue, text, onDeactivate, onActivate, setCurrentField, setCurrentCondition, setCurrentStep, errorId]);
172
+ }, [step.id, step.conditions.length, step.context, hasPriority, currentConditionId, addCondition, removeCondition, minConditionsLength, maxConditionsLength, currentStepId, currentField, selectParameter, selectOperator, getPopupContainerOverride, setStepConditionFactorType, setStepConditionFactorValue, text, onDeactivate, onActivate, setCurrentField, setCurrentCondition, setCurrentStep]);
175
173
  return /*#__PURE__*/React.createElement(S.Step, {
176
174
  key: step.id,
177
175
  id: "condition-step-" + step.id,
@@ -7,7 +7,6 @@ import { ConditionStep, ConditionTexts, ConditionProps } from '../Condition.type
7
7
  export declare type ConditionStepProps = {
8
8
  index: number;
9
9
  step: ConditionStep;
10
- errorId?: string;
11
10
  hasPriority?: boolean;
12
11
  onStepActivate?: (stepid: React.ReactText) => void;
13
12
  getPopupContainerOverride?: ConditionProps['getPopupContainerOverride'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-condition",
3
- "version": "0.17.3",
3
+ "version": "0.17.6",
4
4
  "description": "Condition UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -33,14 +33,14 @@
33
33
  "types": "dist/index.d.ts",
34
34
  "dependencies": {
35
35
  "@synerise/ds-button": "^0.17.2",
36
- "@synerise/ds-context-selector": "^0.12.1",
36
+ "@synerise/ds-context-selector": "^0.12.2",
37
37
  "@synerise/ds-core": "^0.34.0",
38
38
  "@synerise/ds-cruds": "^0.3.9",
39
- "@synerise/ds-factors": "^0.14.2",
39
+ "@synerise/ds-factors": "^0.14.4",
40
40
  "@synerise/ds-icon": "^0.49.0",
41
- "@synerise/ds-inline-edit": "^0.6.12",
42
- "@synerise/ds-operators": "^0.9.0",
43
- "@synerise/ds-subject": "^0.9.0",
41
+ "@synerise/ds-inline-edit": "^0.6.13",
42
+ "@synerise/ds-operators": "^0.9.1",
43
+ "@synerise/ds-subject": "^0.9.1",
44
44
  "@synerise/ds-tooltip": "^0.11.9",
45
45
  "@synerise/ds-utils": "^0.19.0",
46
46
  "react-sortablejs": "^6.0.0"
@@ -49,5 +49,5 @@
49
49
  "@synerise/ds-core": "*",
50
50
  "react": ">=16.9.0 < 17.0.0"
51
51
  },
52
- "gitHead": "99aebc2358ae0c570c4d5bcf4280ac37f811be22"
52
+ "gitHead": "d787395998e479858cb58f6d56555e4c51fe45d5"
53
53
  }