@synerise/ds-condition 0.14.3 → 0.15.0
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 +22 -0
- package/dist/Condition.js +19 -6
- package/dist/Condition.style.d.ts +9 -4
- package/dist/Condition.style.js +49 -34
- package/dist/Condition.types.d.ts +3 -0
- package/dist/ConditionStep/ConditionRow/ConditionRow.js +7 -1
- package/dist/ConditionStep/ConditionRow/ConditionRow.types.d.ts +1 -0
- package/dist/ConditionStep/ConditionStep.js +34 -7
- package/dist/ConditionStep/ConditionStep.types.d.ts +2 -0
- package/dist/ConditionStep/StepHeader/StepHeader.js +3 -2
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
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.15.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.14.4...@synerise/ds-condition@0.15.0) (2022-04-29)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **condition:** clearing active step on deactivating inner components ([ad45310](https://github.com/Synerise/synerise-design/commit/ad45310cde108e40b2b88c0a88bf801d679056db))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [0.14.4](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.14.3...@synerise/ds-condition@0.14.4) (2022-04-13)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **condition:** conditionally render addCondition renderProp ([78a3de7](https://github.com/Synerise/synerise-design/commit/78a3de75d8ec9c917d96c1b54c70d24f50dc8c7a))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## [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
29
|
|
|
8
30
|
|
package/dist/Condition.js
CHANGED
|
@@ -39,6 +39,7 @@ var Condition = function Condition(props) {
|
|
|
39
39
|
duplicateStep = props.duplicateStep,
|
|
40
40
|
removeStep = props.removeStep,
|
|
41
41
|
addStep = props.addStep,
|
|
42
|
+
renderAddStep = props.renderAddStep,
|
|
42
43
|
onChangeOrder = props.onChangeOrder,
|
|
43
44
|
_props$minConditionsL = props.minConditionsLength,
|
|
44
45
|
minConditionsLength = _props$minConditionsL === void 0 ? 1 : _props$minConditionsL,
|
|
@@ -51,7 +52,8 @@ var Condition = function Condition(props) {
|
|
|
51
52
|
onChangeFactorType = props.onChangeFactorType,
|
|
52
53
|
onChangeFactorValue = props.onChangeFactorValue,
|
|
53
54
|
onUpdateStepName = props.onUpdateStepName,
|
|
54
|
-
getPopupContainerOverride = props.getPopupContainerOverride
|
|
55
|
+
getPopupContainerOverride = props.getPopupContainerOverride,
|
|
56
|
+
showSuffix = props.showSuffix;
|
|
55
57
|
|
|
56
58
|
var _useIntl = useIntl(),
|
|
57
59
|
formatMessage = _useIntl.formatMessage;
|
|
@@ -61,6 +63,10 @@ var Condition = function Condition(props) {
|
|
|
61
63
|
addStep: formatMessage({
|
|
62
64
|
id: 'DS.CONDITION.ADD-STEP',
|
|
63
65
|
defaultMessage: 'and then...'
|
|
66
|
+
}),
|
|
67
|
+
conditionSuffix: formatMessage({
|
|
68
|
+
id: 'DS.CONDITION.SUFFIX',
|
|
69
|
+
defaultMessage: 'and'
|
|
64
70
|
})
|
|
65
71
|
}, texts);
|
|
66
72
|
}, [texts, formatMessage]);
|
|
@@ -195,7 +201,7 @@ var Condition = function Condition(props) {
|
|
|
195
201
|
setCurrentField(SUBJECT);
|
|
196
202
|
}
|
|
197
203
|
}, [addStep]);
|
|
198
|
-
var
|
|
204
|
+
var handleAddCondition = React.useMemo(function () {
|
|
199
205
|
if (!addCondition) {
|
|
200
206
|
return undefined;
|
|
201
207
|
}
|
|
@@ -210,6 +216,11 @@ var Condition = function Condition(props) {
|
|
|
210
216
|
}
|
|
211
217
|
};
|
|
212
218
|
}, [addCondition]);
|
|
219
|
+
var handleClearActiveCondition = React.useCallback(function () {
|
|
220
|
+
setCurrentConditionId(DEFAULT_CONDITION);
|
|
221
|
+
setCurrentStepId(DEFAULT_STEP);
|
|
222
|
+
setCurrentField(DEFAULT_FIELD);
|
|
223
|
+
}, []);
|
|
213
224
|
return React.useMemo(function () {
|
|
214
225
|
return /*#__PURE__*/React.createElement(S.Condition, {
|
|
215
226
|
className: "ds-conditions",
|
|
@@ -241,10 +252,12 @@ var Condition = function Condition(props) {
|
|
|
241
252
|
currentStepId: currentStepId,
|
|
242
253
|
currentField: currentField,
|
|
243
254
|
removeCondition: removeCondition,
|
|
244
|
-
addCondition:
|
|
255
|
+
addCondition: handleAddCondition,
|
|
245
256
|
setCurrentField: setCurrentField,
|
|
246
257
|
setCurrentCondition: setCurrentConditionId,
|
|
247
|
-
setCurrentStep: setCurrentStepId
|
|
258
|
+
setCurrentStep: setCurrentStepId,
|
|
259
|
+
onDeactivate: handleClearActiveCondition,
|
|
260
|
+
showSuffix: showSuffix
|
|
248
261
|
});
|
|
249
262
|
})), addStep && /*#__PURE__*/React.createElement(S.AddStepButton, null, /*#__PURE__*/React.createElement(Button, {
|
|
250
263
|
type: "ghost",
|
|
@@ -252,8 +265,8 @@ var Condition = function Condition(props) {
|
|
|
252
265
|
onClick: handleAddStep
|
|
253
266
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
254
267
|
component: /*#__PURE__*/React.createElement(Add3M, null)
|
|
255
|
-
}), text.addStep)));
|
|
256
|
-
}, [steps, onChangeOrder, addStep, handleAddStep, text,
|
|
268
|
+
}), text.addStep)), renderAddStep && /*#__PURE__*/React.createElement(S.AddStepButton, null, renderAddStep()));
|
|
269
|
+
}, [steps, onChangeOrder, addStep, handleAddStep, text, renderAddStep, currentStepId, getPopupContainerOverride, draggableEnabled, selectOperator, selectParameter, selectContext, selectSubject, onUpdateStepName, duplicateStep, removeStep, minConditionsLength, maxConditionsLength, setStepConditionFactorType, setStepConditionFactorValue, currentConditionId, currentField, removeCondition, handleAddCondition, handleClearActiveCondition, showSuffix]);
|
|
257
270
|
};
|
|
258
271
|
|
|
259
272
|
export default Condition;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { ConditionRowProps } from './ConditionStep/ConditionRow';
|
|
3
|
+
export declare const DragIcon: import("styled-components").StyledComponent<import("react").FC<import("@synerise/ds-icon").IconProps>, any, {}, never>;
|
|
4
|
+
export declare const StepConditionCruds: import("styled-components").StyledComponent<import("react").FC<import("@synerise/ds-cruds/dist/Cruds.types").CrudsProps> & import("@synerise/ds-cruds/dist/Cruds.types").CrudsSubComponents, any, {}, never>;
|
|
2
5
|
export declare const StepConditions: import("styled-components").StyledComponent<"div", any, {
|
|
3
6
|
withoutStepName: boolean;
|
|
4
7
|
}, never>;
|
|
@@ -6,13 +9,14 @@ export declare const StepName: import("styled-components").StyledComponent<"div"
|
|
|
6
9
|
export declare const Condition: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
10
|
export declare const ConditionStepWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
11
|
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>;
|
|
10
12
|
export declare const StepCruds: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
11
13
|
export declare const LeftSide: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
12
|
-
export declare const StepHeader: import("styled-components").StyledComponent<"div", any, {
|
|
13
|
-
|
|
14
|
+
export declare const StepHeader: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
15
|
+
export declare const DraggedLabel: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
16
|
+
export declare const Step: import("styled-components").StyledComponent<"div", any, {
|
|
17
|
+
active: boolean;
|
|
18
|
+
showSuffix: boolean | undefined;
|
|
14
19
|
}, never>;
|
|
15
|
-
export declare const Step: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
16
20
|
export declare const ConditionWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
17
21
|
fullWidth?: boolean | undefined;
|
|
18
22
|
}, never>;
|
|
@@ -21,6 +25,7 @@ export declare const RemoveIconWrapper: import("styled-components").StyledCompon
|
|
|
21
25
|
export declare const ConditionRows: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
22
26
|
export declare const ConditionRow: import("styled-components").StyledComponent<"div", any, {
|
|
23
27
|
index: number;
|
|
28
|
+
stepType: ConditionRowProps['stepType'];
|
|
24
29
|
}, never>;
|
|
25
30
|
export declare const AddConditionRow: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
26
31
|
export declare const ConditionConnections: import("styled-components").StyledComponent<"span", any, {
|
package/dist/Condition.style.js
CHANGED
|
@@ -1,92 +1,107 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
2
|
import { IconWrapper } from '@synerise/ds-inline-edit/dist/InlineEdit.styles';
|
|
3
3
|
import Icon from '@synerise/ds-icon';
|
|
4
|
+
import Cruds from '@synerise/ds-cruds';
|
|
5
|
+
export var DragIcon = styled(Icon).withConfig({
|
|
6
|
+
displayName: "Conditionstyle__DragIcon",
|
|
7
|
+
componentId: "sc-1lk06p3-0"
|
|
8
|
+
})(["opacity:0;visibility:hidden;position:absolute;top:0;left:-24px;cursor:grab;"]);
|
|
9
|
+
export var StepConditionCruds = styled(Cruds).withConfig({
|
|
10
|
+
displayName: "Conditionstyle__StepConditionCruds",
|
|
11
|
+
componentId: "sc-1lk06p3-1"
|
|
12
|
+
})(["position:absolute;top:16px;right:24px;visibility:hidden;opacity:0;"]);
|
|
4
13
|
export var StepConditions = styled.div.withConfig({
|
|
5
14
|
displayName: "Conditionstyle__StepConditions",
|
|
6
|
-
componentId: "sc-1lk06p3-
|
|
7
|
-
})(["display:flex;flex-direction:row;align-items:flex-start;justify-content:flex-start;margin-top:0;padding:0 24px;width:
|
|
15
|
+
componentId: "sc-1lk06p3-2"
|
|
16
|
+
})(["display:flex;flex-direction:row;align-items:flex-start;justify-content:flex-start;margin-top:0;padding:0 24px;width:", ";", "{left:0;top:16px;}"], function (props) {
|
|
17
|
+
return props.withoutStepName ? 'calc(100% - 48px)' : '100%';
|
|
18
|
+
}, DragIcon);
|
|
8
19
|
export var StepName = styled.div.withConfig({
|
|
9
20
|
displayName: "Conditionstyle__StepName",
|
|
10
|
-
componentId: "sc-1lk06p3-
|
|
21
|
+
componentId: "sc-1lk06p3-3"
|
|
11
22
|
})(["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
23
|
return props.theme.palette['grey-800'];
|
|
13
24
|
});
|
|
14
25
|
export var Condition = styled.div.withConfig({
|
|
15
26
|
displayName: "Conditionstyle__Condition",
|
|
16
|
-
componentId: "sc-1lk06p3-
|
|
27
|
+
componentId: "sc-1lk06p3-4"
|
|
17
28
|
})(["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
29
|
export var ConditionStepWrapper = styled.div.withConfig({
|
|
19
30
|
displayName: "Conditionstyle__ConditionStepWrapper",
|
|
20
|
-
componentId: "sc-1lk06p3-
|
|
31
|
+
componentId: "sc-1lk06p3-5"
|
|
21
32
|
})(["display:flex;align-items:flex-start;justify-content:flex-start;flex-direction:column;width:100%;"]);
|
|
22
33
|
export var And = styled.div.withConfig({
|
|
23
34
|
displayName: "Conditionstyle__And",
|
|
24
|
-
componentId: "sc-1lk06p3-
|
|
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;"]);
|
|
35
|
+
componentId: "sc-1lk06p3-6"
|
|
36
|
+
})(["display:contents;"]);
|
|
30
37
|
export var StepCruds = styled.div.withConfig({
|
|
31
38
|
displayName: "Conditionstyle__StepCruds",
|
|
32
|
-
componentId: "sc-1lk06p3-
|
|
39
|
+
componentId: "sc-1lk06p3-7"
|
|
33
40
|
})(["display:flex;align-items:center;justify-content:flex-end;opacity:0;visibility:hidden;"]);
|
|
34
41
|
export var LeftSide = styled.div.withConfig({
|
|
35
42
|
displayName: "Conditionstyle__LeftSide",
|
|
36
|
-
componentId: "sc-1lk06p3-
|
|
43
|
+
componentId: "sc-1lk06p3-8"
|
|
37
44
|
})(["display:flex;flex-direction:row;align-items:center;justify-content:flex-start;position:relative;"]);
|
|
38
45
|
export var StepHeader = styled.div.withConfig({
|
|
39
46
|
displayName: "Conditionstyle__StepHeader",
|
|
40
|
-
componentId: "sc-1lk06p3-
|
|
41
|
-
})(["display:flex;width:100%;flex-direction:row;align-items:flex-end;justify-content:space-between;margin-bottom:8px;padding:
|
|
42
|
-
|
|
47
|
+
componentId: "sc-1lk06p3-9"
|
|
48
|
+
})(["display:flex;width:100%;flex-direction:row;align-items:flex-end;justify-content:space-between;margin-bottom:8px;padding:0 24px;"]);
|
|
49
|
+
export var DraggedLabel = styled.span.withConfig({
|
|
50
|
+
displayName: "Conditionstyle__DraggedLabel",
|
|
51
|
+
componentId: "sc-1lk06p3-10"
|
|
52
|
+
})(["width:100%;height:100%;display:none;position:absolute;top:0;left:0;align-items:center;justify-content:flex-start;padding-left:18px;color:", ";font-size:13px;"], function (props) {
|
|
53
|
+
return props.theme.palette['grey-600'];
|
|
43
54
|
});
|
|
44
55
|
export var Step = styled.div.withConfig({
|
|
45
56
|
displayName: "Conditionstyle__Step",
|
|
46
|
-
componentId: "sc-1lk06p3-
|
|
47
|
-
})(["display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;padding:
|
|
57
|
+
componentId: "sc-1lk06p3-11"
|
|
58
|
+
})(["display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;padding:12px 0 12px;position:relative;", " &:first-of-type{&.steps-list-ghost-element{&:after{display:none;}}}background-color:", ";&:hover{background-color:", ";", "{opacity:1;visibility:visible;}", "{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;&:after{display:none;}", "{align-items:center;}", "{margin:0;", "{display:none;}}", "{display:none;}", "{display:flex;}}&.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;&:before{content:attr(data-dropLabel);text-align:center;position:relative;color:", ";}", "{display:none;}*{display:none;}}}"], function (props) {
|
|
59
|
+
return Boolean(props.showSuffix) && css(["&:after{display:none;width:100%;padding:18px 0 18px 24px;bottom:-18px;content:attr(data-conditionSuffix);background-color:", ";position:relative;font-size:16px;font-weight:500;color:#3f4c5b;}&:first-child:not(:last-child){&:after{display:flex;}}&:not(:last-child){&:after{display:flex;}}"], props.theme.palette.white);
|
|
60
|
+
}, function (props) {
|
|
61
|
+
return props.active ? props.theme.palette['grey-050'] : 'transparent';
|
|
62
|
+
}, function (props) {
|
|
48
63
|
return props.theme.palette['grey-050'];
|
|
49
|
-
}, StepCruds, DragIcon, function (props) {
|
|
64
|
+
}, StepCruds, StepConditionCruds, DragIcon, function (props) {
|
|
50
65
|
return props.theme.palette.white;
|
|
51
|
-
}, StepHeader, StepName, IconWrapper, StepConditions, function (props) {
|
|
66
|
+
}, StepHeader, StepName, IconWrapper, StepConditions, DraggedLabel, function (props) {
|
|
52
67
|
return props.theme.palette['blue-050'];
|
|
53
68
|
}, function (props) {
|
|
54
69
|
return props.theme.palette['blue-600'];
|
|
55
|
-
}, function (props) {
|
|
56
|
-
return props.theme.palette['grey-300'];
|
|
57
70
|
}, function (props) {
|
|
58
71
|
return props.theme.palette['blue-600'];
|
|
59
|
-
});
|
|
72
|
+
}, DraggedLabel);
|
|
60
73
|
export var ConditionWrapper = styled.div.withConfig({
|
|
61
74
|
displayName: "Conditionstyle__ConditionWrapper",
|
|
62
|
-
componentId: "sc-1lk06p3-
|
|
75
|
+
componentId: "sc-1lk06p3-12"
|
|
63
76
|
})([""]);
|
|
64
77
|
export var Subject = styled.div.withConfig({
|
|
65
78
|
displayName: "Conditionstyle__Subject",
|
|
66
|
-
componentId: "sc-1lk06p3-
|
|
79
|
+
componentId: "sc-1lk06p3-13"
|
|
67
80
|
})([""]);
|
|
68
81
|
export var RemoveIconWrapper = styled.span.withConfig({
|
|
69
82
|
displayName: "Conditionstyle__RemoveIconWrapper",
|
|
70
|
-
componentId: "sc-1lk06p3-
|
|
83
|
+
componentId: "sc-1lk06p3-14"
|
|
71
84
|
})(["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;"]);
|
|
72
85
|
export var ConditionRows = styled.div.withConfig({
|
|
73
86
|
displayName: "Conditionstyle__ConditionRows",
|
|
74
|
-
componentId: "sc-1lk06p3-
|
|
87
|
+
componentId: "sc-1lk06p3-15"
|
|
75
88
|
})(["display:flex;align-items:flex-start;justify-content:flex-start;flex-direction:column;"]);
|
|
76
89
|
export var ConditionRow = styled.div.withConfig({
|
|
77
90
|
displayName: "Conditionstyle__ConditionRow",
|
|
78
|
-
componentId: "sc-1lk06p3-
|
|
79
|
-
})(["display:flex;flex-direction:row;align-items:flex-start;justify-content:flex-start;padding-bottom:
|
|
91
|
+
componentId: "sc-1lk06p3-16"
|
|
92
|
+
})(["display:flex;flex-direction:row;align-items:flex-start;justify-content:flex-start;padding-bottom:", ";z-index:", ";", "{margin-right:8px;&:last-of-type{margin-right:0;}}&:hover{", "{opacity:1;visibility:visible;pointer-events:all;cursor:pointer;}}"], function (props) {
|
|
93
|
+
return props.stepType === 'event' ? '16px' : '0';
|
|
94
|
+
}, function (props) {
|
|
80
95
|
return 10000 - props.index;
|
|
81
96
|
}, ConditionWrapper, RemoveIconWrapper);
|
|
82
97
|
export var AddConditionRow = styled.div.withConfig({
|
|
83
98
|
displayName: "Conditionstyle__AddConditionRow",
|
|
84
|
-
componentId: "sc-1lk06p3-
|
|
99
|
+
componentId: "sc-1lk06p3-17"
|
|
85
100
|
})(["display:flex;align-items:flex-start;justify-content:flex-start;flex-direction:row;"]);
|
|
86
101
|
export var ConditionConnections = styled.span.withConfig({
|
|
87
102
|
displayName: "Conditionstyle__ConditionConnections",
|
|
88
|
-
componentId: "sc-1lk06p3-
|
|
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) {
|
|
103
|
+
componentId: "sc-1lk06p3-18"
|
|
104
|
+
})(["display:flex;width:32px;min-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) {
|
|
90
105
|
return props.first ? '100%' : '16px';
|
|
91
106
|
}, function (props) {
|
|
92
107
|
return props.first ? '0' : '16px';
|
|
@@ -103,5 +118,5 @@ export var ConditionConnections = styled.span.withConfig({
|
|
|
103
118
|
});
|
|
104
119
|
export var AddStepButton = styled.div.withConfig({
|
|
105
120
|
displayName: "Conditionstyle__AddStepButton",
|
|
106
|
-
componentId: "sc-1lk06p3-
|
|
121
|
+
componentId: "sc-1lk06p3-19"
|
|
107
122
|
})(["margin:12px 24px 0;"]);
|
|
@@ -26,11 +26,13 @@ export declare type ConditionTexts = {
|
|
|
26
26
|
moveTooltip: string;
|
|
27
27
|
duplicateTooltip: string;
|
|
28
28
|
removeTooltip: string;
|
|
29
|
+
conditionSuffix: string;
|
|
29
30
|
};
|
|
30
31
|
export declare type ConditionProps = {
|
|
31
32
|
steps: ConditionStep[];
|
|
32
33
|
getPopupContainerOverride?: (trigger: HTMLElement | null) => HTMLElement;
|
|
33
34
|
addCondition?: (stepId: React.ReactText) => string | undefined;
|
|
35
|
+
renderAddStep?: () => React.ReactNode;
|
|
34
36
|
removeCondition?: (stepId: React.ReactText, conditionRowId: React.ReactText) => void;
|
|
35
37
|
removeStep?: (stepId: React.ReactText) => void;
|
|
36
38
|
duplicateStep?: (stepId: React.ReactText) => void;
|
|
@@ -48,4 +50,5 @@ export declare type ConditionProps = {
|
|
|
48
50
|
onChangeFactorType: (stepId: React.ReactText, conditionId: React.ReactText, value: FactorType | undefined) => void;
|
|
49
51
|
onUpdateStepName?: (stepId: React.ReactText, value: string) => void;
|
|
50
52
|
type?: 'attribute' | 'event';
|
|
53
|
+
showSuffix?: boolean;
|
|
51
54
|
};
|
|
@@ -31,8 +31,11 @@ export var ConditionRow = function ConditionRow(_ref) {
|
|
|
31
31
|
getPopupContainerOverride = _ref.getPopupContainerOverride,
|
|
32
32
|
_onActivate = _ref.onActivate,
|
|
33
33
|
hasPriority = _ref.hasPriority,
|
|
34
|
-
texts = _ref.texts
|
|
34
|
+
texts = _ref.texts,
|
|
35
|
+
stepType = _ref.stepType,
|
|
36
|
+
onDeactivate = _ref.onDeactivate;
|
|
35
37
|
return /*#__PURE__*/React.createElement(S.ConditionRow, {
|
|
38
|
+
stepType: stepType,
|
|
36
39
|
style: hasPriority ? {
|
|
37
40
|
zIndex: 10001
|
|
38
41
|
} : undefined,
|
|
@@ -46,6 +49,7 @@ export var ConditionRow = function ConditionRow(_ref) {
|
|
|
46
49
|
onActivate: function onActivate() {
|
|
47
50
|
return _onActivate && _onActivate(PARAMETER);
|
|
48
51
|
},
|
|
52
|
+
onDeactivate: onDeactivate,
|
|
49
53
|
onChangeValue: function onChangeValue(value) {
|
|
50
54
|
return selectParameter(stepId, conditionId, value);
|
|
51
55
|
},
|
|
@@ -55,6 +59,7 @@ export var ConditionRow = function ConditionRow(_ref) {
|
|
|
55
59
|
onActivate: function onActivate() {
|
|
56
60
|
return _onActivate && _onActivate(OPERATOR);
|
|
57
61
|
},
|
|
62
|
+
onDeactivate: onDeactivate,
|
|
58
63
|
onChange: function onChange(value) {
|
|
59
64
|
return selectOperator(stepId, conditionId, value);
|
|
60
65
|
},
|
|
@@ -66,6 +71,7 @@ export var ConditionRow = function ConditionRow(_ref) {
|
|
|
66
71
|
onActivate: function onActivate() {
|
|
67
72
|
return _onActivate && _onActivate(FACTOR);
|
|
68
73
|
},
|
|
74
|
+
onDeactivate: onDeactivate,
|
|
69
75
|
setSelectedFactorType: function setSelectedFactorType(factorType) {
|
|
70
76
|
return setStepConditionFactorType(stepId, conditionId, factorType);
|
|
71
77
|
},
|
|
@@ -6,6 +6,7 @@ export declare type ConditionRowProps = {
|
|
|
6
6
|
index: number;
|
|
7
7
|
hasPriority?: boolean;
|
|
8
8
|
onActivate?: (fieldType: string) => void;
|
|
9
|
+
onDeactivate?: () => void;
|
|
9
10
|
conditionId: React.ReactText;
|
|
10
11
|
addCondition?: (stepId: React.ReactText) => void;
|
|
11
12
|
conditionParameter: FactorsProps;
|
|
@@ -10,6 +10,7 @@ import * as React from 'react';
|
|
|
10
10
|
import Subject from '@synerise/ds-subject';
|
|
11
11
|
import ContextSelector from '@synerise/ds-context-selector';
|
|
12
12
|
import { useIntl } from 'react-intl';
|
|
13
|
+
import { DragHandleM } from '@synerise/ds-icon';
|
|
13
14
|
import * as S from '../Condition.style';
|
|
14
15
|
import { StepHeader } from './StepHeader';
|
|
15
16
|
import { AddCondition } from './AddCondition';
|
|
@@ -17,6 +18,8 @@ import { ConditionRow } from './ConditionRow';
|
|
|
17
18
|
import { SUBJECT } from '../Condition'; // eslint-disable-next-line import/prefer-default-export
|
|
18
19
|
|
|
19
20
|
export var ConditionStep = function ConditionStep(_ref) {
|
|
21
|
+
var _step$subject2, _step$subject2$select, _step$context3, _step$context3$select;
|
|
22
|
+
|
|
20
23
|
var step = _ref.step,
|
|
21
24
|
texts = _ref.texts,
|
|
22
25
|
index = _ref.index,
|
|
@@ -42,7 +45,9 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
42
45
|
currentField = _ref.currentField,
|
|
43
46
|
setCurrentField = _ref.setCurrentField,
|
|
44
47
|
setCurrentCondition = _ref.setCurrentCondition,
|
|
45
|
-
setCurrentStep = _ref.setCurrentStep
|
|
48
|
+
setCurrentStep = _ref.setCurrentStep,
|
|
49
|
+
onDeactivate = _ref.onDeactivate,
|
|
50
|
+
showSuffix = _ref.showSuffix;
|
|
46
51
|
|
|
47
52
|
var _useIntl = useIntl(),
|
|
48
53
|
formatMessage = _useIntl.formatMessage;
|
|
@@ -84,6 +89,10 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
84
89
|
addStep: formatMessage({
|
|
85
90
|
id: 'DS.CONDITION.ADD-STEP',
|
|
86
91
|
defaultMessage: 'Add step'
|
|
92
|
+
}),
|
|
93
|
+
conditionSuffix: formatMessage({
|
|
94
|
+
id: 'DS.CONDITION.SUFFIX',
|
|
95
|
+
defaultMessage: 'and'
|
|
87
96
|
})
|
|
88
97
|
}, texts);
|
|
89
98
|
}, [texts, formatMessage]);
|
|
@@ -156,21 +165,29 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
156
165
|
setStepConditionFactorType: setStepConditionFactorType,
|
|
157
166
|
setStepConditionFactorValue: setStepConditionFactorValue,
|
|
158
167
|
texts: text,
|
|
159
|
-
stepType: (_step$context2 = step.context) == null ? void 0 : _step$context2.type
|
|
168
|
+
stepType: (_step$context2 = step.context) == null ? void 0 : _step$context2.type,
|
|
169
|
+
onDeactivate: onDeactivate
|
|
160
170
|
});
|
|
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]);
|
|
171
|
+
}, [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]);
|
|
162
172
|
return /*#__PURE__*/React.createElement(S.Step, {
|
|
163
173
|
key: step.id,
|
|
164
174
|
id: "condition-step-" + step.id,
|
|
165
175
|
"data-dropLabel": text.dropLabel,
|
|
176
|
+
"data-conditionSuffix": text.conditionSuffix,
|
|
166
177
|
style: hasPriority ? {
|
|
167
178
|
zIndex: 10001
|
|
168
|
-
} : undefined
|
|
169
|
-
|
|
179
|
+
} : undefined,
|
|
180
|
+
active: step.id === currentStepId && currentField !== '',
|
|
181
|
+
showSuffix: showSuffix
|
|
182
|
+
}, !updateStepName && /*#__PURE__*/React.createElement(S.DraggedLabel, null, ((_step$subject2 = step.subject) == null ? void 0 : (_step$subject2$select = _step$subject2.selectedItem) == null ? void 0 : _step$subject2$select.name) || ((_step$context3 = step.context) == null ? void 0 : (_step$context3$select = _step$context3.selectedItem) == null ? void 0 : _step$context3$select.name)), updateStepName && stepHeader, /*#__PURE__*/React.createElement(S.StepConditions, {
|
|
170
183
|
withoutStepName: updateStepName === undefined
|
|
171
|
-
},
|
|
184
|
+
}, draggableEnabled && !updateStepName && /*#__PURE__*/React.createElement(S.DragIcon, {
|
|
185
|
+
className: "step-drag-handler",
|
|
186
|
+
component: /*#__PURE__*/React.createElement(DragHandleM, null)
|
|
187
|
+
}), /*#__PURE__*/React.createElement(S.Subject, null, step.subject && /*#__PURE__*/React.createElement(Subject, _extends({}, step.subject, {
|
|
172
188
|
getPopupContainerOverride: getPopupContainerOverride,
|
|
173
189
|
onActivate: onActivate,
|
|
190
|
+
onDeactivate: onDeactivate,
|
|
174
191
|
opened: step.id === currentStepId && currentField === SUBJECT,
|
|
175
192
|
onSelectItem: function onSelectItem(value) {
|
|
176
193
|
return selectSubject(value, step.id);
|
|
@@ -178,9 +195,19 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
178
195
|
})), step.context && /*#__PURE__*/React.createElement(ContextSelector, _extends({}, step.context, {
|
|
179
196
|
getPopupContainerOverride: getPopupContainerOverride,
|
|
180
197
|
onActivate: onActivate,
|
|
198
|
+
onDeactivate: onDeactivate,
|
|
181
199
|
opened: step.id === currentStepId && currentField === SUBJECT,
|
|
182
200
|
onSelectItem: function onSelectItem(value) {
|
|
183
201
|
return selectContext(value, step.id);
|
|
184
202
|
}
|
|
185
|
-
}))), /*#__PURE__*/React.createElement(S.ConditionRows, null, step.conditions.length > 0 && step.conditions.map(renderConditionRow), addConditionButton)
|
|
203
|
+
}))), /*#__PURE__*/React.createElement(S.ConditionRows, null, step.conditions.length > 0 && step.conditions.map(renderConditionRow), addConditionButton), !updateStepName && /*#__PURE__*/React.createElement(S.StepConditionCruds, {
|
|
204
|
+
onDuplicate: duplicateStep ? function () {
|
|
205
|
+
return duplicateStep(step.id);
|
|
206
|
+
} : undefined,
|
|
207
|
+
onDelete: removeStep ? function () {
|
|
208
|
+
return removeStep(step.id);
|
|
209
|
+
} : undefined,
|
|
210
|
+
duplicateTooltip: text.duplicateTooltip,
|
|
211
|
+
deleteTooltip: text.removeTooltip
|
|
212
|
+
})));
|
|
186
213
|
};
|
|
@@ -29,11 +29,12 @@ export var StepHeader = function StepHeader(_ref) {
|
|
|
29
29
|
onChangeNameDebounce(stepId, event.target.value);
|
|
30
30
|
}, [onChangeNameDebounce, stepId]);
|
|
31
31
|
return /*#__PURE__*/React.createElement(S.StepHeader, {
|
|
32
|
-
className: "step-
|
|
32
|
+
className: "ds-condition-step-header",
|
|
33
33
|
draggable: draggableEnabled
|
|
34
34
|
}, /*#__PURE__*/React.createElement(S.LeftSide, null, draggableEnabled && /*#__PURE__*/React.createElement(S.DragIcon, {
|
|
35
|
+
className: "step-drag-handler",
|
|
35
36
|
component: /*#__PURE__*/React.createElement(DragHandleM, null)
|
|
36
|
-
}),
|
|
37
|
+
}), /*#__PURE__*/React.createElement(S.StepName, {
|
|
37
38
|
className: "ds-condition-step-name"
|
|
38
39
|
}, "" + (index + 1), ' ', /*#__PURE__*/React.createElement(InlineEdit, {
|
|
39
40
|
size: "small",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-condition",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
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.12.0",
|
|
37
|
+
"@synerise/ds-core": "^0.34.0",
|
|
38
38
|
"@synerise/ds-cruds": "^0.3.9",
|
|
39
|
-
"@synerise/ds-factors": "^0.
|
|
39
|
+
"@synerise/ds-factors": "^0.13.0",
|
|
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.12",
|
|
42
|
+
"@synerise/ds-operators": "^0.9.0",
|
|
43
|
+
"@synerise/ds-subject": "^0.9.0",
|
|
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": "4a658911645846d1e329609ba9db06a7bc64962b"
|
|
53
53
|
}
|