@synerise/ds-condition 0.21.11 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
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.22.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.21.11...@synerise/ds-condition@0.22.0) (2024-03-05)
7
+
8
+
9
+ ### Features
10
+
11
+ * **input:** support autoresize to stretch to parent ([329c866](https://github.com/Synerise/synerise-design/commit/329c866cb54921ad1260ae217cb8c471e43b986e))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [0.21.11](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.21.10...@synerise/ds-condition@0.21.11) (2024-03-04)
7
18
 
8
19
  **Note:** Version bump only for package @synerise/ds-condition
@@ -1,7 +1,3 @@
1
1
  import * as T from './Condition.types';
2
- export declare const OPERATOR = "operator";
3
- export declare const PARAMETER = "parameter";
4
- export declare const FACTOR = "factor";
5
- export declare const SUBJECT = "subject";
6
2
  declare const Condition: (props: T.ConditionProps) => JSX.Element;
7
3
  export default Condition;
package/dist/Condition.js CHANGED
@@ -15,21 +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
- var DEFAULT_FIELD = '';
19
- var DEFAULT_CONDITION = '';
20
- var DEFAULT_STEP = '';
21
- export var OPERATOR = 'operator';
22
- export var PARAMETER = 'parameter';
23
- export var FACTOR = 'factor';
24
- export var SUBJECT = 'subject';
25
- var SORTABLE_CONFIG = {
26
- ghostClass: 'steps-list-ghost-element',
27
- className: 'steps-list',
28
- handle: '.step-drag-handler',
29
- filter: '.ds-condition-step-name, .ds-cruds',
30
- animation: 150,
31
- forceFallback: true
32
- };
18
+ import { SORTABLE_CONFIG, DEFAULT_CONDITION, DEFAULT_FIELD, DEFAULT_STEP, OPERATOR, FACTOR, PARAMETER, SUBJECT, DEFAULT_INPUT_PROPS } from './constants';
33
19
 
34
20
  var Condition = function Condition(props) {
35
21
  var steps = props.steps,
@@ -279,7 +265,7 @@ var Condition = function Condition(props) {
279
265
  onDeactivate: handleClearActiveCondition,
280
266
  showSuffix: showSuffix,
281
267
  hoverDisabled: hoverDisabled || currentStepId !== step.id && currentStepId !== undefined,
282
- inputProps: inputProps,
268
+ inputProps: _objectSpread({}, DEFAULT_INPUT_PROPS, {}, inputProps),
283
269
  readOnly: readOnly
284
270
  });
285
271
  })), addStep && /*#__PURE__*/React.createElement(S.AddStepButton, null, /*#__PURE__*/React.createElement(Button, {
@@ -1,10 +1,9 @@
1
1
  /// <reference types="react" />
2
- import { ConditionRowProps } from './ConditionStep/ConditionRow';
3
2
  export declare const ErrorWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
4
3
  export declare const DragIcon: import("styled-components").StyledComponent<import("react").FC<import("@synerise/ds-icon").IconProps>, any, {}, never>;
5
4
  export declare const StepConditionCruds: import("styled-components").StyledComponent<import("react").FC<import("@synerise/ds-cruds/dist/Cruds.types").CrudsProps> & import("@synerise/ds-cruds/dist/Cruds.types").CrudsSubComponents, any, {}, never>;
6
5
  export declare const StepConditions: import("styled-components").StyledComponent<"div", any, {
7
- withoutStepName: boolean;
6
+ withCruds?: boolean | undefined;
8
7
  }, never>;
9
8
  export declare const StepName: import("styled-components").StyledComponent<"div", any, {}, never>;
10
9
  export declare const StepIndexWrapper: import("styled-components").StyledComponent<"span", any, {}, never>;
@@ -20,11 +19,11 @@ export declare const Step: import("styled-components").StyledComponent<"div", an
20
19
  showSuffix: boolean | undefined;
21
20
  hoverDisabled?: boolean | undefined;
22
21
  }, never>;
23
- export declare const ConditionWrapper: import("styled-components").StyledComponent<"div", any, {
24
- fullWidth?: boolean | undefined;
25
- }, never>;
26
22
  export declare const Subject: import("styled-components").StyledComponent<"div", any, {}, never>;
27
23
  export declare const RemoveIconWrapper: import("styled-components").StyledComponent<"span", any, {}, never>;
24
+ export declare const ConditionWrapper: import("styled-components").StyledComponent<"div", any, {
25
+ withRemoveTrigger?: boolean | undefined;
26
+ }, never>;
28
27
  export declare const ConditionRows: import("styled-components").StyledComponent<"div", any, {}, never>;
29
28
  export declare const ConditionRowDefinition: import("styled-components").StyledComponent<"div", any, {}, never>;
30
29
  export declare const ConditionRowLine: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -37,7 +36,7 @@ export declare const ConditionConnections: import("styled-components").StyledCom
37
36
  export declare const ConditionRow: import("styled-components").StyledComponent<"div", any, {
38
37
  withError: boolean;
39
38
  index: number;
40
- stepType: ConditionRowProps['stepType'];
39
+ onlyChild?: boolean | undefined;
41
40
  last?: boolean | undefined;
42
41
  }, never>;
43
42
  export declare const AddStepButton: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -2,6 +2,7 @@ import styled, { css } from 'styled-components';
2
2
  import { IconWrapper } from '@synerise/ds-inline-edit/dist/InlineEdit.styles';
3
3
  import Icon from '@synerise/ds-icon';
4
4
  import Cruds from '@synerise/ds-cruds';
5
+ import { InputGroupItem } from '@synerise/ds-input/dist/InputGroup.styles';
5
6
  export var ErrorWrapper = styled.div.withConfig({
6
7
  displayName: "Conditionstyle__ErrorWrapper",
7
8
  componentId: "sc-1lk06p3-0"
@@ -20,7 +21,7 @@ export var StepConditions = styled.div.withConfig({
20
21
  displayName: "Conditionstyle__StepConditions",
21
22
  componentId: "sc-1lk06p3-3"
22
23
  })(["display:flex;flex-direction:row;align-items:flex-start;justify-content:flex-start;margin-top:0;padding:0 24px;width:", ";", "{left:0;top:16px;}"], function (props) {
23
- return props.withoutStepName ? 'calc(100% - 48px)' : '100%';
24
+ return props.withCruds ? 'calc(100% - 48px)' : '100%';
24
25
  }, DragIcon);
25
26
  export var StepName = styled.div.withConfig({
26
27
  displayName: "Conditionstyle__StepName",
@@ -35,11 +36,11 @@ export var StepIndexWrapper = styled.span.withConfig({
35
36
  export var Condition = styled.div.withConfig({
36
37
  displayName: "Conditionstyle__Condition",
37
38
  componentId: "sc-1lk06p3-6"
38
- })(["padding:12px 0;display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;min-width:575px;width:100%;.steps-list{width:100%;}"]);
39
+ })(["padding:12px 0;display:block;min-width:575px;width:100%;.steps-list{width:100%;}"]);
39
40
  export var ConditionStepWrapper = styled.div.withConfig({
40
41
  displayName: "Conditionstyle__ConditionStepWrapper",
41
42
  componentId: "sc-1lk06p3-7"
42
- })(["display:flex;align-items:flex-start;justify-content:flex-start;flex-direction:column;width:100%;"]);
43
+ })([""]);
43
44
  export var And = styled.div.withConfig({
44
45
  displayName: "Conditionstyle__And",
45
46
  componentId: "sc-1lk06p3-8"
@@ -65,12 +66,12 @@ export var DraggedLabel = styled.span.withConfig({
65
66
  export var Step = styled.div.withConfig({
66
67
  displayName: "Conditionstyle__Step",
67
68
  componentId: "sc-1lk06p3-13"
68
- })(["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) {
69
+ })(["padding:12px 0 12px;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 (props) {
69
70
  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);
70
71
  }, function (props) {
71
72
  return props.active ? props.theme.palette['grey-050'] : 'transparent';
72
73
  }, function (props) {
73
- return props.hoverDisabled ? 'transparent' : props.theme.palette['grey-050'];
74
+ return !props.hoverDisabled && "background-color: " + props.theme.palette['grey-050'];
74
75
  }, StepCruds, StepConditionCruds, DragIcon, function (props) {
75
76
  return props.theme.palette.white;
76
77
  }, StepHeader, StepName, IconWrapper, StepConditions, DraggedLabel, function (props) {
@@ -80,22 +81,24 @@ export var Step = styled.div.withConfig({
80
81
  }, function (props) {
81
82
  return props.theme.palette['blue-600'];
82
83
  }, DraggedLabel);
83
- export var ConditionWrapper = styled.div.withConfig({
84
- displayName: "Conditionstyle__ConditionWrapper",
85
- componentId: "sc-1lk06p3-14"
86
- })([""]);
87
84
  export var Subject = styled.div.withConfig({
88
85
  displayName: "Conditionstyle__Subject",
89
- componentId: "sc-1lk06p3-15"
86
+ componentId: "sc-1lk06p3-14"
90
87
  })([""]);
91
88
  export var RemoveIconWrapper = styled.span.withConfig({
92
89
  displayName: "Conditionstyle__RemoveIconWrapper",
90
+ componentId: "sc-1lk06p3-15"
91
+ })(["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;"]);
92
+ export var ConditionWrapper = styled.div.withConfig({
93
+ displayName: "Conditionstyle__ConditionWrapper",
93
94
  componentId: "sc-1lk06p3-16"
94
- })(["visibility:hidden;pointer-events:none;opacity:0;transition:all 0.3s ease;width:32px;height:32px;display:flex;align-items:center;justify-content:center;margin-left:8px;"]);
95
+ })(["", ";", "{min-width:0;}"], function (props) {
96
+ return Boolean(props.withRemoveTrigger) && css(["&{display:flex;> *{min-width:0;}}", "{flex:0 0 24px;}"], RemoveIconWrapper);
97
+ }, InputGroupItem);
95
98
  export var ConditionRows = styled.div.withConfig({
96
99
  displayName: "Conditionstyle__ConditionRows",
97
100
  componentId: "sc-1lk06p3-17"
98
- })(["display:flex;align-items:flex-start;justify-content:flex-start;flex-direction:column;"]);
101
+ })(["flex-grow:1;min-width:0;"]);
99
102
  export var ConditionRowDefinition = styled.div.withConfig({
100
103
  displayName: "Conditionstyle__ConditionRowDefinition",
101
104
  componentId: "sc-1lk06p3-18"
@@ -103,7 +106,7 @@ export var ConditionRowDefinition = styled.div.withConfig({
103
106
  export var ConditionRowLine = styled.div.withConfig({
104
107
  displayName: "Conditionstyle__ConditionRowLine",
105
108
  componentId: "sc-1lk06p3-19"
106
- })([""]);
109
+ })(["flex-grow:1;min-width:0;"]);
107
110
  export var AddConditionRow = styled.div.withConfig({
108
111
  displayName: "Conditionstyle__AddConditionRow",
109
112
  componentId: "sc-1lk06p3-20"
@@ -129,8 +132,8 @@ export var ConditionConnections = styled.span.withConfig({
129
132
  export var ConditionRow = styled.div.withConfig({
130
133
  displayName: "Conditionstyle__ConditionRow",
131
134
  componentId: "sc-1lk06p3-22"
132
- })(["padding-bottom:", ";display:flex;", "{height:", ";", "}}", "{margin-right:8px;&:last-of-type{margin-right:0;}}&:hover{", "{opacity:1;visibility:visible;pointer-events:all;cursor:pointer;}}"], function (props) {
133
- return props.stepType === 'event' ? '16px' : '0';
135
+ })(["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) {
136
+ return props.onlyChild ? '0' : '16px';
134
137
  }, ConditionConnections, function (props) {
135
138
  return props.withError ? 'auto' : '32px';
136
139
  }, function (props) {
@@ -7,7 +7,7 @@ import Icon, { CloseS } from '@synerise/ds-icon';
7
7
  import { theme } from '@synerise/ds-core';
8
8
  import { getPopupContainer } from '@synerise/ds-utils';
9
9
  import * as React from 'react';
10
- import { FACTOR, OPERATOR, PARAMETER } from '../../Condition';
10
+ import { FACTOR, OPERATOR, PARAMETER } from '../../constants';
11
11
  import * as S from '../../Condition.style';
12
12
  // eslint-disable-next-line import/prefer-default-export
13
13
  export var ConditionRow = function ConditionRow(_ref) {
@@ -33,7 +33,6 @@ export var ConditionRow = function ConditionRow(_ref) {
33
33
  _onActivate = _ref.onActivate,
34
34
  hasPriority = _ref.hasPriority,
35
35
  texts = _ref.texts,
36
- stepType = _ref.stepType,
37
36
  onDeactivate = _ref.onDeactivate,
38
37
  inputProps = _ref.inputProps,
39
38
  _ref$readOnly = _ref.readOnly,
@@ -55,8 +54,34 @@ export var ConditionRow = function ConditionRow(_ref) {
55
54
 
56
55
  return errorText ? /*#__PURE__*/React.createElement(S.ErrorWrapper, null, errorText) : /*#__PURE__*/React.createElement(React.Fragment, null);
57
56
  }, [conditionOperatorErrorText, conditionFactorErrorText, conditionParameterErrorText]);
57
+ var removeConditionTrigger = !readOnly && removeCondition && conditionsNumber > minConditionLength && /*#__PURE__*/React.createElement(S.RemoveIconWrapper, {
58
+ onClick: function onClick() {
59
+ return removeCondition(stepId, conditionId);
60
+ },
61
+ className: "ds-conditions-remove-row"
62
+ }, /*#__PURE__*/React.createElement(Tooltip, {
63
+ title: texts.removeConditionRowTooltip,
64
+ trigger: ['hover']
65
+ }, /*#__PURE__*/React.createElement(Icon, {
66
+ component: /*#__PURE__*/React.createElement(CloseS, null),
67
+ color: theme.palette['red-600']
68
+ })));
69
+ var renderConditionParameterWrapper = Boolean(conditionParameter);
70
+ var renderConditionOperatorWrapper = Boolean((!conditionParameter || (conditionParameter == null ? void 0 : conditionParameter.value) && (conditionParameter == null ? void 0 : conditionParameter.value).name !== '') && conditionOperator);
71
+ var renderConditionFactorWrapper = Boolean(conditionFactor !== undefined && (conditionOperator == null ? void 0 : conditionOperator.value) && (conditionFactor == null ? void 0 : conditionFactor.availableFactorTypes) !== null);
72
+ var lastConditionWrapper = '';
73
+
74
+ if (renderConditionFactorWrapper) {
75
+ lastConditionWrapper = 'factor';
76
+ } else if (renderConditionOperatorWrapper) {
77
+ lastConditionWrapper = 'operator';
78
+ } else if (renderConditionParameterWrapper) {
79
+ lastConditionWrapper = 'parameter';
80
+ }
81
+
58
82
  return /*#__PURE__*/React.createElement(S.ConditionRow, {
59
- stepType: stepType,
83
+ "data-testid": "condition-row",
84
+ onlyChild: maxConditionLength === 1,
60
85
  style: hasPriority ? {
61
86
  zIndex: 10001
62
87
  } : undefined,
@@ -67,7 +92,10 @@ export var ConditionRow = function ConditionRow(_ref) {
67
92
  first: index === 0,
68
93
  last: readOnly ? Boolean(index + 1 === conditionsNumber) : Boolean(addCondition && index + 1 === conditionsNumber && maxConditionLength !== undefined && conditionsNumber === maxConditionLength),
69
94
  readOnly: readOnly
70
- }), /*#__PURE__*/React.createElement(S.ConditionRowLine, null, /*#__PURE__*/React.createElement(S.ConditionRowDefinition, null, /*#__PURE__*/React.createElement(S.ConditionWrapper, null, conditionParameter && /*#__PURE__*/React.createElement(Factors, _extends({}, conditionParameter, {
95
+ }), /*#__PURE__*/React.createElement(S.ConditionRowLine, null, /*#__PURE__*/React.createElement(S.ConditionRowDefinition, null, /*#__PURE__*/React.createElement(S.ConditionWrapper, {
96
+ "data-testid": "condition-parameter-wrapper",
97
+ withRemoveTrigger: lastConditionWrapper === 'parameter'
98
+ }, renderConditionParameterWrapper && /*#__PURE__*/React.createElement(Factors, _extends({}, conditionParameter, {
71
99
  inputProps: inputProps,
72
100
  getPopupContainerOverride: getPopupContainerOverride || getPopupContainer,
73
101
  onActivate: function onActivate() {
@@ -80,7 +108,10 @@ export var ConditionRow = function ConditionRow(_ref) {
80
108
  opened: hasPriority && stepId === currentStepId && conditionId === currentConditionId && currentField === PARAMETER,
81
109
  readOnly: readOnly,
82
110
  error: Boolean(conditionParameter.errorText)
83
- }))), (!conditionParameter || (conditionParameter == null ? void 0 : conditionParameter.value) && (conditionParameter == null ? void 0 : conditionParameter.value).name !== '') && conditionOperator && /*#__PURE__*/React.createElement(S.ConditionWrapper, null, /*#__PURE__*/React.createElement(Operators, _extends({}, conditionOperator, {
111
+ })), lastConditionWrapper === 'parameter' && removeConditionTrigger), renderConditionOperatorWrapper && /*#__PURE__*/React.createElement(S.ConditionWrapper, {
112
+ "data-testid": "condition-operator-wrapper",
113
+ withRemoveTrigger: lastConditionWrapper === 'operator'
114
+ }, /*#__PURE__*/React.createElement(Operators, _extends({}, conditionOperator, {
84
115
  getPopupContainerOverride: getPopupContainerOverride || getPopupContainer,
85
116
  onActivate: function onActivate() {
86
117
  return _onActivate && _onActivate(OPERATOR);
@@ -92,8 +123,9 @@ export var ConditionRow = function ConditionRow(_ref) {
92
123
  opened: hasPriority && stepId === currentStepId && conditionId === currentConditionId && currentField === OPERATOR,
93
124
  readOnly: readOnly,
94
125
  errorText: conditionOperator.errorText
95
- }))), conditionFactor !== undefined && (conditionOperator == null ? void 0 : conditionOperator.value) && (conditionFactor == null ? void 0 : conditionFactor.availableFactorTypes) !== null && /*#__PURE__*/React.createElement(S.ConditionWrapper, {
96
- fullWidth: true
126
+ })), lastConditionWrapper === 'operator' && removeConditionTrigger), renderConditionFactorWrapper && /*#__PURE__*/React.createElement(S.ConditionWrapper, {
127
+ "data-testid": "condition-factor-wrapper",
128
+ withRemoveTrigger: lastConditionWrapper === 'factor'
97
129
  }, (conditionFactor == null ? void 0 : conditionFactor.withCustomFactor) || /*#__PURE__*/React.createElement(Factors, _extends({}, conditionFactor, {
98
130
  inputProps: inputProps,
99
131
  getPopupContainerOverride: getPopupContainerOverride || getPopupContainer,
@@ -111,16 +143,5 @@ export var ConditionRow = function ConditionRow(_ref) {
111
143
  error: Boolean(conditionFactor.errorText),
112
144
  opened: hasPriority && stepId === currentStepId && conditionId === currentConditionId && currentField === FACTOR,
113
145
  readOnly: readOnly
114
- }))), !readOnly && removeCondition && conditionsNumber > minConditionLength && /*#__PURE__*/React.createElement(S.RemoveIconWrapper, {
115
- onClick: function onClick() {
116
- return removeCondition(stepId, conditionId);
117
- },
118
- className: "ds-conditions-remove-row"
119
- }, /*#__PURE__*/React.createElement(Tooltip, {
120
- title: texts.removeConditionRowTooltip,
121
- trigger: ['hover']
122
- }, /*#__PURE__*/React.createElement(Icon, {
123
- component: /*#__PURE__*/React.createElement(CloseS, null),
124
- color: theme.palette['red-600']
125
- })))), conditionErrorMessage));
146
+ })), lastConditionWrapper === 'factor' && removeConditionTrigger)), conditionErrorMessage));
126
147
  };
@@ -1,2 +1,2 @@
1
1
  import * as T from './ConditionStep.types';
2
- 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, hoverDisabled, inputProps, readOnly, }: T.ConditionStepProps) => JSX.Element;
2
+ 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) => JSX.Element;
@@ -15,7 +15,7 @@ import * as S from '../Condition.style';
15
15
  import { StepHeader } from './StepHeader';
16
16
  import { AddCondition } from './AddCondition';
17
17
  import { ConditionRow } from './ConditionRow';
18
- import { SUBJECT } from '../Condition';
18
+ import { SUBJECT } from '../constants';
19
19
  export var ConditionStep = function ConditionStep(_ref) {
20
20
  var _step$subject2, _step$subject2$select, _step$context3, _step$context3$select;
21
21
 
@@ -47,7 +47,6 @@ export var ConditionStep = function ConditionStep(_ref) {
47
47
  setCurrentStep = _ref.setCurrentStep,
48
48
  onDeactivate = _ref.onDeactivate,
49
49
  showSuffix = _ref.showSuffix,
50
- hoverDisabled = _ref.hoverDisabled,
51
50
  inputProps = _ref.inputProps,
52
51
  _ref$readOnly = _ref.readOnly,
53
52
  readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly;
@@ -99,6 +98,7 @@ export var ConditionStep = function ConditionStep(_ref) {
99
98
  })
100
99
  }, texts);
101
100
  }, [texts, formatMessage]);
101
+ var withCruds = !readOnly && (duplicateStep || removeStep);
102
102
  var onActivate = useCallback(function () {
103
103
  return setCurrentStep ? function () {
104
104
  return setCurrentStep(step.id);
@@ -187,14 +187,16 @@ export var ConditionStep = function ConditionStep(_ref) {
187
187
  zIndex: 10001
188
188
  } : undefined,
189
189
  active: step.id === currentStepId && currentField !== '',
190
- hoverDisabled: hoverDisabled,
190
+ hoverDisabled: Boolean(currentStepId),
191
191
  showSuffix: showSuffix
192
192
  }, !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, {
193
- withoutStepName: updateStepName === undefined
193
+ withCruds: Boolean(!updateStepName && withCruds)
194
194
  }, draggableEnabled && !updateStepName && /*#__PURE__*/React.createElement(S.DragIcon, {
195
195
  className: "step-drag-handler",
196
196
  component: /*#__PURE__*/React.createElement(DragHandleM, null)
197
- }), /*#__PURE__*/React.createElement(S.Subject, null, step.subject && /*#__PURE__*/React.createElement(Subject, _extends({}, step.subject, {
197
+ }), /*#__PURE__*/React.createElement(S.Subject, {
198
+ "data-testid": "condition-subject-or-context"
199
+ }, step.subject && /*#__PURE__*/React.createElement(Subject, _extends({}, step.subject, {
198
200
  getPopupContainerOverride: getPopupContainerOverride,
199
201
  onActivate: onActivate,
200
202
  onDeactivate: onDeactivate,
@@ -211,7 +213,7 @@ export var ConditionStep = function ConditionStep(_ref) {
211
213
  return selectContext(value, step.id);
212
214
  },
213
215
  readOnly: readOnly
214
- }))), /*#__PURE__*/React.createElement(S.ConditionRows, null, step.conditions.length > 0 && step.conditions.map(renderConditionRow), addConditionButton), !updateStepName && !readOnly && /*#__PURE__*/React.createElement(S.StepConditionCruds, {
216
+ }))), /*#__PURE__*/React.createElement(S.ConditionRows, null, step.conditions.length > 0 && step.conditions.map(renderConditionRow), addConditionButton), !updateStepName && withCruds && /*#__PURE__*/React.createElement(S.StepConditionCruds, {
215
217
  onDuplicate: duplicateStep ? function () {
216
218
  return duplicateStep(step.id);
217
219
  } : undefined,
@@ -0,0 +1,21 @@
1
+ export declare const DEFAULT_FIELD = "";
2
+ export declare const DEFAULT_CONDITION = "";
3
+ export declare const DEFAULT_STEP = "";
4
+ export declare const OPERATOR = "operator";
5
+ export declare const PARAMETER = "parameter";
6
+ export declare const FACTOR = "factor";
7
+ export declare const SUBJECT = "subject";
8
+ export declare const SORTABLE_CONFIG: {
9
+ ghostClass: string;
10
+ className: string;
11
+ handle: string;
12
+ filter: string;
13
+ animation: number;
14
+ forceFallback: boolean;
15
+ };
16
+ export declare const DEFAULT_INPUT_PROPS: {
17
+ autoResize: {
18
+ minWidth: string;
19
+ stretchToFit: boolean;
20
+ };
21
+ };
@@ -0,0 +1,21 @@
1
+ export var DEFAULT_FIELD = '';
2
+ export var DEFAULT_CONDITION = '';
3
+ export var DEFAULT_STEP = '';
4
+ export var OPERATOR = 'operator';
5
+ export var PARAMETER = 'parameter';
6
+ export var FACTOR = 'factor';
7
+ export var SUBJECT = 'subject';
8
+ export var SORTABLE_CONFIG = {
9
+ ghostClass: 'steps-list-ghost-element',
10
+ className: 'steps-list',
11
+ handle: '.step-drag-handler',
12
+ filter: '.ds-condition-step-name, .ds-cruds',
13
+ animation: 150,
14
+ forceFallback: true
15
+ };
16
+ export var DEFAULT_INPUT_PROPS = {
17
+ autoResize: {
18
+ minWidth: '173px',
19
+ stretchToFit: true
20
+ }
21
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-condition",
3
- "version": "0.21.11",
3
+ "version": "0.22.0",
4
4
  "description": "Condition UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -33,17 +33,18 @@
33
33
  ],
34
34
  "types": "dist/index.d.ts",
35
35
  "dependencies": {
36
- "@synerise/ds-button": "^0.19.2",
37
- "@synerise/ds-context-selector": "^0.20.8",
36
+ "@synerise/ds-button": "^0.19.3",
37
+ "@synerise/ds-context-selector": "^0.21.0",
38
38
  "@synerise/ds-core": "^0.40.12",
39
- "@synerise/ds-cruds": "^0.4.6",
40
- "@synerise/ds-factors": "^0.21.8",
41
- "@synerise/ds-icon": "^0.60.2",
42
- "@synerise/ds-inline-edit": "^0.6.98",
43
- "@synerise/ds-operators": "^0.10.57",
44
- "@synerise/ds-subject": "^0.9.85",
45
- "@synerise/ds-tooltip": "^0.14.19",
46
- "@synerise/ds-utils": "^0.24.26",
39
+ "@synerise/ds-cruds": "^0.4.7",
40
+ "@synerise/ds-factors": "^0.22.0",
41
+ "@synerise/ds-icon": "^0.60.3",
42
+ "@synerise/ds-inline-edit": "^0.6.99",
43
+ "@synerise/ds-input": "^0.20.0",
44
+ "@synerise/ds-operators": "^0.10.58",
45
+ "@synerise/ds-subject": "^0.9.86",
46
+ "@synerise/ds-tooltip": "^0.14.20",
47
+ "@synerise/ds-utils": "^0.25.0",
47
48
  "lodash": "^4.17.19",
48
49
  "react-intl": "3.12.0",
49
50
  "react-sortablejs": "^6.0.0",
@@ -58,5 +59,5 @@
58
59
  "@testing-library/jest-dom": "5.1.1",
59
60
  "@testing-library/react": "10.0.1"
60
61
  },
61
- "gitHead": "d249737414ed45f95fa21a77e30f47f0eb14d534"
62
+ "gitHead": "6b8da853a2bb4e993d89e9b0b3041216f0c9c976"
62
63
  }