@blaze-cms/react-page-builder 0.128.0-admin-updates.3 → 0.128.0-admin-updates.7
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 +24 -0
- package/lib/components/Card/Card.js +1 -1
- package/lib/components/Card/Card.js.map +1 -1
- package/lib/components/Card/CardsContainer.js +53 -24
- package/lib/components/Card/CardsContainer.js.map +1 -1
- package/lib/components/Card/CardsRender.js +2 -2
- package/lib/components/Card/CardsRender.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryTypes/ItemDetailsSummary/ItemDetailsSummaryContent.js +3 -1
- package/lib/components/DataSummary/DataSummaryTypes/ItemDetailsSummary/ItemDetailsSummaryContent.js.map +1 -1
- package/lib/components/Image/Image.js +1 -1
- package/lib/components/Image/Image.js.map +1 -1
- package/lib/components/List/components/Full/FullRender.js.map +1 -1
- package/lib/components/List/components/helpers/check-if-should-render-banner.js +27 -5
- package/lib/components/List/components/helpers/check-if-should-render-banner.js.map +1 -1
- package/lib/components/List/components/helpers/index.js +8 -2
- package/lib/components/List/components/helpers/index.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib/components/SearchFilter/components/Checkbox.js +6 -1
- package/lib/components/SearchFilter/components/Checkbox.js.map +1 -1
- package/lib/components/SearchFilter/components/Range.js +9 -5
- package/lib/components/SearchFilter/components/Range.js.map +1 -1
- package/lib/components/SearchFilter/components/Select.js +9 -5
- package/lib/components/SearchFilter/components/Select.js.map +1 -1
- package/lib/components/SearchFilter/components/TextSearch.js +9 -5
- package/lib/components/SearchFilter/components/TextSearch.js.map +1 -1
- package/lib-es/components/Card/Card.js +1 -1
- package/lib-es/components/Card/Card.js.map +1 -1
- package/lib-es/components/Card/CardsContainer.js +59 -35
- package/lib-es/components/Card/CardsContainer.js.map +1 -1
- package/lib-es/components/Card/CardsRender.js +1 -1
- package/lib-es/components/Card/CardsRender.js.map +1 -1
- package/lib-es/components/DataSummary/DataSummaryTypes/ItemDetailsSummary/ItemDetailsSummaryContent.js +3 -1
- package/lib-es/components/DataSummary/DataSummaryTypes/ItemDetailsSummary/ItemDetailsSummaryContent.js.map +1 -1
- package/lib-es/components/Image/Image.js +1 -1
- package/lib-es/components/Image/Image.js.map +1 -1
- package/lib-es/components/List/components/Full/FullRender.js.map +1 -1
- package/lib-es/components/List/components/helpers/check-if-should-render-banner.js +29 -3
- package/lib-es/components/List/components/helpers/check-if-should-render-banner.js.map +1 -1
- package/lib-es/components/List/components/helpers/index.js +3 -2
- package/lib-es/components/List/components/helpers/index.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib-es/components/SearchFilter/components/Checkbox.js +6 -1
- package/lib-es/components/SearchFilter/components/Checkbox.js.map +1 -1
- package/lib-es/components/SearchFilter/components/Range.js +9 -5
- package/lib-es/components/SearchFilter/components/Range.js.map +1 -1
- package/lib-es/components/SearchFilter/components/Select.js +9 -5
- package/lib-es/components/SearchFilter/components/Select.js.map +1 -1
- package/lib-es/components/SearchFilter/components/TextSearch.js +9 -5
- package/lib-es/components/SearchFilter/components/TextSearch.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Card/Card.js +2 -2
- package/src/components/Card/CardsContainer.js +54 -35
- package/src/components/Card/CardsRender.js +9 -7
- package/src/components/DataSummary/DataSummaryTypes/ItemDetailsSummary/ItemDetailsSummaryContent.js +1 -1
- package/src/components/Image/Image.js +1 -1
- package/src/components/List/components/Full/FullRender.js +0 -1
- package/src/components/List/components/helpers/check-if-should-render-banner.js +24 -3
- package/src/components/List/components/helpers/index.js +4 -2
- package/src/components/SearchFilter/SearchFilter/SearchFilter.js +0 -1
- package/src/components/SearchFilter/components/Checkbox.js +4 -0
- package/src/components/SearchFilter/components/Range.js +7 -4
- package/src/components/SearchFilter/components/Select.js +23 -17
- package/src/components/SearchFilter/components/TextSearch.js +30 -26
- package/tests/unit/src/components/Card/__snapshots__/Card.test.js.snap +10 -10
- package/tests/unit/src/components/Card/__snapshots__/CardContainer.test.js.snap +8 -8
- package/tests/unit/src/components/DataSummary/DataSummaryTypes/__snapshots__/ItemDetailsSummary.test.js.snap +24 -4
- package/tests/unit/src/components/List/components/Cards/__snapshots__/CardsRender.test.js.snap +12 -12
- package/tests/unit/src/components/List/components/helpers/check-if-should-render-banner.test.js +59 -28
|
@@ -9,8 +9,9 @@ import Card from './Card';
|
|
|
9
9
|
import { getDynamicGridClasses } from './helpers';
|
|
10
10
|
import { getEntitiesWithBanner, parsePropsToDisplay } from '../../helpers';
|
|
11
11
|
import { getPropsToDisplayModifiers } from '../../utils';
|
|
12
|
+
import { checkIfShouldRenderBanner, checkNewBannerSettings } from '../List/components/helpers';
|
|
12
13
|
|
|
13
|
-
const
|
|
14
|
+
const CardContainer = ({
|
|
14
15
|
cardData,
|
|
15
16
|
gridModifier,
|
|
16
17
|
style,
|
|
@@ -36,14 +37,20 @@ const CardsContainer = ({
|
|
|
36
37
|
titleOverlayModifier,
|
|
37
38
|
...cardProps
|
|
38
39
|
}) => {
|
|
39
|
-
const cardsWithBanners = getEntitiesWithBanner(cardData, cardProps);
|
|
40
40
|
const { itemId } = useContext(MainContext);
|
|
41
|
+
const { banner } = cardProps;
|
|
42
|
+
// TODO: remove this check and all associated code once old banner setup is no longer supported
|
|
43
|
+
const hasNewBannerSettings = checkNewBannerSettings(banner);
|
|
44
|
+
const parsedCardsData = hasNewBannerSettings
|
|
45
|
+
? cardData
|
|
46
|
+
: getEntitiesWithBanner(cardData, cardProps);
|
|
41
47
|
const propsToDisplayModifiers = getPropsToDisplayModifiers(propsToDisplay);
|
|
42
48
|
const dynamicWrapperSizes = enableCarousel
|
|
43
49
|
? ''
|
|
44
50
|
: getDynamicGridClasses('grid', itemsPerRow, designConfig);
|
|
45
|
-
let renderCounter = 0;
|
|
46
51
|
const CardWrapper = enableCarousel ? CarouselWrapper : Wrapper;
|
|
52
|
+
let bannerIndex = 0;
|
|
53
|
+
const bannerProps = banner ? { ...cardProps, ...banner, type: 'banner' } : null;
|
|
47
54
|
|
|
48
55
|
return (
|
|
49
56
|
<CardWrapper
|
|
@@ -53,13 +60,48 @@ const CardsContainer = ({
|
|
|
53
60
|
bannerModifier={bannerModifier}
|
|
54
61
|
enableAutoScroll={enableAutoScroll}
|
|
55
62
|
autoScrollTimer={autoScrollTimer}>
|
|
56
|
-
{
|
|
63
|
+
{parsedCardsData.map((currentEntity, index) => {
|
|
64
|
+
const { baseAdunit, id, ...entityProps } = currentEntity;
|
|
65
|
+
const shouldRenderBanner = !!bannerProps && checkIfShouldRenderBanner(index, banner);
|
|
57
66
|
const extraProps = parsePropsToDisplay(entityProps, propsToDisplay);
|
|
58
67
|
const dynamicKey = [itemId, index].join('-');
|
|
59
|
-
if (baseAdunit) renderCounter += 1;
|
|
60
|
-
|
|
61
68
|
const priority = priorityLimit > 0 && index + 1 <= priorityLimit;
|
|
69
|
+
if (hasNewBannerSettings && shouldRenderBanner) bannerIndex += 1;
|
|
70
|
+
if (!hasNewBannerSettings && baseAdunit) bannerIndex += 1;
|
|
71
|
+
const parsedCardProps = {
|
|
72
|
+
key: id,
|
|
73
|
+
id,
|
|
74
|
+
enableCarousel,
|
|
75
|
+
graphqlEntityMap,
|
|
76
|
+
propsToDisplay,
|
|
77
|
+
parsedPropsToDisplay: extraProps,
|
|
78
|
+
propsToDisplayModifiers,
|
|
79
|
+
modifier,
|
|
80
|
+
style,
|
|
81
|
+
cardChildren,
|
|
82
|
+
gtmChildren,
|
|
83
|
+
gtmId: name,
|
|
84
|
+
gridModifier,
|
|
85
|
+
entityProps,
|
|
86
|
+
displayCategory,
|
|
87
|
+
displayThumbnail,
|
|
88
|
+
displayTitle,
|
|
89
|
+
priority,
|
|
90
|
+
enableOverlay,
|
|
91
|
+
overlayModifier,
|
|
92
|
+
titleOverlayModifier,
|
|
93
|
+
...entityProps
|
|
94
|
+
};
|
|
62
95
|
|
|
96
|
+
if (hasNewBannerSettings)
|
|
97
|
+
return (
|
|
98
|
+
<>
|
|
99
|
+
<Card key={id} {...parsedCardProps} />
|
|
100
|
+
{shouldRenderBanner && (
|
|
101
|
+
<Banner key={dynamicKey} {...bannerProps} renderCounter={bannerIndex} />
|
|
102
|
+
)}
|
|
103
|
+
</>
|
|
104
|
+
);
|
|
63
105
|
return baseAdunit ? (
|
|
64
106
|
<Banner
|
|
65
107
|
key={dynamicKey}
|
|
@@ -67,44 +109,21 @@ const CardsContainer = ({
|
|
|
67
109
|
baseAdunit={baseAdunit}
|
|
68
110
|
{...entityProps}
|
|
69
111
|
modifier={modifier}
|
|
70
|
-
renderCounter={
|
|
112
|
+
renderCounter={bannerIndex}
|
|
71
113
|
/>
|
|
72
114
|
) : (
|
|
73
|
-
<Card
|
|
74
|
-
key={id}
|
|
75
|
-
id={id}
|
|
76
|
-
enableCarousel={enableCarousel}
|
|
77
|
-
graphqlEntityMap={graphqlEntityMap}
|
|
78
|
-
propsToDisplay={propsToDisplay}
|
|
79
|
-
parsedPropsToDisplay={extraProps}
|
|
80
|
-
propsToDisplayModifiers={propsToDisplayModifiers}
|
|
81
|
-
modifier={modifier}
|
|
82
|
-
style={style}
|
|
83
|
-
cardChildren={cardChildren}
|
|
84
|
-
gtmChildren={gtmChildren}
|
|
85
|
-
gtmId={name}
|
|
86
|
-
gridModifier={gridModifier}
|
|
87
|
-
entityProps={entityProps}
|
|
88
|
-
displayCategory={displayCategory}
|
|
89
|
-
displayThumbnail={displayThumbnail}
|
|
90
|
-
displayTitle={displayTitle}
|
|
91
|
-
priority={priority}
|
|
92
|
-
enableOverlay={enableOverlay}
|
|
93
|
-
overlayModifier={overlayModifier}
|
|
94
|
-
titleOverlayModifier={titleOverlayModifier}
|
|
95
|
-
{...entityProps}
|
|
96
|
-
/>
|
|
115
|
+
<Card key={id} {...parsedCardProps} />
|
|
97
116
|
);
|
|
98
117
|
})}
|
|
99
118
|
</CardWrapper>
|
|
100
119
|
);
|
|
101
120
|
};
|
|
102
121
|
|
|
103
|
-
|
|
122
|
+
CardContainer.propTypes = {
|
|
104
123
|
cardData: PropTypes.array.isRequired,
|
|
124
|
+
graphqlEntityMap: PropTypes.object.isRequired,
|
|
105
125
|
name: PropTypes.string,
|
|
106
126
|
entity: PropTypes.string.isRequired,
|
|
107
|
-
graphqlEntityMap: PropTypes.object.isRequired,
|
|
108
127
|
gridModifier: PropTypes.string,
|
|
109
128
|
gtmChildren: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
110
129
|
cardChildren: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
@@ -126,7 +145,7 @@ CardsContainer.propTypes = {
|
|
|
126
145
|
autoScrollTimer: PropTypes.number
|
|
127
146
|
};
|
|
128
147
|
|
|
129
|
-
|
|
148
|
+
CardContainer.defaultProps = {
|
|
130
149
|
gtmChildren: [],
|
|
131
150
|
cardChildren: [],
|
|
132
151
|
name: '',
|
|
@@ -149,4 +168,4 @@ CardsContainer.defaultProps = {
|
|
|
149
168
|
titleOverlayModifier: ''
|
|
150
169
|
};
|
|
151
170
|
|
|
152
|
-
export default withTitle(
|
|
171
|
+
export default withTitle(CardContainer);
|
|
@@ -95,13 +95,14 @@ const CardsRender = ({
|
|
|
95
95
|
isPreview,
|
|
96
96
|
itemEntityUpdated: unpublishedParentEntityName
|
|
97
97
|
});
|
|
98
|
-
const {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
98
|
+
const {
|
|
99
|
+
data: { entityData: parentEntityData = {} } = {},
|
|
100
|
+
error: _err,
|
|
101
|
+
loading: _load
|
|
102
|
+
} = useQuery(generateSingleItemQuery(getAction, queryProps), {
|
|
103
|
+
variables: { id: parentId },
|
|
104
|
+
skip: shouldSkipSingleQuery(_loading, getAction, queryProps)
|
|
105
|
+
});
|
|
105
106
|
|
|
106
107
|
const {
|
|
107
108
|
data: requiredSchema = {},
|
|
@@ -138,6 +139,7 @@ const CardsRender = ({
|
|
|
138
139
|
fetchPolicy: useRandomSort ? 'cache-and-network' : 'cache-first',
|
|
139
140
|
skip: shouldReturn(!updatedFilterBy, _loading, _load, schemaLoading, _error, _err, schemaError)
|
|
140
141
|
});
|
|
142
|
+
|
|
141
143
|
const imageIds = itemsToDisplay.map(({ imageId }) => imageId).filter(Boolean);
|
|
142
144
|
const { data: imagesData, loading: imagesLoading } = useGetImages(imageIds, true);
|
|
143
145
|
const isLoading = shouldReturn(_loading, _load, schemaLoading, cardsLoading, imagesLoading);
|
|
@@ -78,7 +78,7 @@ const Image = ({
|
|
|
78
78
|
|
|
79
79
|
return (
|
|
80
80
|
<Wrapper ref={outerRef} className={wrapperClassName} modifiers={modifiers} {...otherProps}>
|
|
81
|
-
{elementTitle && <
|
|
81
|
+
{elementTitle && <div className="heading heading--section">{elementTitle}</div>}
|
|
82
82
|
{shouldDisplayImage && (
|
|
83
83
|
<ImgWrapper {...imgWrapperProps}>
|
|
84
84
|
<ImageRender
|
|
@@ -17,7 +17,6 @@ const FullRender = ({ orderedListData, omitWrappers, paginationType, ...props })
|
|
|
17
17
|
? { hasBanner, parent, entity, propsToDisplay, ...banner, type: BANNER }
|
|
18
18
|
: null;
|
|
19
19
|
let bannerIndex = 0;
|
|
20
|
-
|
|
21
20
|
const WrapperToUse = omitWrappers ? Fragment : Wrapper;
|
|
22
21
|
|
|
23
22
|
return (
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
const
|
|
2
|
-
if (!banner) return false;
|
|
1
|
+
const legacyCheckIfShouldRenderBanner = (elementIndex, banner) => {
|
|
3
2
|
const { interval, repeat, hasBanner } = banner;
|
|
4
3
|
if (!hasBanner || !interval) return false;
|
|
5
4
|
const position = elementIndex + 1;
|
|
@@ -8,5 +7,27 @@ const checkIfShouldRenderBanner = (elementIndex, banner) => {
|
|
|
8
7
|
if (repeat && repeatMatch) return true;
|
|
9
8
|
return false;
|
|
10
9
|
};
|
|
10
|
+
const checkNewBannerSettings = banner => {
|
|
11
|
+
if (!banner) return false;
|
|
12
|
+
|
|
13
|
+
const { repeatEvery, startingPoint, maxRepetitions } = banner;
|
|
14
|
+
return repeatEvery > 0 || startingPoint > 0 || maxRepetitions > 0;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const checkIfShouldRenderBanner = (elementIndex, banner) => {
|
|
18
|
+
if (!banner) return false;
|
|
19
|
+
if (!checkNewBannerSettings(banner)) return legacyCheckIfShouldRenderBanner(elementIndex, banner);
|
|
20
|
+
|
|
21
|
+
const { repeatEvery, startingPoint, maxRepetitions } = banner;
|
|
22
|
+
const position = elementIndex + 1;
|
|
23
|
+
if (position < startingPoint) return false;
|
|
24
|
+
if (position === startingPoint) return true;
|
|
25
|
+
const positionDifference = position - startingPoint;
|
|
26
|
+
if (positionDifference < repeatEvery) return false;
|
|
27
|
+
const timesRepeated = positionDifference / repeatEvery;
|
|
28
|
+
const repeatMatch = Number.isInteger(timesRepeated);
|
|
29
|
+
if (!repeatMatch) return false;
|
|
30
|
+
return timesRepeated < maxRepetitions;
|
|
31
|
+
};
|
|
11
32
|
|
|
12
|
-
export
|
|
33
|
+
export { checkIfShouldRenderBanner, checkNewBannerSettings };
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { checkIfShouldRenderBanner, checkNewBannerSettings } from './check-if-should-render-banner';
|
|
2
|
+
import checkIfShouldRenderGtm from './check-if-should-render-gtm';
|
|
3
|
+
|
|
4
|
+
export { checkIfShouldRenderBanner, checkNewBannerSettings, checkIfShouldRenderGtm };
|
|
@@ -13,6 +13,7 @@ const Checkbox = ({
|
|
|
13
13
|
updateFilterValues,
|
|
14
14
|
filterValues,
|
|
15
15
|
label,
|
|
16
|
+
elementTitle,
|
|
16
17
|
shouldSearch,
|
|
17
18
|
displayFilterCount
|
|
18
19
|
}) => {
|
|
@@ -68,6 +69,7 @@ const Checkbox = ({
|
|
|
68
69
|
|
|
69
70
|
return (
|
|
70
71
|
<>
|
|
72
|
+
{elementTitle && <div className="heading heading--section">{elementTitle}</div>}
|
|
71
73
|
{label ? <p>{label}</p> : ''}
|
|
72
74
|
<Checkboxes
|
|
73
75
|
className="form-checkbox"
|
|
@@ -109,12 +111,14 @@ Checkbox.propTypes = {
|
|
|
109
111
|
updateFilterValues: PropTypes.func.isRequired,
|
|
110
112
|
shouldSearch: PropTypes.bool,
|
|
111
113
|
label: PropTypes.string,
|
|
114
|
+
elementTitle: PropTypes.string,
|
|
112
115
|
displayFilterCount: PropTypes.bool
|
|
113
116
|
};
|
|
114
117
|
|
|
115
118
|
Checkbox.defaultProps = {
|
|
116
119
|
shouldSearch: false,
|
|
117
120
|
label: '',
|
|
121
|
+
elementTitle: '',
|
|
118
122
|
displayFilterCount: false
|
|
119
123
|
};
|
|
120
124
|
|
|
@@ -6,7 +6,6 @@ import { useRouter } from 'next/router';
|
|
|
6
6
|
import Select from '@blaze-react/select';
|
|
7
7
|
import { parseUrl } from 'query-string';
|
|
8
8
|
import { useGetSingleEntitySchema } from '../../../hooks';
|
|
9
|
-
import { withTitle } from '../../../HOC';
|
|
10
9
|
import { getSelectOptions, getIntersectedProp, getRangeValue, calculateMinMax } from '../helpers';
|
|
11
10
|
import { decodeValue } from '../helpers/decode-encode';
|
|
12
11
|
|
|
@@ -18,7 +17,8 @@ const Range = ({
|
|
|
18
17
|
dataAggregations,
|
|
19
18
|
updateFilterValues,
|
|
20
19
|
filterValues,
|
|
21
|
-
shouldSearch
|
|
20
|
+
shouldSearch,
|
|
21
|
+
elementTitle
|
|
22
22
|
}) => {
|
|
23
23
|
const router = useRouter();
|
|
24
24
|
const debounceAmount = shouldSearch ? 1200 : 400;
|
|
@@ -50,6 +50,7 @@ const Range = ({
|
|
|
50
50
|
|
|
51
51
|
return (
|
|
52
52
|
<>
|
|
53
|
+
{elementTitle && <div className="heading heading--section">{elementTitle}</div>}
|
|
53
54
|
{hasMultipleOptions && (
|
|
54
55
|
<>
|
|
55
56
|
<label>{label}</label>
|
|
@@ -93,13 +94,15 @@ Range.propTypes = {
|
|
|
93
94
|
shouldSearch: PropTypes.bool,
|
|
94
95
|
rangeInterval: PropTypes.number,
|
|
95
96
|
label: PropTypes.string,
|
|
97
|
+
elementTitle: PropTypes.string,
|
|
96
98
|
dataAggregations: PropTypes.object.isRequired
|
|
97
99
|
};
|
|
98
100
|
|
|
99
101
|
Range.defaultProps = {
|
|
100
102
|
shouldSearch: false,
|
|
101
103
|
rangeInterval: 1,
|
|
102
|
-
label: ''
|
|
104
|
+
label: '',
|
|
105
|
+
elementTitle: ''
|
|
103
106
|
};
|
|
104
107
|
|
|
105
|
-
export default
|
|
108
|
+
export default Range;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import Select from '@blaze-react/select';
|
|
4
|
-
import { withTitle } from '../../../HOC';
|
|
5
4
|
import { DEFAULT_OPTION } from '../constants';
|
|
6
5
|
|
|
7
6
|
const SelectFilter = ({
|
|
@@ -12,7 +11,8 @@ const SelectFilter = ({
|
|
|
12
11
|
filterValues,
|
|
13
12
|
shouldSearch,
|
|
14
13
|
displayLabelAsPlaceholder,
|
|
15
|
-
displayFilterCount
|
|
14
|
+
displayFilterCount,
|
|
15
|
+
elementTitle
|
|
16
16
|
}) => {
|
|
17
17
|
const filterValue = filterValues[prop] || '';
|
|
18
18
|
const disabledOptions = [];
|
|
@@ -35,20 +35,23 @@ const SelectFilter = ({
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
return (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
38
|
+
<>
|
|
39
|
+
{elementTitle && <div className="heading heading--section">{elementTitle}</div>}
|
|
40
|
+
<Select
|
|
41
|
+
label={labelToUse}
|
|
42
|
+
value={filterValue}
|
|
43
|
+
id={prop}
|
|
44
|
+
data-testid={`filter-${prop}`}
|
|
45
|
+
options={options}
|
|
46
|
+
defaultTextValue={defaultTextValue}
|
|
47
|
+
onChange={({ value }) => {
|
|
48
|
+
let valueToUse = value;
|
|
49
|
+
if (value === defaultTextValue) valueToUse = '';
|
|
50
|
+
updateFilterValues({ [prop]: valueToUse }, shouldSearch);
|
|
51
|
+
}}
|
|
52
|
+
disabled={disabledOptions}
|
|
53
|
+
/>
|
|
54
|
+
</>
|
|
52
55
|
);
|
|
53
56
|
};
|
|
54
57
|
|
|
@@ -59,6 +62,8 @@ SelectFilter.propTypes = {
|
|
|
59
62
|
updateFilterValues: PropTypes.func.isRequired,
|
|
60
63
|
shouldSearch: PropTypes.bool,
|
|
61
64
|
label: PropTypes.string,
|
|
65
|
+
elementTitle: PropTypes.string,
|
|
66
|
+
|
|
62
67
|
displayLabelAsPlaceholder: PropTypes.bool,
|
|
63
68
|
displayFilterCount: PropTypes.bool
|
|
64
69
|
};
|
|
@@ -67,8 +72,9 @@ SelectFilter.defaultProps = {
|
|
|
67
72
|
filterValues: {},
|
|
68
73
|
shouldSearch: false,
|
|
69
74
|
label: '',
|
|
75
|
+
elementTitle: '',
|
|
70
76
|
displayLabelAsPlaceholder: false,
|
|
71
77
|
displayFilterCount: false
|
|
72
78
|
};
|
|
73
79
|
|
|
74
|
-
export default
|
|
80
|
+
export default SelectFilter;
|
|
@@ -2,45 +2,49 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import Input from '@blaze-react/input';
|
|
4
4
|
import { MdSearch } from 'react-icons/md';
|
|
5
|
-
import { withTitle } from '../../../HOC';
|
|
6
5
|
import { SEARCH_TERM } from '../constants';
|
|
7
6
|
|
|
8
|
-
const TextSearch = ({ label, searchValue, updateFilterValues }) => (
|
|
9
|
-
|
|
10
|
-
<div className="
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
const TextSearch = ({ label, searchValue, updateFilterValues, elementTitle }) => (
|
|
8
|
+
<>
|
|
9
|
+
{elementTitle && <div className="heading heading--section">{elementTitle}</div>}
|
|
10
|
+
<div className="search">
|
|
11
|
+
<div className="search__wrapper">
|
|
12
|
+
<div className="form-field form-field--input form-field--search">
|
|
13
|
+
<Input
|
|
14
|
+
id={SEARCH_TERM}
|
|
15
|
+
value={searchValue}
|
|
16
|
+
placeholder={label || 'Search'}
|
|
17
|
+
onChange={({ value: eValue }) => {
|
|
18
|
+
updateFilterValues({ [SEARCH_TERM]: eValue }, false);
|
|
19
|
+
}}
|
|
20
|
+
/>
|
|
21
|
+
</div>
|
|
22
|
+
<button
|
|
23
|
+
type="button"
|
|
24
|
+
className="icon-button icon-button--search"
|
|
25
|
+
onClick={e => {
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
updateFilterValues({ [SEARCH_TERM]: searchValue }, true);
|
|
28
|
+
}}>
|
|
29
|
+
<i>
|
|
30
|
+
<MdSearch />
|
|
31
|
+
</i>
|
|
32
|
+
</button>
|
|
20
33
|
</div>
|
|
21
|
-
<button
|
|
22
|
-
type="button"
|
|
23
|
-
className="icon-button icon-button--search"
|
|
24
|
-
onClick={e => {
|
|
25
|
-
e.preventDefault();
|
|
26
|
-
updateFilterValues({ [SEARCH_TERM]: searchValue }, true);
|
|
27
|
-
}}>
|
|
28
|
-
<i>
|
|
29
|
-
<MdSearch />
|
|
30
|
-
</i>
|
|
31
|
-
</button>
|
|
32
34
|
</div>
|
|
33
|
-
|
|
35
|
+
</>
|
|
34
36
|
);
|
|
35
37
|
|
|
36
38
|
TextSearch.propTypes = {
|
|
37
39
|
searchValue: PropTypes.string.isRequired,
|
|
38
40
|
updateFilterValues: PropTypes.func.isRequired,
|
|
41
|
+
elementTitle: PropTypes.string,
|
|
39
42
|
label: PropTypes.string
|
|
40
43
|
};
|
|
41
44
|
|
|
42
45
|
TextSearch.defaultProps = {
|
|
46
|
+
elementTitle: '',
|
|
43
47
|
label: ''
|
|
44
48
|
};
|
|
45
49
|
|
|
46
|
-
export default
|
|
50
|
+
export default TextSearch;
|
|
@@ -30,7 +30,7 @@ exports[`Card component should not render alternative headline if alternativePre
|
|
|
30
30
|
>
|
|
31
31
|
category-name
|
|
32
32
|
</a>
|
|
33
|
-
<
|
|
33
|
+
<div
|
|
34
34
|
class="card__title card__title--portrait "
|
|
35
35
|
>
|
|
36
36
|
<a
|
|
@@ -38,7 +38,7 @@ exports[`Card component should not render alternative headline if alternativePre
|
|
|
38
38
|
>
|
|
39
39
|
mock name
|
|
40
40
|
</a>
|
|
41
|
-
</
|
|
41
|
+
</div>
|
|
42
42
|
<div
|
|
43
43
|
class="card__details card__details--portrait"
|
|
44
44
|
>
|
|
@@ -99,7 +99,7 @@ exports[`Card component should not render alternative headline if displayCategor
|
|
|
99
99
|
<div
|
|
100
100
|
class="card__content card__content--portrait"
|
|
101
101
|
>
|
|
102
|
-
<
|
|
102
|
+
<div
|
|
103
103
|
class="card__title card__title--portrait "
|
|
104
104
|
>
|
|
105
105
|
<a
|
|
@@ -107,7 +107,7 @@ exports[`Card component should not render alternative headline if displayCategor
|
|
|
107
107
|
>
|
|
108
108
|
mock name
|
|
109
109
|
</a>
|
|
110
|
-
</
|
|
110
|
+
</div>
|
|
111
111
|
<div
|
|
112
112
|
class="card__details card__details--portrait"
|
|
113
113
|
>
|
|
@@ -174,7 +174,7 @@ exports[`Card component should not render preHeader if alternativeHeadline is no
|
|
|
174
174
|
>
|
|
175
175
|
category-name
|
|
176
176
|
</a>
|
|
177
|
-
<
|
|
177
|
+
<div
|
|
178
178
|
class="card__title card__title--portrait "
|
|
179
179
|
>
|
|
180
180
|
<a
|
|
@@ -182,7 +182,7 @@ exports[`Card component should not render preHeader if alternativeHeadline is no
|
|
|
182
182
|
>
|
|
183
183
|
mock name
|
|
184
184
|
</a>
|
|
185
|
-
</
|
|
185
|
+
</div>
|
|
186
186
|
<div
|
|
187
187
|
class="card__details card__details--portrait"
|
|
188
188
|
>
|
|
@@ -248,7 +248,7 @@ exports[`Card component should render customPreheader and alternativeHeadline in
|
|
|
248
248
|
>
|
|
249
249
|
Pre header
|
|
250
250
|
</div>
|
|
251
|
-
<
|
|
251
|
+
<div
|
|
252
252
|
class="card__title card__title--portrait "
|
|
253
253
|
>
|
|
254
254
|
<a
|
|
@@ -256,7 +256,7 @@ exports[`Card component should render customPreheader and alternativeHeadline in
|
|
|
256
256
|
>
|
|
257
257
|
Alternative headline
|
|
258
258
|
</a>
|
|
259
|
-
</
|
|
259
|
+
</div>
|
|
260
260
|
<div
|
|
261
261
|
class="card__details card__details--portrait"
|
|
262
262
|
>
|
|
@@ -323,7 +323,7 @@ exports[`Card component should render without throwing an error and match snapsh
|
|
|
323
323
|
>
|
|
324
324
|
category-name
|
|
325
325
|
</a>
|
|
326
|
-
<
|
|
326
|
+
<div
|
|
327
327
|
class="card__title card__title--portrait "
|
|
328
328
|
>
|
|
329
329
|
<a
|
|
@@ -331,7 +331,7 @@ exports[`Card component should render without throwing an error and match snapsh
|
|
|
331
331
|
>
|
|
332
332
|
mock name
|
|
333
333
|
</a>
|
|
334
|
-
</
|
|
334
|
+
</div>
|
|
335
335
|
<div
|
|
336
336
|
class="card__details card__details--portrait"
|
|
337
337
|
>
|
|
@@ -36,7 +36,7 @@ exports[`CardsContainer component should render with carousel if option is enabl
|
|
|
36
36
|
>
|
|
37
37
|
page
|
|
38
38
|
</div>
|
|
39
|
-
<
|
|
39
|
+
<div
|
|
40
40
|
class="card__title card__title--portrait "
|
|
41
41
|
>
|
|
42
42
|
<a
|
|
@@ -44,7 +44,7 @@ exports[`CardsContainer component should render with carousel if option is enabl
|
|
|
44
44
|
>
|
|
45
45
|
Swan 78
|
|
46
46
|
</a>
|
|
47
|
-
</
|
|
47
|
+
</div>
|
|
48
48
|
</div>
|
|
49
49
|
<div
|
|
50
50
|
class="card__child-content"
|
|
@@ -73,7 +73,7 @@ exports[`CardsContainer component should render with carousel if option is enabl
|
|
|
73
73
|
>
|
|
74
74
|
page
|
|
75
75
|
</div>
|
|
76
|
-
<
|
|
76
|
+
<div
|
|
77
77
|
class="card__title card__title--portrait "
|
|
78
78
|
>
|
|
79
79
|
<a
|
|
@@ -81,7 +81,7 @@ exports[`CardsContainer component should render with carousel if option is enabl
|
|
|
81
81
|
>
|
|
82
82
|
Swan 98
|
|
83
83
|
</a>
|
|
84
|
-
</
|
|
84
|
+
</div>
|
|
85
85
|
</div>
|
|
86
86
|
<div
|
|
87
87
|
class="card__child-content"
|
|
@@ -123,7 +123,7 @@ exports[`CardsContainer component should render without throwing error and match
|
|
|
123
123
|
>
|
|
124
124
|
page
|
|
125
125
|
</div>
|
|
126
|
-
<
|
|
126
|
+
<div
|
|
127
127
|
class="card__title card__title--portrait "
|
|
128
128
|
>
|
|
129
129
|
<a
|
|
@@ -131,7 +131,7 @@ exports[`CardsContainer component should render without throwing error and match
|
|
|
131
131
|
>
|
|
132
132
|
Swan 78
|
|
133
133
|
</a>
|
|
134
|
-
</
|
|
134
|
+
</div>
|
|
135
135
|
</div>
|
|
136
136
|
<div
|
|
137
137
|
class="card__child-content"
|
|
@@ -160,7 +160,7 @@ exports[`CardsContainer component should render without throwing error and match
|
|
|
160
160
|
>
|
|
161
161
|
page
|
|
162
162
|
</div>
|
|
163
|
-
<
|
|
163
|
+
<div
|
|
164
164
|
class="card__title card__title--portrait "
|
|
165
165
|
>
|
|
166
166
|
<a
|
|
@@ -168,7 +168,7 @@ exports[`CardsContainer component should render without throwing error and match
|
|
|
168
168
|
>
|
|
169
169
|
Swan 98
|
|
170
170
|
</a>
|
|
171
|
-
</
|
|
171
|
+
</div>
|
|
172
172
|
</div>
|
|
173
173
|
<div
|
|
174
174
|
class="card__child-content"
|