@synerise/ds-condition 0.25.2 → 0.25.3
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 +8 -0
- package/dist/Condition.js +42 -71
- package/dist/ConditionStep/AddCondition/AddCondition.js +6 -6
- package/dist/ConditionStep/ConditionRow/ConditionRow.js +25 -36
- package/dist/ConditionStep/ConditionStep.js +37 -53
- package/dist/ConditionStep/EmptyCondition/EmptyCondition.js +2 -2
- package/dist/ConditionStep/StepHeader/StepHeader.js +11 -13
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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.25.3](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.25.2...@synerise/ds-condition@0.25.3) (2024-11-22)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-condition
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [0.25.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.25.1...@synerise/ds-condition@0.25.2) (2024-11-21)
|
|
7
15
|
|
|
8
16
|
|
package/dist/Condition.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
|
|
7
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
-
|
|
9
5
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
10
|
-
|
|
11
6
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
12
|
-
|
|
13
7
|
import React, { useEffect, useState, useCallback, useMemo } from 'react';
|
|
14
8
|
import { useIntl } from 'react-intl';
|
|
15
9
|
import { ReactSortable } from 'react-sortablejs';
|
|
@@ -20,46 +14,43 @@ import usePrevious from '@synerise/ds-utils/dist/usePrevious/usePrevious';
|
|
|
20
14
|
import { ConditionStep } from './ConditionStep';
|
|
21
15
|
import * as S from './Condition.style';
|
|
22
16
|
import { SORTABLE_CONFIG, DEFAULT_CONDITION, DEFAULT_FIELD, DEFAULT_STEP, OPERATOR, FACTOR, PARAMETER, SUBJECT, DEFAULT_INPUT_PROPS, ACTION_ATTRIBUTE } from './constants';
|
|
23
|
-
|
|
24
17
|
var Condition = function Condition(props) {
|
|
25
18
|
var steps = props.steps,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
19
|
+
addCondition = props.addCondition,
|
|
20
|
+
removeCondition = props.removeCondition,
|
|
21
|
+
texts = props.texts,
|
|
22
|
+
duplicateStep = props.duplicateStep,
|
|
23
|
+
removeStep = props.removeStep,
|
|
24
|
+
addStep = props.addStep,
|
|
25
|
+
renderAddStep = props.renderAddStep,
|
|
26
|
+
onChangeOrder = props.onChangeOrder,
|
|
27
|
+
_props$minConditionsL = props.minConditionsLength,
|
|
28
|
+
minConditionsLength = _props$minConditionsL === void 0 ? 1 : _props$minConditionsL,
|
|
29
|
+
maxConditionsLength = props.maxConditionsLength,
|
|
30
|
+
autoClearCondition = props.autoClearCondition,
|
|
31
|
+
onChangeContext = props.onChangeContext,
|
|
32
|
+
onChangeSubject = props.onChangeSubject,
|
|
33
|
+
onChangeParameter = props.onChangeParameter,
|
|
34
|
+
onChangeOperator = props.onChangeOperator,
|
|
35
|
+
onChangeFactorType = props.onChangeFactorType,
|
|
36
|
+
onChangeFactorValue = props.onChangeFactorValue,
|
|
37
|
+
onUpdateStepName = props.onUpdateStepName,
|
|
38
|
+
getPopupContainerOverride = props.getPopupContainerOverride,
|
|
39
|
+
showSuffix = props.showSuffix,
|
|
40
|
+
hoverDisabled = props.hoverDisabled,
|
|
41
|
+
_props$autoOpenedComp = props.autoOpenedComponent,
|
|
42
|
+
autoOpenedComponent = _props$autoOpenedComp === void 0 ? DEFAULT_FIELD : _props$autoOpenedComp,
|
|
43
|
+
inputProps = props.inputProps,
|
|
44
|
+
onDeactivate = props.onDeactivate,
|
|
45
|
+
_props$readOnly = props.readOnly,
|
|
46
|
+
readOnly = _props$readOnly === void 0 ? false : _props$readOnly,
|
|
47
|
+
singleStepCondition = props.singleStepCondition,
|
|
48
|
+
showActionAttribute = props.showActionAttribute,
|
|
49
|
+
onChangeActionAttribute = props.onChangeActionAttribute,
|
|
50
|
+
_props$showEmptyCondi = props.showEmptyConditionPlaceholder,
|
|
51
|
+
showEmptyConditionPlaceholder = _props$showEmptyCondi === void 0 ? false : _props$showEmptyCondi;
|
|
60
52
|
var _useIntl = useIntl(),
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
formatMessage = _useIntl.formatMessage;
|
|
63
54
|
var text = useMemo(function () {
|
|
64
55
|
return _objectSpread({
|
|
65
56
|
addStep: formatMessage({
|
|
@@ -76,34 +67,29 @@ var Condition = function Condition(props) {
|
|
|
76
67
|
})
|
|
77
68
|
}, texts);
|
|
78
69
|
}, [texts, formatMessage]);
|
|
79
|
-
|
|
80
70
|
var _useState = useState(DEFAULT_CONDITION),
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
71
|
+
currentConditionId = _useState[0],
|
|
72
|
+
setCurrentConditionId = _useState[1];
|
|
84
73
|
var _useState2 = useState(DEFAULT_STEP),
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
74
|
+
currentStepId = _useState2[0],
|
|
75
|
+
setCurrentStepId = _useState2[1];
|
|
88
76
|
var _useState3 = useState(autoOpenedComponent),
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
77
|
+
currentField = _useState3[0],
|
|
78
|
+
setCurrentField = _useState3[1];
|
|
92
79
|
var prevSteps = usePrevious(steps);
|
|
93
80
|
useEffect(function () {
|
|
94
81
|
if (autoOpenedComponent && steps.length && steps[0].conditions[0].operator && steps[0].conditions[0].operator.value === undefined) {
|
|
95
82
|
setCurrentStepId(steps[0].id);
|
|
96
83
|
setCurrentConditionId(steps[0].conditions[0].id);
|
|
97
84
|
setCurrentField(autoOpenedComponent);
|
|
98
|
-
}
|
|
99
|
-
|
|
85
|
+
}
|
|
86
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
100
87
|
}, []);
|
|
101
88
|
useEffect(function () {
|
|
102
89
|
var newConditionId = prevSteps && steps && steps.reduce(function (id, step) {
|
|
103
90
|
var result = id;
|
|
104
91
|
var conditions = step.conditions.map(function (condition) {
|
|
105
92
|
var _condition$parameter;
|
|
106
|
-
|
|
107
93
|
return {
|
|
108
94
|
id: condition.id,
|
|
109
95
|
value: (_condition$parameter = condition.parameter) == null ? void 0 : _condition$parameter.value
|
|
@@ -112,7 +98,6 @@ var Condition = function Condition(props) {
|
|
|
112
98
|
var oldStep = prevSteps.find(function (prevStep) {
|
|
113
99
|
return prevStep.id === step.id;
|
|
114
100
|
});
|
|
115
|
-
|
|
116
101
|
if (oldStep) {
|
|
117
102
|
var oldConditions = oldStep.conditions.map(function (condition) {
|
|
118
103
|
return condition.id;
|
|
@@ -123,13 +108,10 @@ var Condition = function Condition(props) {
|
|
|
123
108
|
result = newCondition && !newCondition.value ? newCondition.id : result;
|
|
124
109
|
} else {
|
|
125
110
|
var _step$conditions$;
|
|
126
|
-
|
|
127
111
|
result = (_step$conditions$ = step.conditions[0]) == null ? void 0 : _step$conditions$.id;
|
|
128
112
|
}
|
|
129
|
-
|
|
130
113
|
return result;
|
|
131
114
|
}, undefined);
|
|
132
|
-
|
|
133
115
|
if (newConditionId && newConditionId !== currentConditionId) {
|
|
134
116
|
setCurrentConditionId(newConditionId);
|
|
135
117
|
}
|
|
@@ -139,7 +121,6 @@ var Condition = function Condition(props) {
|
|
|
139
121
|
return s.id === stepId;
|
|
140
122
|
});
|
|
141
123
|
if (step === undefined || step.conditions.length === 0) return;
|
|
142
|
-
|
|
143
124
|
if (removeCondition && addCondition) {
|
|
144
125
|
step.conditions.forEach(function (condition, index) {
|
|
145
126
|
if (index > 0) {
|
|
@@ -147,7 +128,6 @@ var Condition = function Condition(props) {
|
|
|
147
128
|
}
|
|
148
129
|
});
|
|
149
130
|
}
|
|
150
|
-
|
|
151
131
|
autoClearCondition && step.conditions.forEach(function (condition) {
|
|
152
132
|
onChangeFactorValue && onChangeFactorValue(step.id, condition.id, undefined);
|
|
153
133
|
onChangeOperator && onChangeOperator(step.id, condition.id, undefined);
|
|
@@ -155,7 +135,6 @@ var Condition = function Condition(props) {
|
|
|
155
135
|
});
|
|
156
136
|
setCurrentConditionId(step.conditions[0].id);
|
|
157
137
|
setCurrentStepId(step.id);
|
|
158
|
-
|
|
159
138
|
if (step.conditions[0].parameter) {
|
|
160
139
|
setCurrentField(PARAMETER);
|
|
161
140
|
} else if (step.conditions[0].operator) {
|
|
@@ -165,25 +144,21 @@ var Condition = function Condition(props) {
|
|
|
165
144
|
var selectSubject = useCallback(function (value, stepId) {
|
|
166
145
|
clearConditionRow(stepId);
|
|
167
146
|
setCurrentStepId(stepId);
|
|
168
|
-
|
|
169
147
|
if (showActionAttribute) {
|
|
170
148
|
setCurrentField(ACTION_ATTRIBUTE);
|
|
171
149
|
} else {
|
|
172
150
|
setCurrentField(PARAMETER);
|
|
173
151
|
}
|
|
174
|
-
|
|
175
152
|
onChangeSubject && onChangeSubject(stepId, value);
|
|
176
153
|
}, [clearConditionRow, onChangeSubject, showActionAttribute]);
|
|
177
154
|
var selectContext = useCallback(function (value, stepId) {
|
|
178
155
|
clearConditionRow(stepId);
|
|
179
156
|
setCurrentStepId(stepId);
|
|
180
|
-
|
|
181
157
|
if (showActionAttribute) {
|
|
182
158
|
setCurrentField(ACTION_ATTRIBUTE);
|
|
183
159
|
} else {
|
|
184
160
|
setCurrentField(PARAMETER);
|
|
185
161
|
}
|
|
186
|
-
|
|
187
162
|
onChangeContext && onChangeContext(stepId, value);
|
|
188
163
|
}, [clearConditionRow, onChangeContext, showActionAttribute]);
|
|
189
164
|
var selectActionAttribute = useCallback(function (value, stepId) {
|
|
@@ -227,7 +202,6 @@ var Condition = function Condition(props) {
|
|
|
227
202
|
}, [steps, onChangeOrder]);
|
|
228
203
|
var handleAddStep = useCallback(function () {
|
|
229
204
|
var newStepId = addStep ? addStep() : undefined;
|
|
230
|
-
|
|
231
205
|
if (newStepId) {
|
|
232
206
|
setCurrentStepId(newStepId);
|
|
233
207
|
setCurrentField(SUBJECT);
|
|
@@ -237,10 +211,8 @@ var Condition = function Condition(props) {
|
|
|
237
211
|
if (!addCondition) {
|
|
238
212
|
return undefined;
|
|
239
213
|
}
|
|
240
|
-
|
|
241
214
|
return function (stepId) {
|
|
242
215
|
var newConditionId = addCondition ? addCondition(stepId) : undefined;
|
|
243
|
-
|
|
244
216
|
if (newConditionId) {
|
|
245
217
|
setCurrentConditionId(newConditionId);
|
|
246
218
|
setCurrentStepId(stepId);
|
|
@@ -308,5 +280,4 @@ var Condition = function Condition(props) {
|
|
|
308
280
|
}), text.addStep)), !readOnly && renderAddStep && /*#__PURE__*/React.createElement(S.AddStepButton, null, renderAddStep()));
|
|
309
281
|
}, [steps, onChangeOrder, addStep, handleAddStep, text, readOnly, renderAddStep, currentStepId, getPopupContainerOverride, draggableEnabled, selectOperator, selectParameter, selectContext, selectSubject, onUpdateStepName, duplicateStep, removeStep, minConditionsLength, maxConditionsLength, setStepConditionFactorType, setStepConditionFactorValue, currentConditionId, currentField, removeCondition, handleAddCondition, handleClearActiveCondition, showSuffix, hoverDisabled, inputProps, singleStepCondition, selectActionAttribute, showActionAttribute, showEmptyConditionPlaceholder]);
|
|
310
282
|
};
|
|
311
|
-
|
|
312
283
|
export default Condition;
|
|
@@ -4,12 +4,12 @@ import Icon, { Add2M } from '@synerise/ds-icon';
|
|
|
4
4
|
import * as S from '../../Condition.style';
|
|
5
5
|
export var AddCondition = function AddCondition(_ref) {
|
|
6
6
|
var addCondition = _ref.addCondition,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
stepId = _ref.stepId,
|
|
8
|
+
conditionsNumber = _ref.conditionsNumber,
|
|
9
|
+
texts = _ref.texts,
|
|
10
|
+
_ref$isDisabled = _ref.isDisabled,
|
|
11
|
+
isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
|
|
12
|
+
errorText = _ref.errorText;
|
|
13
13
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(S.AddConditionRow, null, /*#__PURE__*/React.createElement(S.ConditionConnections, {
|
|
14
14
|
last: true,
|
|
15
15
|
first: conditionsNumber === 0
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
|
|
7
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
-
|
|
9
5
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
10
|
-
|
|
11
6
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
12
|
-
|
|
13
7
|
import React, { useMemo } from 'react';
|
|
14
8
|
import Factors from '@synerise/ds-factors';
|
|
15
9
|
import Operators from '@synerise/ds-operators';
|
|
@@ -21,38 +15,37 @@ import { FACTOR, OPERATOR, PARAMETER } from '../../constants';
|
|
|
21
15
|
import * as S from '../../Condition.style';
|
|
22
16
|
export var ConditionRow = function ConditionRow(_ref) {
|
|
23
17
|
var index = _ref.index,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
18
|
+
conditionId = _ref.conditionId,
|
|
19
|
+
conditionParameter = _ref.conditionParameter,
|
|
20
|
+
conditionOperator = _ref.conditionOperator,
|
|
21
|
+
conditionFactor = _ref.conditionFactor,
|
|
22
|
+
removeCondition = _ref.removeCondition,
|
|
23
|
+
addCondition = _ref.addCondition,
|
|
24
|
+
minConditionLength = _ref.minConditionLength,
|
|
25
|
+
maxConditionLength = _ref.maxConditionLength,
|
|
26
|
+
conditionsNumber = _ref.conditionsNumber,
|
|
27
|
+
stepId = _ref.stepId,
|
|
28
|
+
currentStepId = _ref.currentStepId,
|
|
29
|
+
currentConditionId = _ref.currentConditionId,
|
|
30
|
+
currentField = _ref.currentField,
|
|
31
|
+
selectParameter = _ref.selectParameter,
|
|
32
|
+
selectOperator = _ref.selectOperator,
|
|
33
|
+
setStepConditionFactorType = _ref.setStepConditionFactorType,
|
|
34
|
+
setStepConditionFactorValue = _ref.setStepConditionFactorValue,
|
|
35
|
+
getPopupContainerOverride = _ref.getPopupContainerOverride,
|
|
36
|
+
_onActivate = _ref.onActivate,
|
|
37
|
+
hasPriority = _ref.hasPriority,
|
|
38
|
+
texts = _ref.texts,
|
|
39
|
+
onDeactivate = _ref.onDeactivate,
|
|
40
|
+
inputProps = _ref.inputProps,
|
|
41
|
+
_ref$readOnly = _ref.readOnly,
|
|
42
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly;
|
|
49
43
|
var conditionFactorErrorText = conditionFactor == null ? void 0 : conditionFactor.errorText;
|
|
50
44
|
var conditionParameterErrorText = conditionParameter == null ? void 0 : conditionParameter.errorText;
|
|
51
45
|
var conditionOperatorErrorText = conditionOperator == null ? void 0 : conditionOperator.errorText;
|
|
52
46
|
var rowHasError = !!(conditionParameterErrorText || conditionOperatorErrorText || conditionFactorErrorText);
|
|
53
47
|
var conditionErrorMessage = useMemo(function () {
|
|
54
48
|
var errorText;
|
|
55
|
-
|
|
56
49
|
if (conditionParameterErrorText) {
|
|
57
50
|
errorText = conditionParameterErrorText;
|
|
58
51
|
} else if (conditionOperatorErrorText) {
|
|
@@ -60,7 +53,6 @@ export var ConditionRow = function ConditionRow(_ref) {
|
|
|
60
53
|
} else if (conditionFactorErrorText) {
|
|
61
54
|
errorText = conditionFactorErrorText;
|
|
62
55
|
}
|
|
63
|
-
|
|
64
56
|
return errorText ? /*#__PURE__*/React.createElement(S.ErrorWrapper, null, errorText) : /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
65
57
|
}, [conditionOperatorErrorText, conditionFactorErrorText, conditionParameterErrorText]);
|
|
66
58
|
var removeConditionTrigger = !readOnly && removeCondition && conditionsNumber > minConditionLength && /*#__PURE__*/React.createElement(S.RemoveIconWrapper, {
|
|
@@ -79,7 +71,6 @@ export var ConditionRow = function ConditionRow(_ref) {
|
|
|
79
71
|
var renderConditionOperatorWrapper = Boolean((!conditionParameter || (conditionParameter == null ? void 0 : conditionParameter.value) && (conditionParameter == null ? void 0 : conditionParameter.value).name !== '') && conditionOperator);
|
|
80
72
|
var renderConditionFactorWrapper = Boolean(conditionFactor !== undefined && (conditionOperator == null ? void 0 : conditionOperator.value) && (conditionFactor == null ? void 0 : conditionFactor.availableFactorTypes) !== null);
|
|
81
73
|
var lastConditionWrapper = '';
|
|
82
|
-
|
|
83
74
|
if (renderConditionFactorWrapper) {
|
|
84
75
|
lastConditionWrapper = 'factor';
|
|
85
76
|
} else if (renderConditionOperatorWrapper) {
|
|
@@ -87,10 +78,8 @@ export var ConditionRow = function ConditionRow(_ref) {
|
|
|
87
78
|
} else if (renderConditionParameterWrapper) {
|
|
88
79
|
lastConditionWrapper = 'parameter';
|
|
89
80
|
}
|
|
90
|
-
|
|
91
81
|
var conditionFactorProps = useMemo(function () {
|
|
92
82
|
var _conditionFactor$para, _conditionFactor$para2;
|
|
93
|
-
|
|
94
83
|
return _objectSpread({}, conditionFactor, {
|
|
95
84
|
parameters: (conditionFactor == null ? void 0 : conditionFactor.parameters) && _objectSpread({}, conditionFactor.parameters, {
|
|
96
85
|
selectedButtonColored: ((_conditionFactor$para = conditionFactor.parameters) == null ? void 0 : _conditionFactor$para.selectedButtonColored) === undefined ? true : (_conditionFactor$para2 = conditionFactor.parameters) == null ? void 0 : _conditionFactor$para2.selectedButtonColored
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
|
|
7
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
-
|
|
9
5
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
10
|
-
|
|
11
6
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
12
|
-
|
|
13
7
|
import React, { useCallback, useMemo } from 'react';
|
|
14
8
|
import Subject from '@synerise/ds-subject';
|
|
15
9
|
import ContextSelector from '@synerise/ds-context-selector';
|
|
@@ -24,48 +18,45 @@ import { ACTION_ATTRIBUTE, SUBJECT } from '../constants';
|
|
|
24
18
|
import { EmptyCondition } from './EmptyCondition';
|
|
25
19
|
export var ConditionStep = function ConditionStep(_ref) {
|
|
26
20
|
var _step$actionAttribute2, _step$subject3, _step$context4, _step$actionAttribute4, _step$context6, _step$subject4, _step$context7, _step$actionAttribute5, _step$actionAttribute6;
|
|
27
|
-
|
|
28
21
|
var step = _ref.step,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
22
|
+
texts = _ref.texts,
|
|
23
|
+
index = _ref.index,
|
|
24
|
+
addCondition = _ref.addCondition,
|
|
25
|
+
removeCondition = _ref.removeCondition,
|
|
26
|
+
updateStepName = _ref.updateStepName,
|
|
27
|
+
removeStep = _ref.removeStep,
|
|
28
|
+
duplicateStep = _ref.duplicateStep,
|
|
29
|
+
_ref$minConditionsLen = _ref.minConditionsLength,
|
|
30
|
+
minConditionsLength = _ref$minConditionsLen === void 0 ? 1 : _ref$minConditionsLen,
|
|
31
|
+
maxConditionsLength = _ref.maxConditionsLength,
|
|
32
|
+
draggableEnabled = _ref.draggableEnabled,
|
|
33
|
+
selectSubject = _ref.selectSubject,
|
|
34
|
+
selectContext = _ref.selectContext,
|
|
35
|
+
selectActionAttribute = _ref.selectActionAttribute,
|
|
36
|
+
selectOperator = _ref.selectOperator,
|
|
37
|
+
selectParameter = _ref.selectParameter,
|
|
38
|
+
setStepConditionFactorType = _ref.setStepConditionFactorType,
|
|
39
|
+
setStepConditionFactorValue = _ref.setStepConditionFactorValue,
|
|
40
|
+
getPopupContainerOverride = _ref.getPopupContainerOverride,
|
|
41
|
+
hasPriority = _ref.hasPriority,
|
|
42
|
+
currentStepId = _ref.currentStepId,
|
|
43
|
+
currentConditionId = _ref.currentConditionId,
|
|
44
|
+
currentField = _ref.currentField,
|
|
45
|
+
setCurrentField = _ref.setCurrentField,
|
|
46
|
+
setCurrentCondition = _ref.setCurrentCondition,
|
|
47
|
+
setCurrentStep = _ref.setCurrentStep,
|
|
48
|
+
onDeactivate = _ref.onDeactivate,
|
|
49
|
+
showSuffix = _ref.showSuffix,
|
|
50
|
+
inputProps = _ref.inputProps,
|
|
51
|
+
_ref$readOnly = _ref.readOnly,
|
|
52
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
53
|
+
_ref$singleStepCondit = _ref.singleStepCondition,
|
|
54
|
+
singleStepCondition = _ref$singleStepCondit === void 0 ? false : _ref$singleStepCondit,
|
|
55
|
+
showActionAttribute = _ref.showActionAttribute,
|
|
56
|
+
_ref$showEmptyConditi = _ref.showEmptyConditionPlaceholder,
|
|
57
|
+
showEmptyConditionPlaceholder = _ref$showEmptyConditi === void 0 ? false : _ref$showEmptyConditi;
|
|
66
58
|
var _useIntl = useIntl(),
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
formatMessage = _useIntl.formatMessage;
|
|
69
60
|
var text = useMemo(function () {
|
|
70
61
|
return _objectSpread({
|
|
71
62
|
stepNamePlaceholder: formatMessage({
|
|
@@ -111,13 +102,11 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
111
102
|
}, texts);
|
|
112
103
|
}, [texts, formatMessage]);
|
|
113
104
|
var withCruds = !readOnly && (duplicateStep || removeStep);
|
|
114
|
-
|
|
115
105
|
var _onActivate = useCallback(function () {
|
|
116
106
|
return setCurrentStep ? function () {
|
|
117
107
|
return setCurrentStep(step.id);
|
|
118
108
|
} : undefined;
|
|
119
109
|
}, [step.id, setCurrentStep]);
|
|
120
|
-
|
|
121
110
|
var onAddCondition = useCallback(function (stepId) {
|
|
122
111
|
addCondition && addCondition(stepId);
|
|
123
112
|
_onActivate && _onActivate();
|
|
@@ -137,7 +126,6 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
137
126
|
}, [draggableEnabled, duplicateStep, index, removeStep, step.id, step.stepName, text, updateStepName, readOnly]);
|
|
138
127
|
var addConditionButton = useMemo(function () {
|
|
139
128
|
var _step$subject, _step$context, _step$actionAttribute;
|
|
140
|
-
|
|
141
129
|
return !readOnly && addCondition && (maxConditionsLength === undefined || step.conditions.length < maxConditionsLength) && /*#__PURE__*/React.createElement(AddCondition, {
|
|
142
130
|
errorText: step.addConditionErrorText,
|
|
143
131
|
texts: text,
|
|
@@ -149,7 +137,6 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
149
137
|
}, [addCondition, onAddCondition, maxConditionsLength, step.conditions.length, step.context, step.id, step.subject, text, readOnly, step.addConditionErrorText, showActionAttribute, (_step$actionAttribute2 = step.actionAttribute) == null ? void 0 : _step$actionAttribute2.value]);
|
|
150
138
|
var renderConditionRow = useCallback(function (condition, conditionIndex) {
|
|
151
139
|
var _step$context2;
|
|
152
|
-
|
|
153
140
|
var handleActivation = function handleActivation(conditionId) {
|
|
154
141
|
return function (fieldType) {
|
|
155
142
|
_onActivate && _onActivate();
|
|
@@ -158,7 +145,6 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
158
145
|
setCurrentStep && setCurrentStep(step.id);
|
|
159
146
|
};
|
|
160
147
|
};
|
|
161
|
-
|
|
162
148
|
return /*#__PURE__*/React.createElement(ConditionRow, {
|
|
163
149
|
key: "step-" + step.id + "-condition-" + condition.id,
|
|
164
150
|
hasPriority: hasPriority && currentConditionId === condition.id,
|
|
@@ -193,12 +179,10 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
193
179
|
}, [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, inputProps, readOnly]);
|
|
194
180
|
var hasSelectedSubjectOrContext = useMemo(function () {
|
|
195
181
|
var _step$subject2, _step$context3;
|
|
196
|
-
|
|
197
182
|
return ((_step$subject2 = step.subject) == null ? void 0 : _step$subject2.selectedItem) || ((_step$context3 = step.context) == null ? void 0 : _step$context3.selectedItem);
|
|
198
183
|
}, [(_step$subject3 = step.subject) == null ? void 0 : _step$subject3.selectedItem, (_step$context4 = step.context) == null ? void 0 : _step$context4.selectedItem]);
|
|
199
184
|
var contextOrActionErrorText = useMemo(function () {
|
|
200
185
|
var _step$context5, _step$actionAttribute3;
|
|
201
|
-
|
|
202
186
|
return ((_step$context5 = step.context) == null ? void 0 : _step$context5.errorText) || showActionAttribute && ((_step$actionAttribute3 = step.actionAttribute) == null ? void 0 : _step$actionAttribute3.errorText);
|
|
203
187
|
}, [showActionAttribute, (_step$actionAttribute4 = step.actionAttribute) == null ? void 0 : _step$actionAttribute4.errorText, (_step$context6 = step.context) == null ? void 0 : _step$context6.errorText]);
|
|
204
188
|
return /*#__PURE__*/React.createElement(S.Step, {
|
|
@@ -4,8 +4,8 @@ import { theme } from '@synerise/ds-core';
|
|
|
4
4
|
import * as S from './emptyCondition.styles';
|
|
5
5
|
export var EmptyCondition = function EmptyCondition(_ref) {
|
|
6
6
|
var _ref$icon = _ref.icon,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
icon = _ref$icon === void 0 ? /*#__PURE__*/React.createElement(ClickM, null) : _ref$icon,
|
|
8
|
+
label = _ref.label;
|
|
9
9
|
return /*#__PURE__*/React.createElement(S.EmptyConditionWrapper, null, /*#__PURE__*/React.createElement(Icon, {
|
|
10
10
|
component: icon,
|
|
11
11
|
color: theme.palette['grey-500']
|
|
@@ -7,21 +7,19 @@ import { NOOP } from '@synerise/ds-utils';
|
|
|
7
7
|
import * as S from '../../Condition.style';
|
|
8
8
|
export var StepHeader = function StepHeader(_ref) {
|
|
9
9
|
var stepName = _ref.stepName,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
stepId = _ref.stepId,
|
|
11
|
+
texts = _ref.texts,
|
|
12
|
+
updateStepName = _ref.updateStepName,
|
|
13
|
+
duplicateStep = _ref.duplicateStep,
|
|
14
|
+
removeStep = _ref.removeStep,
|
|
15
|
+
index = _ref.index,
|
|
16
|
+
draggableEnabled = _ref.draggableEnabled,
|
|
17
|
+
_ref$readOnly = _ref.readOnly,
|
|
18
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly;
|
|
19
19
|
var onChangeNameDebounce = useRef(debounce(updateStepName || NOOP, 300)).current;
|
|
20
|
-
|
|
21
20
|
var _useState = useState(stepName),
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
localName = _useState[0],
|
|
22
|
+
setLocalName = _useState[1];
|
|
25
23
|
useEffect(function () {
|
|
26
24
|
setLocalName(stepName);
|
|
27
25
|
}, [stepName]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-condition",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.3",
|
|
4
4
|
"description": "Condition UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"types": "dist/index.d.ts",
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@synerise/ds-button": "^0.21.19",
|
|
38
|
-
"@synerise/ds-context-selector": "^0.25.
|
|
38
|
+
"@synerise/ds-context-selector": "^0.25.16",
|
|
39
39
|
"@synerise/ds-cruds": "^0.5.29",
|
|
40
|
-
"@synerise/ds-factors": "^0.27.
|
|
40
|
+
"@synerise/ds-factors": "^0.27.3",
|
|
41
41
|
"@synerise/ds-icon": "^0.67.0",
|
|
42
42
|
"@synerise/ds-inline-edit": "^0.9.1",
|
|
43
43
|
"@synerise/ds-input": "^0.24.14",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"react-intl": ">=3.12.0 <= 6.8",
|
|
56
56
|
"styled-components": "5.0.1"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "e9897e5ecb13a9c022f5ed002db76e4ab78318c5"
|
|
59
59
|
}
|