@synerise/ds-filter 0.8.0 → 0.9.2
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 +36 -0
- package/dist/Filter.js +17 -6
- package/dist/Filter.types.d.ts +20 -3
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,42 @@
|
|
|
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.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-filter@0.9.1...@synerise/ds-filter@0.9.2) (2022-06-20)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **filter:** adds ability to override default translation ([ea9d27c](https://github.com/Synerise/synerise-design/commit/ea9d27c018678539a5b835273b8110175334d51b))
|
|
12
|
+
* **filter:** update text prop types ([663e4f9](https://github.com/Synerise/synerise-design/commit/663e4f9ecd327e5414f8424d43711dc2c3f0c563))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [0.9.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-filter@0.9.0...@synerise/ds-filter@0.9.1) (2022-06-15)
|
|
19
|
+
|
|
20
|
+
**Note:** Version bump only for package @synerise/ds-filter
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# [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)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Bug Fixes
|
|
30
|
+
|
|
31
|
+
* **condition:** disabling hover effect on nonactive condition in filter ([228f242](https://github.com/Synerise/synerise-design/commit/228f242e6ce244c73e9da93adb2c4317cd65ec91))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Features
|
|
35
|
+
|
|
36
|
+
* **condition:** adds defaultOpenedComponent prop ([6b6721d](https://github.com/Synerise/synerise-design/commit/6b6721dbd12be7e744100d303a5d3d7823467c3b))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
6
42
|
# [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
43
|
|
|
8
44
|
|
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
|
|
|
@@ -110,14 +118,14 @@ var Filter = function Filter(_ref) {
|
|
|
110
118
|
id: 'DS.STEP-CARD.DUPLICATE'
|
|
111
119
|
})
|
|
112
120
|
}, texts == null ? void 0 : texts.step),
|
|
113
|
-
placeholder: {
|
|
121
|
+
placeholder: _objectSpread({
|
|
114
122
|
chooseCondition: formatMessage({
|
|
115
123
|
id: 'DS.PLACEHOLDER.CHOOSE-CONDITION'
|
|
116
124
|
}),
|
|
117
125
|
getPreview: formatMessage({
|
|
118
126
|
id: 'DS.PLACEHOLDER.GET-PREVIEW'
|
|
119
127
|
})
|
|
120
|
-
}
|
|
128
|
+
}, texts == null ? void 0 : texts.placeholder)
|
|
121
129
|
});
|
|
122
130
|
}, [formatMessage, texts]);
|
|
123
131
|
var getContextTypeTexts = React.useCallback(function (expression) {
|
|
@@ -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
|
|
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
|
|
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, {
|
package/dist/Filter.types.d.ts
CHANGED
|
@@ -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
|
|
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,28 @@ 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?:
|
|
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
|
+
};
|
|
46
|
+
placeholder?: {
|
|
47
|
+
chooseCondition?: string;
|
|
48
|
+
getPreview?: string;
|
|
49
|
+
};
|
|
33
50
|
addFilter?: string;
|
|
34
51
|
dropMeHere?: string;
|
|
35
52
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-filter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Filter UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@synerise/ds-button": "^0.17.2",
|
|
36
36
|
"@synerise/ds-icon": "^0.49.0",
|
|
37
37
|
"@synerise/ds-logic": "^0.7.0",
|
|
38
|
-
"@synerise/ds-step-card": "^0.6.
|
|
38
|
+
"@synerise/ds-step-card": "^0.6.3",
|
|
39
39
|
"react-sortablejs": "^6.0.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"@synerise/ds-step-card": "*",
|
|
44
44
|
"react": ">=16.9.0 < 17.0.0"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "ba00650b327ad60ca34761d45e404695d0666b7f"
|
|
47
47
|
}
|