@synerise/ds-filter 0.8.0 → 0.9.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,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.9.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-filter@0.8.0...@synerise/ds-filter@0.9.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
+
13
+
14
+ ### Features
15
+
16
+ * **condition:** adds defaultOpenedComponent prop ([6b6721d](https://github.com/Synerise/synerise-design/commit/6b6721dbd12be7e744100d303a5d3d7823467c3b))
17
+
18
+
19
+
20
+
21
+
6
22
  # [0.8.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-filter@0.7.1...@synerise/ds-filter@0.8.0) (2022-04-29)
7
23
 
8
24
 
package/dist/Filter.js CHANGED
@@ -13,6 +13,7 @@ import Matching from '@synerise/ds-logic/dist/Matching/Matching';
13
13
  import Placeholder from '@synerise/ds-logic/dist/Placeholder/Placeholder';
14
14
  import StepCard from '@synerise/ds-step-card';
15
15
  import { useIntl } from 'react-intl';
16
+ import { usePrevious } from '@synerise/ds-utils';
16
17
  import * as S from './Filter.styles';
17
18
  import { MatchingWrapper } from './Filter.styles';
18
19
  var SORTABLE_CONFIG = {
@@ -41,11 +42,18 @@ var Filter = function Filter(_ref) {
41
42
  renderStepContent = _ref.renderStepContent,
42
43
  addFilterComponent = _ref.addFilterComponent,
43
44
  texts = _ref.texts;
45
+ var previousExpressions = usePrevious(expressions);
44
46
 
45
47
  var _React$useState = React.useState(null),
46
48
  activeExpressionId = _React$useState[0],
47
49
  setActiveExpressionId = _React$useState[1];
48
50
 
51
+ React.useEffect(function () {
52
+ if (previousExpressions && expressions.length > previousExpressions.length) {
53
+ setActiveExpressionId(expressions[expressions.length - 1].id);
54
+ }
55
+ }, [expressions, previousExpressions]);
56
+
49
57
  var _useIntl = useIntl(),
50
58
  formatMessage = _useIntl.formatMessage;
51
59
 
@@ -128,6 +136,9 @@ var Filter = function Filter(_ref) {
128
136
  conditionType: contextType === 'attribute' ? text.step.attribute : text.step.event
129
137
  };
130
138
  }, [text]);
139
+ var isActive = React.useCallback(function (expression) {
140
+ return expression.id === activeExpressionId;
141
+ }, [activeExpressionId]);
131
142
  var componentProps = React.useCallback(function (expression) {
132
143
  var contextTypeTexts = getContextTypeTexts(expression);
133
144
  var props = {
@@ -150,12 +161,12 @@ var Filter = function Filter(_ref) {
150
161
  return onDuplicateStep(expression.id);
151
162
  },
152
163
  footer: renderStepFooter && renderStepFooter(expression),
153
- children: renderStepContent && renderStepContent(expression),
164
+ children: renderStepContent && renderStepContent(expression, !!activeExpressionId && !isActive(expression)),
154
165
  texts: _objectSpread({}, text.step, {}, contextTypeTexts)
155
166
  }
156
167
  };
157
168
  return props[expression.type];
158
- }, [getContextTypeTexts, onChangeLogic, onChangeStepMatching, onChangeStepName, onDeleteStep, onDuplicateStep, renderStepContent, renderStepFooter, text.step]);
169
+ }, [activeExpressionId, getContextTypeTexts, isActive, onChangeLogic, onChangeStepMatching, onChangeStepName, onDeleteStep, onDuplicateStep, renderStepContent, renderStepFooter, text.step]);
159
170
  var renderExpression = React.useCallback(function (expression, index) {
160
171
  var Component = component[expression.type];
161
172
  var LogicComponent = expression.logic && component[expression.logic.type];
@@ -163,14 +174,14 @@ var Filter = function Filter(_ref) {
163
174
  key: expression.id,
164
175
  "data-dropLabel": text.dropMeHere,
165
176
  index: index,
166
- style: expression.id === activeExpressionId ? {
177
+ style: isActive(expression) ? {
167
178
  zIndex: 10001
168
179
  } : undefined,
169
180
  onClick: function onClick() {
170
181
  return setActiveExpressionId(expression.id);
171
182
  }
172
183
  }, /*#__PURE__*/React.createElement(Component, _extends({}, expression.data, componentProps(expression))), expression.logic && index + 1 < expressions.length && /*#__PURE__*/React.createElement(S.LogicWrapper, null, /*#__PURE__*/React.createElement(LogicComponent, _extends({}, expression.logic.data, componentProps(expression.logic)))));
173
- }, [componentProps, expressions.length, activeExpressionId, text]);
184
+ }, [text.dropMeHere, isActive, componentProps, expressions.length]);
174
185
  return /*#__PURE__*/React.createElement(S.FilterWrapper, null, matching && /*#__PURE__*/React.createElement(MatchingWrapper, null, /*#__PURE__*/React.createElement(Matching, _extends({}, matching, {
175
186
  texts: text.matching
176
187
  }))), /*#__PURE__*/React.createElement(React.Fragment, null, expressions.length > 0 ? /*#__PURE__*/React.createElement(ReactSortable, _extends({}, SORTABLE_CONFIG, {
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { LogicOperatorValue, LogicProps } from '@synerise/ds-logic/src/Logic.types';
3
- import { StepCardProps, StepCardTexts } from '@synerise/ds-step-card/src/StepCard.types';
3
+ import { StepCardProps } from '@synerise/ds-step-card/src/StepCard.types';
4
4
  import { MatchingProps, MatchingTexts } from '@synerise/ds-logic/src/Matching/Matching.types';
5
5
  declare type LogicType = {
6
6
  type: 'LOGIC';
@@ -25,11 +25,24 @@ export declare type FilterProps = {
25
25
  onDeleteStep: (id: string) => void;
26
26
  onDuplicateStep: (id: string) => void;
27
27
  renderStepFooter?: (expression: Expression) => React.ReactNode;
28
- renderStepContent?: (expression: Expression) => React.ReactNode;
28
+ renderStepContent?: (expression: Expression, hoverDisabled?: boolean) => React.ReactNode;
29
29
  addFilterComponent?: React.ReactNode;
30
30
  texts?: {
31
31
  matching?: MatchingTexts;
32
- step?: StepCardTexts;
32
+ step?: {
33
+ matching?: string;
34
+ notMatching?: string;
35
+ have?: string;
36
+ performed?: string;
37
+ notHave?: string;
38
+ notPerformed?: string;
39
+ attribute?: string;
40
+ event?: string;
41
+ namePlaceholder?: string;
42
+ moveTooltip?: string;
43
+ deleteTooltip?: string;
44
+ duplicateTooltip?: string;
45
+ };
33
46
  addFilter?: string;
34
47
  dropMeHere?: string;
35
48
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-filter",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Filter UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -43,5 +43,5 @@
43
43
  "@synerise/ds-step-card": "*",
44
44
  "react": ">=16.9.0 < 17.0.0"
45
45
  },
46
- "gitHead": "4a658911645846d1e329609ba9db06a7bc64962b"
46
+ "gitHead": "25e5737ebe9d4319de963b369bc281651872887c"
47
47
  }