@synerise/ds-condition 0.15.1 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,23 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.16.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.15.1...@synerise/ds-condition@0.16.0) (2022-05-13)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **condition:** disabling hover effect on nonactive condition in filter ([228f242](https://github.com/Synerise/synerise-design/commit/228f242e6ce244c73e9da93adb2c4317cd65ec91))
12
+ * **condition:** fixes styles of dragged condition with opened dropdown ([0449e94](https://github.com/Synerise/synerise-design/commit/0449e948dc598974c81e7f857431c519c5fa2666))
13
+
14
+
15
+ ### Features
16
+
17
+ * **condition:** adds defaultOpenedComponent prop ([6b6721d](https://github.com/Synerise/synerise-design/commit/6b6721dbd12be7e744100d303a5d3d7823467c3b))
18
+
19
+
20
+
21
+
22
+
6
23
  ## [0.15.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-condition@0.15.0...@synerise/ds-condition@0.15.1) (2022-04-29)
7
24
 
8
25
  **Note:** Version bump only for package @synerise/ds-condition
package/README.md CHANGED
@@ -123,6 +123,7 @@ import Condition from '@synerise/ds-condition'
123
123
  | onChangeFactorType | Callback called when user change type of condition factor | (stepId: React.ReactText, conditionId: React.ReactText, value: FactorType \ undefined) => void | - |
124
124
  | onUpdateStepName | Callback called when user change the name of step condition | (stepId: React.ReactText, value: string) => void | - |
125
125
  | getPopupContainerOverride | Popup container function for child tooltips and dropdowns | (trigger: HTMLElement | null) => HTMLElement; | - |
126
+ | defaultOpenedComponent | Component which should be opened after render | 'subject' \ 'operator' \ 'factor' \ 'parameter' \ 'context' | - |
126
127
 
127
128
  ### ConditionStep
128
129
 
package/dist/Condition.js CHANGED
@@ -53,7 +53,10 @@ var Condition = function Condition(props) {
53
53
  onChangeFactorValue = props.onChangeFactorValue,
54
54
  onUpdateStepName = props.onUpdateStepName,
55
55
  getPopupContainerOverride = props.getPopupContainerOverride,
56
- showSuffix = props.showSuffix;
56
+ showSuffix = props.showSuffix,
57
+ hoverDisabled = props.hoverDisabled,
58
+ _props$autoOpenedComp = props.autoOpenedComponent,
59
+ autoOpenedComponent = _props$autoOpenedComp === void 0 ? DEFAULT_FIELD : _props$autoOpenedComp;
57
60
 
58
61
  var _useIntl = useIntl(),
59
62
  formatMessage = _useIntl.formatMessage;
@@ -79,11 +82,19 @@ var Condition = function Condition(props) {
79
82
  currentStepId = _React$useState2[0],
80
83
  setCurrentStepId = _React$useState2[1];
81
84
 
82
- var _React$useState3 = React.useState(DEFAULT_FIELD),
85
+ var _React$useState3 = React.useState(autoOpenedComponent),
83
86
  currentField = _React$useState3[0],
84
87
  setCurrentField = _React$useState3[1];
85
88
 
86
89
  var prevSteps = usePrevious(steps);
90
+ React.useEffect(function () {
91
+ if (autoOpenedComponent && steps.length && steps[0].conditions[0].operator && steps[0].conditions[0].operator.value === undefined) {
92
+ setCurrentStepId(steps[0].id);
93
+ setCurrentConditionId(steps[0].conditions[0].id);
94
+ setCurrentField(autoOpenedComponent);
95
+ } // eslint-disable-next-line react-hooks/exhaustive-deps
96
+
97
+ }, []);
87
98
  React.useEffect(function () {
88
99
  var newConditionId = prevSteps && steps && steps.reduce(function (id, step) {
89
100
  var result = id;
@@ -257,7 +268,8 @@ var Condition = function Condition(props) {
257
268
  setCurrentCondition: setCurrentConditionId,
258
269
  setCurrentStep: setCurrentStepId,
259
270
  onDeactivate: handleClearActiveCondition,
260
- showSuffix: showSuffix
271
+ showSuffix: showSuffix,
272
+ hoverDisabled: hoverDisabled || currentStepId !== step.id && currentStepId !== undefined
261
273
  });
262
274
  })), addStep && /*#__PURE__*/React.createElement(S.AddStepButton, null, /*#__PURE__*/React.createElement(Button, {
263
275
  type: "ghost",
@@ -266,7 +278,7 @@ var Condition = function Condition(props) {
266
278
  }, /*#__PURE__*/React.createElement(Icon, {
267
279
  component: /*#__PURE__*/React.createElement(Add3M, null)
268
280
  }), text.addStep)), renderAddStep && /*#__PURE__*/React.createElement(S.AddStepButton, null, renderAddStep()));
269
- }, [steps, onChangeOrder, addStep, handleAddStep, text, renderAddStep, currentStepId, getPopupContainerOverride, draggableEnabled, selectOperator, selectParameter, selectContext, selectSubject, onUpdateStepName, duplicateStep, removeStep, minConditionsLength, maxConditionsLength, setStepConditionFactorType, setStepConditionFactorValue, currentConditionId, currentField, removeCondition, handleAddCondition, handleClearActiveCondition, showSuffix]);
281
+ }, [steps, onChangeOrder, addStep, handleAddStep, text, renderAddStep, currentStepId, getPopupContainerOverride, draggableEnabled, selectOperator, selectParameter, selectContext, selectSubject, onUpdateStepName, duplicateStep, removeStep, minConditionsLength, maxConditionsLength, setStepConditionFactorType, setStepConditionFactorValue, currentConditionId, currentField, removeCondition, handleAddCondition, handleClearActiveCondition, showSuffix, hoverDisabled]);
270
282
  };
271
283
 
272
284
  export default Condition;
@@ -16,6 +16,7 @@ export declare const DraggedLabel: import("styled-components").StyledComponent<"
16
16
  export declare const Step: import("styled-components").StyledComponent<"div", any, {
17
17
  active: boolean;
18
18
  showSuffix: boolean | undefined;
19
+ hoverDisabled?: boolean | undefined;
19
20
  }, never>;
20
21
  export declare const ConditionWrapper: import("styled-components").StyledComponent<"div", any, {
21
22
  fullWidth?: boolean | undefined;
@@ -55,12 +55,12 @@ export var DraggedLabel = styled.span.withConfig({
55
55
  export var Step = styled.div.withConfig({
56
56
  displayName: "Conditionstyle__Step",
57
57
  componentId: "sc-1lk06p3-11"
58
- })(["display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;padding:12px 0 12px;position:relative;", " &:first-of-type{&.steps-list-ghost-element{&:after{display:none;}}}background-color:", ";&:hover{background-color:", ";", "{opacity:1;visibility:visible;}", "{opacity:1;visibility:visible;}", "{opacity:1;visibility:visible;}}&.sortable-chosen{cursor:grabbing;width:100%;opacity:1 !important;height:50px;background-color:", ";display:flex;align-items:center;justify-content:center;padding:0 20px;box-shadow:0 16px 32px 0 #23293619;&:after{display:none;}", "{align-items:center;}", "{margin:0;", "{display:none;}}", "{display:none;}", "{display:flex;}}&.steps-list-ghost-element{cursor:grabbing;width:100%;background-color:", ";border-left:2px solid ", ";border-radius:0;display:flex;align-items:center;justify-content:center;padding:0;height:50px;box-shadow:none;position:relative;&:before{content:attr(data-dropLabel);text-align:center;position:relative;color:", ";}", "{display:none;}*{display:none;}}}"], function (props) {
58
+ })(["display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;padding:12px 0 12px;position:relative;", " &:first-of-type{&.steps-list-ghost-element{&:after{display:none;}}}background-color:", ";&:hover{background-color:", ";", "{opacity:1;visibility:visible;}", "{opacity:1;visibility:visible;}", "{opacity:1;visibility:visible;}}&.sortable-chosen,&.sortable-drag{cursor:grabbing;width:100%;opacity:1 !important;height:50px;background-color:", ";display:flex;align-items:center;justify-content:center;padding:0 20px;box-shadow:0 16px 32px 0 #23293619;&:after{display:none;}", "{align-items:center;}", "{margin:0;", "{display:none;}}", "{display:none;}", "{display:flex;}}&.steps-list-ghost-element{cursor:grabbing;width:100%;background-color:", ";border-left:2px solid ", ";border-radius:0;display:flex;align-items:center;justify-content:center;padding:0;height:50px;box-shadow:none;position:relative;&:before{content:attr(data-dropLabel);text-align:center;position:relative;color:", ";}", "{display:none;}*{display:none;}&:after{display:none;content:'';}}}"], function (props) {
59
59
  return Boolean(props.showSuffix) && css(["&:after{display:none;width:100%;padding:18px 0 18px 24px;bottom:-18px;content:attr(data-conditionSuffix);background-color:", ";position:relative;font-size:16px;font-weight:500;color:#3f4c5b;}&:first-child:not(:last-child){&:after{display:flex;}}&:not(:last-child){&:after{display:flex;}}"], props.theme.palette.white);
60
60
  }, function (props) {
61
61
  return props.active ? props.theme.palette['grey-050'] : 'transparent';
62
62
  }, function (props) {
63
- return props.theme.palette['grey-050'];
63
+ return props.hoverDisabled ? 'transparent' : props.theme.palette['grey-050'];
64
64
  }, StepCruds, StepConditionCruds, DragIcon, function (props) {
65
65
  return props.theme.palette.white;
66
66
  }, StepHeader, StepName, IconWrapper, StepConditions, DraggedLabel, function (props) {
@@ -51,4 +51,6 @@ export declare type ConditionProps = {
51
51
  onUpdateStepName?: (stepId: React.ReactText, value: string) => void;
52
52
  type?: 'attribute' | 'event';
53
53
  showSuffix?: boolean;
54
+ hoverDisabled?: boolean;
55
+ autoOpenedComponent?: 'subject' | 'operator' | 'factor' | 'parameter' | 'context';
54
56
  };
@@ -47,7 +47,8 @@ export var ConditionStep = function ConditionStep(_ref) {
47
47
  setCurrentCondition = _ref.setCurrentCondition,
48
48
  setCurrentStep = _ref.setCurrentStep,
49
49
  onDeactivate = _ref.onDeactivate,
50
- showSuffix = _ref.showSuffix;
50
+ showSuffix = _ref.showSuffix,
51
+ hoverDisabled = _ref.hoverDisabled;
51
52
 
52
53
  var _useIntl = useIntl(),
53
54
  formatMessage = _useIntl.formatMessage;
@@ -178,6 +179,7 @@ export var ConditionStep = function ConditionStep(_ref) {
178
179
  zIndex: 10001
179
180
  } : undefined,
180
181
  active: step.id === currentStepId && currentField !== '',
182
+ hoverDisabled: hoverDisabled,
181
183
  showSuffix: showSuffix
182
184
  }, !updateStepName && /*#__PURE__*/React.createElement(S.DraggedLabel, null, ((_step$subject2 = step.subject) == null ? void 0 : (_step$subject2$select = _step$subject2.selectedItem) == null ? void 0 : _step$subject2$select.name) || ((_step$context3 = step.context) == null ? void 0 : (_step$context3$select = _step$context3.selectedItem) == null ? void 0 : _step$context3$select.name)), updateStepName && stepHeader, /*#__PURE__*/React.createElement(S.StepConditions, {
183
185
  withoutStepName: updateStepName === undefined
@@ -33,4 +33,5 @@ export declare type ConditionStepProps = {
33
33
  setCurrentStep: (stepId: React.ReactText) => void;
34
34
  onDeactivate: () => void;
35
35
  showSuffix?: boolean;
36
+ hoverDisabled?: boolean;
36
37
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-condition",
3
- "version": "0.15.1",
3
+ "version": "0.16.0",
4
4
  "description": "Condition UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -36,7 +36,7 @@
36
36
  "@synerise/ds-context-selector": "^0.12.1",
37
37
  "@synerise/ds-core": "^0.34.0",
38
38
  "@synerise/ds-cruds": "^0.3.9",
39
- "@synerise/ds-factors": "^0.13.1",
39
+ "@synerise/ds-factors": "^0.13.2",
40
40
  "@synerise/ds-icon": "^0.49.0",
41
41
  "@synerise/ds-inline-edit": "^0.6.12",
42
42
  "@synerise/ds-operators": "^0.9.0",
@@ -49,5 +49,5 @@
49
49
  "@synerise/ds-core": "*",
50
50
  "react": ">=16.9.0 < 17.0.0"
51
51
  },
52
- "gitHead": "21879cf06623fe6e1c2523ebf7c055ab9dbd50ef"
52
+ "gitHead": "25e5737ebe9d4319de963b369bc281651872887c"
53
53
  }