@synerise/ds-condition 0.15.1 → 0.17.1
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 +39 -0
- package/README.md +1 -0
- package/dist/Condition.js +42 -6
- package/dist/Condition.style.d.ts +1 -0
- package/dist/Condition.style.js +2 -2
- package/dist/Condition.types.d.ts +2 -0
- package/dist/ConditionStep/ConditionRow/ConditionRow.js +3 -1
- package/dist/ConditionStep/ConditionRow/ConditionRow.types.d.ts +1 -0
- package/dist/ConditionStep/ConditionStep.js +7 -3
- package/dist/ConditionStep/ConditionStep.types.d.ts +2 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,45 @@
|
|
|
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.17.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.17.0...@synerise/ds-condition@0.17.1) (2022-05-29)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **condition:** fix test & returnLast method ([ba67918](https://github.com/Synerise/synerise-design/commit/ba67918f739fb74c99ba19d2dff0f20de6c950cf))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [0.17.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.16.0...@synerise/ds-condition@0.17.0) (2022-05-28)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* **condition:** validation condition ([b8d9e62](https://github.com/Synerise/synerise-design/commit/b8d9e627f2d62113abc4716d4049c2e27ad49718))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# [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)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Bug Fixes
|
|
32
|
+
|
|
33
|
+
* **condition:** disabling hover effect on nonactive condition in filter ([228f242](https://github.com/Synerise/synerise-design/commit/228f242e6ce244c73e9da93adb2c4317cd65ec91))
|
|
34
|
+
* **condition:** fixes styles of dragged condition with opened dropdown ([0449e94](https://github.com/Synerise/synerise-design/commit/0449e948dc598974c81e7f857431c519c5fa2666))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Features
|
|
38
|
+
|
|
39
|
+
* **condition:** adds defaultOpenedComponent prop ([6b6721d](https://github.com/Synerise/synerise-design/commit/6b6721dbd12be7e744100d303a5d3d7823467c3b))
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
6
45
|
## [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)
|
|
7
46
|
|
|
8
47
|
**Note:** Version bump only for package @synerise/ds-condition
|
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
|
@@ -53,7 +53,10 @@ var Condition = function Condition(props) {
|
|
|
53
53
|
onChangeFactorValue = props.onChangeFactorValue,
|
|
54
54
|
onUpdateStepName = props.onUpdateStepName,
|
|
55
55
|
getPopupContainerOverride = props.getPopupContainerOverride,
|
|
56
|
-
showSuffix = props.showSuffix
|
|
56
|
+
showSuffix = props.showSuffix,
|
|
57
|
+
hoverDisabled = props.hoverDisabled,
|
|
58
|
+
_props$autoOpenedComp = props.autoOpenedComponent,
|
|
59
|
+
autoOpenedComponent = _props$autoOpenedComp === void 0 ? DEFAULT_FIELD : _props$autoOpenedComp;
|
|
57
60
|
|
|
58
61
|
var _useIntl = useIntl(),
|
|
59
62
|
formatMessage = _useIntl.formatMessage;
|
|
@@ -79,11 +82,23 @@ var Condition = function Condition(props) {
|
|
|
79
82
|
currentStepId = _React$useState2[0],
|
|
80
83
|
setCurrentStepId = _React$useState2[1];
|
|
81
84
|
|
|
82
|
-
var _React$useState3 = React.useState(
|
|
85
|
+
var _React$useState3 = React.useState(autoOpenedComponent),
|
|
83
86
|
currentField = _React$useState3[0],
|
|
84
87
|
setCurrentField = _React$useState3[1];
|
|
85
88
|
|
|
89
|
+
var _React$useState4 = React.useState(''),
|
|
90
|
+
errorId = _React$useState4[0],
|
|
91
|
+
setErrorId = _React$useState4[1];
|
|
92
|
+
|
|
86
93
|
var prevSteps = usePrevious(steps);
|
|
94
|
+
React.useEffect(function () {
|
|
95
|
+
if (autoOpenedComponent && steps.length && steps[0].conditions[0].operator && steps[0].conditions[0].operator.value === undefined) {
|
|
96
|
+
setCurrentStepId(steps[0].id);
|
|
97
|
+
setCurrentConditionId(steps[0].conditions[0].id);
|
|
98
|
+
setCurrentField(autoOpenedComponent);
|
|
99
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
100
|
+
|
|
101
|
+
}, []);
|
|
87
102
|
React.useEffect(function () {
|
|
88
103
|
var newConditionId = prevSteps && steps && steps.reduce(function (id, step) {
|
|
89
104
|
var result = id;
|
|
@@ -201,13 +216,32 @@ var Condition = function Condition(props) {
|
|
|
201
216
|
setCurrentField(SUBJECT);
|
|
202
217
|
}
|
|
203
218
|
}, [addStep]);
|
|
219
|
+
var returnLast = React.useCallback(function (arr) {
|
|
220
|
+
return arr[arr.length - 1];
|
|
221
|
+
}, []);
|
|
222
|
+
var testPrevValueElement = React.useCallback(function () {
|
|
223
|
+
return steps == null ? void 0 : steps.map(function (step) {
|
|
224
|
+
var _returnLast;
|
|
225
|
+
|
|
226
|
+
return !((_returnLast = returnLast(step.conditions)) != null && _returnLast.factor.value) && setErrorId(returnLast(step.conditions).id);
|
|
227
|
+
});
|
|
228
|
+
}, [steps, returnLast]);
|
|
204
229
|
var handleAddCondition = React.useMemo(function () {
|
|
230
|
+
var lastStep = returnLast(steps);
|
|
231
|
+
var lastCondition = returnLast(lastStep.conditions);
|
|
232
|
+
|
|
205
233
|
if (!addCondition) {
|
|
206
234
|
return undefined;
|
|
207
235
|
}
|
|
208
236
|
|
|
209
237
|
return function (stepId) {
|
|
210
|
-
var newConditionId
|
|
238
|
+
var newConditionId;
|
|
239
|
+
|
|
240
|
+
if (addCondition && lastCondition != null && lastCondition.factor.value || (lastStep == null ? void 0 : lastStep.conditions.length) === 0) {
|
|
241
|
+
newConditionId = addCondition(stepId);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
testPrevValueElement();
|
|
211
245
|
|
|
212
246
|
if (newConditionId) {
|
|
213
247
|
setCurrentConditionId(newConditionId);
|
|
@@ -215,7 +249,7 @@ var Condition = function Condition(props) {
|
|
|
215
249
|
setCurrentField(PARAMETER);
|
|
216
250
|
}
|
|
217
251
|
};
|
|
218
|
-
}, [addCondition]);
|
|
252
|
+
}, [addCondition, steps, testPrevValueElement, returnLast]);
|
|
219
253
|
var handleClearActiveCondition = React.useCallback(function () {
|
|
220
254
|
setCurrentConditionId(DEFAULT_CONDITION);
|
|
221
255
|
setCurrentStepId(DEFAULT_STEP);
|
|
@@ -257,7 +291,9 @@ var Condition = function Condition(props) {
|
|
|
257
291
|
setCurrentCondition: setCurrentConditionId,
|
|
258
292
|
setCurrentStep: setCurrentStepId,
|
|
259
293
|
onDeactivate: handleClearActiveCondition,
|
|
260
|
-
showSuffix: showSuffix
|
|
294
|
+
showSuffix: showSuffix,
|
|
295
|
+
hoverDisabled: hoverDisabled || currentStepId !== step.id && currentStepId !== undefined,
|
|
296
|
+
errorId: errorId
|
|
261
297
|
});
|
|
262
298
|
})), addStep && /*#__PURE__*/React.createElement(S.AddStepButton, null, /*#__PURE__*/React.createElement(Button, {
|
|
263
299
|
type: "ghost",
|
|
@@ -266,7 +302,7 @@ var Condition = function Condition(props) {
|
|
|
266
302
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
267
303
|
component: /*#__PURE__*/React.createElement(Add3M, null)
|
|
268
304
|
}), 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]);
|
|
305
|
+
}, [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, errorId]);
|
|
270
306
|
};
|
|
271
307
|
|
|
272
308
|
export default Condition;
|
|
@@ -16,6 +16,7 @@ export declare const DraggedLabel: import("styled-components").StyledComponent<"
|
|
|
16
16
|
export declare const Step: import("styled-components").StyledComponent<"div", any, {
|
|
17
17
|
active: boolean;
|
|
18
18
|
showSuffix: boolean | undefined;
|
|
19
|
+
hoverDisabled?: boolean | undefined;
|
|
19
20
|
}, never>;
|
|
20
21
|
export declare const ConditionWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
21
22
|
fullWidth?: boolean | undefined;
|
package/dist/Condition.style.js
CHANGED
|
@@ -55,12 +55,12 @@ export var DraggedLabel = styled.span.withConfig({
|
|
|
55
55
|
export var Step = styled.div.withConfig({
|
|
56
56
|
displayName: "Conditionstyle__Step",
|
|
57
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) {
|
|
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
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
60
|
}, function (props) {
|
|
61
61
|
return props.active ? props.theme.palette['grey-050'] : 'transparent';
|
|
62
62
|
}, function (props) {
|
|
63
|
-
return props.theme.palette['grey-050'];
|
|
63
|
+
return props.hoverDisabled ? 'transparent' : props.theme.palette['grey-050'];
|
|
64
64
|
}, StepCruds, StepConditionCruds, DragIcon, function (props) {
|
|
65
65
|
return props.theme.palette.white;
|
|
66
66
|
}, StepHeader, StepName, IconWrapper, StepConditions, DraggedLabel, function (props) {
|
|
@@ -51,4 +51,6 @@ export declare type ConditionProps = {
|
|
|
51
51
|
onUpdateStepName?: (stepId: React.ReactText, value: string) => void;
|
|
52
52
|
type?: 'attribute' | 'event';
|
|
53
53
|
showSuffix?: boolean;
|
|
54
|
+
hoverDisabled?: boolean;
|
|
55
|
+
autoOpenedComponent?: 'subject' | 'operator' | 'factor' | 'parameter' | 'context';
|
|
54
56
|
};
|
|
@@ -33,7 +33,8 @@ export var ConditionRow = function ConditionRow(_ref) {
|
|
|
33
33
|
hasPriority = _ref.hasPriority,
|
|
34
34
|
texts = _ref.texts,
|
|
35
35
|
stepType = _ref.stepType,
|
|
36
|
-
onDeactivate = _ref.onDeactivate
|
|
36
|
+
onDeactivate = _ref.onDeactivate,
|
|
37
|
+
error = _ref.error;
|
|
37
38
|
return /*#__PURE__*/React.createElement(S.ConditionRow, {
|
|
38
39
|
stepType: stepType,
|
|
39
40
|
style: hasPriority ? {
|
|
@@ -79,6 +80,7 @@ export var ConditionRow = function ConditionRow(_ref) {
|
|
|
79
80
|
return setStepConditionFactorValue(stepId, conditionId, value);
|
|
80
81
|
},
|
|
81
82
|
factorKey: conditionId,
|
|
83
|
+
error: error,
|
|
82
84
|
opened: hasPriority && stepId === currentStepId && conditionId === currentConditionId && currentField === FACTOR
|
|
83
85
|
})))), removeCondition && conditionsNumber > minConditionLength && /*#__PURE__*/React.createElement(S.RemoveIconWrapper, {
|
|
84
86
|
onClick: function onClick() {
|
|
@@ -4,6 +4,7 @@ import { OperatorsProps } from '@synerise/ds-operators/dist/Operator.types';
|
|
|
4
4
|
import { ConditionProps, ConditionTexts } from '../../Condition.types';
|
|
5
5
|
export declare type ConditionRowProps = {
|
|
6
6
|
index: number;
|
|
7
|
+
error?: boolean;
|
|
7
8
|
hasPriority?: boolean;
|
|
8
9
|
onActivate?: (fieldType: string) => void;
|
|
9
10
|
onDeactivate?: () => void;
|
|
@@ -47,7 +47,9 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
47
47
|
setCurrentCondition = _ref.setCurrentCondition,
|
|
48
48
|
setCurrentStep = _ref.setCurrentStep,
|
|
49
49
|
onDeactivate = _ref.onDeactivate,
|
|
50
|
-
showSuffix = _ref.showSuffix
|
|
50
|
+
showSuffix = _ref.showSuffix,
|
|
51
|
+
hoverDisabled = _ref.hoverDisabled,
|
|
52
|
+
errorId = _ref.errorId;
|
|
51
53
|
|
|
52
54
|
var _useIntl = useIntl(),
|
|
53
55
|
formatMessage = _useIntl.formatMessage;
|
|
@@ -166,9 +168,10 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
166
168
|
setStepConditionFactorValue: setStepConditionFactorValue,
|
|
167
169
|
texts: text,
|
|
168
170
|
stepType: (_step$context2 = step.context) == null ? void 0 : _step$context2.type,
|
|
169
|
-
onDeactivate: onDeactivate
|
|
171
|
+
onDeactivate: onDeactivate,
|
|
172
|
+
error: errorId === condition.id && !condition.factor.value && true
|
|
170
173
|
});
|
|
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]);
|
|
174
|
+
}, [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, errorId]);
|
|
172
175
|
return /*#__PURE__*/React.createElement(S.Step, {
|
|
173
176
|
key: step.id,
|
|
174
177
|
id: "condition-step-" + step.id,
|
|
@@ -178,6 +181,7 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
178
181
|
zIndex: 10001
|
|
179
182
|
} : undefined,
|
|
180
183
|
active: step.id === currentStepId && currentField !== '',
|
|
184
|
+
hoverDisabled: hoverDisabled,
|
|
181
185
|
showSuffix: showSuffix
|
|
182
186
|
}, !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, {
|
|
183
187
|
withoutStepName: updateStepName === undefined
|
|
@@ -7,6 +7,7 @@ import { ConditionStep, ConditionTexts, ConditionProps } from '../Condition.type
|
|
|
7
7
|
export declare type ConditionStepProps = {
|
|
8
8
|
index: number;
|
|
9
9
|
step: ConditionStep;
|
|
10
|
+
errorId?: string;
|
|
10
11
|
hasPriority?: boolean;
|
|
11
12
|
onStepActivate?: (stepid: React.ReactText) => void;
|
|
12
13
|
getPopupContainerOverride?: ConditionProps['getPopupContainerOverride'];
|
|
@@ -33,4 +34,5 @@ export declare type ConditionStepProps = {
|
|
|
33
34
|
setCurrentStep: (stepId: React.ReactText) => void;
|
|
34
35
|
onDeactivate: () => void;
|
|
35
36
|
showSuffix?: boolean;
|
|
37
|
+
hoverDisabled?: boolean;
|
|
36
38
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-condition",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"description": "Condition UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@synerise/ds-context-selector": "^0.12.1",
|
|
37
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.14.0",
|
|
40
40
|
"@synerise/ds-icon": "^0.49.0",
|
|
41
41
|
"@synerise/ds-inline-edit": "^0.6.12",
|
|
42
42
|
"@synerise/ds-operators": "^0.9.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": "1c65dc24717f6aa8df3c0fa61ed4e9f1f42b80d6"
|
|
53
53
|
}
|