@synerise/ds-condition 0.13.9 → 0.14.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 +55 -0
- package/dist/Condition.d.ts +1 -0
- package/dist/Condition.js +41 -15
- package/dist/Condition.style.d.ts +12 -2
- package/dist/Condition.style.js +44 -23
- package/dist/Condition.types.d.ts +3 -2
- package/dist/ConditionStep/AddCondition/AddCondition.types.d.ts +3 -3
- package/dist/ConditionStep/ConditionRow/ConditionRow.js +17 -9
- package/dist/ConditionStep/ConditionRow/ConditionRow.types.d.ts +2 -2
- package/dist/ConditionStep/ConditionStep.js +16 -13
- package/dist/ConditionStep/ConditionStep.types.d.ts +3 -0
- package/dist/ConditionStep/StepHeader/StepHeader.js +11 -10
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,61 @@
|
|
|
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.14.3](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.14.2...@synerise/ds-condition@0.14.3) (2022-04-12)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **condition:** rules-of-hooks dependencies ([10e573e](https://github.com/Synerise/synerise-design/commit/10e573e018ca7e2f69f3f317f35d51eace89ded8))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [0.14.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.14.1...@synerise/ds-condition@0.14.2) (2022-04-12)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* fix filter dropdowns ([eaab107](https://github.com/Synerise/synerise-design/commit/eaab107b6dca7401a17c2e36806febd11edc677b))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## [0.14.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.14.0...@synerise/ds-condition@0.14.1) (2022-04-08)
|
|
29
|
+
|
|
30
|
+
**Note:** Version bump only for package @synerise/ds-condition
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# [0.14.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.13.10...@synerise/ds-condition@0.14.0) (2022-04-05)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Bug Fixes
|
|
40
|
+
|
|
41
|
+
* **condition:** styles of StepHeader, hiding step name in stories ([9924476](https://github.com/Synerise/synerise-design/commit/9924476909449c5a11db7f784ba3a30008f48120))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Features
|
|
45
|
+
|
|
46
|
+
* **condition:** updates styles, allows to dragging by header, not only icon ([4c070eb](https://github.com/Synerise/synerise-design/commit/4c070ebaa5c3779733acea5cdff06d06842719b0))
|
|
47
|
+
* **filter:** fixes bugs ([b862ddd](https://github.com/Synerise/synerise-design/commit/b862dddbce1293c2a5381663fc903bb574edd135))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
## [0.13.10](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.13.9...@synerise/ds-condition@0.13.10) (2022-03-31)
|
|
54
|
+
|
|
55
|
+
**Note:** Version bump only for package @synerise/ds-condition
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
6
61
|
## [0.13.9](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.13.8...@synerise/ds-condition@0.13.9) (2022-03-30)
|
|
7
62
|
|
|
8
63
|
**Note:** Version bump only for package @synerise/ds-condition
|
package/dist/Condition.d.ts
CHANGED
|
@@ -3,5 +3,6 @@ import * as T from './Condition.types';
|
|
|
3
3
|
export declare const OPERATOR = "operator";
|
|
4
4
|
export declare const PARAMETER = "parameter";
|
|
5
5
|
export declare const FACTOR = "factor";
|
|
6
|
+
export declare const SUBJECT = "subject";
|
|
6
7
|
declare const Condition: React.FC<T.ConditionProps>;
|
|
7
8
|
export default Condition;
|
package/dist/Condition.js
CHANGED
|
@@ -21,10 +21,12 @@ var DEFAULT_STEP = '';
|
|
|
21
21
|
export var OPERATOR = 'operator';
|
|
22
22
|
export var PARAMETER = 'parameter';
|
|
23
23
|
export var FACTOR = 'factor';
|
|
24
|
+
export var SUBJECT = 'subject';
|
|
24
25
|
var SORTABLE_CONFIG = {
|
|
25
26
|
ghostClass: 'steps-list-ghost-element',
|
|
26
27
|
className: 'steps-list',
|
|
27
28
|
handle: '.step-drag-handler',
|
|
29
|
+
filter: '.ds-condition-step-name, .ds-cruds',
|
|
28
30
|
animation: 150,
|
|
29
31
|
forceFallback: true
|
|
30
32
|
};
|
|
@@ -58,7 +60,7 @@ var Condition = function Condition(props) {
|
|
|
58
60
|
return _objectSpread({
|
|
59
61
|
addStep: formatMessage({
|
|
60
62
|
id: 'DS.CONDITION.ADD-STEP',
|
|
61
|
-
defaultMessage: '
|
|
63
|
+
defaultMessage: 'and then...'
|
|
62
64
|
})
|
|
63
65
|
}, texts);
|
|
64
66
|
}, [texts, formatMessage]);
|
|
@@ -75,10 +77,6 @@ var Condition = function Condition(props) {
|
|
|
75
77
|
currentField = _React$useState3[0],
|
|
76
78
|
setCurrentField = _React$useState3[1];
|
|
77
79
|
|
|
78
|
-
var _React$useState4 = React.useState(null),
|
|
79
|
-
priorityStepId = _React$useState4[0],
|
|
80
|
-
setPriorityStepId = _React$useState4[1];
|
|
81
|
-
|
|
82
80
|
var prevSteps = usePrevious(steps);
|
|
83
81
|
React.useEffect(function () {
|
|
84
82
|
var newConditionId = prevSteps && steps && steps.reduce(function (id, step) {
|
|
@@ -147,11 +145,13 @@ var Condition = function Condition(props) {
|
|
|
147
145
|
var selectSubject = React.useCallback(function (value, stepId) {
|
|
148
146
|
clearConditionRow(stepId);
|
|
149
147
|
setCurrentStepId(stepId);
|
|
148
|
+
setCurrentField(PARAMETER);
|
|
150
149
|
onChangeSubject && onChangeSubject(stepId, value);
|
|
151
150
|
}, [clearConditionRow, onChangeSubject]);
|
|
152
151
|
var selectContext = React.useCallback(function (value, stepId) {
|
|
153
152
|
clearConditionRow(stepId);
|
|
154
153
|
setCurrentStepId(stepId);
|
|
154
|
+
setCurrentField(PARAMETER);
|
|
155
155
|
onChangeContext && onChangeContext(stepId, value);
|
|
156
156
|
}, [clearConditionRow, onChangeContext]);
|
|
157
157
|
var selectParameter = React.useCallback(function (stepId, conditionId, value) {
|
|
@@ -187,9 +187,33 @@ var Condition = function Condition(props) {
|
|
|
187
187
|
var draggableEnabled = React.useMemo(function () {
|
|
188
188
|
return onChangeOrder && steps.length > 1;
|
|
189
189
|
}, [steps, onChangeOrder]);
|
|
190
|
+
var handleAddStep = React.useCallback(function () {
|
|
191
|
+
var newStepId = addStep ? addStep() : undefined;
|
|
192
|
+
|
|
193
|
+
if (newStepId) {
|
|
194
|
+
setCurrentStepId(newStepId);
|
|
195
|
+
setCurrentField(SUBJECT);
|
|
196
|
+
}
|
|
197
|
+
}, [addStep]);
|
|
198
|
+
var handleAddCondtion = React.useMemo(function () {
|
|
199
|
+
if (!addCondition) {
|
|
200
|
+
return undefined;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return function (stepId) {
|
|
204
|
+
var newConditionId = addCondition ? addCondition(stepId) : undefined;
|
|
205
|
+
|
|
206
|
+
if (newConditionId) {
|
|
207
|
+
setCurrentConditionId(newConditionId);
|
|
208
|
+
setCurrentStepId(stepId);
|
|
209
|
+
setCurrentField(PARAMETER);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
}, [addCondition]);
|
|
190
213
|
return React.useMemo(function () {
|
|
191
214
|
return /*#__PURE__*/React.createElement(S.Condition, {
|
|
192
|
-
className: "ds-conditions"
|
|
215
|
+
className: "ds-conditions",
|
|
216
|
+
"data-popup-container": true
|
|
193
217
|
}, /*#__PURE__*/React.createElement(ReactSortable, _extends({}, SORTABLE_CONFIG, {
|
|
194
218
|
list: steps,
|
|
195
219
|
setList: onChangeOrder || NOOP
|
|
@@ -197,10 +221,9 @@ var Condition = function Condition(props) {
|
|
|
197
221
|
return /*#__PURE__*/React.createElement(ConditionStep, {
|
|
198
222
|
key: "step-id-" + step.id,
|
|
199
223
|
step: step,
|
|
200
|
-
texts:
|
|
224
|
+
texts: text,
|
|
201
225
|
index: index,
|
|
202
|
-
hasPriority: step.id ===
|
|
203
|
-
onStepActivate: setPriorityStepId,
|
|
226
|
+
hasPriority: step.id === currentStepId,
|
|
204
227
|
getPopupContainerOverride: getPopupContainerOverride,
|
|
205
228
|
draggableEnabled: draggableEnabled,
|
|
206
229
|
selectOperator: selectOperator,
|
|
@@ -218,16 +241,19 @@ var Condition = function Condition(props) {
|
|
|
218
241
|
currentStepId: currentStepId,
|
|
219
242
|
currentField: currentField,
|
|
220
243
|
removeCondition: removeCondition,
|
|
221
|
-
addCondition:
|
|
244
|
+
addCondition: handleAddCondtion,
|
|
245
|
+
setCurrentField: setCurrentField,
|
|
246
|
+
setCurrentCondition: setCurrentConditionId,
|
|
247
|
+
setCurrentStep: setCurrentStepId
|
|
222
248
|
});
|
|
223
|
-
})), addStep && /*#__PURE__*/React.createElement(Button, {
|
|
224
|
-
type: "ghost
|
|
249
|
+
})), addStep && /*#__PURE__*/React.createElement(S.AddStepButton, null, /*#__PURE__*/React.createElement(Button, {
|
|
250
|
+
type: "ghost",
|
|
225
251
|
mode: "icon-label",
|
|
226
|
-
onClick:
|
|
252
|
+
onClick: handleAddStep
|
|
227
253
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
228
254
|
component: /*#__PURE__*/React.createElement(Add3M, null)
|
|
229
|
-
}), text.addStep));
|
|
230
|
-
}, [steps,
|
|
255
|
+
}), text.addStep)));
|
|
256
|
+
}, [steps, onChangeOrder, addStep, handleAddStep, text, currentConditionId, currentStepId, currentField, getPopupContainerOverride, draggableEnabled, handleAddCondtion, selectOperator, selectParameter, selectContext, selectSubject, onUpdateStepName, duplicateStep, removeStep, minConditionsLength, maxConditionsLength, setStepConditionFactorType, setStepConditionFactorValue, removeCondition]);
|
|
231
257
|
};
|
|
232
258
|
|
|
233
259
|
export default Condition;
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export declare const StepConditions: import("styled-components").StyledComponent<"div", any, {
|
|
2
3
|
withoutStepName: boolean;
|
|
3
4
|
}, never>;
|
|
4
5
|
export declare const StepName: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
6
|
export declare const Condition: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
|
+
export declare const ConditionStepWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
|
+
export declare const And: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
9
|
+
export declare const DragIcon: import("styled-components").StyledComponent<import("react").FC<import("@synerise/ds-icon").IconProps>, any, {}, never>;
|
|
6
10
|
export declare const StepCruds: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
|
-
export declare const
|
|
11
|
+
export declare const LeftSide: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
12
|
+
export declare const StepHeader: import("styled-components").StyledComponent<"div", any, {
|
|
13
|
+
draggable: boolean;
|
|
14
|
+
}, never>;
|
|
8
15
|
export declare const Step: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
9
|
-
export declare const ConditionWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
16
|
+
export declare const ConditionWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
17
|
+
fullWidth?: boolean | undefined;
|
|
18
|
+
}, never>;
|
|
10
19
|
export declare const Subject: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
11
20
|
export declare const RemoveIconWrapper: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
12
21
|
export declare const ConditionRows: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -18,3 +27,4 @@ export declare const ConditionConnections: import("styled-components").StyledCom
|
|
|
18
27
|
first?: boolean | undefined;
|
|
19
28
|
last?: boolean | undefined;
|
|
20
29
|
}, never>;
|
|
30
|
+
export declare const AddStepButton: import("styled-components").StyledComponent<"div", any, {}, never>;
|
package/dist/Condition.style.js
CHANGED
|
@@ -1,40 +1,57 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
import { IconWrapper } from '@synerise/ds-inline-edit/dist/InlineEdit.styles';
|
|
3
|
+
import Icon from '@synerise/ds-icon';
|
|
3
4
|
export var StepConditions = styled.div.withConfig({
|
|
4
5
|
displayName: "Conditionstyle__StepConditions",
|
|
5
6
|
componentId: "sc-1lk06p3-0"
|
|
6
|
-
})(["display:flex;flex-direction:row;align-items:flex-start;justify-content:flex-start;margin-top:
|
|
7
|
-
return props.withoutStepName ? '22px' : '0';
|
|
8
|
-
});
|
|
7
|
+
})(["display:flex;flex-direction:row;align-items:flex-start;justify-content:flex-start;margin-top:0;padding:0 24px;width:100%;"]);
|
|
9
8
|
export var StepName = styled.div.withConfig({
|
|
10
9
|
displayName: "Conditionstyle__StepName",
|
|
11
10
|
componentId: "sc-1lk06p3-1"
|
|
12
|
-
})(["font-size:13px;line-height:1.84;color:", ";
|
|
13
|
-
return props.theme.palette['grey-
|
|
11
|
+
})(["font-size:13px;line-height:1.84;color:", ";display:flex;flex-direction:row;align-items:center;justify-content:flex-start;white-space:pre-wrap;&&& input{margin-top:2px;cursor:default;}"], function (props) {
|
|
12
|
+
return props.theme.palette['grey-800'];
|
|
14
13
|
});
|
|
15
14
|
export var Condition = styled.div.withConfig({
|
|
16
15
|
displayName: "Conditionstyle__Condition",
|
|
17
16
|
componentId: "sc-1lk06p3-2"
|
|
18
|
-
})(["padding:12px 0;display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;min-width:575px
|
|
17
|
+
})(["padding:12px 0;display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;min-width:575px;width:100%;.steps-list{width:100%;}"]);
|
|
18
|
+
export var ConditionStepWrapper = styled.div.withConfig({
|
|
19
|
+
displayName: "Conditionstyle__ConditionStepWrapper",
|
|
20
|
+
componentId: "sc-1lk06p3-3"
|
|
21
|
+
})(["display:flex;align-items:flex-start;justify-content:flex-start;flex-direction:column;width:100%;"]);
|
|
22
|
+
export var And = styled.div.withConfig({
|
|
23
|
+
displayName: "Conditionstyle__And",
|
|
24
|
+
componentId: "sc-1lk06p3-4"
|
|
25
|
+
})([""]);
|
|
26
|
+
export var DragIcon = styled(Icon).withConfig({
|
|
27
|
+
displayName: "Conditionstyle__DragIcon",
|
|
28
|
+
componentId: "sc-1lk06p3-5"
|
|
29
|
+
})(["opacity:0;visibility:hidden;position:absolute;top:0;left:-24px;"]);
|
|
19
30
|
export var StepCruds = styled.div.withConfig({
|
|
20
31
|
displayName: "Conditionstyle__StepCruds",
|
|
21
|
-
componentId: "sc-1lk06p3-
|
|
22
|
-
})(["display:flex;align-items:center;justify-content:flex-end;opacity:0;visibility:hidden;
|
|
32
|
+
componentId: "sc-1lk06p3-6"
|
|
33
|
+
})(["display:flex;align-items:center;justify-content:flex-end;opacity:0;visibility:hidden;"]);
|
|
34
|
+
export var LeftSide = styled.div.withConfig({
|
|
35
|
+
displayName: "Conditionstyle__LeftSide",
|
|
36
|
+
componentId: "sc-1lk06p3-7"
|
|
37
|
+
})(["display:flex;flex-direction:row;align-items:center;justify-content:flex-start;position:relative;"]);
|
|
23
38
|
export var StepHeader = styled.div.withConfig({
|
|
24
39
|
displayName: "Conditionstyle__StepHeader",
|
|
25
|
-
componentId: "sc-1lk06p3-
|
|
26
|
-
})(["display:flex;width:100%;
|
|
40
|
+
componentId: "sc-1lk06p3-8"
|
|
41
|
+
})(["display:flex;width:100%;flex-direction:row;align-items:flex-end;justify-content:space-between;margin-bottom:8px;padding:12px 24px 0;cursor:", ";"], function (props) {
|
|
42
|
+
return props.draggable ? 'grab' : 'default';
|
|
43
|
+
});
|
|
27
44
|
export var Step = styled.div.withConfig({
|
|
28
45
|
displayName: "Conditionstyle__Step",
|
|
29
|
-
componentId: "sc-1lk06p3-
|
|
30
|
-
})(["display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;padding:0 0
|
|
31
|
-
return props.theme.palette['grey-
|
|
32
|
-
}, StepCruds, function (props) {
|
|
46
|
+
componentId: "sc-1lk06p3-9"
|
|
47
|
+
})(["display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;padding:0 0 12px;position:relative;&:first-of-type{&.steps-list-ghost-element{&:after{display:none;}}}&:hover{background-color:", ";", "{opacity:1;visibility:visible;}", "{opacity:1;visibility:visible;}}&.sortable-chosen{cursor:grabbing;width:100%;opacity:1 !important;height:50px;background-color:", ";display:flex;align-items:center;justify-content:center;padding:0 20px;box-shadow:0 16px 32px 0 #23293619;", "{align-items:center;}", "{margin:0;", "{display:none;}}", "{display:none;}}&.steps-list-ghost-element{cursor:grabbing;width:100%;background-color:", ";border-left:2px solid ", ";border-radius:0;display:flex;align-items:center;justify-content:center;padding:0;height:50px;box-shadow:none;position:relative;margin:24px 0;&:after{content:'';position:absolute;top:-24px;left:0;width:100%;height:1px;border-bottom:1px dotted ", ";}&:before{content:attr(data-dropLabel);text-align:center;position:relative;color:", ";}*{display:none;}}}"], function (props) {
|
|
48
|
+
return props.theme.palette['grey-050'];
|
|
49
|
+
}, StepCruds, DragIcon, function (props) {
|
|
33
50
|
return props.theme.palette.white;
|
|
34
51
|
}, StepHeader, StepName, IconWrapper, StepConditions, function (props) {
|
|
35
52
|
return props.theme.palette['blue-050'];
|
|
36
53
|
}, function (props) {
|
|
37
|
-
return props.theme.palette['blue-
|
|
54
|
+
return props.theme.palette['blue-600'];
|
|
38
55
|
}, function (props) {
|
|
39
56
|
return props.theme.palette['grey-300'];
|
|
40
57
|
}, function (props) {
|
|
@@ -42,33 +59,33 @@ export var Step = styled.div.withConfig({
|
|
|
42
59
|
});
|
|
43
60
|
export var ConditionWrapper = styled.div.withConfig({
|
|
44
61
|
displayName: "Conditionstyle__ConditionWrapper",
|
|
45
|
-
componentId: "sc-1lk06p3-
|
|
62
|
+
componentId: "sc-1lk06p3-10"
|
|
46
63
|
})([""]);
|
|
47
64
|
export var Subject = styled.div.withConfig({
|
|
48
65
|
displayName: "Conditionstyle__Subject",
|
|
49
|
-
componentId: "sc-1lk06p3-
|
|
66
|
+
componentId: "sc-1lk06p3-11"
|
|
50
67
|
})([""]);
|
|
51
68
|
export var RemoveIconWrapper = styled.span.withConfig({
|
|
52
69
|
displayName: "Conditionstyle__RemoveIconWrapper",
|
|
53
|
-
componentId: "sc-1lk06p3-
|
|
70
|
+
componentId: "sc-1lk06p3-12"
|
|
54
71
|
})(["visibility:hidden;pointer-events:none;opacity:0;transition:all 0.3s ease;width:32px;height:32px;display:flex;align-items:center;justify-content:center;margin-left:8px;"]);
|
|
55
72
|
export var ConditionRows = styled.div.withConfig({
|
|
56
73
|
displayName: "Conditionstyle__ConditionRows",
|
|
57
|
-
componentId: "sc-1lk06p3-
|
|
74
|
+
componentId: "sc-1lk06p3-13"
|
|
58
75
|
})(["display:flex;align-items:flex-start;justify-content:flex-start;flex-direction:column;"]);
|
|
59
76
|
export var ConditionRow = styled.div.withConfig({
|
|
60
77
|
displayName: "Conditionstyle__ConditionRow",
|
|
61
|
-
componentId: "sc-1lk06p3-
|
|
78
|
+
componentId: "sc-1lk06p3-14"
|
|
62
79
|
})(["display:flex;flex-direction:row;align-items:flex-start;justify-content:flex-start;padding-bottom:16px;min-width:780px;z-index:", ";", "{margin-right:8px;&:last-of-type{margin-right:0;}}&:hover{", "{opacity:1;visibility:visible;pointer-events:all;cursor:pointer;}}"], function (props) {
|
|
63
80
|
return 10000 - props.index;
|
|
64
81
|
}, ConditionWrapper, RemoveIconWrapper);
|
|
65
82
|
export var AddConditionRow = styled.div.withConfig({
|
|
66
83
|
displayName: "Conditionstyle__AddConditionRow",
|
|
67
|
-
componentId: "sc-1lk06p3-
|
|
84
|
+
componentId: "sc-1lk06p3-15"
|
|
68
85
|
})(["display:flex;align-items:flex-start;justify-content:flex-start;flex-direction:row;"]);
|
|
69
86
|
export var ConditionConnections = styled.span.withConfig({
|
|
70
87
|
displayName: "Conditionstyle__ConditionConnections",
|
|
71
|
-
componentId: "sc-1lk06p3-
|
|
88
|
+
componentId: "sc-1lk06p3-16"
|
|
72
89
|
})(["display:flex;width:32px;margin:0 12px;position:relative;height:32px;&:before{position:absolute;content:'';width:", ";height:1px;top:50%;left:", ";background-color:", ";}&:after{display:", ";position:absolute;content:'';width:1px;left:50%;height:auto;top:", ";bottom:", ";background-color:", ";}"], function (props) {
|
|
73
90
|
return props.first ? '100%' : '16px';
|
|
74
91
|
}, function (props) {
|
|
@@ -83,4 +100,8 @@ export var ConditionConnections = styled.span.withConfig({
|
|
|
83
100
|
return props.last ? '16px' : '-16px';
|
|
84
101
|
}, function (props) {
|
|
85
102
|
return props.theme.palette['grey-300'];
|
|
86
|
-
});
|
|
103
|
+
});
|
|
104
|
+
export var AddStepButton = styled.div.withConfig({
|
|
105
|
+
displayName: "Conditionstyle__AddStepButton",
|
|
106
|
+
componentId: "sc-1lk06p3-17"
|
|
107
|
+
})(["margin:12px 24px 0;"]);
|
|
@@ -30,11 +30,11 @@ export declare type ConditionTexts = {
|
|
|
30
30
|
export declare type ConditionProps = {
|
|
31
31
|
steps: ConditionStep[];
|
|
32
32
|
getPopupContainerOverride?: (trigger: HTMLElement | null) => HTMLElement;
|
|
33
|
-
addCondition?: (stepId: React.ReactText) =>
|
|
33
|
+
addCondition?: (stepId: React.ReactText) => string | undefined;
|
|
34
34
|
removeCondition?: (stepId: React.ReactText, conditionRowId: React.ReactText) => void;
|
|
35
35
|
removeStep?: (stepId: React.ReactText) => void;
|
|
36
36
|
duplicateStep?: (stepId: React.ReactText) => void;
|
|
37
|
-
addStep?: () =>
|
|
37
|
+
addStep?: () => string | undefined;
|
|
38
38
|
onChangeOrder?: (newOrder: ConditionStep[]) => void;
|
|
39
39
|
texts?: Partial<ConditionTexts>;
|
|
40
40
|
minConditionsLength: number;
|
|
@@ -47,4 +47,5 @@ export declare type ConditionProps = {
|
|
|
47
47
|
onChangeFactorValue: (stepId: React.ReactText, conditionId: React.ReactText, value: FactorValueType | undefined) => void;
|
|
48
48
|
onChangeFactorType: (stepId: React.ReactText, conditionId: React.ReactText, value: FactorType | undefined) => void;
|
|
49
49
|
onUpdateStepName?: (stepId: React.ReactText, value: string) => void;
|
|
50
|
+
type?: 'attribute' | 'event';
|
|
50
51
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ConditionTexts } from '../../Condition.types';
|
|
3
3
|
export declare type AddConditionProps = {
|
|
4
|
-
addCondition:
|
|
4
|
+
addCondition: (stepId: React.ReactText) => void;
|
|
5
5
|
stepId: React.ReactText;
|
|
6
6
|
conditionsNumber: number;
|
|
7
7
|
texts: Partial<ConditionTexts>;
|
|
@@ -29,7 +29,7 @@ export var ConditionRow = function ConditionRow(_ref) {
|
|
|
29
29
|
setStepConditionFactorType = _ref.setStepConditionFactorType,
|
|
30
30
|
setStepConditionFactorValue = _ref.setStepConditionFactorValue,
|
|
31
31
|
getPopupContainerOverride = _ref.getPopupContainerOverride,
|
|
32
|
-
|
|
32
|
+
_onActivate = _ref.onActivate,
|
|
33
33
|
hasPriority = _ref.hasPriority,
|
|
34
34
|
texts = _ref.texts;
|
|
35
35
|
return /*#__PURE__*/React.createElement(S.ConditionRow, {
|
|
@@ -43,21 +43,29 @@ export var ConditionRow = function ConditionRow(_ref) {
|
|
|
43
43
|
last: Boolean(addCondition && index + 1 === conditionsNumber && maxConditionLength !== undefined && conditionsNumber === maxConditionLength)
|
|
44
44
|
}), /*#__PURE__*/React.createElement(S.ConditionWrapper, null, conditionParameter && /*#__PURE__*/React.createElement(Factors, _extends({}, conditionParameter, {
|
|
45
45
|
getPopupContainerOverride: getPopupContainerOverride,
|
|
46
|
-
onActivate: onActivate
|
|
46
|
+
onActivate: function onActivate() {
|
|
47
|
+
return _onActivate && _onActivate(PARAMETER);
|
|
48
|
+
},
|
|
47
49
|
onChangeValue: function onChangeValue(value) {
|
|
48
50
|
return selectParameter(stepId, conditionId, value);
|
|
49
51
|
},
|
|
50
|
-
opened: stepId === currentStepId && conditionId === currentConditionId && currentField === PARAMETER
|
|
51
|
-
}))), (!conditionParameter || (conditionParameter == null ? void 0 : conditionParameter.value)) && conditionOperator && /*#__PURE__*/React.createElement(S.ConditionWrapper, null, /*#__PURE__*/React.createElement(Operators, _extends({}, conditionOperator, {
|
|
52
|
+
opened: hasPriority && stepId === currentStepId && conditionId === currentConditionId && currentField === PARAMETER
|
|
53
|
+
}))), (!conditionParameter || (conditionParameter == null ? void 0 : conditionParameter.value) && (conditionParameter == null ? void 0 : conditionParameter.value).name !== '') && conditionOperator && /*#__PURE__*/React.createElement(S.ConditionWrapper, null, /*#__PURE__*/React.createElement(Operators, _extends({}, conditionOperator, {
|
|
52
54
|
getPopupContainerOverride: getPopupContainerOverride,
|
|
53
|
-
onActivate: onActivate
|
|
55
|
+
onActivate: function onActivate() {
|
|
56
|
+
return _onActivate && _onActivate(OPERATOR);
|
|
57
|
+
},
|
|
54
58
|
onChange: function onChange(value) {
|
|
55
59
|
return selectOperator(stepId, conditionId, value);
|
|
56
60
|
},
|
|
57
|
-
opened: stepId === currentStepId && conditionId === currentConditionId && currentField === OPERATOR
|
|
58
|
-
}))), (conditionOperator == null ? void 0 : conditionOperator.value) &&
|
|
61
|
+
opened: hasPriority && stepId === currentStepId && conditionId === currentConditionId && currentField === OPERATOR
|
|
62
|
+
}))), conditionFactor !== undefined && (conditionOperator == null ? void 0 : conditionOperator.value) && (conditionFactor == null ? void 0 : conditionFactor.availableFactorTypes) !== null && /*#__PURE__*/React.createElement(S.ConditionWrapper, {
|
|
63
|
+
fullWidth: true
|
|
64
|
+
}, /*#__PURE__*/React.createElement(React.Fragment, null, (conditionFactor == null ? void 0 : conditionFactor.withCustomFactor) || /*#__PURE__*/React.createElement(Factors, _extends({}, conditionFactor, {
|
|
59
65
|
getPopupContainerOverride: getPopupContainerOverride,
|
|
60
|
-
onActivate: onActivate
|
|
66
|
+
onActivate: function onActivate() {
|
|
67
|
+
return _onActivate && _onActivate(FACTOR);
|
|
68
|
+
},
|
|
61
69
|
setSelectedFactorType: function setSelectedFactorType(factorType) {
|
|
62
70
|
return setStepConditionFactorType(stepId, conditionId, factorType);
|
|
63
71
|
},
|
|
@@ -65,7 +73,7 @@ export var ConditionRow = function ConditionRow(_ref) {
|
|
|
65
73
|
return setStepConditionFactorValue(stepId, conditionId, value);
|
|
66
74
|
},
|
|
67
75
|
factorKey: conditionId,
|
|
68
|
-
opened: stepId === currentStepId && conditionId === currentConditionId && currentField === FACTOR
|
|
76
|
+
opened: hasPriority && stepId === currentStepId && conditionId === currentConditionId && currentField === FACTOR
|
|
69
77
|
})))), removeCondition && conditionsNumber > minConditionLength && /*#__PURE__*/React.createElement(S.RemoveIconWrapper, {
|
|
70
78
|
onClick: function onClick() {
|
|
71
79
|
return removeCondition(stepId, conditionId);
|
|
@@ -5,9 +5,9 @@ import { ConditionProps, ConditionTexts } from '../../Condition.types';
|
|
|
5
5
|
export declare type ConditionRowProps = {
|
|
6
6
|
index: number;
|
|
7
7
|
hasPriority?: boolean;
|
|
8
|
-
onActivate?: () => void;
|
|
8
|
+
onActivate?: (fieldType: string) => void;
|
|
9
9
|
conditionId: React.ReactText;
|
|
10
|
-
addCondition:
|
|
10
|
+
addCondition?: (stepId: React.ReactText) => void;
|
|
11
11
|
conditionParameter: FactorsProps;
|
|
12
12
|
conditionOperator: OperatorsProps;
|
|
13
13
|
conditionFactor: FactorsProps;
|
|
@@ -13,7 +13,8 @@ import { useIntl } from 'react-intl';
|
|
|
13
13
|
import * as S from '../Condition.style';
|
|
14
14
|
import { StepHeader } from './StepHeader';
|
|
15
15
|
import { AddCondition } from './AddCondition';
|
|
16
|
-
import { ConditionRow } from './ConditionRow';
|
|
16
|
+
import { ConditionRow } from './ConditionRow';
|
|
17
|
+
import { SUBJECT } from '../Condition'; // eslint-disable-next-line import/prefer-default-export
|
|
17
18
|
|
|
18
19
|
export var ConditionStep = function ConditionStep(_ref) {
|
|
19
20
|
var step = _ref.step,
|
|
@@ -35,15 +36,13 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
35
36
|
setStepConditionFactorType = _ref.setStepConditionFactorType,
|
|
36
37
|
setStepConditionFactorValue = _ref.setStepConditionFactorValue,
|
|
37
38
|
getPopupContainerOverride = _ref.getPopupContainerOverride,
|
|
38
|
-
onStepActivate = _ref.onStepActivate,
|
|
39
39
|
hasPriority = _ref.hasPriority,
|
|
40
40
|
currentStepId = _ref.currentStepId,
|
|
41
41
|
currentConditionId = _ref.currentConditionId,
|
|
42
|
-
currentField = _ref.currentField
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
setActiveConditionId = _React$useState[1];
|
|
42
|
+
currentField = _ref.currentField,
|
|
43
|
+
setCurrentField = _ref.setCurrentField,
|
|
44
|
+
setCurrentCondition = _ref.setCurrentCondition,
|
|
45
|
+
setCurrentStep = _ref.setCurrentStep;
|
|
47
46
|
|
|
48
47
|
var _useIntl = useIntl(),
|
|
49
48
|
formatMessage = _useIntl.formatMessage;
|
|
@@ -88,8 +87,8 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
88
87
|
})
|
|
89
88
|
}, texts);
|
|
90
89
|
}, [texts, formatMessage]);
|
|
91
|
-
var onActivate =
|
|
92
|
-
return
|
|
90
|
+
var onActivate = setCurrentStep ? function () {
|
|
91
|
+
return setCurrentStep(step.id);
|
|
93
92
|
} : undefined;
|
|
94
93
|
var onAddCondition = React.useCallback(function (stepId) {
|
|
95
94
|
addCondition && addCondition(stepId);
|
|
@@ -123,15 +122,17 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
123
122
|
var _step$context2;
|
|
124
123
|
|
|
125
124
|
var handleActivation = function handleActivation(conditionId) {
|
|
126
|
-
return function () {
|
|
127
|
-
setActiveConditionId(conditionId);
|
|
125
|
+
return function (fieldType) {
|
|
128
126
|
onActivate && onActivate();
|
|
127
|
+
setCurrentField && setCurrentField(fieldType);
|
|
128
|
+
setCurrentCondition && setCurrentCondition(conditionId);
|
|
129
|
+
setCurrentStep && setCurrentStep(step.id);
|
|
129
130
|
};
|
|
130
131
|
};
|
|
131
132
|
|
|
132
133
|
return /*#__PURE__*/React.createElement(ConditionRow, {
|
|
133
134
|
key: "step-" + step.id + "-condition-" + condition.id,
|
|
134
|
-
hasPriority: hasPriority &&
|
|
135
|
+
hasPriority: hasPriority && currentConditionId === condition.id,
|
|
135
136
|
index: conditionIndex,
|
|
136
137
|
conditionId: condition.id,
|
|
137
138
|
addCondition: addCondition,
|
|
@@ -157,7 +158,7 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
157
158
|
texts: text,
|
|
158
159
|
stepType: (_step$context2 = step.context) == null ? void 0 : _step$context2.type
|
|
159
160
|
});
|
|
160
|
-
}, [
|
|
161
|
+
}, [step.id, step.conditions.length, step.context, hasPriority, currentConditionId, addCondition, removeCondition, minConditionsLength, maxConditionsLength, currentStepId, currentField, selectParameter, selectOperator, getPopupContainerOverride, setStepConditionFactorType, setStepConditionFactorValue, text, onActivate, setCurrentField, setCurrentCondition, setCurrentStep]);
|
|
161
162
|
return /*#__PURE__*/React.createElement(S.Step, {
|
|
162
163
|
key: step.id,
|
|
163
164
|
id: "condition-step-" + step.id,
|
|
@@ -170,12 +171,14 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
170
171
|
}, /*#__PURE__*/React.createElement(S.Subject, null, step.subject && /*#__PURE__*/React.createElement(Subject, _extends({}, step.subject, {
|
|
171
172
|
getPopupContainerOverride: getPopupContainerOverride,
|
|
172
173
|
onActivate: onActivate,
|
|
174
|
+
opened: step.id === currentStepId && currentField === SUBJECT,
|
|
173
175
|
onSelectItem: function onSelectItem(value) {
|
|
174
176
|
return selectSubject(value, step.id);
|
|
175
177
|
}
|
|
176
178
|
})), step.context && /*#__PURE__*/React.createElement(ContextSelector, _extends({}, step.context, {
|
|
177
179
|
getPopupContainerOverride: getPopupContainerOverride,
|
|
178
180
|
onActivate: onActivate,
|
|
181
|
+
opened: step.id === currentStepId && currentField === SUBJECT,
|
|
179
182
|
onSelectItem: function onSelectItem(value) {
|
|
180
183
|
return selectContext(value, step.id);
|
|
181
184
|
}
|
|
@@ -28,4 +28,7 @@ export declare type ConditionStepProps = {
|
|
|
28
28
|
currentStepId: React.ReactText;
|
|
29
29
|
currentConditionId: React.ReactText;
|
|
30
30
|
currentField: React.ReactText;
|
|
31
|
+
setCurrentField: (field: string) => void;
|
|
32
|
+
setCurrentCondition: (conditionId: string) => void;
|
|
33
|
+
setCurrentStep: (stepId: React.ReactText) => void;
|
|
31
34
|
};
|
|
@@ -10,13 +10,12 @@ export var StepHeader = function StepHeader(_ref) {
|
|
|
10
10
|
var stepName = _ref.stepName,
|
|
11
11
|
stepId = _ref.stepId,
|
|
12
12
|
texts = _ref.texts,
|
|
13
|
-
|
|
14
|
-
updateStepName = _ref$updateStepName === void 0 ? NOOP : _ref$updateStepName,
|
|
13
|
+
updateStepName = _ref.updateStepName,
|
|
15
14
|
duplicateStep = _ref.duplicateStep,
|
|
16
15
|
removeStep = _ref.removeStep,
|
|
17
16
|
index = _ref.index,
|
|
18
17
|
draggableEnabled = _ref.draggableEnabled;
|
|
19
|
-
var onChangeNameDebounce = React.useCallback(debounce(updateStepName, 300), [updateStepName]);
|
|
18
|
+
var onChangeNameDebounce = React.useCallback(debounce(updateStepName || NOOP, 300), [updateStepName]);
|
|
20
19
|
|
|
21
20
|
var _React$useState = React.useState(stepName),
|
|
22
21
|
localName = _React$useState[0],
|
|
@@ -29,7 +28,14 @@ export var StepHeader = function StepHeader(_ref) {
|
|
|
29
28
|
setLocalName(event.target.value);
|
|
30
29
|
onChangeNameDebounce(stepId, event.target.value);
|
|
31
30
|
}, [onChangeNameDebounce, stepId]);
|
|
32
|
-
return /*#__PURE__*/React.createElement(S.StepHeader,
|
|
31
|
+
return /*#__PURE__*/React.createElement(S.StepHeader, {
|
|
32
|
+
className: "step-drag-handler",
|
|
33
|
+
draggable: draggableEnabled
|
|
34
|
+
}, /*#__PURE__*/React.createElement(S.LeftSide, null, draggableEnabled && /*#__PURE__*/React.createElement(S.DragIcon, {
|
|
35
|
+
component: /*#__PURE__*/React.createElement(DragHandleM, null)
|
|
36
|
+
}), updateStepName && /*#__PURE__*/React.createElement(S.StepName, {
|
|
37
|
+
className: "ds-condition-step-name"
|
|
38
|
+
}, "" + (index + 1), ' ', /*#__PURE__*/React.createElement(InlineEdit, {
|
|
33
39
|
size: "small",
|
|
34
40
|
input: {
|
|
35
41
|
value: localName,
|
|
@@ -37,12 +43,7 @@ export var StepHeader = function StepHeader(_ref) {
|
|
|
37
43
|
placeholder: texts.stepNamePlaceholder,
|
|
38
44
|
onChange: handleChangeName
|
|
39
45
|
}
|
|
40
|
-
})), /*#__PURE__*/React.createElement(S.StepCruds, null,
|
|
41
|
-
icon: /*#__PURE__*/React.createElement(DragHandleM, null),
|
|
42
|
-
title: texts.moveTooltip,
|
|
43
|
-
onClick: NOOP,
|
|
44
|
-
className: "step-drag-handler"
|
|
45
|
-
}), /*#__PURE__*/React.createElement(Cruds, {
|
|
46
|
+
}))), /*#__PURE__*/React.createElement(S.StepCruds, null, /*#__PURE__*/React.createElement(Cruds, {
|
|
46
47
|
onDuplicate: duplicateStep ? function () {
|
|
47
48
|
return duplicateStep(stepId);
|
|
48
49
|
} : undefined,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-condition",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.3",
|
|
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.
|
|
37
|
-
"@synerise/ds-core": "^0.
|
|
36
|
+
"@synerise/ds-context-selector": "^0.11.0",
|
|
37
|
+
"@synerise/ds-core": "^0.33.0",
|
|
38
38
|
"@synerise/ds-cruds": "^0.3.9",
|
|
39
|
-
"@synerise/ds-factors": "^0.
|
|
39
|
+
"@synerise/ds-factors": "^0.12.2",
|
|
40
40
|
"@synerise/ds-icon": "^0.49.0",
|
|
41
|
-
"@synerise/ds-inline-edit": "^0.6.
|
|
42
|
-
"@synerise/ds-operators": "^0.
|
|
43
|
-
"@synerise/ds-subject": "^0.
|
|
41
|
+
"@synerise/ds-inline-edit": "^0.6.11",
|
|
42
|
+
"@synerise/ds-operators": "^0.8.1",
|
|
43
|
+
"@synerise/ds-subject": "^0.8.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": "
|
|
52
|
+
"gitHead": "78a3de75d8ec9c917d96c1b54c70d24f50dc8c7a"
|
|
53
53
|
}
|