@synerise/ds-condition 0.11.1 → 0.12.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 +32 -0
- package/dist/Condition.js +25 -35
- package/dist/Condition.types.js +1 -0
- package/dist/ConditionStep/AddCondition/AddCondition.js +5 -6
- package/dist/ConditionStep/AddCondition/AddCondition.types.js +1 -0
- package/dist/ConditionStep/ConditionRow/ConditionRow.js +15 -12
- package/dist/ConditionStep/ConditionRow/ConditionRow.types.d.ts +1 -0
- package/dist/ConditionStep/ConditionRow/ConditionRow.types.js +1 -0
- package/dist/ConditionStep/ConditionStep.js +37 -17
- package/dist/ConditionStep/ConditionStep.types.d.ts +2 -0
- package/dist/ConditionStep/ConditionStep.types.js +1 -0
- package/dist/ConditionStep/StepHeader/StepHeader.js +8 -21
- package/dist/ConditionStep/StepHeader/StepHeader.types.js +1 -0
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,38 @@
|
|
|
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.12.3](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.12.2...@synerise/ds-condition@0.12.3) (2021-11-22)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-condition
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.12.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.12.1...@synerise/ds-condition@0.12.2) (2021-11-16)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @synerise/ds-condition
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [0.12.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.11.1...@synerise/ds-condition@0.12.1) (2021-11-09)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @synerise/ds-condition
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# [0.12.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.11.1...@synerise/ds-condition@0.12.0) (2021-11-09)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @synerise/ds-condition
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
6
38
|
## [0.11.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.11.0...@synerise/ds-condition@0.11.1) (2021-11-05)
|
|
7
39
|
|
|
8
40
|
**Note:** Version bump only for package @synerise/ds-condition
|
package/dist/Condition.js
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign || 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
2
|
|
|
3
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
-
|
|
5
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
-
|
|
7
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
-
|
|
9
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
10
|
-
|
|
11
|
-
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
12
|
-
|
|
13
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
-
|
|
15
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
16
4
|
|
|
17
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
@@ -21,8 +9,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
21
9
|
import * as React from 'react';
|
|
22
10
|
import { useIntl } from 'react-intl';
|
|
23
11
|
import { ReactSortable } from 'react-sortablejs';
|
|
24
|
-
import { Add3M } from '@synerise/ds-icon
|
|
25
|
-
import Icon from '@synerise/ds-icon';
|
|
12
|
+
import Icon, { Add3M } from '@synerise/ds-icon';
|
|
26
13
|
import Button from '@synerise/ds-button';
|
|
27
14
|
import { NOOP } from '@synerise/ds-utils';
|
|
28
15
|
import usePrevious from '@synerise/ds-utils/dist/usePrevious/usePrevious';
|
|
@@ -77,19 +64,20 @@ var Condition = function Condition(props) {
|
|
|
77
64
|
}, [texts, formatMessage]);
|
|
78
65
|
|
|
79
66
|
var _React$useState = React.useState(DEFAULT_CONDITION),
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
67
|
+
currentConditionId = _React$useState[0],
|
|
68
|
+
setCurrentConditionId = _React$useState[1];
|
|
69
|
+
|
|
70
|
+
var _React$useState2 = React.useState(DEFAULT_STEP),
|
|
71
|
+
currentStepId = _React$useState2[0],
|
|
72
|
+
setCurrentStepId = _React$useState2[1];
|
|
83
73
|
|
|
84
|
-
var _React$useState3 = React.useState(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
setCurrentStepId = _React$useState4[1];
|
|
74
|
+
var _React$useState3 = React.useState(DEFAULT_FIELD),
|
|
75
|
+
currentField = _React$useState3[0],
|
|
76
|
+
setCurrentField = _React$useState3[1];
|
|
88
77
|
|
|
89
|
-
var _React$
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
setCurrentField = _React$useState6[1];
|
|
78
|
+
var _React$useState4 = React.useState(null),
|
|
79
|
+
priorityStepId = _React$useState4[0],
|
|
80
|
+
setPriorityStepId = _React$useState4[1];
|
|
93
81
|
|
|
94
82
|
var prevSteps = usePrevious(steps);
|
|
95
83
|
React.useEffect(function () {
|
|
@@ -100,7 +88,7 @@ var Condition = function Condition(props) {
|
|
|
100
88
|
|
|
101
89
|
return {
|
|
102
90
|
id: condition.id,
|
|
103
|
-
value: (_condition$parameter = condition.parameter)
|
|
91
|
+
value: (_condition$parameter = condition.parameter) == null ? void 0 : _condition$parameter.value
|
|
104
92
|
};
|
|
105
93
|
});
|
|
106
94
|
var oldStep = prevSteps.find(function (prevStep) {
|
|
@@ -118,7 +106,7 @@ var Condition = function Condition(props) {
|
|
|
118
106
|
} else {
|
|
119
107
|
var _step$conditions$;
|
|
120
108
|
|
|
121
|
-
result = (_step$conditions$ = step.conditions[0])
|
|
109
|
+
result = (_step$conditions$ = step.conditions[0]) == null ? void 0 : _step$conditions$.id;
|
|
122
110
|
}
|
|
123
111
|
|
|
124
112
|
return result;
|
|
@@ -200,17 +188,19 @@ var Condition = function Condition(props) {
|
|
|
200
188
|
return onChangeOrder && steps.length > 1;
|
|
201
189
|
}, [steps, onChangeOrder]);
|
|
202
190
|
return React.useMemo(function () {
|
|
203
|
-
return React.createElement(S.Condition, {
|
|
191
|
+
return /*#__PURE__*/React.createElement(S.Condition, {
|
|
204
192
|
className: "ds-conditions"
|
|
205
|
-
}, React.createElement(ReactSortable, _extends({}, SORTABLE_CONFIG, {
|
|
193
|
+
}, /*#__PURE__*/React.createElement(ReactSortable, _extends({}, SORTABLE_CONFIG, {
|
|
206
194
|
list: steps,
|
|
207
195
|
setList: onChangeOrder || NOOP
|
|
208
196
|
}), steps.map(function (step, index) {
|
|
209
|
-
return React.createElement(ConditionStep, {
|
|
210
|
-
key: "step-id-"
|
|
197
|
+
return /*#__PURE__*/React.createElement(ConditionStep, {
|
|
198
|
+
key: "step-id-" + step.id,
|
|
211
199
|
step: step,
|
|
212
200
|
texts: texts,
|
|
213
201
|
index: index,
|
|
202
|
+
hasPriority: step.id === priorityStepId,
|
|
203
|
+
onStepActivate: setPriorityStepId,
|
|
214
204
|
getPopupContainerOverride: getPopupContainerOverride,
|
|
215
205
|
draggableEnabled: draggableEnabled,
|
|
216
206
|
selectOperator: selectOperator,
|
|
@@ -230,14 +220,14 @@ var Condition = function Condition(props) {
|
|
|
230
220
|
removeCondition: removeCondition,
|
|
231
221
|
addCondition: addCondition
|
|
232
222
|
});
|
|
233
|
-
})), addStep && React.createElement(Button, {
|
|
223
|
+
})), addStep && /*#__PURE__*/React.createElement(Button, {
|
|
234
224
|
type: "ghost-primary",
|
|
235
225
|
mode: "icon-label",
|
|
236
226
|
onClick: addStep
|
|
237
|
-
}, React.createElement(Icon, {
|
|
238
|
-
component: React.createElement(Add3M, null)
|
|
227
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
228
|
+
component: /*#__PURE__*/React.createElement(Add3M, null)
|
|
239
229
|
}), text.addStep));
|
|
240
|
-
}, [steps, onChangeOrder, addStep, text.addStep, texts, draggableEnabled, selectOperator, selectParameter, selectContext, selectSubject, onUpdateStepName, duplicateStep, removeStep, minConditionsLength, maxConditionsLength, setStepConditionFactorType, setStepConditionFactorValue, currentConditionId, currentStepId, currentField, removeCondition, addCondition, getPopupContainerOverride]);
|
|
230
|
+
}, [steps, priorityStepId, setPriorityStepId, onChangeOrder, addStep, text.addStep, texts, draggableEnabled, selectOperator, selectParameter, selectContext, selectSubject, onUpdateStepName, duplicateStep, removeStep, minConditionsLength, maxConditionsLength, setStepConditionFactorType, setStepConditionFactorValue, currentConditionId, currentStepId, currentField, removeCondition, addCondition, getPopupContainerOverride]);
|
|
241
231
|
};
|
|
242
232
|
|
|
243
233
|
export default Condition;
|
package/dist/Condition.types.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import Button from '@synerise/ds-button';
|
|
3
|
-
import Icon from '@synerise/ds-icon';
|
|
4
|
-
import { Add2M } from '@synerise/ds-icon/dist/icons';
|
|
3
|
+
import Icon, { Add2M } from '@synerise/ds-icon';
|
|
5
4
|
import * as S from '../../Condition.style';
|
|
6
5
|
// eslint-disable-next-line import/prefer-default-export
|
|
7
6
|
export var AddCondition = function AddCondition(_ref) {
|
|
@@ -11,17 +10,17 @@ export var AddCondition = function AddCondition(_ref) {
|
|
|
11
10
|
texts = _ref.texts,
|
|
12
11
|
selectedSubject = _ref.selectedSubject,
|
|
13
12
|
selectedContext = _ref.selectedContext;
|
|
14
|
-
return React.createElement(S.AddConditionRow, null, React.createElement(S.ConditionConnections, {
|
|
13
|
+
return /*#__PURE__*/React.createElement(S.AddConditionRow, null, /*#__PURE__*/React.createElement(S.ConditionConnections, {
|
|
15
14
|
last: true,
|
|
16
15
|
first: conditionsNumber === 0
|
|
17
|
-
}), React.createElement(Button, {
|
|
16
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
18
17
|
type: "ghost",
|
|
19
18
|
mode: "icon-label",
|
|
20
19
|
onClick: function onClick() {
|
|
21
20
|
addCondition && addCondition(stepId);
|
|
22
21
|
},
|
|
23
22
|
disabled: !(selectedSubject || selectedContext)
|
|
24
|
-
}, React.createElement(Icon, {
|
|
25
|
-
component: React.createElement(Add2M, null)
|
|
23
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
24
|
+
component: /*#__PURE__*/React.createElement(Add2M, null)
|
|
26
25
|
}), conditionsNumber > 0 ? texts.addConditionRowButton : texts.addFirstConditionRowButton));
|
|
27
26
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,8 +3,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
3
3
|
import Factors from '@synerise/ds-factors';
|
|
4
4
|
import Operators from '@synerise/ds-operators';
|
|
5
5
|
import Tooltip from '@synerise/ds-tooltip';
|
|
6
|
-
import Icon from '@synerise/ds-icon';
|
|
7
|
-
import { CloseS } from '@synerise/ds-icon/dist/icons';
|
|
6
|
+
import Icon, { CloseS } from '@synerise/ds-icon';
|
|
8
7
|
import theme from '@synerise/ds-core/dist/js/DSProvider/ThemeProvider/theme';
|
|
9
8
|
import * as React from 'react';
|
|
10
9
|
import { FACTOR, OPERATOR, PARAMETER } from '../../Condition';
|
|
@@ -30,27 +29,31 @@ export var ConditionRow = function ConditionRow(_ref) {
|
|
|
30
29
|
setStepConditionFactorType = _ref.setStepConditionFactorType,
|
|
31
30
|
setStepConditionFactorValue = _ref.setStepConditionFactorValue,
|
|
32
31
|
getPopupContainerOverride = _ref.getPopupContainerOverride,
|
|
32
|
+
onActivate = _ref.onActivate,
|
|
33
33
|
texts = _ref.texts;
|
|
34
|
-
return React.createElement(S.ConditionRow, {
|
|
35
|
-
key: "condition-row-"
|
|
34
|
+
return /*#__PURE__*/React.createElement(S.ConditionRow, {
|
|
35
|
+
key: "condition-row-" + conditionId,
|
|
36
36
|
index: index
|
|
37
|
-
}, React.createElement(S.ConditionConnections, {
|
|
37
|
+
}, /*#__PURE__*/React.createElement(S.ConditionConnections, {
|
|
38
38
|
first: index === 0,
|
|
39
39
|
last: Boolean(addCondition && index + 1 === conditionsNumber && maxConditionLength !== undefined && conditionsNumber === maxConditionLength)
|
|
40
|
-
}), React.createElement(S.ConditionWrapper, null, conditionParameter && React.createElement(Factors, _extends({}, conditionParameter, {
|
|
40
|
+
}), /*#__PURE__*/React.createElement(S.ConditionWrapper, null, conditionParameter && /*#__PURE__*/React.createElement(Factors, _extends({}, conditionParameter, {
|
|
41
41
|
getPopupContainerOverride: getPopupContainerOverride,
|
|
42
|
+
onActivate: onActivate,
|
|
42
43
|
onChangeValue: function onChangeValue(value) {
|
|
43
44
|
return selectParameter(stepId, conditionId, value);
|
|
44
45
|
},
|
|
45
46
|
opened: stepId === currentStepId && conditionId === currentConditionId && currentField === PARAMETER
|
|
46
|
-
}))), (!conditionParameter || (conditionParameter
|
|
47
|
+
}))), (!conditionParameter || (conditionParameter == null ? void 0 : conditionParameter.value)) && conditionOperator && /*#__PURE__*/React.createElement(S.ConditionWrapper, null, /*#__PURE__*/React.createElement(Operators, _extends({}, conditionOperator, {
|
|
47
48
|
getPopupContainerOverride: getPopupContainerOverride,
|
|
49
|
+
onActivate: onActivate,
|
|
48
50
|
onChange: function onChange(value) {
|
|
49
51
|
return selectOperator(stepId, conditionId, value);
|
|
50
52
|
},
|
|
51
53
|
opened: stepId === currentStepId && conditionId === currentConditionId && currentField === OPERATOR
|
|
52
|
-
}))), (conditionOperator
|
|
54
|
+
}))), (conditionOperator == null ? void 0 : conditionOperator.value) && /*#__PURE__*/React.createElement(S.ConditionWrapper, null, /*#__PURE__*/React.createElement(React.Fragment, null, (conditionFactor == null ? void 0 : conditionFactor.withCustomFactor) || /*#__PURE__*/React.createElement(Factors, _extends({}, conditionFactor, {
|
|
53
55
|
getPopupContainerOverride: getPopupContainerOverride,
|
|
56
|
+
onActivate: onActivate,
|
|
54
57
|
setSelectedFactorType: function setSelectedFactorType(factorType) {
|
|
55
58
|
return setStepConditionFactorType(stepId, conditionId, factorType);
|
|
56
59
|
},
|
|
@@ -59,16 +62,16 @@ export var ConditionRow = function ConditionRow(_ref) {
|
|
|
59
62
|
},
|
|
60
63
|
factorKey: conditionId,
|
|
61
64
|
opened: stepId === currentStepId && conditionId === currentConditionId && currentField === FACTOR
|
|
62
|
-
})))), removeCondition && conditionsNumber > minConditionLength && React.createElement(S.RemoveIconWrapper, {
|
|
65
|
+
})))), removeCondition && conditionsNumber > minConditionLength && /*#__PURE__*/React.createElement(S.RemoveIconWrapper, {
|
|
63
66
|
onClick: function onClick() {
|
|
64
67
|
return removeCondition(stepId, conditionId);
|
|
65
68
|
},
|
|
66
69
|
className: "ds-conditions-remove-row"
|
|
67
|
-
}, React.createElement(Tooltip, {
|
|
70
|
+
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
68
71
|
title: texts.removeConditionRowTooltip,
|
|
69
72
|
trigger: ['hover']
|
|
70
|
-
}, React.createElement(Icon, {
|
|
71
|
-
component: React.createElement(CloseS, null),
|
|
73
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
74
|
+
component: /*#__PURE__*/React.createElement(CloseS, null),
|
|
72
75
|
color: theme.palette['red-600']
|
|
73
76
|
}))));
|
|
74
77
|
};
|
|
@@ -4,6 +4,7 @@ import { OperatorsProps } from '@synerise/ds-operators/dist/Operator.types';
|
|
|
4
4
|
import { ConditionProps, ConditionTexts } from '../../Condition.types';
|
|
5
5
|
export declare type ConditionRowProps = {
|
|
6
6
|
index: number;
|
|
7
|
+
onActivate?: () => void;
|
|
7
8
|
conditionId: React.ReactText;
|
|
8
9
|
addCondition: ConditionProps['addCondition'];
|
|
9
10
|
conditionParameter: FactorsProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -35,6 +35,8 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
35
35
|
setStepConditionFactorType = _ref.setStepConditionFactorType,
|
|
36
36
|
setStepConditionFactorValue = _ref.setStepConditionFactorValue,
|
|
37
37
|
getPopupContainerOverride = _ref.getPopupContainerOverride,
|
|
38
|
+
onStepActivate = _ref.onStepActivate,
|
|
39
|
+
hasPriority = _ref.hasPriority,
|
|
38
40
|
currentStepId = _ref.currentStepId,
|
|
39
41
|
currentConditionId = _ref.currentConditionId,
|
|
40
42
|
currentField = _ref.currentField;
|
|
@@ -82,8 +84,15 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
82
84
|
})
|
|
83
85
|
}, texts);
|
|
84
86
|
}, [texts, formatMessage]);
|
|
87
|
+
var onActivate = onStepActivate ? function () {
|
|
88
|
+
return onStepActivate(step.id);
|
|
89
|
+
} : undefined;
|
|
90
|
+
var onAddCondition = React.useCallback(function (stepId) {
|
|
91
|
+
addCondition && addCondition(stepId);
|
|
92
|
+
onActivate && onActivate();
|
|
93
|
+
}, [addCondition, onActivate]);
|
|
85
94
|
var stepHeader = React.useMemo(function () {
|
|
86
|
-
return React.createElement(StepHeader, {
|
|
95
|
+
return /*#__PURE__*/React.createElement(StepHeader, {
|
|
87
96
|
index: index,
|
|
88
97
|
stepId: step.id,
|
|
89
98
|
stepName: step.stepName || '',
|
|
@@ -97,20 +106,20 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
97
106
|
var addConditionButton = React.useMemo(function () {
|
|
98
107
|
var _step$subject, _step$context;
|
|
99
108
|
|
|
100
|
-
return addCondition && (maxConditionsLength === undefined || step.conditions.length < maxConditionsLength) && React.createElement(AddCondition, {
|
|
109
|
+
return addCondition && (maxConditionsLength === undefined || step.conditions.length < maxConditionsLength) && /*#__PURE__*/React.createElement(AddCondition, {
|
|
101
110
|
texts: text,
|
|
102
111
|
stepId: step.id,
|
|
103
|
-
addCondition:
|
|
112
|
+
addCondition: onAddCondition,
|
|
104
113
|
conditionsNumber: step.conditions.length,
|
|
105
|
-
selectedSubject: Boolean((_step$subject = step.subject)
|
|
106
|
-
selectedContext: Boolean((_step$context = step.context)
|
|
114
|
+
selectedSubject: Boolean((_step$subject = step.subject) == null ? void 0 : _step$subject.selectedItem),
|
|
115
|
+
selectedContext: Boolean((_step$context = step.context) == null ? void 0 : _step$context.selectedItem)
|
|
107
116
|
});
|
|
108
|
-
}, [addCondition, maxConditionsLength, step.conditions.length, step.context, step.id, step.subject, text]);
|
|
117
|
+
}, [addCondition, onAddCondition, maxConditionsLength, step.conditions.length, step.context, step.id, step.subject, text]);
|
|
109
118
|
var renderConditionRow = React.useCallback(function (condition, conditionIndex) {
|
|
110
119
|
var _step$context2;
|
|
111
120
|
|
|
112
|
-
return React.createElement(ConditionRow, {
|
|
113
|
-
key: "step-"
|
|
121
|
+
return /*#__PURE__*/React.createElement(ConditionRow, {
|
|
122
|
+
key: "step-" + step.id + "-condition-" + condition.id,
|
|
114
123
|
index: conditionIndex,
|
|
115
124
|
conditionId: condition.id,
|
|
116
125
|
addCondition: addCondition,
|
|
@@ -121,31 +130,42 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
121
130
|
minConditionLength: minConditionsLength,
|
|
122
131
|
maxConditionLength: maxConditionsLength,
|
|
123
132
|
conditionsNumber: step.conditions.length,
|
|
133
|
+
onActivate: onActivate,
|
|
124
134
|
stepId: step.id,
|
|
125
135
|
currentStepId: currentStepId,
|
|
126
136
|
currentConditionId: currentConditionId,
|
|
127
137
|
currentField: currentField,
|
|
128
138
|
selectParameter: selectParameter,
|
|
129
139
|
selectOperator: selectOperator,
|
|
130
|
-
getPopupContainerOverride: getPopupContainerOverride
|
|
140
|
+
getPopupContainerOverride: getPopupContainerOverride || function () {
|
|
141
|
+
return document.querySelector("#condition-step-" + step.id) || document.body;
|
|
142
|
+
},
|
|
131
143
|
setStepConditionFactorType: setStepConditionFactorType,
|
|
132
144
|
setStepConditionFactorValue: setStepConditionFactorValue,
|
|
133
145
|
texts: text,
|
|
134
|
-
stepType: (_step$context2 = step.context)
|
|
146
|
+
stepType: (_step$context2 = step.context) == null ? void 0 : _step$context2.type
|
|
135
147
|
});
|
|
136
|
-
}, [getPopupContainerOverride, addCondition, currentConditionId, currentField, currentStepId, maxConditionsLength, minConditionsLength, removeCondition, selectOperator, selectParameter, setStepConditionFactorType, setStepConditionFactorValue, step.conditions.length, step.context, step.id, text]);
|
|
137
|
-
return React.createElement(S.Step, {
|
|
148
|
+
}, [getPopupContainerOverride, addCondition, currentConditionId, currentField, currentStepId, maxConditionsLength, minConditionsLength, removeCondition, selectOperator, selectParameter, setStepConditionFactorType, setStepConditionFactorValue, step.conditions.length, step.context, step.id, text, onActivate]);
|
|
149
|
+
return /*#__PURE__*/React.createElement(S.Step, {
|
|
138
150
|
key: step.id,
|
|
139
|
-
"
|
|
140
|
-
|
|
151
|
+
id: "condition-step-" + step.id,
|
|
152
|
+
"data-dropLabel": text.dropLabel,
|
|
153
|
+
style: hasPriority ? {
|
|
154
|
+
zIndex: 10001
|
|
155
|
+
} : undefined
|
|
156
|
+
}, updateStepName && stepHeader, /*#__PURE__*/React.createElement(S.StepConditions, {
|
|
141
157
|
withoutStepName: updateStepName === undefined
|
|
142
|
-
}, React.createElement(S.Subject, null, step.subject && React.createElement(Subject, _extends({}, step.subject, {
|
|
158
|
+
}, /*#__PURE__*/React.createElement(S.Subject, null, step.subject && /*#__PURE__*/React.createElement(Subject, _extends({}, step.subject, {
|
|
159
|
+
getPopupContainerOverride: getPopupContainerOverride,
|
|
160
|
+
onActivate: onActivate,
|
|
143
161
|
onSelectItem: function onSelectItem(value) {
|
|
144
162
|
return selectSubject(value, step.id);
|
|
145
163
|
}
|
|
146
|
-
})), step.context && React.createElement(ContextSelector, _extends({}, step.context, {
|
|
164
|
+
})), step.context && /*#__PURE__*/React.createElement(ContextSelector, _extends({}, step.context, {
|
|
165
|
+
getPopupContainerOverride: getPopupContainerOverride,
|
|
166
|
+
onActivate: onActivate,
|
|
147
167
|
onSelectItem: function onSelectItem(value) {
|
|
148
168
|
return selectContext(value, step.id);
|
|
149
169
|
}
|
|
150
|
-
}))), React.createElement(S.ConditionRows, null, step.conditions.length > 0 && step.conditions.map(renderConditionRow), addConditionButton)));
|
|
170
|
+
}))), /*#__PURE__*/React.createElement(S.ConditionRows, null, step.conditions.length > 0 && step.conditions.map(renderConditionRow), addConditionButton)));
|
|
151
171
|
};
|
|
@@ -7,6 +7,8 @@ import { ConditionStep, ConditionTexts, ConditionProps } from '../Condition.type
|
|
|
7
7
|
export declare type ConditionStepProps = {
|
|
8
8
|
index: number;
|
|
9
9
|
step: ConditionStep;
|
|
10
|
+
hasPriority?: boolean;
|
|
11
|
+
onStepActivate?: (stepid: React.ReactText) => void;
|
|
10
12
|
getPopupContainerOverride?: ConditionProps['getPopupContainerOverride'];
|
|
11
13
|
addCondition?: (stepId: React.ReactText) => void;
|
|
12
14
|
removeCondition?: (stepId: React.ReactText, conditionRowId: React.ReactText) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
-
|
|
3
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
|
|
5
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
-
|
|
7
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
8
|
-
|
|
9
|
-
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
10
|
-
|
|
11
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
-
|
|
13
1
|
import InlineEdit from '@synerise/ds-inline-edit';
|
|
14
2
|
import * as React from 'react';
|
|
15
3
|
import Cruds from '@synerise/ds-cruds';
|
|
16
|
-
import { DragHandleM } from '@synerise/ds-icon/
|
|
4
|
+
import { DragHandleM } from '@synerise/ds-icon/';
|
|
17
5
|
import { NOOP } from '@synerise/ds-utils';
|
|
18
6
|
import { debounce } from 'lodash';
|
|
19
7
|
import * as S from '../../Condition.style';
|
|
@@ -31,9 +19,8 @@ export var StepHeader = function StepHeader(_ref) {
|
|
|
31
19
|
var onChangeNameDebounce = React.useCallback(debounce(updateStepName, 300), [updateStepName]);
|
|
32
20
|
|
|
33
21
|
var _React$useState = React.useState(stepName),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
setLocalName = _React$useState2[1];
|
|
22
|
+
localName = _React$useState[0],
|
|
23
|
+
setLocalName = _React$useState[1];
|
|
37
24
|
|
|
38
25
|
React.useEffect(function () {
|
|
39
26
|
setLocalName(stepName);
|
|
@@ -42,20 +29,20 @@ export var StepHeader = function StepHeader(_ref) {
|
|
|
42
29
|
setLocalName(event.target.value);
|
|
43
30
|
onChangeNameDebounce(stepId, event.target.value);
|
|
44
31
|
}, [onChangeNameDebounce, stepId]);
|
|
45
|
-
return React.createElement(S.StepHeader, null, updateStepName && React.createElement(S.StepName, null,
|
|
32
|
+
return /*#__PURE__*/React.createElement(S.StepHeader, null, updateStepName && /*#__PURE__*/React.createElement(S.StepName, null, index + 1 + ".", ' ', /*#__PURE__*/React.createElement(InlineEdit, {
|
|
46
33
|
size: "small",
|
|
47
34
|
input: {
|
|
48
35
|
value: localName,
|
|
49
|
-
name: "condition-step-name-"
|
|
36
|
+
name: "condition-step-name-" + stepId,
|
|
50
37
|
placeholder: texts.stepNamePlaceholder,
|
|
51
38
|
onChange: handleChangeName
|
|
52
39
|
}
|
|
53
|
-
})), React.createElement(S.StepCruds, null, draggableEnabled && React.createElement(Cruds.CustomAction, {
|
|
54
|
-
icon: React.createElement(DragHandleM, null),
|
|
40
|
+
})), /*#__PURE__*/React.createElement(S.StepCruds, null, draggableEnabled && /*#__PURE__*/React.createElement(Cruds.CustomAction, {
|
|
41
|
+
icon: /*#__PURE__*/React.createElement(DragHandleM, null),
|
|
55
42
|
title: texts.moveTooltip,
|
|
56
43
|
onClick: NOOP,
|
|
57
44
|
className: "step-drag-handler"
|
|
58
|
-
}), React.createElement(Cruds, {
|
|
45
|
+
}), /*#__PURE__*/React.createElement(Cruds, {
|
|
59
46
|
onDuplicate: duplicateStep ? function () {
|
|
60
47
|
return duplicateStep(stepId);
|
|
61
48
|
} : undefined,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-condition",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.3",
|
|
4
4
|
"description": "Condition UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -32,16 +32,16 @@
|
|
|
32
32
|
],
|
|
33
33
|
"types": "dist/index.d.ts",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@synerise/ds-button": "^0.
|
|
36
|
-
"@synerise/ds-context-selector": "^0.
|
|
37
|
-
"@synerise/ds-core": "^0.
|
|
38
|
-
"@synerise/ds-cruds": "^0.2
|
|
39
|
-
"@synerise/ds-factors": "^0.
|
|
40
|
-
"@synerise/ds-icon": "^0.
|
|
41
|
-
"@synerise/ds-inline-edit": "^0.
|
|
42
|
-
"@synerise/ds-operators": "^0.
|
|
43
|
-
"@synerise/ds-subject": "^0.
|
|
44
|
-
"@synerise/ds-tooltip": "^0.
|
|
35
|
+
"@synerise/ds-button": "^0.16.2",
|
|
36
|
+
"@synerise/ds-context-selector": "^0.8.3",
|
|
37
|
+
"@synerise/ds-core": "^0.31.2",
|
|
38
|
+
"@synerise/ds-cruds": "^0.3.2",
|
|
39
|
+
"@synerise/ds-factors": "^0.10.3",
|
|
40
|
+
"@synerise/ds-icon": "^0.46.2",
|
|
41
|
+
"@synerise/ds-inline-edit": "^0.5.3",
|
|
42
|
+
"@synerise/ds-operators": "^0.6.3",
|
|
43
|
+
"@synerise/ds-subject": "^0.6.3",
|
|
44
|
+
"@synerise/ds-tooltip": "^0.11.2",
|
|
45
45
|
"@synerise/ds-utils": "^0.19.0",
|
|
46
46
|
"react-sortablejs": "^6.0.0"
|
|
47
47
|
},
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"@synerise/ds-core": "*",
|
|
50
50
|
"react": ">=16.9.0 < 17.0.0"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "2468359677783819939fb9f1ef5acc36667ecd1a"
|
|
53
53
|
}
|