@synerise/ds-filter 0.7.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 +35 -0
- package/dist/Filter.js +43 -26
- package/dist/Filter.types.d.ts +16 -3
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,41 @@
|
|
|
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
|
+
|
|
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)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* **factors:** adds onDeactivate prop, updates Readme.md ([ff85234](https://github.com/Synerise/synerise-design/commit/ff852349a5c77047d6d0642d4b5587dbcc6d24cd))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## [0.7.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-filter@0.7.0...@synerise/ds-filter@0.7.1) (2022-04-08)
|
|
34
|
+
|
|
35
|
+
**Note:** Version bump only for package @synerise/ds-filter
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
6
41
|
# [0.7.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-filter@0.6.4...@synerise/ds-filter@0.7.0) (2022-04-05)
|
|
7
42
|
|
|
8
43
|
|
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
|
|
|
@@ -73,6 +81,30 @@ var Filter = function Filter(_ref) {
|
|
|
73
81
|
notMatching: formatMessage({
|
|
74
82
|
id: 'DS.MATCHING.NOT-MATCHING'
|
|
75
83
|
}),
|
|
84
|
+
have: formatMessage({
|
|
85
|
+
id: 'DS.MATCHING.HAVE',
|
|
86
|
+
defaultMessage: 'Have'
|
|
87
|
+
}),
|
|
88
|
+
performed: formatMessage({
|
|
89
|
+
id: 'DS.MATCHING.PERFORMED',
|
|
90
|
+
defaultMessage: 'Performed'
|
|
91
|
+
}),
|
|
92
|
+
notHave: formatMessage({
|
|
93
|
+
id: 'DS.MATCHING.NOT-HAVE',
|
|
94
|
+
defaultMessage: 'Does not have'
|
|
95
|
+
}),
|
|
96
|
+
notPerformed: formatMessage({
|
|
97
|
+
id: 'DS.MATCHING.NOT-PERFORMED',
|
|
98
|
+
defaultMessage: 'Have not performed'
|
|
99
|
+
}),
|
|
100
|
+
attribute: formatMessage({
|
|
101
|
+
id: 'DS.MATCHING.EXPRESSION-TYPE.ATTRIBUTE',
|
|
102
|
+
defaultMessage: 'attribute'
|
|
103
|
+
}),
|
|
104
|
+
event: formatMessage({
|
|
105
|
+
id: 'DS.MATCHING.EXPRESSION-TYPE.EVENT',
|
|
106
|
+
defaultMessage: 'event'
|
|
107
|
+
}),
|
|
76
108
|
namePlaceholder: formatMessage({
|
|
77
109
|
id: 'DS.STEP-CARD.NAME-PLACEHOLDER'
|
|
78
110
|
}),
|
|
@@ -99,29 +131,14 @@ var Filter = function Filter(_ref) {
|
|
|
99
131
|
var getContextTypeTexts = React.useCallback(function (expression) {
|
|
100
132
|
var contextType = expression.expressionType;
|
|
101
133
|
return {
|
|
102
|
-
matching: contextType === 'attribute' ?
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}) : formatMessage({
|
|
106
|
-
id: 'DS.MATCHING.PERFORMED',
|
|
107
|
-
defaultMessage: 'Performed'
|
|
108
|
-
}),
|
|
109
|
-
notMatching: contextType === 'attribute' ? formatMessage({
|
|
110
|
-
id: 'DS.MATCHING.NOT-HAVE',
|
|
111
|
-
defaultMessage: 'Not have'
|
|
112
|
-
}) : formatMessage({
|
|
113
|
-
id: 'DS.MATCHING.NOT-PERFORMED',
|
|
114
|
-
defaultMessage: 'Not performed'
|
|
115
|
-
}),
|
|
116
|
-
conditionType: contextType === 'attribute' ? formatMessage({
|
|
117
|
-
id: 'DS.MATCHING.EXPRESSION-TYPE.ATTRIBUTE',
|
|
118
|
-
defaultMessage: 'attribute'
|
|
119
|
-
}) : formatMessage({
|
|
120
|
-
id: 'DS.MATCHING.EXPRESSION-TYPE.EVENT',
|
|
121
|
-
defaultMessage: 'event'
|
|
122
|
-
})
|
|
134
|
+
matching: contextType === 'attribute' ? text.step.have : text.step.performed,
|
|
135
|
+
notMatching: contextType === 'attribute' ? text.step.notHave : text.step.notPerformed,
|
|
136
|
+
conditionType: contextType === 'attribute' ? text.step.attribute : text.step.event
|
|
123
137
|
};
|
|
124
|
-
}, [
|
|
138
|
+
}, [text]);
|
|
139
|
+
var isActive = React.useCallback(function (expression) {
|
|
140
|
+
return expression.id === activeExpressionId;
|
|
141
|
+
}, [activeExpressionId]);
|
|
125
142
|
var componentProps = React.useCallback(function (expression) {
|
|
126
143
|
var contextTypeTexts = getContextTypeTexts(expression);
|
|
127
144
|
var props = {
|
|
@@ -144,12 +161,12 @@ var Filter = function Filter(_ref) {
|
|
|
144
161
|
return onDuplicateStep(expression.id);
|
|
145
162
|
},
|
|
146
163
|
footer: renderStepFooter && renderStepFooter(expression),
|
|
147
|
-
children: renderStepContent && renderStepContent(expression),
|
|
164
|
+
children: renderStepContent && renderStepContent(expression, !!activeExpressionId && !isActive(expression)),
|
|
148
165
|
texts: _objectSpread({}, text.step, {}, contextTypeTexts)
|
|
149
166
|
}
|
|
150
167
|
};
|
|
151
168
|
return props[expression.type];
|
|
152
|
-
}, [getContextTypeTexts, onChangeLogic, onChangeStepMatching, onChangeStepName, onDeleteStep, onDuplicateStep, renderStepContent, renderStepFooter, text.step]);
|
|
169
|
+
}, [activeExpressionId, getContextTypeTexts, isActive, onChangeLogic, onChangeStepMatching, onChangeStepName, onDeleteStep, onDuplicateStep, renderStepContent, renderStepFooter, text.step]);
|
|
153
170
|
var renderExpression = React.useCallback(function (expression, index) {
|
|
154
171
|
var Component = component[expression.type];
|
|
155
172
|
var LogicComponent = expression.logic && component[expression.logic.type];
|
|
@@ -157,14 +174,14 @@ var Filter = function Filter(_ref) {
|
|
|
157
174
|
key: expression.id,
|
|
158
175
|
"data-dropLabel": text.dropMeHere,
|
|
159
176
|
index: index,
|
|
160
|
-
style: expression
|
|
177
|
+
style: isActive(expression) ? {
|
|
161
178
|
zIndex: 10001
|
|
162
179
|
} : undefined,
|
|
163
180
|
onClick: function onClick() {
|
|
164
181
|
return setActiveExpressionId(expression.id);
|
|
165
182
|
}
|
|
166
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)))));
|
|
167
|
-
}, [componentProps, expressions.length
|
|
184
|
+
}, [text.dropMeHere, isActive, componentProps, expressions.length]);
|
|
168
185
|
return /*#__PURE__*/React.createElement(S.FilterWrapper, null, matching && /*#__PURE__*/React.createElement(MatchingWrapper, null, /*#__PURE__*/React.createElement(Matching, _extends({}, matching, {
|
|
169
186
|
texts: text.matching
|
|
170
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,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?:
|
|
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.
|
|
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",
|
|
@@ -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.2",
|
|
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": "25e5737ebe9d4319de963b369bc281651872887c"
|
|
47
47
|
}
|