@blaze-cms/react-page-builder 0.130.0-admin-updates.8 → 0.130.0-alpha.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 +4 -60
- package/lib/components/Code/Code.js +3 -7
- package/lib/components/Code/Code.js.map +1 -1
- package/lib/components/DataSummary/helpers/build-loop-props-content.js +1 -3
- package/lib/components/DataSummary/helpers/build-loop-props-content.js.map +1 -1
- package/lib/components/DataSummary/helpers/build-props-to-display-with-content.js +2 -3
- package/lib/components/DataSummary/helpers/build-props-to-display-with-content.js.map +1 -1
- package/lib/components/Layout/Layout.js +10 -4
- package/lib/components/Layout/Layout.js.map +1 -1
- package/lib/components/SearchContent/SearchContent.js +6 -8
- package/lib/components/SearchContent/SearchContent.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilterContainer.js +1 -2
- package/lib/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib/components/SearchFilter/helpers/build-new-query.js +2 -3
- package/lib/components/SearchFilter/helpers/build-new-query.js.map +1 -1
- package/lib/components/SearchFilterSort/helpers/handle-sort-update.js +2 -5
- package/lib/components/SearchFilterSort/helpers/handle-sort-update.js.map +1 -1
- package/lib/components/SearchFilterSort/helpers/update-sort.js +1 -2
- package/lib/components/SearchFilterSort/helpers/update-sort.js.map +1 -1
- package/lib/helpers/build-props-query.js +2 -5
- package/lib/helpers/build-props-query.js.map +1 -1
- package/lib/helpers/get-wrapped-value-with-link.js +3 -2
- package/lib/helpers/get-wrapped-value-with-link.js.map +1 -1
- package/lib/helpers/index.js +0 -7
- package/lib/helpers/index.js.map +1 -1
- package/lib/helpers/parse-props-to-display.js +8 -13
- package/lib/helpers/parse-props-to-display.js.map +1 -1
- package/lib-es/components/Code/Code.js +4 -8
- package/lib-es/components/Code/Code.js.map +1 -1
- package/lib-es/components/DataSummary/helpers/build-loop-props-content.js +1 -3
- package/lib-es/components/DataSummary/helpers/build-loop-props-content.js.map +1 -1
- package/lib-es/components/DataSummary/helpers/build-props-to-display-with-content.js +3 -4
- package/lib-es/components/DataSummary/helpers/build-props-to-display-with-content.js.map +1 -1
- package/lib-es/components/Layout/Layout.js +11 -5
- package/lib-es/components/Layout/Layout.js.map +1 -1
- package/lib-es/components/SearchContent/SearchContent.js +6 -8
- package/lib-es/components/SearchContent/SearchContent.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilterContainer.js +1 -2
- package/lib-es/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/build-new-query.js +2 -3
- package/lib-es/components/SearchFilter/helpers/build-new-query.js.map +1 -1
- package/lib-es/components/SearchFilterSort/helpers/handle-sort-update.js +2 -7
- package/lib-es/components/SearchFilterSort/helpers/handle-sort-update.js.map +1 -1
- package/lib-es/components/SearchFilterSort/helpers/update-sort.js +2 -2
- package/lib-es/components/SearchFilterSort/helpers/update-sort.js.map +1 -1
- package/lib-es/helpers/build-props-query.js +2 -4
- package/lib-es/helpers/build-props-query.js.map +1 -1
- package/lib-es/helpers/get-wrapped-value-with-link.js +2 -2
- package/lib-es/helpers/get-wrapped-value-with-link.js.map +1 -1
- package/lib-es/helpers/index.js +0 -1
- package/lib-es/helpers/index.js.map +1 -1
- package/lib-es/helpers/parse-props-to-display.js +9 -12
- package/lib-es/helpers/parse-props-to-display.js.map +1 -1
- package/package.json +10 -10
- package/src/components/Code/Code.js +3 -7
- package/src/components/DataSummary/helpers/build-loop-props-content.js +1 -4
- package/src/components/DataSummary/helpers/build-props-to-display-with-content.js +3 -6
- package/src/components/Layout/Layout.js +9 -2
- package/src/components/SearchContent/SearchContent.js +6 -8
- package/src/components/SearchFilter/SearchFilterContainer.js +1 -2
- package/src/components/SearchFilter/helpers/build-new-query.js +2 -3
- package/src/components/SearchFilterSort/helpers/handle-sort-update.js +3 -7
- package/src/components/SearchFilterSort/helpers/update-sort.js +2 -2
- package/src/helpers/build-props-query.js +2 -4
- package/src/helpers/get-wrapped-value-with-link.js +3 -6
- package/src/helpers/index.js +0 -1
- package/src/helpers/parse-props-to-display.js +21 -25
- package/tests/unit/src/components/Code/Code.test.js +0 -5
- package/tests/unit/src/components/Code/__snapshots__/Code.test.js.snap +0 -8
- package/tests/unit/src/components/DataSummary/helpers/build-loop-props-content.test.js +0 -9
- package/tests/unit/src/components/SearchFilter/helpers/build-new-query.test.js +1 -15
- package/tests/unit/src/components/SearchFilterSort/helpers/handle-sort-update.test.js +3 -9
- package/tests/unit/src/components/SearchFilterSort/helpers/update-sort.test.js +1 -10
- package/tests/unit/src/helpers/build-props-query.test.js +0 -25
- package/tests/unit/src/helpers/get-wrapped-value-with-link.test.js +2 -2
- package/tests/unit/src/helpers/parse-props-to-display.test.js +0 -4
- package/lib/helpers/process-data-summary-value.js +0 -56
- package/lib/helpers/process-data-summary-value.js.map +0 -1
- package/lib-es/helpers/process-data-summary-value.js +0 -36
- package/lib-es/helpers/process-data-summary-value.js.map +0 -1
- package/src/helpers/process-data-summary-value.js +0 -22
- package/tests/unit/src/helpers/__snapshots__/get-wrapped-value-with-link.test.js.snap +0 -18
- package/tests/unit/src/helpers/prcoess-data-summary-value.test.js +0 -52
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import upperFirst from 'lodash.upperfirst';
|
|
2
2
|
import flatten from 'lodash.flatten';
|
|
3
|
-
import { isObject
|
|
3
|
+
import { isObject } from '../../../helpers';
|
|
4
4
|
import getLinkToPublishedContent from './get-link-to-published-content';
|
|
5
5
|
import getPropValue from './get-prop-value';
|
|
6
6
|
import getLinkBasedOnValue from './get-link-based-on-value';
|
|
@@ -27,18 +27,15 @@ const buildPropsToDisplayWithContent = (props, propsToDisplay = []) => {
|
|
|
27
27
|
const objPropValue = getPropValue(key, props, options);
|
|
28
28
|
if (!objPropValue) return null;
|
|
29
29
|
|
|
30
|
-
const
|
|
30
|
+
const link = getLink(enableLink, key, props, objPropValue);
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return [upperFirst(label), processedValue, link, modifier];
|
|
32
|
+
return [upperFirst(label), objPropValue, link, modifier];
|
|
35
33
|
});
|
|
36
34
|
})
|
|
37
35
|
).filter(Boolean);
|
|
38
36
|
};
|
|
39
37
|
|
|
40
38
|
export default buildPropsToDisplayWithContent;
|
|
41
|
-
|
|
42
39
|
function getLink(enableLink, key, props, objPropValue) {
|
|
43
40
|
let link = '';
|
|
44
41
|
if (enableLink) {
|
|
@@ -14,6 +14,7 @@ const Layout = ({
|
|
|
14
14
|
modifier,
|
|
15
15
|
backgroundImage,
|
|
16
16
|
tagType,
|
|
17
|
+
dataNoSnippet,
|
|
17
18
|
...otherProps
|
|
18
19
|
}) => {
|
|
19
20
|
const {
|
|
@@ -28,12 +29,16 @@ const Layout = ({
|
|
|
28
29
|
|
|
29
30
|
if (type === COLUMN && !hasChildren(children)) return null;
|
|
30
31
|
|
|
32
|
+
const otherWrapperProps = {};
|
|
33
|
+
if (dataNoSnippet) otherWrapperProps['data-nosnippet'] = true;
|
|
34
|
+
|
|
31
35
|
return (
|
|
32
36
|
<Wrapper
|
|
33
37
|
tagType={tagType}
|
|
34
38
|
className={type}
|
|
35
39
|
modifiers={`${classModifiers}${additionalRowModifier}`}
|
|
36
|
-
style={style}
|
|
40
|
+
style={style}
|
|
41
|
+
{...otherWrapperProps}>
|
|
37
42
|
{title && <h2 className="heading heading--section">{title}</h2>}
|
|
38
43
|
{renderChildren(children, otherProps)}
|
|
39
44
|
</Wrapper>
|
|
@@ -48,6 +53,7 @@ Layout.propTypes = {
|
|
|
48
53
|
modifier: PropTypes.string,
|
|
49
54
|
backgroundImage: PropTypes.string,
|
|
50
55
|
tagType: PropTypes.string,
|
|
56
|
+
dataNoSnippet: PropTypes.bool,
|
|
51
57
|
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired
|
|
52
58
|
};
|
|
53
59
|
|
|
@@ -57,7 +63,8 @@ Layout.defaultProps = {
|
|
|
57
63
|
},
|
|
58
64
|
backgroundImage: '',
|
|
59
65
|
modifier: '',
|
|
60
|
-
tagType: ''
|
|
66
|
+
tagType: '',
|
|
67
|
+
dataNoSnippet: false
|
|
61
68
|
};
|
|
62
69
|
|
|
63
70
|
export default Layout;
|
|
@@ -10,12 +10,12 @@ const SearchContent = ({
|
|
|
10
10
|
searchInputAlignment,
|
|
11
11
|
searchInputWrapperMobile,
|
|
12
12
|
searchInputWrapperDesktop,
|
|
13
|
+
collapsible,
|
|
13
14
|
isMobile,
|
|
14
15
|
placeholder,
|
|
15
|
-
modifier
|
|
16
|
-
collapsedSearch
|
|
16
|
+
modifier
|
|
17
17
|
}) => {
|
|
18
|
-
const [collapsed, setCollapsed] = useState(
|
|
18
|
+
const [collapsed, setCollapsed] = useState(collapsible);
|
|
19
19
|
const router = useRouter();
|
|
20
20
|
|
|
21
21
|
const { results, searchTerm, setSearchTerm, debouncedSearchTerm } = useDebounceSearch({
|
|
@@ -50,7 +50,7 @@ const SearchContent = ({
|
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
const handleOnBlur = () => {
|
|
53
|
-
if (!
|
|
53
|
+
if (!collapsible) return;
|
|
54
54
|
if (!debouncedSearchTerm || debouncedSearchTerm === '') setCollapsed(true);
|
|
55
55
|
};
|
|
56
56
|
|
|
@@ -120,8 +120,7 @@ SearchContent.propTypes = {
|
|
|
120
120
|
isMobile: PropTypes.bool,
|
|
121
121
|
collapsible: PropTypes.bool,
|
|
122
122
|
entities: PropTypes.array.isRequired,
|
|
123
|
-
modifier: PropTypes.string
|
|
124
|
-
collapsedSearch: PropTypes.bool
|
|
123
|
+
modifier: PropTypes.string
|
|
125
124
|
};
|
|
126
125
|
|
|
127
126
|
SearchContent.defaultProps = {
|
|
@@ -131,8 +130,7 @@ SearchContent.defaultProps = {
|
|
|
131
130
|
placeholder: '',
|
|
132
131
|
isMobile: false,
|
|
133
132
|
collapsible: false,
|
|
134
|
-
modifier: ''
|
|
135
|
-
collapsedSearch: false
|
|
133
|
+
modifier: ''
|
|
136
134
|
};
|
|
137
135
|
|
|
138
136
|
export default SearchContent;
|
|
@@ -128,8 +128,7 @@ const SearchFilterContainer = ({
|
|
|
128
128
|
setKey(`filter-${name}:${Date.now()}`); // remove after range component update
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
-
const
|
|
132
|
-
const newUrl = buildNewQuery(url, currentUrl, newQuery, sortValues, hashBit);
|
|
131
|
+
const newUrl = buildNewQuery(url, currentUrl, newQuery, sortValues);
|
|
133
132
|
scrollToFirstList();
|
|
134
133
|
setUrlPath(newUrl);
|
|
135
134
|
return router.push('/Resolver', newUrl, { shallow: !hasUrl, scroll: false });
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
const buildNewQuery = (url, currentUrl, queryParams, sortValues
|
|
1
|
+
const buildNewQuery = (url, currentUrl, queryParams, sortValues) => {
|
|
2
2
|
const newUrl = url ? `${url}?${queryParams}` : `${currentUrl}?${queryParams}`;
|
|
3
|
-
|
|
4
|
-
return hashBit ? `${withSortValues}#${hashBit}` : withSortValues;
|
|
3
|
+
return sortValues ? `${newUrl}&${sortValues}` : newUrl;
|
|
5
4
|
};
|
|
6
5
|
|
|
7
6
|
export default buildNewQuery;
|
|
@@ -5,10 +5,6 @@ import updateSort from './update-sort';
|
|
|
5
5
|
const handleSortUpdate = (router, value, query, url, selectLabel) => {
|
|
6
6
|
const queryWithoutSort = {};
|
|
7
7
|
const routerOptions = { shallow: true, scroll: false };
|
|
8
|
-
|
|
9
|
-
const { asPath } = router;
|
|
10
|
-
const hashBit = asPath.split('#')[1];
|
|
11
|
-
const parsedHash = hashBit ? `#${hashBit}` : '';
|
|
12
8
|
Object.keys(query).forEach(key => {
|
|
13
9
|
if (key.indexOf(PAGINATION_QUERY) !== -1) return;
|
|
14
10
|
if (key !== SORTBY && key !== SORT) queryWithoutSort[key] = query[key];
|
|
@@ -17,10 +13,10 @@ const handleSortUpdate = (router, value, query, url, selectLabel) => {
|
|
|
17
13
|
const stringifiedQuery = stringify(queryWithoutSort);
|
|
18
14
|
|
|
19
15
|
return stringifiedQuery
|
|
20
|
-
? router.push(`/Resolver`, `${url}?${stringifiedQuery}
|
|
21
|
-
: router.push(`/Resolver`,
|
|
16
|
+
? router.push(`/Resolver`, `${url}?${stringifiedQuery}`, routerOptions)
|
|
17
|
+
: router.push(`/Resolver`, url, routerOptions);
|
|
22
18
|
}
|
|
23
|
-
const updatedSortUrl = updateSort(value, queryWithoutSort, url
|
|
19
|
+
const updatedSortUrl = updateSort(value, queryWithoutSort, url);
|
|
24
20
|
return router.push('/Resolver', updatedSortUrl, routerOptions);
|
|
25
21
|
};
|
|
26
22
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { stringify } from 'query-string';
|
|
2
2
|
|
|
3
|
-
const updateSort = (value, query, url
|
|
3
|
+
const updateSort = (value, query, url) => {
|
|
4
4
|
const [newSortBy, newSort] = value.split(':');
|
|
5
5
|
const updatedQuery = { ...query, sortby: newSortBy, sort: newSort };
|
|
6
6
|
const parsedQuery = stringify(updatedQuery);
|
|
7
|
-
return `${url}?${parsedQuery}
|
|
7
|
+
return `${url}?${parsedQuery}`;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
export default updateSort;
|
|
@@ -44,21 +44,19 @@ const buildPropsQuery = (entitySchema, extraProps = [], cardOptions = null, link
|
|
|
44
44
|
const buildComplexProps = (
|
|
45
45
|
shouldAddCategoryProps,
|
|
46
46
|
props,
|
|
47
|
-
{ relations = [], dynamicProperties = {}
|
|
47
|
+
{ relations = [], dynamicProperties = {} },
|
|
48
48
|
linkProps
|
|
49
49
|
) =>
|
|
50
50
|
Object.keys(props).map(base => {
|
|
51
51
|
const nestedProps = props[base];
|
|
52
52
|
const hasLink = !!linkProps.find(linkProp => linkProp.includes(base));
|
|
53
|
-
const matchingProperty = !!properties[base];
|
|
54
53
|
const matchingRelation = relations.find(({ localField }) => localField === base);
|
|
55
54
|
const matchingDynamicProp = Object.keys(dynamicProperties).find(
|
|
56
55
|
dynamicKey => dynamicKey === base
|
|
57
56
|
);
|
|
58
57
|
|
|
59
58
|
if (matchingRelation && !nestedProps.includes('id')) nestedProps.push('id');
|
|
60
|
-
if (hasLink && (!!
|
|
61
|
-
nestedProps.push('url');
|
|
59
|
+
if (hasLink && (!!matchingRelation || !!matchingDynamicProp)) nestedProps.push('url');
|
|
62
60
|
const jointNestedProps = nestedProps.join(',');
|
|
63
61
|
if (base === 'category' && shouldAddCategoryProps)
|
|
64
62
|
return `${base}{${jointNestedProps}, ${categoryProps}}`;
|
|
@@ -6,16 +6,13 @@ const getWrappedValueWithLink = (value, link, keyPrefix = '') => {
|
|
|
6
6
|
const arrayResults = value.map((arrValue, index) => {
|
|
7
7
|
const { keyField, url } = arrValue;
|
|
8
8
|
const keyValue = arrValue[keyField];
|
|
9
|
-
|
|
10
9
|
const isLastItem = index === value.length - 1;
|
|
11
|
-
const keyFieldValue = isLastItem ? keyValue :
|
|
10
|
+
const keyFieldValue = isLastItem ? keyValue : keyValue.concat(',');
|
|
12
11
|
|
|
13
12
|
return url ? (
|
|
14
|
-
<BlazeLink key={[keyPrefix, index].join('-')} href={url}>
|
|
15
|
-
{<>{keyFieldValue} </>}
|
|
16
|
-
</BlazeLink>
|
|
13
|
+
<BlazeLink key={[keyPrefix, index].join('-')} href={url}>{`${keyFieldValue} `}</BlazeLink>
|
|
17
14
|
) : (
|
|
18
|
-
|
|
15
|
+
`${keyFieldValue} `
|
|
19
16
|
);
|
|
20
17
|
});
|
|
21
18
|
|
package/src/helpers/index.js
CHANGED
|
@@ -51,4 +51,3 @@ export { default as getParsedPropValues } from './get-parsed-prop-values';
|
|
|
51
51
|
export { default as getSanitizedPropValues } from './get-sanitized-prop-values';
|
|
52
52
|
export { default as appendImages } from './append-images';
|
|
53
53
|
export { default as parseTextBlock } from './parse-TextBlock';
|
|
54
|
-
export { default as processDataSummaryValue } from './process-data-summary-value';
|
|
@@ -4,39 +4,35 @@ import isObject from './is-object';
|
|
|
4
4
|
import getParsedPropValues from './get-parsed-prop-values';
|
|
5
5
|
import getSanitizedPropValues from './get-sanitized-prop-values';
|
|
6
6
|
import { BOLD_TAG, BLANK_SPACE_UNICODE_STRING } from '../constants';
|
|
7
|
-
import processDataSummaryValue from './process-data-summary-value';
|
|
8
7
|
|
|
9
8
|
// TODO this helper should be removed if database is wiped clean and all elements change to new props struc
|
|
10
9
|
const parsePropsToDisplay = (props = {}, propsToDisplay = []) => {
|
|
11
10
|
if (!isObject(propsToDisplay[0])) return at(props, propsToDisplay).filter(Boolean);
|
|
12
11
|
|
|
13
|
-
return propsToDisplay.map(
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
return propsToDisplay.map(
|
|
13
|
+
({ bold, propertiesToDisplay, prefix, suffix, shouldStrip, enableLink }, currentIndex) => {
|
|
14
|
+
const Wrapper = bold ? BOLD_TAG : Fragment;
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
const parsedPropValues = getParsedPropValues({
|
|
17
|
+
propertiesToDisplay,
|
|
18
|
+
props,
|
|
19
|
+
enableLink,
|
|
20
|
+
shouldStrip
|
|
21
|
+
});
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const sanitizedPropValues = getSanitizedPropValues(parsedPropValues);
|
|
24
|
+
if (!sanitizedPropValues || !sanitizedPropValues.length) return null;
|
|
25
|
+
const stringEndBlank =
|
|
26
|
+
currentIndex + 1 === propsToDisplay.length ? '' : BLANK_SPACE_UNICODE_STRING;
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
</Wrapper>
|
|
38
|
-
);
|
|
39
|
-
});
|
|
28
|
+
return (
|
|
29
|
+
<Wrapper>
|
|
30
|
+
{prefix} {sanitizedPropValues} {suffix}
|
|
31
|
+
{stringEndBlank}
|
|
32
|
+
</Wrapper>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
);
|
|
40
36
|
};
|
|
41
37
|
|
|
42
38
|
export default parsePropsToDisplay;
|
|
@@ -23,11 +23,6 @@ describe('Code component', () => {
|
|
|
23
23
|
expect(asFragment()).toMatchSnapshot();
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
it('should not render wrapper', () => {
|
|
27
|
-
const { asFragment } = render(Code, { ...props, disableWrapper: true });
|
|
28
|
-
expect(asFragment()).toMatchSnapshot();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
26
|
it('should return null if there is not embed code', () => {
|
|
32
27
|
const { container } = render(Code, {});
|
|
33
28
|
expect(container.innerHTML).toBe('');
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import '@testing-library/jest-dom/extend-expect';
|
|
2
2
|
import buildLoopPropsContent from '../../../../../../src/components/DataSummary/helpers/build-loop-props-content';
|
|
3
3
|
import { mockedLoopProps, mockedPropsToDisplay, mockedData, mockedResults } from './mocks';
|
|
4
|
-
import processDataSummaryValue from '../../../../../../src/helpers/process-data-summary-value';
|
|
5
|
-
|
|
6
|
-
jest.mock('../../../../../../src/helpers/process-data-summary-value', () =>
|
|
7
|
-
jest.fn(value => value)
|
|
8
|
-
);
|
|
9
4
|
|
|
10
5
|
describe('buildLoopPropsContent helper function', () => {
|
|
11
6
|
const noParamsPassed = buildLoopPropsContent();
|
|
@@ -46,10 +41,6 @@ describe('buildLoopPropsContent helper function', () => {
|
|
|
46
41
|
expect(noDataPassed).toEqual([]);
|
|
47
42
|
});
|
|
48
43
|
|
|
49
|
-
it('should call processDataSummaryValue', () => {
|
|
50
|
-
expect(processDataSummaryValue).toHaveBeenCalledWith('pre data name', mockedPropsToDisplay[0]);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
44
|
it('should return regular dataSummary content if no loopable values are found', () => {
|
|
54
45
|
expect(withNoLoopValues).toEqual(mockedResults[0]);
|
|
55
46
|
expect(withNoLoopableValues).toEqual(mockedResults[1]);
|
|
@@ -3,21 +3,13 @@ import buildNewQuery from '../../../../../../src/components/SearchFilter/helpers
|
|
|
3
3
|
const mockedProps = [
|
|
4
4
|
['', 'current-as-path', 'some=query¶ms=value'],
|
|
5
5
|
['urlFromProps', '', 'other=query&with=value'],
|
|
6
|
-
['urlFromProps', 'not=used', 'another=query&withthis=value', 'sort=asc&sortby=name']
|
|
7
|
-
[
|
|
8
|
-
'urlFromProps',
|
|
9
|
-
'not=used',
|
|
10
|
-
'another=query&withthis=value',
|
|
11
|
-
'sort=asc&sortby=name',
|
|
12
|
-
'this-is-content'
|
|
13
|
-
]
|
|
6
|
+
['urlFromProps', 'not=used', 'another=query&withthis=value', 'sort=asc&sortby=name']
|
|
14
7
|
];
|
|
15
8
|
|
|
16
9
|
describe('buildNewQuery helper function', () => {
|
|
17
10
|
const simpleExample = buildNewQuery(...mockedProps[0]);
|
|
18
11
|
const withPropsUrl = buildNewQuery(...mockedProps[1]);
|
|
19
12
|
const withSort = buildNewQuery(...mockedProps[2]);
|
|
20
|
-
const withHash = buildNewQuery(...mockedProps[3]);
|
|
21
13
|
|
|
22
14
|
it('should always return a string', () => {
|
|
23
15
|
expect(typeof simpleExample).toBe('string');
|
|
@@ -36,10 +28,4 @@ describe('buildNewQuery helper function', () => {
|
|
|
36
28
|
it('should return new url with sort if passed', () => {
|
|
37
29
|
expect(withSort).toEqual('urlFromProps?another=query&withthis=value&sort=asc&sortby=name');
|
|
38
30
|
});
|
|
39
|
-
|
|
40
|
-
it('should return new url with hash if passed', () => {
|
|
41
|
-
expect(withHash).toEqual(
|
|
42
|
-
'urlFromProps?another=query&withthis=value&sort=asc&sortby=name#this-is-content'
|
|
43
|
-
);
|
|
44
|
-
});
|
|
45
31
|
});
|
|
@@ -2,22 +2,16 @@ import handleSortUpdate from '../../../../../../src/components/SearchFilterSort/
|
|
|
2
2
|
|
|
3
3
|
const routerPushResultMock = () => ({ then: jest.fn() });
|
|
4
4
|
const mockedProps = [
|
|
5
|
+
[{ push: jest.fn(routerPushResultMock) }, 'defaultOption', {}, 'url', 'defaultOption'],
|
|
5
6
|
[
|
|
6
|
-
{
|
|
7
|
-
'defaultOption',
|
|
8
|
-
{},
|
|
9
|
-
'url',
|
|
10
|
-
'defaultOption'
|
|
11
|
-
],
|
|
12
|
-
[
|
|
13
|
-
{ push: jest.fn(routerPushResultMock), asPath: 'asPath' },
|
|
7
|
+
{ push: jest.fn(routerPushResultMock) },
|
|
14
8
|
'defaultOption',
|
|
15
9
|
{ sort: 'asc', sortby: 'name', type: 'big' },
|
|
16
10
|
'baseurl',
|
|
17
11
|
'defaultOption'
|
|
18
12
|
],
|
|
19
13
|
[
|
|
20
|
-
{ push: jest.fn(routerPushResultMock)
|
|
14
|
+
{ push: jest.fn(routerPushResultMock) },
|
|
21
15
|
'name:desc',
|
|
22
16
|
{ someOther: 'ott' },
|
|
23
17
|
'url',
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import updateSort from '../../../../../../src/components/SearchFilterSort/helpers/update-sort';
|
|
2
2
|
|
|
3
|
-
const mockedProps = [
|
|
4
|
-
['name:asc', {}, 'aurl'],
|
|
5
|
-
['name:asc', { other: '12', query2: 'an' }, 'aurl'],
|
|
6
|
-
['name:desc', { query1: 'aquery' }, 'theUrl', '#hashBit']
|
|
7
|
-
];
|
|
3
|
+
const mockedProps = [['name:asc', {}, 'aurl'], ['name:asc', { other: '12', query2: 'an' }, 'aurl']];
|
|
8
4
|
|
|
9
5
|
describe('updateSort helper function', () => {
|
|
10
6
|
const basicSort = updateSort(...mockedProps[0]);
|
|
11
7
|
const sortWithOtherQuerys = updateSort(...mockedProps[1]);
|
|
12
|
-
const sortWithhash = updateSort(...mockedProps[2]);
|
|
13
8
|
|
|
14
9
|
it('should return a parsed url based on the parameters passed', () => {
|
|
15
10
|
expect(basicSort).toEqual('aurl?sort=asc&sortby=name');
|
|
@@ -18,8 +13,4 @@ describe('updateSort helper function', () => {
|
|
|
18
13
|
it('should return a parsed url with extra query params if passed', () => {
|
|
19
14
|
expect(sortWithOtherQuerys).toEqual('aurl?other=12&query2=an&sort=asc&sortby=name');
|
|
20
15
|
});
|
|
21
|
-
|
|
22
|
-
it('should return a parsed url with extra query params and hash if passed', () => {
|
|
23
|
-
expect(sortWithhash).toEqual('theUrl?query1=aquery&sort=desc&sortby=name#hashBit');
|
|
24
|
-
});
|
|
25
16
|
});
|
|
@@ -182,31 +182,6 @@ describe('get card render props', () => {
|
|
|
182
182
|
'id,name,url,sponsored,featured,category{name,listingPageId,listingPageEntity, id publishedListingPage{id, url}},address{country,id}'
|
|
183
183
|
);
|
|
184
184
|
});
|
|
185
|
-
|
|
186
|
-
it('should url props where enableLink is set', () => {
|
|
187
|
-
const _data = {
|
|
188
|
-
getEntitySchema: {
|
|
189
|
-
interfaces: [CONTENT_INTERFACE],
|
|
190
|
-
properties: {
|
|
191
|
-
id: 'id',
|
|
192
|
-
nestedProperty: {
|
|
193
|
-
type: 'object'
|
|
194
|
-
}
|
|
195
|
-
},
|
|
196
|
-
relations: [{ localField: 'address' }],
|
|
197
|
-
dynamicProperties: {
|
|
198
|
-
nestedDynamicProperty: {
|
|
199
|
-
type: 'object'
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
const linkProps = ['nestedProperty.title', 'nestedDynamicProperty.title', 'address.title'];
|
|
205
|
-
const query = buildPropsQuery(_data, linkProps, {}, linkProps);
|
|
206
|
-
expect(query).toEqual(
|
|
207
|
-
'id,name,url,sponsored,featured,nestedProperty{title,url},nestedDynamicProperty{title,url},address{title,id,url}'
|
|
208
|
-
);
|
|
209
|
-
});
|
|
210
185
|
});
|
|
211
186
|
|
|
212
187
|
function testUrlProperty({ extraProperties = {}, dynamicProperties = {}, cardProps }) {
|
|
@@ -33,7 +33,7 @@ describe('get wrapped value with link func', () => {
|
|
|
33
33
|
expect(resultWithArray).toHaveLength(2);
|
|
34
34
|
expect(resultWithArray[0].props.href).toEqual(link);
|
|
35
35
|
expect(resultWithArray[0].key).toEqual(`${keyPrefix}-0`);
|
|
36
|
-
expect(resultWithArray[0].props.children).
|
|
37
|
-
expect(resultWithArray[1]).
|
|
36
|
+
expect(resultWithArray[0].props.children).toEqual(`${arrayOfValues[0][keyField]}, `);
|
|
37
|
+
expect(resultWithArray[1]).toEqual(`${arrayOfValues[1][keyField]} `);
|
|
38
38
|
});
|
|
39
39
|
});
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import '@testing-library/jest-dom/extend-expect';
|
|
2
2
|
import parsePropsToDisplay from '../../../../src/helpers/parse-props-to-display';
|
|
3
|
-
import processDataSummaryValue from '../../../../src/helpers/process-data-summary-value';
|
|
4
|
-
|
|
5
|
-
jest.mock('../../../../src/helpers/process-data-summary-value', () => jest.fn(value => value));
|
|
6
3
|
|
|
7
4
|
const mockedPropsToDisplayStringArr = ['name', 'other', 'cat.name', 'tag.name'];
|
|
8
5
|
const mockedPropsToDisplayObjectArr = [
|
|
@@ -37,7 +34,6 @@ describe('parsePropsToDisplay func', () => {
|
|
|
37
34
|
it('should return an array of react elements if an array of objects is passed', () => {
|
|
38
35
|
const nonElement = !!withObjArr.find(({ type }) => typeof type !== 'symbol');
|
|
39
36
|
expect(nonElement).toEqual(false);
|
|
40
|
-
expect(processDataSummaryValue).toHaveBeenCalled();
|
|
41
37
|
});
|
|
42
38
|
|
|
43
39
|
it('should display bold tag wrapper when props to display has bold property', () => {
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require("core-js/modules/es.symbol.to-primitive.js");
|
|
4
|
-
require("core-js/modules/es.date.to-primitive.js");
|
|
5
|
-
require("core-js/modules/es.symbol.js");
|
|
6
|
-
require("core-js/modules/es.symbol.description.js");
|
|
7
|
-
require("core-js/modules/es.object.to-string.js");
|
|
8
|
-
require("core-js/modules/es.number.constructor.js");
|
|
9
|
-
require("core-js/modules/es.object.keys.js");
|
|
10
|
-
require("core-js/modules/es.array.filter.js");
|
|
11
|
-
require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
12
|
-
require("core-js/modules/es.array.for-each.js");
|
|
13
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
|
14
|
-
require("core-js/modules/es.object.get-own-property-descriptors.js");
|
|
15
|
-
require("core-js/modules/es.object.define-properties.js");
|
|
16
|
-
require("core-js/modules/es.object.define-property.js");
|
|
17
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
18
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
19
|
-
Object.defineProperty(exports, "__esModule", {
|
|
20
|
-
value: true
|
|
21
|
-
});
|
|
22
|
-
exports["default"] = void 0;
|
|
23
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
24
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
25
|
-
require("core-js/modules/es.array.is-array.js");
|
|
26
|
-
require("core-js/modules/es.array.map.js");
|
|
27
|
-
var _react = _interopRequireDefault(require("react"));
|
|
28
|
-
var _components = _interopRequireDefault(require("../components"));
|
|
29
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
30
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
31
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
32
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
33
|
-
var Code = _components["default"].code;
|
|
34
|
-
var renderCode = function renderCode(value) {
|
|
35
|
-
return /*#__PURE__*/_react["default"].createElement(Code, {
|
|
36
|
-
code: value,
|
|
37
|
-
disableWrapper: true
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
var processDataSummaryValue = function processDataSummaryValue(objPropValue, _ref) {
|
|
41
|
-
var isHtml = _ref.isHtml;
|
|
42
|
-
var pValue = objPropValue;
|
|
43
|
-
if (isHtml) {
|
|
44
|
-
pValue = Array.isArray(objPropValue) ? objPropValue.map(function (_ref2) {
|
|
45
|
-
var _objectSpread2;
|
|
46
|
-
var keyField = _ref2.keyField,
|
|
47
|
-
value = _ref2[keyField],
|
|
48
|
-
otherProps = (0, _objectWithoutProperties2["default"])(_ref2, ["keyField", keyField].map(_toPropertyKey));
|
|
49
|
-
return _objectSpread((_objectSpread2 = {}, (0, _defineProperty2["default"])(_objectSpread2, keyField, renderCode(value)), (0, _defineProperty2["default"])(_objectSpread2, "keyField", keyField), _objectSpread2), otherProps);
|
|
50
|
-
}) : renderCode(objPropValue);
|
|
51
|
-
}
|
|
52
|
-
return pValue;
|
|
53
|
-
};
|
|
54
|
-
var _default = processDataSummaryValue;
|
|
55
|
-
exports["default"] = _default;
|
|
56
|
-
//# sourceMappingURL=process-data-summary-value.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"process-data-summary-value.js","names":["_react","_interopRequireDefault","require","_components","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","arg","_toPrimitive","_typeof","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","Code","components","code","renderCode","value","createElement","disableWrapper","processDataSummaryValue","objPropValue","_ref","isHtml","pValue","Array","isArray","map","_ref2","_objectSpread2","keyField","otherProps","_objectWithoutProperties2","_default","exports"],"sources":["../../src/helpers/process-data-summary-value.js"],"sourcesContent":["import React from 'react';\nimport components from '../components';\n\nconst { code: Code } = components;\n\nconst renderCode = value => <Code code={value} disableWrapper />;\n\nconst processDataSummaryValue = (objPropValue, { isHtml }) => {\n let pValue = objPropValue;\n if (isHtml) {\n pValue = Array.isArray(objPropValue)\n ? objPropValue.map(({ keyField, [keyField]: value, ...otherProps }) => ({\n [keyField]: renderCode(value),\n keyField,\n ...otherProps\n }))\n : renderCode(objPropValue);\n }\n return pValue;\n};\n\nexport default processDataSummaryValue;\n"],"mappings":"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"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
6
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import components from '../components';
|
|
9
|
-
const {
|
|
10
|
-
code: Code
|
|
11
|
-
} = components;
|
|
12
|
-
const renderCode = value => /*#__PURE__*/React.createElement(Code, {
|
|
13
|
-
code: value,
|
|
14
|
-
disableWrapper: true
|
|
15
|
-
});
|
|
16
|
-
const processDataSummaryValue = (objPropValue, {
|
|
17
|
-
isHtml
|
|
18
|
-
}) => {
|
|
19
|
-
let pValue = objPropValue;
|
|
20
|
-
if (isHtml) {
|
|
21
|
-
pValue = Array.isArray(objPropValue) ? objPropValue.map(_ref => {
|
|
22
|
-
let {
|
|
23
|
-
keyField,
|
|
24
|
-
[keyField]: value
|
|
25
|
-
} = _ref,
|
|
26
|
-
otherProps = _objectWithoutProperties(_ref, ["keyField", keyField].map(_toPropertyKey));
|
|
27
|
-
return _objectSpread({
|
|
28
|
-
[keyField]: renderCode(value),
|
|
29
|
-
keyField
|
|
30
|
-
}, otherProps);
|
|
31
|
-
}) : renderCode(objPropValue);
|
|
32
|
-
}
|
|
33
|
-
return pValue;
|
|
34
|
-
};
|
|
35
|
-
export default processDataSummaryValue;
|
|
36
|
-
//# sourceMappingURL=process-data-summary-value.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"process-data-summary-value.js","names":["React","components","code","Code","renderCode","value","createElement","disableWrapper","processDataSummaryValue","objPropValue","isHtml","pValue","Array","isArray","map","_ref","keyField","otherProps","_objectWithoutProperties","_toPropertyKey","_objectSpread"],"sources":["../../src/helpers/process-data-summary-value.js"],"sourcesContent":["import React from 'react';\nimport components from '../components';\n\nconst { code: Code } = components;\n\nconst renderCode = value => <Code code={value} disableWrapper />;\n\nconst processDataSummaryValue = (objPropValue, { isHtml }) => {\n let pValue = objPropValue;\n if (isHtml) {\n pValue = Array.isArray(objPropValue)\n ? objPropValue.map(({ keyField, [keyField]: value, ...otherProps }) => ({\n [keyField]: renderCode(value),\n keyField,\n ...otherProps\n }))\n : renderCode(objPropValue);\n }\n return pValue;\n};\n\nexport default processDataSummaryValue;\n"],"mappings":";;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,eAAe;AAEtC,MAAM;EAAEC,IAAI,EAAEC;AAAK,CAAC,GAAGF,UAAU;AAEjC,MAAMG,UAAU,GAAGC,KAAK,iBAAIL,KAAA,CAAAM,aAAA,CAACH,IAAI;EAACD,IAAI,EAAEG,KAAM;EAACE,cAAc;AAAA,CAAE,CAAC;AAEhE,MAAMC,uBAAuB,GAAGA,CAACC,YAAY,EAAE;EAAEC;AAAO,CAAC,KAAK;EAC5D,IAAIC,MAAM,GAAGF,YAAY;EACzB,IAAIC,MAAM,EAAE;IACVC,MAAM,GAAGC,KAAK,CAACC,OAAO,CAACJ,YAAY,CAAC,GAChCA,YAAY,CAACK,GAAG,CAACC,IAAA;MAAA,IAAC;UAAEC,QAAQ;UAAE,CAACA,QAAQ,GAAGX;QAAqB,CAAC,GAAAU,IAAA;QAAZE,UAAU,GAAAC,wBAAA,CAAAH,IAAA,eAA/BC,QAAQ,EAAAF,GAAA,CAAAK,cAAA;MAAA,OAAAC,aAAA;QACrC,CAACJ,QAAQ,GAAGZ,UAAU,CAACC,KAAK,CAAC;QAC7BW;MAAQ,GACLC,UAAU;IAAA,CACb,CAAC,GACHb,UAAU,CAACK,YAAY,CAAC;EAC9B;EACA,OAAOE,MAAM;AACf,CAAC;AAED,eAAeH,uBAAuB"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import components from '../components';
|
|
3
|
-
|
|
4
|
-
const { code: Code } = components;
|
|
5
|
-
|
|
6
|
-
const renderCode = value => <Code code={value} disableWrapper />;
|
|
7
|
-
|
|
8
|
-
const processDataSummaryValue = (objPropValue, { isHtml }) => {
|
|
9
|
-
let pValue = objPropValue;
|
|
10
|
-
if (isHtml) {
|
|
11
|
-
pValue = Array.isArray(objPropValue)
|
|
12
|
-
? objPropValue.map(({ keyField, [keyField]: value, ...otherProps }) => ({
|
|
13
|
-
[keyField]: renderCode(value),
|
|
14
|
-
keyField,
|
|
15
|
-
...otherProps
|
|
16
|
-
}))
|
|
17
|
-
: renderCode(objPropValue);
|
|
18
|
-
}
|
|
19
|
-
return pValue;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default processDataSummaryValue;
|