@synerise/ds-condition 1.2.2 → 1.3.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 +19 -0
- package/dist/Condition.d.ts +2 -2
- package/dist/Condition.js +103 -88
- package/dist/Condition.style.d.ts +8 -1
- package/dist/Condition.style.js +35 -24
- package/dist/ConditionStep/ConditionStep.d.ts +1 -1
- package/dist/ConditionStep/ConditionStep.js +41 -70
- package/dist/ConditionStep/ConditionStep.types.d.ts +2 -0
- package/dist/ConditionStep/StepHeader/StepHeader.d.ts +1 -1
- package/dist/ConditionStep/StepHeader/StepHeader.js +11 -5
- package/dist/ConditionStep/StepHeader/StepHeader.types.d.ts +3 -2
- package/dist/ConditionStep/StepName/StepName.d.ts +9 -0
- package/dist/ConditionStep/StepName/StepName.js +10 -0
- package/dist/constants.d.ts +0 -8
- package/dist/constants.js +0 -8
- package/dist/hooks/useTranslations.d.ts +2 -0
- package/dist/hooks/useTranslations.js +60 -0
- package/package.json +16 -16
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
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
|
+
## [1.3.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@1.3.0...@synerise/ds-condition@1.3.1) (2025-06-26)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-condition
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [1.3.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@1.2.2...@synerise/ds-condition@1.3.0) (2025-06-24)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **condition:** sortable lib ([8cbc3f5](https://github.com/Synerise/synerise-design/commit/8cbc3f5956ce9138f1a6b0a5eb0e7cd85bb7f4e7))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
## [1.2.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@1.2.1...@synerise/ds-condition@1.2.2) (2025-06-12)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package @synerise/ds-condition
|
package/dist/Condition.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
declare const Condition: (props:
|
|
2
|
+
import type { ConditionProps } from './Condition.types';
|
|
3
|
+
declare const Condition: (props: ConditionProps) => React.JSX.Element;
|
|
4
4
|
export default Condition;
|
package/dist/Condition.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
2
|
import React, { useEffect, useState, useCallback, useMemo } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import Icon, { Add3M } from '@synerise/ds-icon';
|
|
3
|
+
import { SortableContainer, DragOverlay } from '@synerise/ds-sortable';
|
|
4
|
+
import Icon, { Add3M, DragHandleM } from '@synerise/ds-icon';
|
|
6
5
|
import Button from '@synerise/ds-button';
|
|
7
|
-
import {
|
|
6
|
+
import { usePrevious } from '@synerise/ds-utils';
|
|
8
7
|
import { ConditionStep } from './ConditionStep';
|
|
9
8
|
import * as S from './Condition.style';
|
|
10
|
-
import {
|
|
9
|
+
import { DEFAULT_CONDITION, DEFAULT_FIELD, DEFAULT_STEP, OPERATOR, FACTOR, PARAMETER, SUBJECT, DEFAULT_INPUT_PROPS, ACTION_ATTRIBUTE } from './constants';
|
|
10
|
+
import { StepName } from './ConditionStep/StepName/StepName';
|
|
11
|
+
import { useTranslations } from './hooks/useTranslations';
|
|
11
12
|
var Condition = function Condition(props) {
|
|
13
|
+
var _draggedStep$context;
|
|
12
14
|
var steps = props.steps,
|
|
13
15
|
addCondition = props.addCondition,
|
|
14
16
|
removeCondition = props.removeCondition,
|
|
@@ -47,33 +49,19 @@ var Condition = function Condition(props) {
|
|
|
47
49
|
actionAttributeParameterSelectorComponent = props.actionAttributeParameterSelectorComponent,
|
|
48
50
|
_props$showEmptyCondi = props.showEmptyConditionPlaceholder,
|
|
49
51
|
showEmptyConditionPlaceholder = _props$showEmptyCondi === void 0 ? false : _props$showEmptyCondi;
|
|
50
|
-
var
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
id: 'DS.CONDITION.STEP_NAME-PREFIX',
|
|
64
|
-
defaultMessage: 'Step'
|
|
65
|
-
})
|
|
66
|
-
}, texts);
|
|
67
|
-
}, [texts, formatMessage]);
|
|
68
|
-
var _useState = useState(DEFAULT_CONDITION),
|
|
69
|
-
currentConditionId = _useState[0],
|
|
70
|
-
setCurrentConditionId = _useState[1];
|
|
71
|
-
var _useState2 = useState(DEFAULT_STEP),
|
|
72
|
-
currentStepId = _useState2[0],
|
|
73
|
-
setCurrentStepId = _useState2[1];
|
|
74
|
-
var _useState3 = useState(autoOpenedComponent),
|
|
75
|
-
currentField = _useState3[0],
|
|
76
|
-
setCurrentField = _useState3[1];
|
|
52
|
+
var allTexts = useTranslations(texts);
|
|
53
|
+
var _useState = useState(),
|
|
54
|
+
draggedStep = _useState[0],
|
|
55
|
+
setDraggedStep = _useState[1];
|
|
56
|
+
var _useState2 = useState(DEFAULT_CONDITION),
|
|
57
|
+
currentConditionId = _useState2[0],
|
|
58
|
+
setCurrentConditionId = _useState2[1];
|
|
59
|
+
var _useState3 = useState(DEFAULT_STEP),
|
|
60
|
+
currentStepId = _useState3[0],
|
|
61
|
+
setCurrentStepId = _useState3[1];
|
|
62
|
+
var _useState4 = useState(autoOpenedComponent),
|
|
63
|
+
currentField = _useState4[0],
|
|
64
|
+
setCurrentField = _useState4[1];
|
|
77
65
|
var prevSteps = usePrevious(steps);
|
|
78
66
|
useEffect(function () {
|
|
79
67
|
if (autoOpenedComponent && steps.length && steps[0].conditions[0].operator && steps[0].conditions[0].operator.value === undefined) {
|
|
@@ -224,62 +212,89 @@ var Condition = function Condition(props) {
|
|
|
224
212
|
setCurrentStepId(DEFAULT_STEP);
|
|
225
213
|
setCurrentField(DEFAULT_FIELD);
|
|
226
214
|
}, [currentConditionId, currentStepId, onDeactivate]);
|
|
227
|
-
return
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
step: step,
|
|
238
|
-
texts: text,
|
|
239
|
-
index: index,
|
|
240
|
-
contextSelectorComponent: contextSelectorComponent,
|
|
241
|
-
parameterSelectorComponent: parameterSelectorComponent,
|
|
242
|
-
factorParameterSelectorComponent: factorParameterSelectorComponent,
|
|
243
|
-
actionAttributeParameterSelectorComponent: actionAttributeParameterSelectorComponent,
|
|
244
|
-
hasPriority: step.id === currentStepId,
|
|
245
|
-
getPopupContainerOverride: getPopupContainerOverride,
|
|
246
|
-
draggableEnabled: draggableEnabled,
|
|
247
|
-
selectOperator: selectOperator,
|
|
248
|
-
selectParameter: selectParameter,
|
|
249
|
-
selectContext: selectContext,
|
|
250
|
-
selectSubject: selectSubject,
|
|
251
|
-
selectActionAttribute: selectActionAttribute,
|
|
252
|
-
updateStepName: onUpdateStepName,
|
|
253
|
-
duplicateStep: duplicateStep,
|
|
254
|
-
removeStep: removeStep,
|
|
255
|
-
minConditionsLength: minConditionsLength,
|
|
256
|
-
maxConditionsLength: maxConditionsLength,
|
|
257
|
-
setStepConditionFactorType: setStepConditionFactorType,
|
|
258
|
-
setStepConditionFactorValue: setStepConditionFactorValue,
|
|
259
|
-
currentConditionId: currentConditionId,
|
|
260
|
-
currentStepId: currentStepId,
|
|
261
|
-
currentField: currentField,
|
|
262
|
-
removeCondition: removeCondition,
|
|
263
|
-
addCondition: handleAddCondition,
|
|
264
|
-
setCurrentField: setCurrentField,
|
|
265
|
-
setCurrentCondition: setCurrentConditionId,
|
|
266
|
-
setCurrentStep: setCurrentStepId,
|
|
267
|
-
onDeactivate: handleClearActiveCondition,
|
|
268
|
-
showSuffix: showSuffix,
|
|
269
|
-
hoverDisabled: hoverDisabled || currentStepId !== step.id && currentStepId !== undefined,
|
|
270
|
-
inputProps: _extends({}, DEFAULT_INPUT_PROPS, inputProps),
|
|
271
|
-
readOnly: readOnly,
|
|
272
|
-
singleStepCondition: singleStepCondition,
|
|
273
|
-
showActionAttribute: showActionAttribute,
|
|
274
|
-
showEmptyConditionPlaceholder: showEmptyConditionPlaceholder
|
|
215
|
+
return /*#__PURE__*/React.createElement(S.Condition, {
|
|
216
|
+
className: "ds-conditions",
|
|
217
|
+
"data-popup-container": true
|
|
218
|
+
}, /*#__PURE__*/React.createElement(SortableContainer, {
|
|
219
|
+
items: steps,
|
|
220
|
+
axis: "y",
|
|
221
|
+
onDragStart: function onDragStart(_ref) {
|
|
222
|
+
var active = _ref.active;
|
|
223
|
+
var stepIndex = steps.findIndex(function (item) {
|
|
224
|
+
return item.id === active.id;
|
|
275
225
|
});
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}
|
|
283
|
-
|
|
226
|
+
setDraggedStep(_extends({}, steps[stepIndex], {
|
|
227
|
+
index: stepIndex
|
|
228
|
+
}));
|
|
229
|
+
},
|
|
230
|
+
onDragEnd: function onDragEnd() {
|
|
231
|
+
setDraggedStep(undefined);
|
|
232
|
+
},
|
|
233
|
+
onDragCancel: function onDragCancel() {
|
|
234
|
+
return setDraggedStep(undefined);
|
|
235
|
+
},
|
|
236
|
+
onOrderChange: onChangeOrder
|
|
237
|
+
}, steps.map(function (step, index) {
|
|
238
|
+
return /*#__PURE__*/React.createElement(ConditionStep, {
|
|
239
|
+
key: "step-id-" + step.id,
|
|
240
|
+
step: step,
|
|
241
|
+
isDragged: (draggedStep == null ? void 0 : draggedStep.id) === step.id,
|
|
242
|
+
isLast: index === steps.length - 1,
|
|
243
|
+
texts: allTexts,
|
|
244
|
+
index: index,
|
|
245
|
+
contextSelectorComponent: contextSelectorComponent,
|
|
246
|
+
parameterSelectorComponent: parameterSelectorComponent,
|
|
247
|
+
factorParameterSelectorComponent: factorParameterSelectorComponent,
|
|
248
|
+
actionAttributeParameterSelectorComponent: actionAttributeParameterSelectorComponent,
|
|
249
|
+
hasPriority: step.id === currentStepId,
|
|
250
|
+
getPopupContainerOverride: getPopupContainerOverride,
|
|
251
|
+
draggableEnabled: draggableEnabled,
|
|
252
|
+
selectOperator: selectOperator,
|
|
253
|
+
selectParameter: selectParameter,
|
|
254
|
+
selectContext: selectContext,
|
|
255
|
+
selectSubject: selectSubject,
|
|
256
|
+
selectActionAttribute: selectActionAttribute,
|
|
257
|
+
updateStepName: onUpdateStepName,
|
|
258
|
+
duplicateStep: duplicateStep,
|
|
259
|
+
removeStep: removeStep,
|
|
260
|
+
minConditionsLength: minConditionsLength,
|
|
261
|
+
maxConditionsLength: maxConditionsLength,
|
|
262
|
+
setStepConditionFactorType: setStepConditionFactorType,
|
|
263
|
+
setStepConditionFactorValue: setStepConditionFactorValue,
|
|
264
|
+
currentConditionId: currentConditionId,
|
|
265
|
+
currentStepId: currentStepId,
|
|
266
|
+
currentField: currentField,
|
|
267
|
+
removeCondition: removeCondition,
|
|
268
|
+
addCondition: handleAddCondition,
|
|
269
|
+
setCurrentField: setCurrentField,
|
|
270
|
+
setCurrentCondition: setCurrentConditionId,
|
|
271
|
+
setCurrentStep: setCurrentStepId,
|
|
272
|
+
onDeactivate: handleClearActiveCondition,
|
|
273
|
+
showSuffix: showSuffix,
|
|
274
|
+
hoverDisabled: hoverDisabled || currentStepId !== step.id && currentStepId !== undefined,
|
|
275
|
+
inputProps: _extends({}, DEFAULT_INPUT_PROPS, inputProps),
|
|
276
|
+
readOnly: readOnly,
|
|
277
|
+
singleStepCondition: singleStepCondition,
|
|
278
|
+
showActionAttribute: showActionAttribute,
|
|
279
|
+
showEmptyConditionPlaceholder: showEmptyConditionPlaceholder
|
|
280
|
+
});
|
|
281
|
+
}), /*#__PURE__*/React.createElement(DragOverlay, {
|
|
282
|
+
dropAnimation: null
|
|
283
|
+
}, draggedStep && /*#__PURE__*/React.createElement(S.StepWrapper, {
|
|
284
|
+
isDragOverlay: true,
|
|
285
|
+
key: "dragOverlay"
|
|
286
|
+
}, /*#__PURE__*/React.createElement(S.DragLabel, null, /*#__PURE__*/React.createElement(Icon, {
|
|
287
|
+
component: /*#__PURE__*/React.createElement(DragHandleM, null)
|
|
288
|
+
}), onUpdateStepName && /*#__PURE__*/React.createElement(StepName, {
|
|
289
|
+
name: draggedStep.stepName,
|
|
290
|
+
index: draggedStep.index,
|
|
291
|
+
texts: allTexts
|
|
292
|
+
}), ((_draggedStep$context = draggedStep.context) == null ? void 0 : _draggedStep$context.selectedItem) && /*#__PURE__*/React.createElement(S.DragLabelPart, null, draggedStep.context.selectedItem.name))))), addStep && /*#__PURE__*/React.createElement(S.AddStepButton, null, /*#__PURE__*/React.createElement(Button, {
|
|
293
|
+
type: "ghost",
|
|
294
|
+
mode: "icon-label",
|
|
295
|
+
onClick: handleAddStep
|
|
296
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
297
|
+
component: /*#__PURE__*/React.createElement(Add3M, null)
|
|
298
|
+
}), allTexts.addStep)), !readOnly && renderAddStep && /*#__PURE__*/React.createElement(S.AddStepButton, null, renderAddStep()));
|
|
284
299
|
};
|
|
285
300
|
export default Condition;
|
|
@@ -16,10 +16,17 @@ export declare const StepHeader: import("styled-components").StyledComponent<"di
|
|
|
16
16
|
export declare const DraggedLabel: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
17
17
|
export declare const Step: import("styled-components").StyledComponent<"div", any, {
|
|
18
18
|
active: boolean;
|
|
19
|
-
showSuffix
|
|
19
|
+
showSuffix?: boolean | undefined;
|
|
20
20
|
hoverDisabled?: boolean | undefined;
|
|
21
21
|
singleStepCondition?: boolean | undefined;
|
|
22
22
|
}, never>;
|
|
23
|
+
export declare const DropLabel: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
24
|
+
export declare const DragLabelPart: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
25
|
+
export declare const DragLabel: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
26
|
+
export declare const StepWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
27
|
+
isDragOverlay?: boolean | undefined;
|
|
28
|
+
isDragged?: boolean | undefined;
|
|
29
|
+
}, never>;
|
|
23
30
|
export declare const Subject: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
24
31
|
export declare const RemoveIconWrapper: import("styled-components").StyledComponent<"span", any, {
|
|
25
32
|
'data-testid': string;
|
package/dist/Condition.style.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import styled, { css } from 'styled-components';
|
|
2
|
-
import { IconWrapper } from '@synerise/ds-inline-edit/dist/InlineEdit.styles';
|
|
3
2
|
import Icon from '@synerise/ds-icon';
|
|
4
3
|
import Cruds from '@synerise/ds-cruds';
|
|
5
4
|
import { InputGroupItem } from '@synerise/ds-input/dist/InputGroup.styles';
|
|
@@ -26,13 +25,13 @@ export var StepConditions = styled.div.withConfig({
|
|
|
26
25
|
export var StepName = styled.div.withConfig({
|
|
27
26
|
displayName: "Conditionstyle__StepName",
|
|
28
27
|
componentId: "sc-1lk06p3-4"
|
|
29
|
-
})(["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) {
|
|
28
|
+
})(["font-size:13px;line-height:1.84;color:", ";display:flex;flex-direction:row;align-items:center;justify-content:flex-start;white-space:pre-wrap;gap:8px;&&& input{margin-top:2px;cursor:default;}"], function (props) {
|
|
30
29
|
return props.theme.palette['grey-800'];
|
|
31
30
|
});
|
|
32
31
|
export var StepIndexWrapper = styled.span.withConfig({
|
|
33
32
|
displayName: "Conditionstyle__StepIndexWrapper",
|
|
34
33
|
componentId: "sc-1lk06p3-5"
|
|
35
|
-
})(["font-size:13px;font-weight:500;
|
|
34
|
+
})(["font-size:13px;font-weight:500;"]);
|
|
36
35
|
export var Condition = styled.div.withConfig({
|
|
37
36
|
displayName: "Conditionstyle__Condition",
|
|
38
37
|
componentId: "sc-1lk06p3-6"
|
|
@@ -66,59 +65,71 @@ export var DraggedLabel = styled.span.withConfig({
|
|
|
66
65
|
export var Step = styled.div.withConfig({
|
|
67
66
|
displayName: "Conditionstyle__Step",
|
|
68
67
|
componentId: "sc-1lk06p3-13"
|
|
69
|
-
})(["padding:", ";position:relative;", "
|
|
68
|
+
})(["padding:", ";position:relative;", " background-color:", ";&:hover{", ";", "{opacity:1;visibility:visible;}", "{opacity:1;visibility:visible;}", "{opacity:1;visibility:visible;}}"], function (_ref) {
|
|
70
69
|
var singleStepCondition = _ref.singleStepCondition;
|
|
71
70
|
return singleStepCondition ? '24px 0' : '12px 0';
|
|
72
71
|
}, function (props) {
|
|
73
|
-
return
|
|
72
|
+
return props.showSuffix && css(["&:after{display:flex;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;}"], props.theme.palette.white);
|
|
74
73
|
}, function (props) {
|
|
75
74
|
return props.active && !props.singleStepCondition ? props.theme.palette['grey-050'] : 'transparent';
|
|
76
75
|
}, function (props) {
|
|
77
76
|
return !props.hoverDisabled && "background-color: " + props.theme.palette['grey-050'];
|
|
78
|
-
}, StepCruds, StepConditionCruds, DragIcon
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
77
|
+
}, StepCruds, StepConditionCruds, DragIcon);
|
|
78
|
+
export var DropLabel = styled.div.withConfig({
|
|
79
|
+
displayName: "Conditionstyle__DropLabel",
|
|
80
|
+
componentId: "sc-1lk06p3-14"
|
|
81
|
+
})(["display:none;"]);
|
|
82
|
+
export var DragLabelPart = styled.div.withConfig({
|
|
83
|
+
displayName: "Conditionstyle__DragLabelPart",
|
|
84
|
+
componentId: "sc-1lk06p3-15"
|
|
85
|
+
})([""]);
|
|
86
|
+
export var DragLabel = styled.div.withConfig({
|
|
87
|
+
displayName: "Conditionstyle__DragLabel",
|
|
88
|
+
componentId: "sc-1lk06p3-16"
|
|
89
|
+
})(["display:none;align-items:center;gap:8px;"]);
|
|
90
|
+
export var StepWrapper = styled.div.withConfig({
|
|
91
|
+
displayName: "Conditionstyle__StepWrapper",
|
|
92
|
+
componentId: "sc-1lk06p3-17"
|
|
93
|
+
})(["", " ", ""], function (props) {
|
|
94
|
+
return props.isDragOverlay && css(["", "{display:none;}height:50px;overflow:hidden;cursor:grabbing;background:", ";box-shadow:0 16px 32px 0 #23293619;display:flex;align-items:center;", "{display:flex;}"], Step, props.theme.palette.white, DragLabel);
|
|
84
95
|
}, function (props) {
|
|
85
|
-
return props.theme.palette['blue-600'];
|
|
86
|
-
}
|
|
96
|
+
return props.isDragged && css(["", "{display:none;}", "{display:block;}height:50px;overflow:hidden;display:flex;align-items:center;justify-content:center;background-color:", ";color:", ";border-left:2px solid ", ";"], Step, DropLabel, props.theme.palette['blue-050'], props.theme.palette['blue-600'], props.theme.palette['blue-600']);
|
|
97
|
+
});
|
|
87
98
|
export var Subject = styled.div.withConfig({
|
|
88
99
|
displayName: "Conditionstyle__Subject",
|
|
89
|
-
componentId: "sc-1lk06p3-
|
|
100
|
+
componentId: "sc-1lk06p3-18"
|
|
90
101
|
})([""]);
|
|
91
102
|
export var RemoveIconWrapper = styled.span.attrs({
|
|
92
103
|
'data-testid': 'ds-conditions-remove-row'
|
|
93
104
|
}).withConfig({
|
|
94
105
|
displayName: "Conditionstyle__RemoveIconWrapper",
|
|
95
|
-
componentId: "sc-1lk06p3-
|
|
106
|
+
componentId: "sc-1lk06p3-19"
|
|
96
107
|
})(["visibility:hidden;pointer-events:none;opacity:0;transition:all 0.3s ease;width:24px;height:32px;display:flex;align-items:center;justify-content:center;margin-left:8px;"]);
|
|
97
108
|
export var ConditionWrapper = styled.div.withConfig({
|
|
98
109
|
displayName: "Conditionstyle__ConditionWrapper",
|
|
99
|
-
componentId: "sc-1lk06p3-
|
|
110
|
+
componentId: "sc-1lk06p3-20"
|
|
100
111
|
})(["", ";", "{min-width:0;}"], function (props) {
|
|
101
112
|
return Boolean(props.withRemoveTrigger) && css(["&{display:flex;> *{min-width:0;}}", "{flex:0 0 24px;}"], RemoveIconWrapper);
|
|
102
113
|
}, InputGroupItem);
|
|
103
114
|
export var ConditionRows = styled.div.withConfig({
|
|
104
115
|
displayName: "Conditionstyle__ConditionRows",
|
|
105
|
-
componentId: "sc-1lk06p3-
|
|
116
|
+
componentId: "sc-1lk06p3-21"
|
|
106
117
|
})(["flex-grow:1;min-width:0;"]);
|
|
107
118
|
export var ConditionRowDefinition = styled.div.withConfig({
|
|
108
119
|
displayName: "Conditionstyle__ConditionRowDefinition",
|
|
109
|
-
componentId: "sc-1lk06p3-
|
|
120
|
+
componentId: "sc-1lk06p3-22"
|
|
110
121
|
})(["display:flex;flex-direction:row;align-items:flex-start;justify-content:flex-start;"]);
|
|
111
122
|
export var ConditionRowLine = styled.div.withConfig({
|
|
112
123
|
displayName: "Conditionstyle__ConditionRowLine",
|
|
113
|
-
componentId: "sc-1lk06p3-
|
|
124
|
+
componentId: "sc-1lk06p3-23"
|
|
114
125
|
})(["flex-grow:1;min-width:0;"]);
|
|
115
126
|
export var AddConditionRow = styled.div.withConfig({
|
|
116
127
|
displayName: "Conditionstyle__AddConditionRow",
|
|
117
|
-
componentId: "sc-1lk06p3-
|
|
128
|
+
componentId: "sc-1lk06p3-24"
|
|
118
129
|
})(["display:flex;align-items:flex-start;justify-content:flex-start;flex-direction:row;"]);
|
|
119
130
|
export var ConditionConnections = styled.span.withConfig({
|
|
120
131
|
displayName: "Conditionstyle__ConditionConnections",
|
|
121
|
-
componentId: "sc-1lk06p3-
|
|
132
|
+
componentId: "sc-1lk06p3-25"
|
|
122
133
|
})(["display:flex;width:32px;min-width:32px;margin:0 12px;position:relative;height:32px;&:before{position:absolute;content:'';width:", ";height:1px;top:16px;left:", ";background-color:", ";}&:after{display:", ";position:absolute;content:'';width:1px;left:50%;height:auto;top:", ";bottom:", ";background-color:", ";}"], function (props) {
|
|
123
134
|
return props.first ? '100%' : '16px';
|
|
124
135
|
}, function (props) {
|
|
@@ -136,7 +147,7 @@ export var ConditionConnections = styled.span.withConfig({
|
|
|
136
147
|
});
|
|
137
148
|
export var ConditionRow = styled.div.withConfig({
|
|
138
149
|
displayName: "Conditionstyle__ConditionRow",
|
|
139
|
-
componentId: "sc-1lk06p3-
|
|
150
|
+
componentId: "sc-1lk06p3-26"
|
|
140
151
|
})(["padding-bottom:", ";display:flex;flex-grow:1;", "{height:", ";", "}}", "{margin-right:8px;&:last-of-type{margin-right:0;flex-grow:1;min-width:0;}&:only-of-type{flex-grow:0;}}&:hover{", "{opacity:1;visibility:visible;pointer-events:all;cursor:pointer;}}"], function (props) {
|
|
141
152
|
return props.onlyChild ? '0' : '16px';
|
|
142
153
|
}, ConditionConnections, function (props) {
|
|
@@ -148,9 +159,9 @@ export var ConditionRow = styled.div.withConfig({
|
|
|
148
159
|
}, ConditionWrapper, RemoveIconWrapper);
|
|
149
160
|
export var AddStepButton = styled.div.withConfig({
|
|
150
161
|
displayName: "Conditionstyle__AddStepButton",
|
|
151
|
-
componentId: "sc-1lk06p3-
|
|
162
|
+
componentId: "sc-1lk06p3-27"
|
|
152
163
|
})(["margin:12px 24px 0;"]);
|
|
153
164
|
export var ActionAttribute = styled.div.withConfig({
|
|
154
165
|
displayName: "Conditionstyle__ActionAttribute",
|
|
155
|
-
componentId: "sc-1lk06p3-
|
|
166
|
+
componentId: "sc-1lk06p3-28"
|
|
156
167
|
})(["margin-left:8px;display:flex;"]);
|
|
@@ -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, selectActionAttribute, selectOperator, selectParameter, setStepConditionFactorType, setStepConditionFactorValue, getPopupContainerOverride, hasPriority, currentStepId, currentConditionId, currentField, setCurrentField, setCurrentCondition, setCurrentStep, onDeactivate, showSuffix, inputProps, readOnly, singleStepCondition, showActionAttribute, contextSelectorComponent: CustomContextSelectorComponent, actionAttributeParameterSelectorComponent, parameterSelectorComponent, factorParameterSelectorComponent, showEmptyConditionPlaceholder, }: T.ConditionStepProps) => React.JSX.Element;
|
|
3
|
+
export declare const ConditionStep: ({ step, texts, index, isLast, isDragged, 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, contextSelectorComponent: CustomContextSelectorComponent, actionAttributeParameterSelectorComponent, parameterSelectorComponent, factorParameterSelectorComponent, showEmptyConditionPlaceholder, }: T.ConditionStepProps) => React.JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
2
|
import React, { useCallback, useMemo } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { useSortable, CSS } from '@synerise/ds-sortable';
|
|
4
4
|
import Subject from '@synerise/ds-subject';
|
|
5
5
|
import ContextSelector from '@synerise/ds-context-selector';
|
|
6
6
|
import { DragHandleM } from '@synerise/ds-icon';
|
|
@@ -11,11 +11,14 @@ import { AddCondition } from './AddCondition';
|
|
|
11
11
|
import { ConditionRow } from './ConditionRow';
|
|
12
12
|
import { ACTION_ATTRIBUTE, SUBJECT } from '../constants';
|
|
13
13
|
import { EmptyCondition } from './EmptyCondition';
|
|
14
|
+
import { useTranslations } from '../hooks/useTranslations';
|
|
14
15
|
export var ConditionStep = function ConditionStep(_ref) {
|
|
15
16
|
var _step$actionAttribute2, _step$subject3, _step$context4, _step$actionAttribute4, _step$context6, _step$subject4, _step$context7, _step$actionAttribute5, _step$actionAttribute6;
|
|
16
17
|
var step = _ref.step,
|
|
17
18
|
texts = _ref.texts,
|
|
18
19
|
index = _ref.index,
|
|
20
|
+
isLast = _ref.isLast,
|
|
21
|
+
isDragged = _ref.isDragged,
|
|
19
22
|
addCondition = _ref.addCondition,
|
|
20
23
|
removeCondition = _ref.removeCondition,
|
|
21
24
|
updateStepName = _ref.updateStepName,
|
|
@@ -54,52 +57,22 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
54
57
|
factorParameterSelectorComponent = _ref.factorParameterSelectorComponent,
|
|
55
58
|
_ref$showEmptyConditi = _ref.showEmptyConditionPlaceholder,
|
|
56
59
|
showEmptyConditionPlaceholder = _ref$showEmptyConditi === void 0 ? false : _ref$showEmptyConditi;
|
|
57
|
-
var
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
addFirstConditionRowButton: formatMessage({
|
|
74
|
-
id: 'DS.CONDITION.ADD-FIRST-CONDITION-ROW-BUTTON',
|
|
75
|
-
defaultMessage: 'Add condition'
|
|
76
|
-
}),
|
|
77
|
-
dropLabel: formatMessage({
|
|
78
|
-
id: 'DS.CONDITION.DROP-LABEL',
|
|
79
|
-
defaultMessage: 'Drop me here'
|
|
80
|
-
}),
|
|
81
|
-
moveTooltip: formatMessage({
|
|
82
|
-
id: 'DS.CONDITION.MOVE-TOOLTIP',
|
|
83
|
-
defaultMessage: 'Move'
|
|
84
|
-
}),
|
|
85
|
-
duplicateTooltip: formatMessage({
|
|
86
|
-
id: 'DS.CONDITION.DUPLICATE-TOOLTIP',
|
|
87
|
-
defaultMessage: 'Duplicate'
|
|
88
|
-
}),
|
|
89
|
-
removeTooltip: formatMessage({
|
|
90
|
-
id: 'DS.CONDITION.REMOVE-TOOLTIP',
|
|
91
|
-
defaultMessage: 'Delete'
|
|
92
|
-
}),
|
|
93
|
-
addStep: formatMessage({
|
|
94
|
-
id: 'DS.CONDITION.ADD-STEP',
|
|
95
|
-
defaultMessage: 'Add step'
|
|
96
|
-
}),
|
|
97
|
-
conditionSuffix: formatMessage({
|
|
98
|
-
id: 'DS.CONDITION.SUFFIX',
|
|
99
|
-
defaultMessage: 'and'
|
|
100
|
-
})
|
|
101
|
-
}, texts);
|
|
102
|
-
}, [texts, formatMessage]);
|
|
60
|
+
var _useSortable = useSortable({
|
|
61
|
+
id: step.id
|
|
62
|
+
}),
|
|
63
|
+
attributes = _useSortable.attributes,
|
|
64
|
+
listeners = _useSortable.listeners,
|
|
65
|
+
setNodeRef = _useSortable.setNodeRef,
|
|
66
|
+
transform = _useSortable.transform,
|
|
67
|
+
transition = _useSortable.transition;
|
|
68
|
+
var zIndexStyle = hasPriority ? {
|
|
69
|
+
zIndex: 1001
|
|
70
|
+
} : {};
|
|
71
|
+
var style = _extends({}, zIndexStyle, {
|
|
72
|
+
transform: CSS.Transform.toString(transform),
|
|
73
|
+
transition: transition
|
|
74
|
+
});
|
|
75
|
+
var allTexts = useTranslations(texts);
|
|
103
76
|
var withCruds = !readOnly && (duplicateStep || removeStep);
|
|
104
77
|
var _onActivate = useCallback(function () {
|
|
105
78
|
return setCurrentStep ? function () {
|
|
@@ -115,14 +88,15 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
115
88
|
index: index,
|
|
116
89
|
stepId: step.id,
|
|
117
90
|
stepName: step.stepName || '',
|
|
118
|
-
texts:
|
|
91
|
+
texts: allTexts,
|
|
119
92
|
updateStepName: updateStepName,
|
|
120
93
|
removeStep: removeStep,
|
|
121
94
|
duplicateStep: duplicateStep,
|
|
122
95
|
draggableEnabled: Boolean(draggableEnabled),
|
|
123
|
-
readOnly: readOnly
|
|
96
|
+
readOnly: readOnly,
|
|
97
|
+
dragHandleProps: _extends({}, attributes, listeners)
|
|
124
98
|
});
|
|
125
|
-
}, [draggableEnabled, duplicateStep, index, removeStep, step.id, step.stepName,
|
|
99
|
+
}, [draggableEnabled, attributes, listeners, duplicateStep, index, removeStep, step.id, step.stepName, allTexts, updateStepName, readOnly]);
|
|
126
100
|
var renderContextSelector = useCallback(function (contextData) {
|
|
127
101
|
var commonProps = _extends({}, contextData, {
|
|
128
102
|
onActivate: _onActivate,
|
|
@@ -145,14 +119,14 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
145
119
|
var _step$subject, _step$context, _step$actionAttribute;
|
|
146
120
|
return !readOnly && addCondition && (maxConditionsLength === undefined || step.conditions.length < maxConditionsLength) && /*#__PURE__*/React.createElement(AddCondition, {
|
|
147
121
|
errorText: step.addConditionErrorText,
|
|
148
|
-
texts:
|
|
122
|
+
texts: allTexts,
|
|
149
123
|
stepId: step.id,
|
|
150
124
|
"data-testid": "ds-add-condition-button",
|
|
151
125
|
addCondition: onAddCondition,
|
|
152
126
|
conditionsNumber: step.conditions.length,
|
|
153
127
|
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)
|
|
154
128
|
});
|
|
155
|
-
}, [addCondition, onAddCondition, maxConditionsLength, step.conditions.length, step.context, step.id, step.subject,
|
|
129
|
+
}, [addCondition, onAddCondition, maxConditionsLength, step.conditions.length, step.context, step.id, step.subject, allTexts, readOnly, step.addConditionErrorText, showActionAttribute, (_step$actionAttribute2 = step.actionAttribute) == null ? void 0 : _step$actionAttribute2.value]);
|
|
156
130
|
var renderConditionRow = useCallback(function (condition, conditionIndex) {
|
|
157
131
|
var _step$context2;
|
|
158
132
|
var handleActivation = function handleActivation(conditionId) {
|
|
@@ -189,14 +163,14 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
189
163
|
},
|
|
190
164
|
setStepConditionFactorType: setStepConditionFactorType,
|
|
191
165
|
setStepConditionFactorValue: setStepConditionFactorValue,
|
|
192
|
-
texts:
|
|
166
|
+
texts: allTexts,
|
|
193
167
|
stepType: (_step$context2 = step.context) == null ? void 0 : _step$context2.type,
|
|
194
168
|
onDeactivate: onDeactivate,
|
|
195
169
|
readOnly: readOnly,
|
|
196
170
|
parameterSelectorComponent: parameterSelectorComponent,
|
|
197
171
|
factorParameterSelectorComponent: factorParameterSelectorComponent
|
|
198
172
|
});
|
|
199
|
-
}, [step.id, step.conditions.length, step.context, hasPriority, currentConditionId, addCondition, removeCondition, minConditionsLength, maxConditionsLength, currentStepId, currentField, selectParameter, selectOperator, getPopupContainerOverride, setStepConditionFactorType, setStepConditionFactorValue,
|
|
173
|
+
}, [step.id, step.conditions.length, step.context, hasPriority, currentConditionId, addCondition, removeCondition, minConditionsLength, maxConditionsLength, currentStepId, currentField, selectParameter, selectOperator, getPopupContainerOverride, setStepConditionFactorType, setStepConditionFactorValue, allTexts, onDeactivate, _onActivate, setCurrentField, setCurrentCondition, setCurrentStep, inputProps, readOnly, parameterSelectorComponent, factorParameterSelectorComponent]);
|
|
200
174
|
var hasSelectedSubjectOrContext = useMemo(function () {
|
|
201
175
|
var _step$subject2, _step$context3;
|
|
202
176
|
return ((_step$subject2 = step.subject) == null ? void 0 : _step$subject2.selectedItem) || ((_step$context3 = step.context) == null ? void 0 : _step$context3.selectedItem);
|
|
@@ -205,24 +179,24 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
205
179
|
var _step$context5, _step$actionAttribute3;
|
|
206
180
|
return ((_step$context5 = step.context) == null ? void 0 : _step$context5.errorText) || showActionAttribute && ((_step$actionAttribute3 = step.actionAttribute) == null ? void 0 : _step$actionAttribute3.errorText);
|
|
207
181
|
}, [showActionAttribute, (_step$actionAttribute4 = step.actionAttribute) == null ? void 0 : _step$actionAttribute4.errorText, (_step$context6 = step.context) == null ? void 0 : _step$context6.errorText]);
|
|
208
|
-
return /*#__PURE__*/React.createElement(S.
|
|
182
|
+
return /*#__PURE__*/React.createElement(S.StepWrapper, {
|
|
183
|
+
style: style,
|
|
209
184
|
key: step.id,
|
|
185
|
+
ref: setNodeRef,
|
|
186
|
+
isDragged: isDragged
|
|
187
|
+
}, isDragged ? /*#__PURE__*/React.createElement(S.DropLabel, null, allTexts.dropLabel) : /*#__PURE__*/React.createElement(S.Step, {
|
|
210
188
|
id: "condition-step-" + step.id,
|
|
211
|
-
"data-
|
|
212
|
-
"data-conditionSuffix": text.conditionSuffix,
|
|
213
|
-
style: hasPriority ? {
|
|
214
|
-
zIndex: 1001
|
|
215
|
-
} : undefined,
|
|
189
|
+
"data-conditionSuffix": allTexts.conditionSuffix,
|
|
216
190
|
active: step.id === currentStepId && currentField !== '',
|
|
217
191
|
hoverDisabled: Boolean(currentStepId) || singleStepCondition,
|
|
218
|
-
showSuffix: showSuffix,
|
|
192
|
+
showSuffix: showSuffix && !isLast && !isDragged,
|
|
219
193
|
singleStepCondition: singleStepCondition
|
|
220
194
|
}, !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, {
|
|
221
195
|
withCruds: Boolean(!updateStepName && withCruds)
|
|
222
|
-
}, draggableEnabled && !updateStepName && /*#__PURE__*/React.createElement(S.DragIcon, {
|
|
196
|
+
}, draggableEnabled && !updateStepName && /*#__PURE__*/React.createElement(S.DragIcon, _extends({
|
|
223
197
|
className: "step-drag-handler",
|
|
224
198
|
component: /*#__PURE__*/React.createElement(DragHandleM, null)
|
|
225
|
-
}), /*#__PURE__*/React.createElement(S.Subject, {
|
|
199
|
+
}, attributes, listeners)), /*#__PURE__*/React.createElement(S.Subject, {
|
|
226
200
|
"data-testid": "condition-subject-or-context"
|
|
227
201
|
}, step.subject && /*#__PURE__*/React.createElement(Subject, _extends({}, step.subject, {
|
|
228
202
|
getPopupContainerOverride: getPopupContainerOverride,
|
|
@@ -272,12 +246,9 @@ export var ConditionStep = function ConditionStep(_ref) {
|
|
|
272
246
|
onDelete: removeStep ? function () {
|
|
273
247
|
return removeStep(step.id);
|
|
274
248
|
} : undefined,
|
|
275
|
-
duplicateTooltip:
|
|
276
|
-
deleteTooltip:
|
|
249
|
+
duplicateTooltip: allTexts.duplicateTooltip,
|
|
250
|
+
deleteTooltip: allTexts.removeTooltip
|
|
277
251
|
})) : /*#__PURE__*/React.createElement(EmptyCondition, {
|
|
278
|
-
label:
|
|
279
|
-
|
|
280
|
-
defaultMessage: 'Choose event first'
|
|
281
|
-
})
|
|
282
|
-
})));
|
|
252
|
+
label: allTexts.emptyConditionLabel
|
|
253
|
+
}))));
|
|
283
254
|
};
|
|
@@ -6,6 +6,8 @@ import type { OperatorsGroup, OperatorsItem } from '@synerise/ds-operators';
|
|
|
6
6
|
import type { ConditionStep, ConditionProps } from '../Condition.types';
|
|
7
7
|
export type ConditionStepProps = Pick<ConditionProps, 'singleStepCondition' | 'showActionAttribute' | 'showEmptyConditionPlaceholder' | 'showSuffix' | 'readOnly' | 'inputProps' | 'hoverDisabled' | 'getPopupContainerOverride' | 'minConditionsLength' | 'addCondition' | 'removeCondition' | 'texts' | 'maxConditionsLength' | 'contextSelectorComponent' | 'factorParameterSelectorComponent' | 'parameterSelectorComponent' | 'actionAttributeParameterSelectorComponent'> & {
|
|
8
8
|
index: number;
|
|
9
|
+
isLast?: boolean;
|
|
10
|
+
isDragged?: boolean;
|
|
9
11
|
step: ConditionStep;
|
|
10
12
|
hasPriority?: boolean;
|
|
11
13
|
onStepActivate?: (stepid: ReactText) => void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import * as T from './StepHeader.types';
|
|
3
|
-
export declare const StepHeader: ({ stepName, stepId, texts, updateStepName, duplicateStep, removeStep, index, draggableEnabled, readOnly, }: T.StepHeaderProps) => React.JSX.Element;
|
|
3
|
+
export declare const StepHeader: ({ stepName, stepId, texts, updateStepName, duplicateStep, removeStep, index, draggableEnabled, dragHandleProps, readOnly, }: T.StepHeaderProps) => React.JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
1
2
|
import React, { useRef, useState, useEffect, useCallback } from 'react';
|
|
2
3
|
import { debounce } from 'lodash';
|
|
3
4
|
import InlineEdit from '@synerise/ds-inline-edit';
|
|
@@ -5,6 +6,7 @@ import Cruds from '@synerise/ds-cruds';
|
|
|
5
6
|
import { DragHandleM } from '@synerise/ds-icon';
|
|
6
7
|
import { NOOP } from '@synerise/ds-utils';
|
|
7
8
|
import * as S from '../../Condition.style';
|
|
9
|
+
import { StepName } from '../StepName/StepName';
|
|
8
10
|
export var StepHeader = function StepHeader(_ref) {
|
|
9
11
|
var stepName = _ref.stepName,
|
|
10
12
|
stepId = _ref.stepId,
|
|
@@ -14,6 +16,8 @@ export var StepHeader = function StepHeader(_ref) {
|
|
|
14
16
|
removeStep = _ref.removeStep,
|
|
15
17
|
index = _ref.index,
|
|
16
18
|
draggableEnabled = _ref.draggableEnabled,
|
|
19
|
+
_ref$dragHandleProps = _ref.dragHandleProps,
|
|
20
|
+
dragHandleProps = _ref$dragHandleProps === void 0 ? {} : _ref$dragHandleProps,
|
|
17
21
|
_ref$readOnly = _ref.readOnly,
|
|
18
22
|
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly;
|
|
19
23
|
var onChangeNameDebounce = useRef(debounce(updateStepName || NOOP, 300)).current;
|
|
@@ -32,10 +36,10 @@ export var StepHeader = function StepHeader(_ref) {
|
|
|
32
36
|
setLocalName(event.target.value);
|
|
33
37
|
onChangeNameDebounce(stepId, event.target.value);
|
|
34
38
|
}, [onChangeNameDebounce, stepId]);
|
|
35
|
-
var dragHandleElement = !readOnly && draggableEnabled && /*#__PURE__*/React.createElement(S.DragIcon, {
|
|
39
|
+
var dragHandleElement = !readOnly && draggableEnabled && /*#__PURE__*/React.createElement(S.DragIcon, _extends({
|
|
36
40
|
className: "step-drag-handler",
|
|
37
41
|
component: /*#__PURE__*/React.createElement(DragHandleM, null)
|
|
38
|
-
});
|
|
42
|
+
}, dragHandleProps));
|
|
39
43
|
var stepNameElement = readOnly ? localName : /*#__PURE__*/React.createElement(InlineEdit, {
|
|
40
44
|
size: "small",
|
|
41
45
|
input: {
|
|
@@ -58,7 +62,9 @@ export var StepHeader = function StepHeader(_ref) {
|
|
|
58
62
|
return /*#__PURE__*/React.createElement(S.StepHeader, {
|
|
59
63
|
className: "ds-condition-step-header",
|
|
60
64
|
draggable: draggableEnabled
|
|
61
|
-
}, /*#__PURE__*/React.createElement(S.LeftSide, null, dragHandleElement, /*#__PURE__*/React.createElement(
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
}, /*#__PURE__*/React.createElement(S.LeftSide, null, dragHandleElement, /*#__PURE__*/React.createElement(StepName, {
|
|
66
|
+
name: stepNameElement,
|
|
67
|
+
index: index,
|
|
68
|
+
texts: texts
|
|
69
|
+
})), crudElement);
|
|
64
70
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { HTMLAttributes } from 'react';
|
|
2
2
|
import { ConditionProps, ConditionTexts } from '../../Condition.types';
|
|
3
3
|
export type StepHeaderProps = {
|
|
4
4
|
index: number;
|
|
5
|
-
texts:
|
|
5
|
+
texts: ConditionTexts;
|
|
6
6
|
stepName: string;
|
|
7
7
|
stepId: React.ReactText;
|
|
8
8
|
removeStep: ConditionProps['removeStep'];
|
|
@@ -10,4 +10,5 @@ export type StepHeaderProps = {
|
|
|
10
10
|
updateStepName: ConditionProps['onUpdateStepName'];
|
|
11
11
|
draggableEnabled: boolean;
|
|
12
12
|
readOnly?: boolean;
|
|
13
|
+
dragHandleProps?: HTMLAttributes<HTMLDivElement>;
|
|
13
14
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { ConditionTexts } from '../../Condition.types';
|
|
3
|
+
type StepNameProps = {
|
|
4
|
+
texts: ConditionTexts;
|
|
5
|
+
index: number;
|
|
6
|
+
name: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
export declare const StepName: ({ texts, index, name }: StepNameProps) => React.JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import * as S from '../../Condition.style';
|
|
3
|
+
export var StepName = function StepName(_ref) {
|
|
4
|
+
var texts = _ref.texts,
|
|
5
|
+
index = _ref.index,
|
|
6
|
+
name = _ref.name;
|
|
7
|
+
return /*#__PURE__*/React.createElement(S.StepName, {
|
|
8
|
+
className: "ds-condition-step-name"
|
|
9
|
+
}, /*#__PURE__*/React.createElement(S.StepIndexWrapper, null, texts.stepNamePrefix, " ", "" + (index + 1)), name);
|
|
10
|
+
};
|
package/dist/constants.d.ts
CHANGED
|
@@ -6,14 +6,6 @@ export declare const PARAMETER = "parameter";
|
|
|
6
6
|
export declare const FACTOR = "factor";
|
|
7
7
|
export declare const SUBJECT = "subject";
|
|
8
8
|
export declare const ACTION_ATTRIBUTE = "actionAttribute";
|
|
9
|
-
export declare const SORTABLE_CONFIG: {
|
|
10
|
-
ghostClass: string;
|
|
11
|
-
className: string;
|
|
12
|
-
handle: string;
|
|
13
|
-
filter: string;
|
|
14
|
-
animation: number;
|
|
15
|
-
forceFallback: boolean;
|
|
16
|
-
};
|
|
17
9
|
export declare const DEFAULT_INPUT_PROPS: {
|
|
18
10
|
autoResize: {
|
|
19
11
|
minWidth: string;
|
package/dist/constants.js
CHANGED
|
@@ -6,14 +6,6 @@ export var PARAMETER = 'parameter';
|
|
|
6
6
|
export var FACTOR = 'factor';
|
|
7
7
|
export var SUBJECT = 'subject';
|
|
8
8
|
export var ACTION_ATTRIBUTE = 'actionAttribute';
|
|
9
|
-
export var SORTABLE_CONFIG = {
|
|
10
|
-
ghostClass: 'steps-list-ghost-element',
|
|
11
|
-
className: 'steps-list',
|
|
12
|
-
handle: '.step-drag-handler',
|
|
13
|
-
filter: '.ds-condition-step-name, .ds-cruds',
|
|
14
|
-
animation: 150,
|
|
15
|
-
forceFallback: true
|
|
16
|
-
};
|
|
17
9
|
export var DEFAULT_INPUT_PROPS = {
|
|
18
10
|
autoResize: {
|
|
19
11
|
minWidth: '173px',
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
4
|
+
export var useTranslations = function useTranslations(defaultTexts) {
|
|
5
|
+
var _useIntl = useIntl(),
|
|
6
|
+
formatMessage = _useIntl.formatMessage;
|
|
7
|
+
var texts = useMemo(function () {
|
|
8
|
+
return _extends({
|
|
9
|
+
stepNamePrefix: formatMessage({
|
|
10
|
+
id: 'DS.CONDITION.STEP_NAME-PREFIX',
|
|
11
|
+
defaultMessage: 'Step'
|
|
12
|
+
}),
|
|
13
|
+
emptyConditionLabel: formatMessage({
|
|
14
|
+
id: 'DS.CONDITION.EMPTY_CONDITION_LABEL',
|
|
15
|
+
defaultMessage: 'Choose event first'
|
|
16
|
+
}),
|
|
17
|
+
stepNamePlaceholder: formatMessage({
|
|
18
|
+
id: 'DS.CONDITION.STEP_NAME-PLACEHOLDER',
|
|
19
|
+
defaultMessage: 'Step name'
|
|
20
|
+
}),
|
|
21
|
+
removeConditionRowTooltip: formatMessage({
|
|
22
|
+
id: 'DS.CONDITION.REMOVE-CONDITION-ROW-TOOLTIP',
|
|
23
|
+
defaultMessage: 'Delete'
|
|
24
|
+
}),
|
|
25
|
+
addConditionRowButton: formatMessage({
|
|
26
|
+
id: 'DS.CONDITION.ADD-CONDITION-ROW-BUTTON',
|
|
27
|
+
defaultMessage: 'Add condition'
|
|
28
|
+
}),
|
|
29
|
+
addFirstConditionRowButton: formatMessage({
|
|
30
|
+
id: 'DS.CONDITION.ADD-FIRST-CONDITION-ROW-BUTTON',
|
|
31
|
+
defaultMessage: 'Add condition'
|
|
32
|
+
}),
|
|
33
|
+
dropLabel: formatMessage({
|
|
34
|
+
id: 'DS.CONDITION.DROP-LABEL',
|
|
35
|
+
defaultMessage: 'Drop me here'
|
|
36
|
+
}),
|
|
37
|
+
moveTooltip: formatMessage({
|
|
38
|
+
id: 'DS.CONDITION.MOVE-TOOLTIP',
|
|
39
|
+
defaultMessage: 'Move'
|
|
40
|
+
}),
|
|
41
|
+
duplicateTooltip: formatMessage({
|
|
42
|
+
id: 'DS.CONDITION.DUPLICATE-TOOLTIP',
|
|
43
|
+
defaultMessage: 'Duplicate'
|
|
44
|
+
}),
|
|
45
|
+
removeTooltip: formatMessage({
|
|
46
|
+
id: 'DS.CONDITION.REMOVE-TOOLTIP',
|
|
47
|
+
defaultMessage: 'Delete'
|
|
48
|
+
}),
|
|
49
|
+
addStep: formatMessage({
|
|
50
|
+
id: 'DS.CONDITION.ADD-STEP',
|
|
51
|
+
defaultMessage: 'Add step'
|
|
52
|
+
}),
|
|
53
|
+
conditionSuffix: formatMessage({
|
|
54
|
+
id: 'DS.CONDITION.SUFFIX',
|
|
55
|
+
defaultMessage: 'and'
|
|
56
|
+
})
|
|
57
|
+
}, defaultTexts || {});
|
|
58
|
+
}, [formatMessage, defaultTexts]);
|
|
59
|
+
return texts;
|
|
60
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-condition",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Condition UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -34,20 +34,20 @@
|
|
|
34
34
|
],
|
|
35
35
|
"types": "dist/index.d.ts",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@synerise/ds-button": "^1.
|
|
38
|
-
"@synerise/ds-context-selector": "^1.1.
|
|
39
|
-
"@synerise/ds-cruds": "^1.0.
|
|
40
|
-
"@synerise/ds-factors": "^1.
|
|
41
|
-
"@synerise/ds-icon": "^1.5.
|
|
42
|
-
"@synerise/ds-inline-edit": "^1.0.
|
|
43
|
-
"@synerise/ds-input": "^1.
|
|
44
|
-
"@synerise/ds-operators": "^1.0.
|
|
45
|
-
"@synerise/ds-
|
|
46
|
-
"@synerise/ds-
|
|
47
|
-
"@synerise/ds-
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
37
|
+
"@synerise/ds-button": "^1.4.1",
|
|
38
|
+
"@synerise/ds-context-selector": "^1.1.15",
|
|
39
|
+
"@synerise/ds-cruds": "^1.0.12",
|
|
40
|
+
"@synerise/ds-factors": "^1.3.1",
|
|
41
|
+
"@synerise/ds-icon": "^1.5.3",
|
|
42
|
+
"@synerise/ds-inline-edit": "^1.0.16",
|
|
43
|
+
"@synerise/ds-input": "^1.3.1",
|
|
44
|
+
"@synerise/ds-operators": "^1.0.15",
|
|
45
|
+
"@synerise/ds-sortable": "^1.3.0",
|
|
46
|
+
"@synerise/ds-subject": "^1.0.16",
|
|
47
|
+
"@synerise/ds-tooltip": "^1.1.11",
|
|
48
|
+
"@synerise/ds-typography": "^1.0.12",
|
|
49
|
+
"@synerise/ds-utils": "^1.3.0",
|
|
50
|
+
"lodash": "^4.17.19"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@synerise/ds-core": "*",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"react-intl": ">=3.12.0 <= 6.8",
|
|
56
56
|
"styled-components": "^5.3.3"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "11fe1d29b2ac23e70c3d5e6ce8ae20201a619a34"
|
|
59
59
|
}
|