@synerise/ds-condition 0.14.3 → 0.16.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 +47 -0
- package/README.md +1 -0
- package/dist/Condition.js +32 -7
- package/dist/Condition.style.d.ts +10 -4
- package/dist/Condition.style.js +50 -35
- package/dist/Condition.types.d.ts +5 -0
- package/dist/ConditionStep/ConditionRow/ConditionRow.js +7 -1
- package/dist/ConditionStep/ConditionRow/ConditionRow.types.d.ts +1 -0
- package/dist/ConditionStep/ConditionStep.js +36 -7
- package/dist/ConditionStep/ConditionStep.types.d.ts +3 -0
- package/dist/ConditionStep/StepHeader/StepHeader.js +3 -2
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,53 @@
|
|
|
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.16.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.15.1...@synerise/ds-condition@0.16.0) (2022-05-13)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **condition:** disabling hover effect on nonactive condition in filter ([228f242](https://github.com/Synerise/synerise-design/commit/228f242e6ce244c73e9da93adb2c4317cd65ec91))
|
|
12
|
+
* **condition:** fixes styles of dragged condition with opened dropdown ([0449e94](https://github.com/Synerise/synerise-design/commit/0449e948dc598974c81e7f857431c519c5fa2666))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **condition:** adds defaultOpenedComponent prop ([6b6721d](https://github.com/Synerise/synerise-design/commit/6b6721dbd12be7e744100d303a5d3d7823467c3b))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## [0.15.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.15.0...@synerise/ds-condition@0.15.1) (2022-04-29)
|
|
24
|
+
|
|
25
|
+
**Note:** Version bump only for package @synerise/ds-condition
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# [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)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Features
|
|
35
|
+
|
|
36
|
+
* **condition:** clearing active step on deactivating inner components ([ad45310](https://github.com/Synerise/synerise-design/commit/ad45310cde108e40b2b88c0a88bf801d679056db))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## [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)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
### Bug Fixes
|
|
46
|
+
|
|
47
|
+
* **condition:** conditionally render addCondition renderProp ([78a3de7](https://github.com/Synerise/synerise-design/commit/78a3de75d8ec9c917d96c1b54c70d24f50dc8c7a))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
6
53
|
## [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
54
|
|
|
8
55
|
|
package/README.md
CHANGED
|
@@ -123,6 +123,7 @@ import Condition from '@synerise/ds-condition'
|
|
|
123
123
|
| onChangeFactorType | Callback called when user change type of condition factor | (stepId: React.ReactText, conditionId: React.ReactText, value: FactorType \ undefined) => void | - |
|
|
124
124
|
| onUpdateStepName | Callback called when user change the name of step condition | (stepId: React.ReactText, value: string) => void | - |
|
|
125
125
|
| getPopupContainerOverride | Popup container function for child tooltips and dropdowns | (trigger: HTMLElement | null) => HTMLElement; | - |
|
|
126
|
+
| defaultOpenedComponent | Component which should be opened after render | 'subject' \ 'operator' \ 'factor' \ 'parameter' \ 'context' | - |
|
|
126
127
|
|
|
127
128
|
### ConditionStep
|
|
128
129
|
|
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,11 @@ 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,
|
|
57
|
+
hoverDisabled = props.hoverDisabled,
|
|
58
|
+
_props$autoOpenedComp = props.autoOpenedComponent,
|
|
59
|
+
autoOpenedComponent = _props$autoOpenedComp === void 0 ? DEFAULT_FIELD : _props$autoOpenedComp;
|
|
55
60
|
|
|
56
61
|
var _useIntl = useIntl(),
|
|
57
62
|
formatMessage = _useIntl.formatMessage;
|
|
@@ -61,6 +66,10 @@ var Condition = function Condition(props) {
|
|
|
61
66
|
addStep: formatMessage({
|
|
62
67
|
id: 'DS.CONDITION.ADD-STEP',
|
|
63
68
|
defaultMessage: 'and then...'
|
|
69
|
+
}),
|
|
70
|
+
conditionSuffix: formatMessage({
|
|
71
|
+
id: 'DS.CONDITION.SUFFIX',
|
|
72
|
+
defaultMessage: 'and'
|
|
64
73
|
})
|
|
65
74
|
}, texts);
|
|
66
75
|
}, [texts, formatMessage]);
|
|
@@ -73,11 +82,19 @@ var Condition = function Condition(props) {
|
|
|
73
82
|
currentStepId = _React$useState2[0],
|
|
74
83
|
setCurrentStepId = _React$useState2[1];
|
|
75
84
|
|
|
76
|
-
var _React$useState3 = React.useState(
|
|
85
|
+
var _React$useState3 = React.useState(autoOpenedComponent),
|
|
77
86
|
currentField = _React$useState3[0],
|
|
78
87
|
setCurrentField = _React$useState3[1];
|
|
79
88
|
|
|
80
89
|
var prevSteps = usePrevious(steps);
|
|
90
|
+
React.useEffect(function () {
|
|
91
|
+
if (autoOpenedComponent && steps.length && steps[0].conditions[0].operator && steps[0].conditions[0].operator.value === undefined) {
|
|
92
|
+
setCurrentStepId(steps[0].id);
|
|
93
|
+
setCurrentConditionId(steps[0].conditions[0].id);
|
|
94
|
+
setCurrentField(autoOpenedComponent);
|
|
95
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
96
|
+
|
|
97
|
+
}, []);
|
|
81
98
|
React.useEffect(function () {
|
|
82
99
|
var newConditionId = prevSteps && steps && steps.reduce(function (id, step) {
|
|
83
100
|
var result = id;
|
|
@@ -195,7 +212,7 @@ var Condition = function Condition(props) {
|
|
|
195
212
|
setCurrentField(SUBJECT);
|
|
196
213
|
}
|
|
197
214
|
}, [addStep]);
|
|
198
|
-
var
|
|
215
|
+
var handleAddCondition = React.useMemo(function () {
|
|
199
216
|
if (!addCondition) {
|
|
200
217
|
return undefined;
|
|
201
218
|
}
|
|
@@ -210,6 +227,11 @@ var Condition = function Condition(props) {
|
|
|
210
227
|
}
|
|
211
228
|
};
|
|
212
229
|
}, [addCondition]);
|
|
230
|
+
var handleClearActiveCondition = React.useCallback(function () {
|
|
231
|
+
setCurrentConditionId(DEFAULT_CONDITION);
|
|
232
|
+
setCurrentStepId(DEFAULT_STEP);
|
|
233
|
+
setCurrentField(DEFAULT_FIELD);
|
|
234
|
+
}, []);
|
|
213
235
|
return React.useMemo(function () {
|
|
214
236
|
return /*#__PURE__*/React.createElement(S.Condition, {
|
|
215
237
|
className: "ds-conditions",
|
|
@@ -241,10 +263,13 @@ var Condition = function Condition(props) {
|
|
|
241
263
|
currentStepId: currentStepId,
|
|
242
264
|
currentField: currentField,
|
|
243
265
|
removeCondition: removeCondition,
|
|
244
|
-
addCondition:
|
|
266
|
+
addCondition: handleAddCondition,
|
|
245
267
|
setCurrentField: setCurrentField,
|
|
246
268
|
setCurrentCondition: setCurrentConditionId,
|
|
247
|
-
setCurrentStep: setCurrentStepId
|
|
269
|
+
setCurrentStep: setCurrentStepId,
|
|
270
|
+
onDeactivate: handleClearActiveCondition,
|
|
271
|
+
showSuffix: showSuffix,
|
|
272
|
+
hoverDisabled: hoverDisabled || currentStepId !== step.id && currentStepId !== undefined
|
|
248
273
|
});
|
|
249
274
|
})), addStep && /*#__PURE__*/React.createElement(S.AddStepButton, null, /*#__PURE__*/React.createElement(Button, {
|
|
250
275
|
type: "ghost",
|
|
@@ -252,8 +277,8 @@ var Condition = function Condition(props) {
|
|
|
252
277
|
onClick: handleAddStep
|
|
253
278
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
254
279
|
component: /*#__PURE__*/React.createElement(Add3M, null)
|
|
255
|
-
}), text.addStep)));
|
|
256
|
-
}, [steps, onChangeOrder, addStep, handleAddStep, text,
|
|
280
|
+
}), text.addStep)), renderAddStep && /*#__PURE__*/React.createElement(S.AddStepButton, null, renderAddStep()));
|
|
281
|
+
}, [steps, onChangeOrder, addStep, handleAddStep, text, renderAddStep, currentStepId, getPopupContainerOverride, draggableEnabled, selectOperator, selectParameter, selectContext, selectSubject, onUpdateStepName, duplicateStep, removeStep, minConditionsLength, maxConditionsLength, setStepConditionFactorType, setStepConditionFactorValue, currentConditionId, currentField, removeCondition, handleAddCondition, handleClearActiveCondition, showSuffix, hoverDisabled]);
|
|
257
282
|
};
|
|
258
283
|
|
|
259
284
|
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,15 @@ 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;
|
|
19
|
+
hoverDisabled?: boolean | undefined;
|
|
14
20
|
}, never>;
|
|
15
|
-
export declare const Step: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
16
21
|
export declare const ConditionWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
17
22
|
fullWidth?: boolean | undefined;
|
|
18
23
|
}, never>;
|
|
@@ -21,6 +26,7 @@ export declare const RemoveIconWrapper: import("styled-components").StyledCompon
|
|
|
21
26
|
export declare const ConditionRows: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
22
27
|
export declare const ConditionRow: import("styled-components").StyledComponent<"div", any, {
|
|
23
28
|
index: number;
|
|
29
|
+
stepType: ConditionRowProps['stepType'];
|
|
24
30
|
}, never>;
|
|
25
31
|
export declare const AddConditionRow: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
26
32
|
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:
|
|
48
|
-
return props.theme.palette
|
|
49
|
-
},
|
|
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,&.sortable-drag{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;}&:after{display:none;content:'';}}}"], 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) {
|
|
63
|
+
return props.hoverDisabled ? 'transparent' : props.theme.palette['grey-050'];
|
|
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,7 @@ 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;
|
|
54
|
+
hoverDisabled?: boolean;
|
|
55
|
+
autoOpenedComponent?: 'subject' | 'operator' | 'factor' | 'parameter' | 'context';
|
|
51
56
|
};
|
|
@@ -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,10 @@ 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,
|
|
51
|
+
hoverDisabled = _ref.hoverDisabled;
|
|
46
52
|
|
|
47
53
|
var _useIntl = useIntl(),
|
|
48
54
|
formatMessage = _useIntl.formatMessage;
|
|
@@ -84,6 +90,10 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
84
90
|
addStep: formatMessage({
|
|
85
91
|
id: 'DS.CONDITION.ADD-STEP',
|
|
86
92
|
defaultMessage: 'Add step'
|
|
93
|
+
}),
|
|
94
|
+
conditionSuffix: formatMessage({
|
|
95
|
+
id: 'DS.CONDITION.SUFFIX',
|
|
96
|
+
defaultMessage: 'and'
|
|
87
97
|
})
|
|
88
98
|
}, texts);
|
|
89
99
|
}, [texts, formatMessage]);
|
|
@@ -156,21 +166,30 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
156
166
|
setStepConditionFactorType: setStepConditionFactorType,
|
|
157
167
|
setStepConditionFactorValue: setStepConditionFactorValue,
|
|
158
168
|
texts: text,
|
|
159
|
-
stepType: (_step$context2 = step.context) == null ? void 0 : _step$context2.type
|
|
169
|
+
stepType: (_step$context2 = step.context) == null ? void 0 : _step$context2.type,
|
|
170
|
+
onDeactivate: onDeactivate
|
|
160
171
|
});
|
|
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]);
|
|
172
|
+
}, [step.id, step.conditions.length, step.context, hasPriority, currentConditionId, addCondition, removeCondition, minConditionsLength, maxConditionsLength, currentStepId, currentField, selectParameter, selectOperator, getPopupContainerOverride, setStepConditionFactorType, setStepConditionFactorValue, text, onDeactivate, onActivate, setCurrentField, setCurrentCondition, setCurrentStep]);
|
|
162
173
|
return /*#__PURE__*/React.createElement(S.Step, {
|
|
163
174
|
key: step.id,
|
|
164
175
|
id: "condition-step-" + step.id,
|
|
165
176
|
"data-dropLabel": text.dropLabel,
|
|
177
|
+
"data-conditionSuffix": text.conditionSuffix,
|
|
166
178
|
style: hasPriority ? {
|
|
167
179
|
zIndex: 10001
|
|
168
|
-
} : undefined
|
|
169
|
-
|
|
180
|
+
} : undefined,
|
|
181
|
+
active: step.id === currentStepId && currentField !== '',
|
|
182
|
+
hoverDisabled: hoverDisabled,
|
|
183
|
+
showSuffix: showSuffix
|
|
184
|
+
}, !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
185
|
withoutStepName: updateStepName === undefined
|
|
171
|
-
},
|
|
186
|
+
}, draggableEnabled && !updateStepName && /*#__PURE__*/React.createElement(S.DragIcon, {
|
|
187
|
+
className: "step-drag-handler",
|
|
188
|
+
component: /*#__PURE__*/React.createElement(DragHandleM, null)
|
|
189
|
+
}), /*#__PURE__*/React.createElement(S.Subject, null, step.subject && /*#__PURE__*/React.createElement(Subject, _extends({}, step.subject, {
|
|
172
190
|
getPopupContainerOverride: getPopupContainerOverride,
|
|
173
191
|
onActivate: onActivate,
|
|
192
|
+
onDeactivate: onDeactivate,
|
|
174
193
|
opened: step.id === currentStepId && currentField === SUBJECT,
|
|
175
194
|
onSelectItem: function onSelectItem(value) {
|
|
176
195
|
return selectSubject(value, step.id);
|
|
@@ -178,9 +197,19 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
178
197
|
})), step.context && /*#__PURE__*/React.createElement(ContextSelector, _extends({}, step.context, {
|
|
179
198
|
getPopupContainerOverride: getPopupContainerOverride,
|
|
180
199
|
onActivate: onActivate,
|
|
200
|
+
onDeactivate: onDeactivate,
|
|
181
201
|
opened: step.id === currentStepId && currentField === SUBJECT,
|
|
182
202
|
onSelectItem: function onSelectItem(value) {
|
|
183
203
|
return selectContext(value, step.id);
|
|
184
204
|
}
|
|
185
|
-
}))), /*#__PURE__*/React.createElement(S.ConditionRows, null, step.conditions.length > 0 && step.conditions.map(renderConditionRow), addConditionButton)
|
|
205
|
+
}))), /*#__PURE__*/React.createElement(S.ConditionRows, null, step.conditions.length > 0 && step.conditions.map(renderConditionRow), addConditionButton), !updateStepName && /*#__PURE__*/React.createElement(S.StepConditionCruds, {
|
|
206
|
+
onDuplicate: duplicateStep ? function () {
|
|
207
|
+
return duplicateStep(step.id);
|
|
208
|
+
} : undefined,
|
|
209
|
+
onDelete: removeStep ? function () {
|
|
210
|
+
return removeStep(step.id);
|
|
211
|
+
} : undefined,
|
|
212
|
+
duplicateTooltip: text.duplicateTooltip,
|
|
213
|
+
deleteTooltip: text.removeTooltip
|
|
214
|
+
})));
|
|
186
215
|
};
|
|
@@ -31,4 +31,7 @@ export declare type ConditionStepProps = {
|
|
|
31
31
|
setCurrentField: (field: string) => void;
|
|
32
32
|
setCurrentCondition: (conditionId: string) => void;
|
|
33
33
|
setCurrentStep: (stepId: React.ReactText) => void;
|
|
34
|
+
onDeactivate: () => void;
|
|
35
|
+
showSuffix?: boolean;
|
|
36
|
+
hoverDisabled?: boolean;
|
|
34
37
|
};
|
|
@@ -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.16.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.1",
|
|
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.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.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": "25e5737ebe9d4319de963b369bc281651872887c"
|
|
53
53
|
}
|