@synerise/ds-condition 0.24.12 → 0.24.14
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 +16 -0
- package/dist/Condition.js +35 -8
- package/dist/Condition.style.d.ts +2 -0
- package/dist/Condition.style.js +10 -3
- package/dist/Condition.types.d.ts +6 -0
- package/dist/ConditionStep/AddCondition/AddCondition.d.ts +1 -1
- package/dist/ConditionStep/AddCondition/AddCondition.js +5 -9
- package/dist/ConditionStep/AddCondition/AddCondition.types.d.ts +1 -3
- package/dist/ConditionStep/ConditionRow/ConditionRow.js +1 -1
- package/dist/ConditionStep/ConditionStep.d.ts +1 -1
- package/dist/ConditionStep/ConditionStep.js +69 -18
- package/dist/ConditionStep/ConditionStep.types.d.ts +4 -0
- package/dist/ConditionStep/EmptyCondition/EmptyCondition.d.ts +7 -0
- package/dist/ConditionStep/EmptyCondition/EmptyCondition.js +15 -0
- package/dist/ConditionStep/EmptyCondition/emptyCondition.styles.d.ts +8 -0
- package/dist/ConditionStep/EmptyCondition/emptyCondition.styles.js +10 -0
- package/dist/ConditionStep/EmptyCondition/index.d.ts +1 -0
- package/dist/ConditionStep/EmptyCondition/index.js +1 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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.24.14](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.24.13...@synerise/ds-condition@0.24.14) (2024-10-29)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-condition
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.24.13](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.24.12...@synerise/ds-condition@0.24.13) (2024-10-28)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @synerise/ds-condition
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [0.24.12](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.24.11...@synerise/ds-condition@0.24.12) (2024-10-24)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @synerise/ds-condition
|
package/dist/Condition.js
CHANGED
|
@@ -15,7 +15,7 @@ import { NOOP } from '@synerise/ds-utils';
|
|
|
15
15
|
import usePrevious from '@synerise/ds-utils/dist/usePrevious/usePrevious';
|
|
16
16
|
import { ConditionStep } from './ConditionStep';
|
|
17
17
|
import * as S from './Condition.style';
|
|
18
|
-
import { SORTABLE_CONFIG, DEFAULT_CONDITION, DEFAULT_FIELD, DEFAULT_STEP, OPERATOR, FACTOR, PARAMETER, SUBJECT, DEFAULT_INPUT_PROPS } from './constants';
|
|
18
|
+
import { SORTABLE_CONFIG, DEFAULT_CONDITION, DEFAULT_FIELD, DEFAULT_STEP, OPERATOR, FACTOR, PARAMETER, SUBJECT, DEFAULT_INPUT_PROPS, ACTION_ATTRIBUTE } from './constants';
|
|
19
19
|
|
|
20
20
|
var Condition = function Condition(props) {
|
|
21
21
|
var steps = props.steps,
|
|
@@ -46,7 +46,12 @@ var Condition = function Condition(props) {
|
|
|
46
46
|
inputProps = props.inputProps,
|
|
47
47
|
onDeactivate = props.onDeactivate,
|
|
48
48
|
_props$readOnly = props.readOnly,
|
|
49
|
-
readOnly = _props$readOnly === void 0 ? false : _props$readOnly
|
|
49
|
+
readOnly = _props$readOnly === void 0 ? false : _props$readOnly,
|
|
50
|
+
singleStepCondition = props.singleStepCondition,
|
|
51
|
+
showActionAttribute = props.showActionAttribute,
|
|
52
|
+
onChangeActionAttribute = props.onChangeActionAttribute,
|
|
53
|
+
_props$showEmptyCondi = props.showEmptyConditionPlaceholder,
|
|
54
|
+
showEmptyConditionPlaceholder = _props$showEmptyCondi === void 0 ? false : _props$showEmptyCondi;
|
|
50
55
|
|
|
51
56
|
var _useIntl = useIntl(),
|
|
52
57
|
formatMessage = _useIntl.formatMessage;
|
|
@@ -156,15 +161,33 @@ var Condition = function Condition(props) {
|
|
|
156
161
|
var selectSubject = useCallback(function (value, stepId) {
|
|
157
162
|
clearConditionRow(stepId);
|
|
158
163
|
setCurrentStepId(stepId);
|
|
159
|
-
|
|
164
|
+
|
|
165
|
+
if (showActionAttribute) {
|
|
166
|
+
setCurrentField(ACTION_ATTRIBUTE);
|
|
167
|
+
} else {
|
|
168
|
+
setCurrentField(PARAMETER);
|
|
169
|
+
}
|
|
170
|
+
|
|
160
171
|
onChangeSubject && onChangeSubject(stepId, value);
|
|
161
|
-
}, [clearConditionRow, onChangeSubject]);
|
|
172
|
+
}, [clearConditionRow, onChangeSubject, showActionAttribute]);
|
|
162
173
|
var selectContext = useCallback(function (value, stepId) {
|
|
163
174
|
clearConditionRow(stepId);
|
|
164
175
|
setCurrentStepId(stepId);
|
|
165
|
-
|
|
176
|
+
|
|
177
|
+
if (showActionAttribute) {
|
|
178
|
+
setCurrentField(ACTION_ATTRIBUTE);
|
|
179
|
+
} else {
|
|
180
|
+
setCurrentField(PARAMETER);
|
|
181
|
+
}
|
|
182
|
+
|
|
166
183
|
onChangeContext && onChangeContext(stepId, value);
|
|
167
|
-
}, [clearConditionRow, onChangeContext]);
|
|
184
|
+
}, [clearConditionRow, onChangeContext, showActionAttribute]);
|
|
185
|
+
var selectActionAttribute = useCallback(function (value, stepId) {
|
|
186
|
+
clearConditionRow(stepId);
|
|
187
|
+
setCurrentStepId(stepId);
|
|
188
|
+
setCurrentField(PARAMETER);
|
|
189
|
+
onChangeActionAttribute && onChangeActionAttribute(stepId, value);
|
|
190
|
+
}, [onChangeActionAttribute, clearConditionRow]);
|
|
168
191
|
var selectParameter = useCallback(function (stepId, conditionId, value) {
|
|
169
192
|
if (conditionId && onChangeParameter) {
|
|
170
193
|
autoClearCondition && onChangeOperator && onChangeOperator(stepId, conditionId, undefined);
|
|
@@ -247,6 +270,7 @@ var Condition = function Condition(props) {
|
|
|
247
270
|
selectParameter: selectParameter,
|
|
248
271
|
selectContext: selectContext,
|
|
249
272
|
selectSubject: selectSubject,
|
|
273
|
+
selectActionAttribute: selectActionAttribute,
|
|
250
274
|
updateStepName: onUpdateStepName,
|
|
251
275
|
duplicateStep: duplicateStep,
|
|
252
276
|
removeStep: removeStep,
|
|
@@ -266,7 +290,10 @@ var Condition = function Condition(props) {
|
|
|
266
290
|
showSuffix: showSuffix,
|
|
267
291
|
hoverDisabled: hoverDisabled || currentStepId !== step.id && currentStepId !== undefined,
|
|
268
292
|
inputProps: _objectSpread({}, DEFAULT_INPUT_PROPS, {}, inputProps),
|
|
269
|
-
readOnly: readOnly
|
|
293
|
+
readOnly: readOnly,
|
|
294
|
+
singleStepCondition: singleStepCondition,
|
|
295
|
+
showActionAttribute: showActionAttribute,
|
|
296
|
+
showEmptyConditionPlaceholder: showEmptyConditionPlaceholder
|
|
270
297
|
});
|
|
271
298
|
})), addStep && /*#__PURE__*/React.createElement(S.AddStepButton, null, /*#__PURE__*/React.createElement(Button, {
|
|
272
299
|
type: "ghost",
|
|
@@ -275,7 +302,7 @@ var Condition = function Condition(props) {
|
|
|
275
302
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
276
303
|
component: /*#__PURE__*/React.createElement(Add3M, null)
|
|
277
304
|
}), text.addStep)), !readOnly && renderAddStep && /*#__PURE__*/React.createElement(S.AddStepButton, null, renderAddStep()));
|
|
278
|
-
}, [steps, onChangeOrder, addStep, handleAddStep, text, readOnly, renderAddStep, currentStepId, getPopupContainerOverride, draggableEnabled, selectOperator, selectParameter, selectContext, selectSubject, onUpdateStepName, duplicateStep, removeStep, minConditionsLength, maxConditionsLength, setStepConditionFactorType, setStepConditionFactorValue, currentConditionId, currentField, removeCondition, handleAddCondition, handleClearActiveCondition, showSuffix, hoverDisabled, inputProps]);
|
|
305
|
+
}, [steps, onChangeOrder, addStep, handleAddStep, text, readOnly, renderAddStep, currentStepId, getPopupContainerOverride, draggableEnabled, selectOperator, selectParameter, selectContext, selectSubject, onUpdateStepName, duplicateStep, removeStep, minConditionsLength, maxConditionsLength, setStepConditionFactorType, setStepConditionFactorValue, currentConditionId, currentField, removeCondition, handleAddCondition, handleClearActiveCondition, showSuffix, hoverDisabled, inputProps, singleStepCondition, selectActionAttribute, showActionAttribute, showEmptyConditionPlaceholder]);
|
|
279
306
|
};
|
|
280
307
|
|
|
281
308
|
export default Condition;
|
|
@@ -18,6 +18,7 @@ export declare const Step: import("styled-components").StyledComponent<"div", an
|
|
|
18
18
|
active: boolean;
|
|
19
19
|
showSuffix: boolean | undefined;
|
|
20
20
|
hoverDisabled?: boolean | undefined;
|
|
21
|
+
singleStepCondition?: boolean | undefined;
|
|
21
22
|
}, never>;
|
|
22
23
|
export declare const Subject: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
23
24
|
export declare const RemoveIconWrapper: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
@@ -40,3 +41,4 @@ export declare const ConditionRow: import("styled-components").StyledComponent<"
|
|
|
40
41
|
last?: boolean | undefined;
|
|
41
42
|
}, never>;
|
|
42
43
|
export declare const AddStepButton: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
44
|
+
export declare const ActionAttribute: import("styled-components").StyledComponent<"div", any, {}, never>;
|
package/dist/Condition.style.js
CHANGED
|
@@ -66,10 +66,13 @@ export var DraggedLabel = styled.span.withConfig({
|
|
|
66
66
|
export var Step = styled.div.withConfig({
|
|
67
67
|
displayName: "Conditionstyle__Step",
|
|
68
68
|
componentId: "sc-1lk06p3-13"
|
|
69
|
-
})(["padding:
|
|
69
|
+
})(["padding:", ";position:relative;", " &:first-of-type{&.steps-list-ghost-element{&:after{display:none;}}}background-color:", ";&:hover{", ";", "{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 (_ref) {
|
|
70
|
+
var singleStepCondition = _ref.singleStepCondition;
|
|
71
|
+
return singleStepCondition ? '24px 0' : '12px 0';
|
|
72
|
+
}, function (props) {
|
|
70
73
|
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);
|
|
71
74
|
}, function (props) {
|
|
72
|
-
return props.active ? props.theme.palette['grey-050'] : 'transparent';
|
|
75
|
+
return props.active && !props.singleStepCondition ? props.theme.palette['grey-050'] : 'transparent';
|
|
73
76
|
}, function (props) {
|
|
74
77
|
return !props.hoverDisabled && "background-color: " + props.theme.palette['grey-050'];
|
|
75
78
|
}, StepCruds, StepConditionCruds, DragIcon, function (props) {
|
|
@@ -144,4 +147,8 @@ export var ConditionRow = styled.div.withConfig({
|
|
|
144
147
|
export var AddStepButton = styled.div.withConfig({
|
|
145
148
|
displayName: "Conditionstyle__AddStepButton",
|
|
146
149
|
componentId: "sc-1lk06p3-23"
|
|
147
|
-
})(["margin:12px 24px 0;"]);
|
|
150
|
+
})(["margin:12px 24px 0;"]);
|
|
151
|
+
export var ActionAttribute = styled.div.withConfig({
|
|
152
|
+
displayName: "Conditionstyle__ActionAttribute",
|
|
153
|
+
componentId: "sc-1lk06p3-24"
|
|
154
|
+
})(["margin-left:8px;display:flex;"]);
|
|
@@ -14,6 +14,7 @@ export type ConditionStep = {
|
|
|
14
14
|
id: ReactText;
|
|
15
15
|
subject?: Omit<SubjectProps, 'onSelectItem'>;
|
|
16
16
|
context?: Omit<ContextProps, 'onSelectItem'>;
|
|
17
|
+
actionAttribute?: Omit<FactorsProps, 'onChangeValue' | 'selectedFactorType' | 'defaultFactorType'>;
|
|
17
18
|
stepName?: string;
|
|
18
19
|
conditions: StepConditions[];
|
|
19
20
|
addConditionErrorText?: ReactNode;
|
|
@@ -30,6 +31,7 @@ export type ConditionTexts = {
|
|
|
30
31
|
removeTooltip: string;
|
|
31
32
|
conditionSuffix: string;
|
|
32
33
|
stepNamePrefix: string;
|
|
34
|
+
emptyConditionLabel: string;
|
|
33
35
|
};
|
|
34
36
|
export type ConditionProps = {
|
|
35
37
|
steps: ConditionStep[];
|
|
@@ -50,6 +52,7 @@ export type ConditionProps = {
|
|
|
50
52
|
onChangeFactorValue: (stepId: ReactText, conditionId: ReactText, value: FactorValueType | undefined) => void;
|
|
51
53
|
onChangeFactorType: (stepId: ReactText, conditionId: ReactText, value: FactorType | undefined) => void;
|
|
52
54
|
onUpdateStepName?: (stepId: ReactText, value: string) => void;
|
|
55
|
+
onChangeActionAttribute?: (stepId: ReactText, value: FactorValueType | undefined) => void;
|
|
53
56
|
type?: 'attribute' | 'event';
|
|
54
57
|
showSuffix?: boolean;
|
|
55
58
|
hoverDisabled?: boolean;
|
|
@@ -57,4 +60,7 @@ export type ConditionProps = {
|
|
|
57
60
|
inputProps?: Partial<InputProps>;
|
|
58
61
|
onDeactivate?: (currentStepId: ReactText, currentConditionId: ReactText) => void;
|
|
59
62
|
readOnly?: boolean;
|
|
63
|
+
singleStepCondition?: boolean;
|
|
64
|
+
showActionAttribute?: boolean;
|
|
65
|
+
showEmptyConditionPlaceholder?: boolean;
|
|
60
66
|
} & ConditionStepCrudActions;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import * as T from './AddCondition.types';
|
|
3
|
-
export declare const AddCondition: React.
|
|
3
|
+
export declare const AddCondition: ({ addCondition, stepId, conditionsNumber, texts, isDisabled, errorText, }: T.AddConditionProps) => React.JSX.Element;
|
|
@@ -2,18 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import Button from '@synerise/ds-button';
|
|
3
3
|
import Icon, { Add2M } from '@synerise/ds-icon';
|
|
4
4
|
import * as S from '../../Condition.style';
|
|
5
|
-
// eslint-disable-next-line import/prefer-default-export
|
|
6
5
|
export var AddCondition = function AddCondition(_ref) {
|
|
7
6
|
var addCondition = _ref.addCondition,
|
|
8
7
|
stepId = _ref.stepId,
|
|
9
8
|
conditionsNumber = _ref.conditionsNumber,
|
|
10
9
|
texts = _ref.texts,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
_ref$readOnly = _ref.readOnly,
|
|
14
|
-
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
10
|
+
_ref$isDisabled = _ref.isDisabled,
|
|
11
|
+
isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
|
|
15
12
|
errorText = _ref.errorText;
|
|
16
|
-
var disabled = !(selectedSubject || selectedContext);
|
|
17
13
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(S.AddConditionRow, null, /*#__PURE__*/React.createElement(S.ConditionConnections, {
|
|
18
14
|
last: true,
|
|
19
15
|
first: conditionsNumber === 0
|
|
@@ -21,12 +17,12 @@ export var AddCondition = function AddCondition(_ref) {
|
|
|
21
17
|
icon: /*#__PURE__*/React.createElement(Icon, {
|
|
22
18
|
component: /*#__PURE__*/React.createElement(Add2M, null)
|
|
23
19
|
}),
|
|
24
|
-
error: !
|
|
20
|
+
error: !isDisabled && Boolean(errorText),
|
|
25
21
|
type: "ghost",
|
|
26
22
|
mode: "icon-label",
|
|
27
23
|
onClick: function onClick() {
|
|
28
24
|
addCondition && addCondition(stepId);
|
|
29
25
|
},
|
|
30
|
-
disabled:
|
|
31
|
-
},
|
|
26
|
+
disabled: isDisabled
|
|
27
|
+
}, conditionsNumber > 0 ? texts.addConditionRowButton : texts.addFirstConditionRowButton), !isDisabled && errorText && /*#__PURE__*/React.createElement(S.ErrorWrapper, null, errorText))));
|
|
32
28
|
};
|
|
@@ -5,8 +5,6 @@ export type AddConditionProps = {
|
|
|
5
5
|
stepId: React.ReactText;
|
|
6
6
|
conditionsNumber: number;
|
|
7
7
|
texts: Partial<ConditionTexts>;
|
|
8
|
-
|
|
9
|
-
selectedContext: boolean;
|
|
10
|
-
readOnly?: boolean;
|
|
8
|
+
isDisabled?: boolean;
|
|
11
9
|
errorText?: React.ReactNode | string;
|
|
12
10
|
};
|
|
@@ -97,7 +97,7 @@ export var ConditionRow = function ConditionRow(_ref) {
|
|
|
97
97
|
"data-testid": "condition-row",
|
|
98
98
|
onlyChild: maxConditionLength === 1,
|
|
99
99
|
style: hasPriority ? {
|
|
100
|
-
zIndex:
|
|
100
|
+
zIndex: 1001
|
|
101
101
|
} : undefined,
|
|
102
102
|
key: "condition-row-" + conditionId,
|
|
103
103
|
index: index,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import * as T from './ConditionStep.types';
|
|
3
|
-
export declare const ConditionStep: ({ step, texts, index, addCondition, removeCondition, updateStepName, removeStep, duplicateStep, minConditionsLength, maxConditionsLength, draggableEnabled, selectSubject, selectContext, selectOperator, selectParameter, setStepConditionFactorType, setStepConditionFactorValue, getPopupContainerOverride, hasPriority, currentStepId, currentConditionId, currentField, setCurrentField, setCurrentCondition, setCurrentStep, onDeactivate, showSuffix, inputProps, readOnly, }: T.ConditionStepProps) => React.JSX.Element;
|
|
3
|
+
export declare const ConditionStep: ({ step, texts, index, addCondition, removeCondition, updateStepName, removeStep, duplicateStep, minConditionsLength, maxConditionsLength, draggableEnabled, selectSubject, selectContext, selectActionAttribute, selectOperator, selectParameter, setStepConditionFactorType, setStepConditionFactorValue, getPopupContainerOverride, hasPriority, currentStepId, currentConditionId, currentField, setCurrentField, setCurrentCondition, setCurrentStep, onDeactivate, showSuffix, inputProps, readOnly, singleStepCondition, showActionAttribute, showEmptyConditionPlaceholder, }: T.ConditionStepProps) => React.JSX.Element;
|
|
@@ -11,13 +11,15 @@ import Subject from '@synerise/ds-subject';
|
|
|
11
11
|
import ContextSelector from '@synerise/ds-context-selector';
|
|
12
12
|
import { useIntl } from 'react-intl';
|
|
13
13
|
import { DragHandleM } from '@synerise/ds-icon';
|
|
14
|
+
import Factors from '@synerise/ds-factors';
|
|
14
15
|
import * as S from '../Condition.style';
|
|
15
16
|
import { StepHeader } from './StepHeader';
|
|
16
17
|
import { AddCondition } from './AddCondition';
|
|
17
18
|
import { ConditionRow } from './ConditionRow';
|
|
18
|
-
import { SUBJECT } from '../constants';
|
|
19
|
+
import { ACTION_ATTRIBUTE, SUBJECT } from '../constants';
|
|
20
|
+
import { EmptyCondition } from './EmptyCondition';
|
|
19
21
|
export var ConditionStep = function ConditionStep(_ref) {
|
|
20
|
-
var _step$
|
|
22
|
+
var _step$actionAttribute2, _step$subject3, _step$context4, _step$actionAttribute4, _step$context6, _step$subject4, _step$context7, _step$actionAttribute5, _step$actionAttribute6;
|
|
21
23
|
|
|
22
24
|
var step = _ref.step,
|
|
23
25
|
texts = _ref.texts,
|
|
@@ -33,6 +35,7 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
33
35
|
draggableEnabled = _ref.draggableEnabled,
|
|
34
36
|
selectSubject = _ref.selectSubject,
|
|
35
37
|
selectContext = _ref.selectContext,
|
|
38
|
+
selectActionAttribute = _ref.selectActionAttribute,
|
|
36
39
|
selectOperator = _ref.selectOperator,
|
|
37
40
|
selectParameter = _ref.selectParameter,
|
|
38
41
|
setStepConditionFactorType = _ref.setStepConditionFactorType,
|
|
@@ -49,7 +52,12 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
49
52
|
showSuffix = _ref.showSuffix,
|
|
50
53
|
inputProps = _ref.inputProps,
|
|
51
54
|
_ref$readOnly = _ref.readOnly,
|
|
52
|
-
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly
|
|
55
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
56
|
+
_ref$singleStepCondit = _ref.singleStepCondition,
|
|
57
|
+
singleStepCondition = _ref$singleStepCondit === void 0 ? false : _ref$singleStepCondit,
|
|
58
|
+
showActionAttribute = _ref.showActionAttribute,
|
|
59
|
+
_ref$showEmptyConditi = _ref.showEmptyConditionPlaceholder,
|
|
60
|
+
showEmptyConditionPlaceholder = _ref$showEmptyConditi === void 0 ? false : _ref$showEmptyConditi;
|
|
53
61
|
|
|
54
62
|
var _useIntl = useIntl(),
|
|
55
63
|
formatMessage = _useIntl.formatMessage;
|
|
@@ -99,15 +107,17 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
99
107
|
}, texts);
|
|
100
108
|
}, [texts, formatMessage]);
|
|
101
109
|
var withCruds = !readOnly && (duplicateStep || removeStep);
|
|
102
|
-
|
|
110
|
+
|
|
111
|
+
var _onActivate = useCallback(function () {
|
|
103
112
|
return setCurrentStep ? function () {
|
|
104
113
|
return setCurrentStep(step.id);
|
|
105
114
|
} : undefined;
|
|
106
115
|
}, [step.id, setCurrentStep]);
|
|
116
|
+
|
|
107
117
|
var onAddCondition = useCallback(function (stepId) {
|
|
108
118
|
addCondition && addCondition(stepId);
|
|
109
|
-
|
|
110
|
-
}, [addCondition,
|
|
119
|
+
_onActivate && _onActivate();
|
|
120
|
+
}, [addCondition, _onActivate]);
|
|
111
121
|
var stepHeader = useMemo(function () {
|
|
112
122
|
return /*#__PURE__*/React.createElement(StepHeader, {
|
|
113
123
|
index: index,
|
|
@@ -122,7 +132,7 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
122
132
|
});
|
|
123
133
|
}, [draggableEnabled, duplicateStep, index, removeStep, step.id, step.stepName, text, updateStepName, readOnly]);
|
|
124
134
|
var addConditionButton = useMemo(function () {
|
|
125
|
-
var _step$subject, _step$context;
|
|
135
|
+
var _step$subject, _step$context, _step$actionAttribute;
|
|
126
136
|
|
|
127
137
|
return !readOnly && addCondition && (maxConditionsLength === undefined || step.conditions.length < maxConditionsLength) && /*#__PURE__*/React.createElement(AddCondition, {
|
|
128
138
|
errorText: step.addConditionErrorText,
|
|
@@ -130,16 +140,15 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
130
140
|
stepId: step.id,
|
|
131
141
|
addCondition: onAddCondition,
|
|
132
142
|
conditionsNumber: step.conditions.length,
|
|
133
|
-
|
|
134
|
-
selectedContext: Boolean((_step$context = step.context) == null ? void 0 : _step$context.selectedItem)
|
|
143
|
+
isDisabled: !((_step$subject = step.subject) != null && _step$subject.selectedItem) && !((_step$context = step.context) != null && _step$context.selectedItem) || showActionAttribute && !((_step$actionAttribute = step.actionAttribute) != null && _step$actionAttribute.value)
|
|
135
144
|
});
|
|
136
|
-
}, [addCondition, onAddCondition, maxConditionsLength, step.conditions.length, step.context, step.id, step.subject, text, readOnly, step.addConditionErrorText]);
|
|
145
|
+
}, [addCondition, onAddCondition, maxConditionsLength, step.conditions.length, step.context, step.id, step.subject, text, readOnly, step.addConditionErrorText, showActionAttribute, (_step$actionAttribute2 = step.actionAttribute) == null ? void 0 : _step$actionAttribute2.value]);
|
|
137
146
|
var renderConditionRow = useCallback(function (condition, conditionIndex) {
|
|
138
147
|
var _step$context2;
|
|
139
148
|
|
|
140
149
|
var handleActivation = function handleActivation(conditionId) {
|
|
141
150
|
return function (fieldType) {
|
|
142
|
-
|
|
151
|
+
_onActivate && _onActivate();
|
|
143
152
|
setCurrentField && setCurrentField(fieldType);
|
|
144
153
|
setCurrentCondition && setCurrentCondition(conditionId);
|
|
145
154
|
setCurrentStep && setCurrentStep(step.id);
|
|
@@ -177,19 +186,30 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
177
186
|
onDeactivate: onDeactivate,
|
|
178
187
|
readOnly: readOnly
|
|
179
188
|
});
|
|
180
|
-
}, [step.id, step.conditions.length, step.context, hasPriority, currentConditionId, addCondition, removeCondition, minConditionsLength, maxConditionsLength, currentStepId, currentField, selectParameter, selectOperator, getPopupContainerOverride, setStepConditionFactorType, setStepConditionFactorValue, text, onDeactivate,
|
|
189
|
+
}, [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, inputProps, readOnly]);
|
|
190
|
+
var hasSelectedSubjectOrContext = useMemo(function () {
|
|
191
|
+
var _step$subject2, _step$context3;
|
|
192
|
+
|
|
193
|
+
return ((_step$subject2 = step.subject) == null ? void 0 : _step$subject2.selectedItem) || ((_step$context3 = step.context) == null ? void 0 : _step$context3.selectedItem);
|
|
194
|
+
}, [(_step$subject3 = step.subject) == null ? void 0 : _step$subject3.selectedItem, (_step$context4 = step.context) == null ? void 0 : _step$context4.selectedItem]);
|
|
195
|
+
var contextOrActionErrorText = useMemo(function () {
|
|
196
|
+
var _step$context5, _step$actionAttribute3;
|
|
197
|
+
|
|
198
|
+
return ((_step$context5 = step.context) == null ? void 0 : _step$context5.errorText) || showActionAttribute && ((_step$actionAttribute3 = step.actionAttribute) == null ? void 0 : _step$actionAttribute3.errorText);
|
|
199
|
+
}, [showActionAttribute, (_step$actionAttribute4 = step.actionAttribute) == null ? void 0 : _step$actionAttribute4.errorText, (_step$context6 = step.context) == null ? void 0 : _step$context6.errorText]);
|
|
181
200
|
return /*#__PURE__*/React.createElement(S.Step, {
|
|
182
201
|
key: step.id,
|
|
183
202
|
id: "condition-step-" + step.id,
|
|
184
203
|
"data-dropLabel": text.dropLabel,
|
|
185
204
|
"data-conditionSuffix": text.conditionSuffix,
|
|
186
205
|
style: hasPriority ? {
|
|
187
|
-
zIndex:
|
|
206
|
+
zIndex: 1001
|
|
188
207
|
} : undefined,
|
|
189
208
|
active: step.id === currentStepId && currentField !== '',
|
|
190
|
-
hoverDisabled: Boolean(currentStepId),
|
|
191
|
-
showSuffix: showSuffix
|
|
192
|
-
|
|
209
|
+
hoverDisabled: Boolean(currentStepId) || singleStepCondition,
|
|
210
|
+
showSuffix: showSuffix,
|
|
211
|
+
singleStepCondition: singleStepCondition
|
|
212
|
+
}, !updateStepName && /*#__PURE__*/React.createElement(S.DraggedLabel, null, ((_step$subject4 = step.subject) == null || (_step$subject4 = _step$subject4.selectedItem) == null ? void 0 : _step$subject4.name) || ((_step$context7 = step.context) == null || (_step$context7 = _step$context7.selectedItem) == null ? void 0 : _step$context7.name)), updateStepName && stepHeader, /*#__PURE__*/React.createElement(S.StepConditions, {
|
|
193
213
|
withCruds: Boolean(!updateStepName && withCruds)
|
|
194
214
|
}, draggableEnabled && !updateStepName && /*#__PURE__*/React.createElement(S.DragIcon, {
|
|
195
215
|
className: "step-drag-handler",
|
|
@@ -198,21 +218,47 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
198
218
|
"data-testid": "condition-subject-or-context"
|
|
199
219
|
}, step.subject && /*#__PURE__*/React.createElement(Subject, _extends({}, step.subject, {
|
|
200
220
|
getPopupContainerOverride: getPopupContainerOverride,
|
|
201
|
-
onActivate:
|
|
221
|
+
onActivate: _onActivate,
|
|
202
222
|
onDeactivate: onDeactivate,
|
|
203
223
|
opened: step.id === currentStepId && currentField === SUBJECT,
|
|
204
224
|
onSelectItem: function onSelectItem(value) {
|
|
205
225
|
return selectSubject(value, step.id);
|
|
206
226
|
}
|
|
207
227
|
})), step.context && /*#__PURE__*/React.createElement(ContextSelector, _extends({}, step.context, {
|
|
228
|
+
errorText: undefined,
|
|
208
229
|
getPopupContainerOverride: getPopupContainerOverride,
|
|
209
|
-
onActivate:
|
|
230
|
+
onActivate: _onActivate,
|
|
210
231
|
onDeactivate: onDeactivate,
|
|
211
232
|
opened: step.id === currentStepId && currentField === SUBJECT,
|
|
212
233
|
onSelectItem: function onSelectItem(value) {
|
|
213
234
|
return selectContext(value, step.id);
|
|
214
235
|
},
|
|
215
236
|
readOnly: step.context.readOnly || readOnly
|
|
237
|
+
})), contextOrActionErrorText && /*#__PURE__*/React.createElement(S.ErrorWrapper, null, contextOrActionErrorText)), hasSelectedSubjectOrContext || !showEmptyConditionPlaceholder ? /*#__PURE__*/React.createElement(React.Fragment, null, showActionAttribute && /*#__PURE__*/React.createElement(S.ActionAttribute, {
|
|
238
|
+
style: {
|
|
239
|
+
zIndex: step.id === currentStepId && currentField === ACTION_ATTRIBUTE ? 10002 : 0
|
|
240
|
+
}
|
|
241
|
+
}, /*#__PURE__*/React.createElement(Factors, _extends({}, step.actionAttribute, {
|
|
242
|
+
errorText: undefined,
|
|
243
|
+
value: (_step$actionAttribute5 = step.actionAttribute) == null ? void 0 : _step$actionAttribute5.value,
|
|
244
|
+
withoutTypeSelector: true,
|
|
245
|
+
selectedFactorType: "parameter",
|
|
246
|
+
defaultFactorType: "parameter",
|
|
247
|
+
inputProps: inputProps,
|
|
248
|
+
getPopupContainerOverride: getPopupContainerOverride,
|
|
249
|
+
onActivate: function onActivate() {
|
|
250
|
+
setCurrentCondition('');
|
|
251
|
+
_onActivate && _onActivate();
|
|
252
|
+
setCurrentField && setCurrentField(ACTION_ATTRIBUTE);
|
|
253
|
+
setCurrentStep && setCurrentStep(step.id);
|
|
254
|
+
},
|
|
255
|
+
onDeactivate: onDeactivate,
|
|
256
|
+
onChangeValue: function onChangeValue(value) {
|
|
257
|
+
return selectActionAttribute(value, step.id);
|
|
258
|
+
},
|
|
259
|
+
opened: step.id === currentStepId && currentField === ACTION_ATTRIBUTE,
|
|
260
|
+
readOnly: readOnly,
|
|
261
|
+
error: Boolean((_step$actionAttribute6 = step.actionAttribute) == null ? void 0 : _step$actionAttribute6.errorText)
|
|
216
262
|
}))), /*#__PURE__*/React.createElement(S.ConditionRows, null, step.conditions.length > 0 && step.conditions.map(renderConditionRow), addConditionButton), !updateStepName && withCruds && /*#__PURE__*/React.createElement(S.StepConditionCruds, {
|
|
217
263
|
onDuplicate: duplicateStep ? function () {
|
|
218
264
|
return duplicateStep(step.id);
|
|
@@ -222,5 +268,10 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
222
268
|
} : undefined,
|
|
223
269
|
duplicateTooltip: text.duplicateTooltip,
|
|
224
270
|
deleteTooltip: text.removeTooltip
|
|
271
|
+
})) : /*#__PURE__*/React.createElement(EmptyCondition, {
|
|
272
|
+
label: (texts == null ? void 0 : texts.emptyConditionLabel) || formatMessage({
|
|
273
|
+
id: 'DS.CONDITION.EMPTY_CONDITION_LABEL',
|
|
274
|
+
defaultMessage: 'Choose event first'
|
|
275
|
+
})
|
|
225
276
|
})));
|
|
226
277
|
};
|
|
@@ -19,6 +19,7 @@ export type ConditionStepProps = {
|
|
|
19
19
|
draggableEnabled?: boolean;
|
|
20
20
|
selectSubject: (value: SubjectItem, stepId: ReactText) => void;
|
|
21
21
|
selectContext: (value: ContextItem | ContextGroup | undefined, stepId: ReactText) => void;
|
|
22
|
+
selectActionAttribute: (value: FactorValueType | undefined, stepId: ReactText) => void;
|
|
22
23
|
selectParameter: (stepId: ReactText, condition: ReactText, value: FactorValueType | undefined) => void;
|
|
23
24
|
selectOperator: (stepId: ReactText, condition: ReactText, value: OperatorsItem | OperatorsGroup | undefined) => void;
|
|
24
25
|
setStepConditionFactorType: (stepId: ReactText, condition: ReactText, factorType: FactorType | undefined) => void;
|
|
@@ -34,6 +35,9 @@ export type ConditionStepProps = {
|
|
|
34
35
|
hoverDisabled?: boolean;
|
|
35
36
|
inputProps?: Partial<InputProps>;
|
|
36
37
|
readOnly?: boolean;
|
|
38
|
+
singleStepCondition?: boolean;
|
|
39
|
+
showActionAttribute?: boolean;
|
|
40
|
+
showEmptyConditionPlaceholder?: boolean;
|
|
37
41
|
} & ConditionStepCrudActions;
|
|
38
42
|
export type ConditionStepCrudActions = {
|
|
39
43
|
removeStep?: (stepId: ReactText) => void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Icon, { ClickM } from '@synerise/ds-icon';
|
|
3
|
+
import { theme } from '@synerise/ds-core';
|
|
4
|
+
import * as S from './emptyCondition.styles';
|
|
5
|
+
export var EmptyCondition = function EmptyCondition(_ref) {
|
|
6
|
+
var _ref$icon = _ref.icon,
|
|
7
|
+
icon = _ref$icon === void 0 ? /*#__PURE__*/React.createElement(ClickM, null) : _ref$icon,
|
|
8
|
+
label = _ref.label;
|
|
9
|
+
return /*#__PURE__*/React.createElement(S.EmptyConditionWrapper, null, /*#__PURE__*/React.createElement(Icon, {
|
|
10
|
+
component: icon,
|
|
11
|
+
color: theme.palette['grey-500']
|
|
12
|
+
}), /*#__PURE__*/React.createElement(S.LabelWrapper, {
|
|
13
|
+
size: "small"
|
|
14
|
+
}, label));
|
|
15
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const LabelWrapper: import("styled-components").StyledComponent<({ size, className, children, ellipsis }: {
|
|
3
|
+
size?: import("@synerise/ds-typography").TextSize | undefined;
|
|
4
|
+
ellipsis?: import("@synerise/ds-typography/dist/Ellipsis").EllipsisProps | undefined;
|
|
5
|
+
children?: import("react").ReactNode;
|
|
6
|
+
className?: string | undefined;
|
|
7
|
+
}) => import("react").JSX.Element, any, {}, never>;
|
|
8
|
+
export declare const EmptyConditionWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { Text } from '@synerise/ds-typography';
|
|
3
|
+
export var LabelWrapper = styled(Text).withConfig({
|
|
4
|
+
displayName: "emptyConditionstyles__LabelWrapper",
|
|
5
|
+
componentId: "sc-150ylnq-0"
|
|
6
|
+
})(["margin-left:8px;"]);
|
|
7
|
+
export var EmptyConditionWrapper = styled.div.withConfig({
|
|
8
|
+
displayName: "emptyConditionstyles__EmptyConditionWrapper",
|
|
9
|
+
componentId: "sc-150ylnq-1"
|
|
10
|
+
})(["display:flex;flex-direction:row;align-items:center;justify-content:flex-start;margin-left:16px;height:32px;"]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './EmptyCondition';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './EmptyCondition';
|
package/dist/constants.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const OPERATOR = "operator";
|
|
|
5
5
|
export declare const PARAMETER = "parameter";
|
|
6
6
|
export declare const FACTOR = "factor";
|
|
7
7
|
export declare const SUBJECT = "subject";
|
|
8
|
+
export declare const ACTION_ATTRIBUTE = "actionAttribute";
|
|
8
9
|
export declare const SORTABLE_CONFIG: {
|
|
9
10
|
ghostClass: string;
|
|
10
11
|
className: string;
|
package/dist/constants.js
CHANGED
|
@@ -5,6 +5,7 @@ export var OPERATOR = 'operator';
|
|
|
5
5
|
export var PARAMETER = 'parameter';
|
|
6
6
|
export var FACTOR = 'factor';
|
|
7
7
|
export var SUBJECT = 'subject';
|
|
8
|
+
export var ACTION_ATTRIBUTE = 'actionAttribute';
|
|
8
9
|
export var SORTABLE_CONFIG = {
|
|
9
10
|
ghostClass: 'steps-list-ghost-element',
|
|
10
11
|
className: 'steps-list',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-condition",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.14",
|
|
4
4
|
"description": "Condition UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -34,17 +34,17 @@
|
|
|
34
34
|
],
|
|
35
35
|
"types": "dist/index.d.ts",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@synerise/ds-button": "^0.21.
|
|
38
|
-
"@synerise/ds-context-selector": "^0.25.
|
|
39
|
-
"@synerise/ds-cruds": "^0.5.
|
|
40
|
-
"@synerise/ds-factors": "^0.26.
|
|
41
|
-
"@synerise/ds-icon": "^0.66.
|
|
42
|
-
"@synerise/ds-inline-edit": "^0.8.
|
|
43
|
-
"@synerise/ds-input": "^0.24.
|
|
44
|
-
"@synerise/ds-operators": "^0.13.
|
|
45
|
-
"@synerise/ds-subject": "^0.10.
|
|
46
|
-
"@synerise/ds-tooltip": "^0.14.
|
|
47
|
-
"@synerise/ds-utils": "^0.30.
|
|
37
|
+
"@synerise/ds-button": "^0.21.16",
|
|
38
|
+
"@synerise/ds-context-selector": "^0.25.12",
|
|
39
|
+
"@synerise/ds-cruds": "^0.5.26",
|
|
40
|
+
"@synerise/ds-factors": "^0.26.5",
|
|
41
|
+
"@synerise/ds-icon": "^0.66.2",
|
|
42
|
+
"@synerise/ds-inline-edit": "^0.8.17",
|
|
43
|
+
"@synerise/ds-input": "^0.24.11",
|
|
44
|
+
"@synerise/ds-operators": "^0.13.7",
|
|
45
|
+
"@synerise/ds-subject": "^0.10.21",
|
|
46
|
+
"@synerise/ds-tooltip": "^0.14.46",
|
|
47
|
+
"@synerise/ds-utils": "^0.30.2",
|
|
48
48
|
"lodash": "^4.17.19",
|
|
49
49
|
"react-intl": "3.12.0",
|
|
50
50
|
"react-sortablejs": "^6.0.0",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"react": ">=16.9.0 <= 17.0.2",
|
|
56
56
|
"styled-components": "5.0.1"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "c9eddd944cd2f08cb02db807652ba7fb2b536a1c"
|
|
59
59
|
}
|