@blaze-cms/react-page-builder 0.131.0-core-styles.0 → 0.131.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 +2 -13
- package/lib/HOC/recreateOnNavigation.js +29 -0
- package/lib/HOC/recreateOnNavigation.js.map +1 -0
- package/lib/components/Button.js +1 -2
- package/lib/components/Button.js.map +1 -1
- package/lib/components/Card/CardsRender.js +6 -13
- package/lib/components/Card/CardsRender.js.map +1 -1
- package/lib/components/Card/helpers/index.js +0 -7
- package/lib/components/Card/helpers/index.js.map +1 -1
- 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 +3 -2
- package/lib/components/Layout/Layout.js.map +1 -1
- package/lib/components/Layout/LayoutFactory.js +35 -0
- package/lib/components/Layout/LayoutFactory.js.map +1 -0
- package/lib/components/Layout/LayoutWithStickyTimer.js +66 -0
- package/lib/components/Layout/LayoutWithStickyTimer.js.map +1 -0
- package/lib/components/Layout/index.js +2 -2
- package/lib/components/Layout/index.js.map +1 -1
- package/lib/components/List/ListFactory.js +11 -16
- package/lib/components/List/ListFactory.js.map +1 -1
- package/lib/components/List/helpers/index.js +0 -14
- package/lib/components/List/helpers/index.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/SearchFilter/SearchFilter.js +11 -17
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilterContainer.js +85 -63
- package/lib/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib/components/SearchFilter/helpers/build-filters-query.js +1 -3
- package/lib/components/SearchFilter/helpers/build-filters-query.js.map +1 -1
- package/lib/components/SearchFilter/helpers/build-new-query.js +15 -0
- package/lib/components/SearchFilter/helpers/build-new-query.js.map +1 -0
- package/lib/components/SearchFilter/helpers/build-query.js +37 -0
- package/lib/components/SearchFilter/helpers/build-query.js.map +1 -0
- package/lib/components/SearchFilter/helpers/get-initial-filter-values.js +43 -0
- package/lib/components/SearchFilter/helpers/get-initial-filter-values.js.map +1 -0
- package/lib/components/SearchFilter/helpers/index.js +11 -18
- package/lib/components/SearchFilter/helpers/index.js.map +1 -1
- package/lib/components/SearchFilter/index.js.map +1 -1
- package/lib/components/SearchFilterSort/SearchFilterSort.js +11 -31
- package/lib/components/SearchFilterSort/SearchFilterSort.js.map +1 -1
- package/lib/components/SearchFilterSort/helpers/handle-sort-update.js +5 -19
- package/lib/components/SearchFilterSort/helpers/handle-sort-update.js.map +1 -1
- package/lib/components/SearchFilterSort/helpers/update-sort.js +5 -9
- package/lib/components/SearchFilterSort/helpers/update-sort.js.map +1 -1
- package/lib/helpers/build-inherited-filters.js +0 -2
- package/lib/helpers/build-inherited-filters.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/build-set-filters.js +1 -5
- package/lib/helpers/build-set-filters.js.map +1 -1
- package/lib/helpers/get-query-filters.js +8 -6
- package/lib/helpers/get-query-filters.js.map +1 -1
- package/lib/helpers/get-query-props.js +2 -13
- package/lib/helpers/get-query-props.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 -14
- 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/utils/get-class-modifiers.js +1 -1
- package/lib/utils/get-class-modifiers.js.map +1 -1
- package/lib-es/HOC/recreateOnNavigation.js +20 -0
- package/lib-es/HOC/recreateOnNavigation.js.map +1 -0
- package/lib-es/components/Button.js +1 -2
- package/lib-es/components/Button.js.map +1 -1
- package/lib-es/components/Card/CardsRender.js +7 -14
- package/lib-es/components/Card/CardsRender.js.map +1 -1
- package/lib-es/components/Card/helpers/index.js +0 -1
- package/lib-es/components/Card/helpers/index.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 +3 -2
- package/lib-es/components/Layout/Layout.js.map +1 -1
- package/lib-es/components/Layout/LayoutFactory.js +14 -0
- package/lib-es/components/Layout/LayoutFactory.js.map +1 -0
- package/lib-es/components/Layout/LayoutWithStickyTimer.js +42 -0
- package/lib-es/components/Layout/LayoutWithStickyTimer.js.map +1 -0
- package/lib-es/components/Layout/index.js +2 -2
- package/lib-es/components/Layout/index.js.map +1 -1
- package/lib-es/components/List/ListFactory.js +12 -16
- package/lib-es/components/List/ListFactory.js.map +1 -1
- package/lib-es/components/List/helpers/index.js +0 -2
- package/lib-es/components/List/helpers/index.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/SearchFilter/SearchFilter.js +11 -18
- package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilterContainer.js +72 -47
- package/lib-es/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/build-filters-query.js +0 -2
- package/lib-es/components/SearchFilter/helpers/build-filters-query.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/build-new-query.js +6 -0
- package/lib-es/components/SearchFilter/helpers/build-new-query.js.map +1 -0
- package/lib-es/components/SearchFilter/helpers/build-query.js +23 -0
- package/lib-es/components/SearchFilter/helpers/build-query.js.map +1 -0
- package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.js +26 -0
- package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.js.map +1 -0
- package/lib-es/components/SearchFilter/helpers/index.js +4 -5
- package/lib-es/components/SearchFilter/helpers/index.js.map +1 -1
- package/lib-es/components/SearchFilter/index.js +2 -2
- package/lib-es/components/SearchFilter/index.js.map +1 -1
- package/lib-es/components/SearchFilterSort/SearchFilterSort.js +10 -26
- package/lib-es/components/SearchFilterSort/SearchFilterSort.js.map +1 -1
- package/lib-es/components/SearchFilterSort/helpers/handle-sort-update.js +4 -21
- package/lib-es/components/SearchFilterSort/helpers/handle-sort-update.js.map +1 -1
- package/lib-es/components/SearchFilterSort/helpers/update-sort.js +4 -8
- package/lib-es/components/SearchFilterSort/helpers/update-sort.js.map +1 -1
- package/lib-es/helpers/build-inherited-filters.js +0 -2
- package/lib-es/helpers/build-inherited-filters.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/build-set-filters.js +1 -5
- package/lib-es/helpers/build-set-filters.js.map +1 -1
- package/lib-es/helpers/get-query-filters.js +8 -6
- package/lib-es/helpers/get-query-filters.js.map +1 -1
- package/lib-es/helpers/get-query-props.js +2 -10
- package/lib-es/helpers/get-query-props.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 -2
- 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/lib-es/utils/get-class-modifiers.js +1 -1
- package/lib-es/utils/get-class-modifiers.js.map +1 -1
- package/package.json +10 -10
- package/src/HOC/recreateOnNavigation.js +21 -0
- package/src/components/Button.js +1 -2
- package/src/components/Card/CardsRender.js +7 -27
- package/src/components/Card/helpers/index.js +0 -1
- 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 +29 -32
- package/src/components/Layout/LayoutFactory.js +17 -0
- package/src/components/Layout/LayoutWithStickyTimer.js +40 -0
- package/src/components/Layout/index.js +2 -2
- package/src/components/List/ListFactory.js +15 -25
- package/src/components/List/helpers/index.js +0 -2
- package/src/components/SearchContent/SearchContent.js +6 -8
- package/src/components/SearchFilter/SearchFilter/SearchFilter.js +12 -21
- package/src/components/SearchFilter/SearchFilterContainer.js +69 -57
- package/src/components/SearchFilter/helpers/build-filters-query.js +1 -9
- package/src/components/SearchFilter/helpers/build-new-query.js +6 -0
- package/src/components/SearchFilter/helpers/build-query.js +26 -0
- package/src/components/SearchFilter/helpers/get-initial-filter-values.js +30 -0
- package/src/components/SearchFilter/helpers/index.js +7 -9
- package/src/components/SearchFilter/index.js +2 -2
- package/src/components/SearchFilterSort/SearchFilterSort.js +8 -18
- package/src/components/SearchFilterSort/helpers/handle-sort-update.js +5 -14
- package/src/components/SearchFilterSort/helpers/update-sort.js +3 -7
- package/src/helpers/build-inherited-filters.js +1 -3
- package/src/helpers/build-props-query.js +2 -4
- package/src/helpers/build-set-filters.js +1 -2
- package/src/helpers/get-query-filters.js +4 -4
- package/src/helpers/get-query-props.js +4 -12
- package/src/helpers/get-wrapped-value-with-link.js +3 -6
- package/src/helpers/index.js +0 -2
- package/src/helpers/parse-props-to-display.js +21 -25
- package/src/utils/get-class-modifiers.js +1 -1
- package/tests/helpers/mocks.js +5 -3
- package/tests/unit/src/HOC/recreateOnNavigation.test.js +28 -0
- 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/Layout/Layout.test.js +1 -1
- package/tests/unit/src/components/Layout/LayoutFactory.test.js +53 -0
- package/tests/unit/src/components/SearchFilter/__snapshots__/SearchFilterContainer.test.js.snap +7 -1
- package/tests/unit/src/components/SearchFilter/helpers/build-new-query.test.js +10 -10
- package/tests/unit/src/components/SearchFilter/helpers/build-query.test.js +7 -24
- package/tests/unit/src/components/SearchFilter/helpers/get-initial-filter-values.test.js +10 -10
- package/tests/unit/src/components/SearchFilterSort/SearchFilterSort.test.js +1 -4
- package/tests/unit/src/components/SearchFilterSort/helpers/handle-sort-update.test.js +19 -26
- 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/components/Card/helpers/get-updated-items-to-display.js +0 -55
- package/lib/components/Card/helpers/get-updated-items-to-display.js.map +0 -1
- package/lib/components/List/helpers/get-list-query.js +0 -43
- package/lib/components/List/helpers/get-list-query.js.map +0 -1
- package/lib/components/List/helpers/get-list-specific-search-filter.js +0 -21
- package/lib/components/List/helpers/get-list-specific-search-filter.js.map +0 -1
- package/lib/components/List/helpers/strip-query-key.js +0 -14
- package/lib/components/List/helpers/strip-query-key.js.map +0 -1
- package/lib/components/SearchFilter/helpers/build-new-url.js +0 -17
- package/lib/components/SearchFilter/helpers/build-new-url.js.map +0 -1
- package/lib/components/SearchFilter/helpers/build-url-query.js +0 -48
- package/lib/components/SearchFilter/helpers/build-url-query.js.map +0 -1
- package/lib/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js +0 -32
- package/lib/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js.map +0 -1
- package/lib/components/SearchFilter/helpers/get-filter-values.js +0 -31
- package/lib/components/SearchFilter/helpers/get-filter-values.js.map +0 -1
- package/lib/components/SearchFilter/searchFilterReducer.js +0 -45
- package/lib/components/SearchFilter/searchFilterReducer.js.map +0 -1
- package/lib/helpers/build-query-key.js +0 -16
- package/lib/helpers/build-query-key.js.map +0 -1
- package/lib/helpers/process-data-summary-value.js +0 -56
- package/lib/helpers/process-data-summary-value.js.map +0 -1
- package/lib-es/components/Card/helpers/get-updated-items-to-display.js +0 -32
- package/lib-es/components/Card/helpers/get-updated-items-to-display.js.map +0 -1
- package/lib-es/components/List/helpers/get-list-query.js +0 -24
- package/lib-es/components/List/helpers/get-list-query.js.map +0 -1
- package/lib-es/components/List/helpers/get-list-specific-search-filter.js +0 -12
- package/lib-es/components/List/helpers/get-list-specific-search-filter.js.map +0 -1
- package/lib-es/components/List/helpers/strip-query-key.js +0 -6
- package/lib-es/components/List/helpers/strip-query-key.js.map +0 -1
- package/lib-es/components/SearchFilter/helpers/build-new-url.js +0 -8
- package/lib-es/components/SearchFilter/helpers/build-new-url.js.map +0 -1
- package/lib-es/components/SearchFilter/helpers/build-url-query.js +0 -30
- package/lib-es/components/SearchFilter/helpers/build-url-query.js.map +0 -1
- package/lib-es/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js +0 -18
- package/lib-es/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js.map +0 -1
- package/lib-es/components/SearchFilter/helpers/get-filter-values.js +0 -19
- package/lib-es/components/SearchFilter/helpers/get-filter-values.js.map +0 -1
- package/lib-es/components/SearchFilter/searchFilterReducer.js +0 -28
- package/lib-es/components/SearchFilter/searchFilterReducer.js.map +0 -1
- package/lib-es/helpers/build-query-key.js +0 -7
- package/lib-es/helpers/build-query-key.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/components/Card/helpers/get-updated-items-to-display.js +0 -32
- package/src/components/List/helpers/get-list-query.js +0 -28
- package/src/components/List/helpers/get-list-specific-search-filter.js +0 -10
- package/src/components/List/helpers/strip-query-key.js +0 -6
- package/src/components/SearchFilter/helpers/build-new-url.js +0 -8
- package/src/components/SearchFilter/helpers/build-url-query.js +0 -31
- package/src/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js +0 -17
- package/src/components/SearchFilter/helpers/get-filter-values.js +0 -21
- package/src/components/SearchFilter/searchFilterReducer.js +0 -15
- package/src/helpers/build-query-key.js +0 -7
- package/src/helpers/process-data-summary-value.js +0 -22
- package/tests/unit/src/components/Card/helpers/get-updated-items-to-display.test.js +0 -72
- 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
|
@@ -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;
|
|
@@ -25,7 +25,7 @@ const iconProps = [BUTTON_TYPE, ...commonProps];
|
|
|
25
25
|
const commonAttributes = { props: commonProps, prefix: null };
|
|
26
26
|
|
|
27
27
|
const supportedTypes = {
|
|
28
|
-
row: { props: [WIDTH, ...responsiveProps, ...commonProps] },
|
|
28
|
+
row: { props: [WIDTH, STICKY, ...responsiveProps, ...commonProps] },
|
|
29
29
|
column: { props: [WIDTH, STICKY, ...responsiveProps, ...commonProps] },
|
|
30
30
|
button: {
|
|
31
31
|
props: buttonProps,
|
package/tests/helpers/mocks.js
CHANGED
|
@@ -1139,9 +1139,11 @@ const MOCKED_PROPS_FILTERS_LIST = {
|
|
|
1139
1139
|
};
|
|
1140
1140
|
|
|
1141
1141
|
const MOCKED_PROPS_SEARCH_FILTER = {
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1142
|
+
router: {
|
|
1143
|
+
asPath: 'somePath',
|
|
1144
|
+
query: {},
|
|
1145
|
+
push: () => {}
|
|
1146
|
+
},
|
|
1145
1147
|
parent: {
|
|
1146
1148
|
itemEntity: 'published_page'
|
|
1147
1149
|
},
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
6
|
+
import { render } from '@testing-library/react';
|
|
7
|
+
import recreateOnNavigation from '../../../../src/HOC/recreateOnNavigation';
|
|
8
|
+
|
|
9
|
+
jest.mock('next/router', () => {
|
|
10
|
+
const mockRouter = {
|
|
11
|
+
asPath: '/abc',
|
|
12
|
+
push: null
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
router: mockRouter,
|
|
16
|
+
useRouter: () => mockRouter
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe('recreateOnNavigation HOC', () => {
|
|
21
|
+
const mockComponent = jest.fn(() => <div>Mock Component</div>);
|
|
22
|
+
it('should render component and change key on route change', async () => {
|
|
23
|
+
const WrapperComponent = recreateOnNavigation(mockComponent);
|
|
24
|
+
const name = 'test';
|
|
25
|
+
render(<WrapperComponent name={name} />);
|
|
26
|
+
expect(mockComponent).toHaveBeenCalledWith(expect.objectContaining({ name }), {});
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -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]);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import '@testing-library/jest-dom/extend-expect';
|
|
6
6
|
import { render } from '@blaze-cms/tools/test-helpers/test-functions';
|
|
7
|
-
import Layout from '../../../../../src/components/Layout';
|
|
7
|
+
import Layout from '../../../../../src/components/Layout/Layout';
|
|
8
8
|
import { COLUMN, ROW } from '../../../../../src/constants';
|
|
9
9
|
import useGetImages from '../../../../../src/hooks/use-get-images';
|
|
10
10
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
6
|
+
import { render } from '@testing-library/react';
|
|
7
|
+
import Layout from '../../../../../src/components/Layout';
|
|
8
|
+
|
|
9
|
+
jest.mock('../../../../../src/components/Layout/Layout', () =>
|
|
10
|
+
jest.fn(({ children }) => <div data-testid="Layout">{children}</div>)
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
jest.mock('next/dynamic', () => {
|
|
14
|
+
const LayoutWithStickyTimer = ({ children }) => (
|
|
15
|
+
<div data-testid="LayoutWithStickyTimer">{children}</div>
|
|
16
|
+
);
|
|
17
|
+
return jest.fn(() => LayoutWithStickyTimer);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const defaultComponentTestId = 'Layout';
|
|
21
|
+
const testId = 'child-test-id';
|
|
22
|
+
|
|
23
|
+
describe('LayoutFactoriy component', () => {
|
|
24
|
+
const props = { someProps: true, children: <div data-testid={testId} /> };
|
|
25
|
+
|
|
26
|
+
it('should be defined', () => {
|
|
27
|
+
expect(Layout).toBeDefined();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should render Layout component', () => {
|
|
31
|
+
const { getByTestId } = render(<Layout {...props} />);
|
|
32
|
+
expect(getByTestId(defaultComponentTestId)).toBeDefined();
|
|
33
|
+
expect(getByTestId(testId)).toBeDefined();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should render LayoutWithStickyTimer component', () => {
|
|
37
|
+
const { getByTestId } = render(<Layout {...props} sticky stickyTimer={10} />);
|
|
38
|
+
expect(getByTestId('LayoutWithStickyTimer')).toBeDefined();
|
|
39
|
+
expect(getByTestId(testId)).toBeDefined();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should render if stickyTimer is not set', () => {
|
|
43
|
+
const { getByTestId } = render(<Layout {...props} sticky />);
|
|
44
|
+
expect(getByTestId(defaultComponentTestId)).toBeDefined();
|
|
45
|
+
expect(getByTestId(testId)).toBeDefined();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('should render if sticky is not set', () => {
|
|
49
|
+
const { getByTestId } = render(<Layout {...props} stickyTimer={20} />);
|
|
50
|
+
expect(getByTestId(defaultComponentTestId)).toBeDefined();
|
|
51
|
+
expect(getByTestId(testId)).toBeDefined();
|
|
52
|
+
});
|
|
53
|
+
});
|
package/tests/unit/src/components/SearchFilter/__snapshots__/SearchFilterContainer.test.js.snap
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`SearchFilter container should match snapshot 1`] =
|
|
3
|
+
exports[`SearchFilter container should match snapshot 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div>
|
|
6
|
+
Mocked component
|
|
7
|
+
</div>
|
|
8
|
+
</DocumentFragment>
|
|
9
|
+
`;
|
|
4
10
|
|
|
5
11
|
exports[`SearchFilter container should return null if no filters are passed 1`] = `<DocumentFragment />`;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import buildNewQuery from '../../../../../../src/components/SearchFilter/helpers/build-new-query';
|
|
2
|
+
|
|
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']
|
|
7
|
-
['urlFromProps', 'not=used', 'another=query&withthis=value', 'this-is-content']
|
|
6
|
+
['urlFromProps', 'not=used', 'another=query&withthis=value', 'sort=asc&sortby=name']
|
|
8
7
|
];
|
|
9
8
|
|
|
10
|
-
describe('
|
|
11
|
-
const simpleExample =
|
|
12
|
-
const withPropsUrl =
|
|
13
|
-
const
|
|
9
|
+
describe('buildNewQuery helper function', () => {
|
|
10
|
+
const simpleExample = buildNewQuery(...mockedProps[0]);
|
|
11
|
+
const withPropsUrl = buildNewQuery(...mockedProps[1]);
|
|
12
|
+
const withSort = buildNewQuery(...mockedProps[2]);
|
|
14
13
|
|
|
15
14
|
it('should always return a string', () => {
|
|
16
15
|
expect(typeof simpleExample).toBe('string');
|
|
17
16
|
expect(typeof withPropsUrl).toBe('string');
|
|
17
|
+
expect(typeof withSort).toBe('string');
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
it('should return new url using asPath and queryParams passed', () => {
|
|
@@ -25,7 +25,7 @@ describe('buildNewUrl helper function', () => {
|
|
|
25
25
|
expect(withPropsUrl).toEqual('urlFromProps?other=query&with=value');
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
it('should return new url with
|
|
29
|
-
expect(
|
|
28
|
+
it('should return new url with sort if passed', () => {
|
|
29
|
+
expect(withSort).toEqual('urlFromProps?another=query&withthis=value&sort=asc&sortby=name');
|
|
30
30
|
});
|
|
31
31
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import buildQuery from '../../../../../../src/components/SearchFilter/helpers/build-query';
|
|
2
2
|
import { SEARCH_TERM } from '../../../../../../src/components/SearchFilter/constants';
|
|
3
3
|
|
|
4
4
|
const mockedProps = [
|
|
@@ -10,15 +10,10 @@ const mockedProps = [
|
|
|
10
10
|
]
|
|
11
11
|
];
|
|
12
12
|
|
|
13
|
-
describe('
|
|
14
|
-
const simpleExample =
|
|
15
|
-
const withTextSearch =
|
|
16
|
-
const withSearchAndRange =
|
|
17
|
-
const withListName = buildUrlQuery(...mockedProps[2], 'listName');
|
|
18
|
-
const withListNameAndOtherQueryBits = buildUrlQuery(...mockedProps[2], 'listName', {
|
|
19
|
-
sort: 'asc',
|
|
20
|
-
anotherQuery: '123'
|
|
21
|
-
});
|
|
13
|
+
describe('buildQuery helper function', () => {
|
|
14
|
+
const simpleExample = buildQuery(...mockedProps[0]);
|
|
15
|
+
const withTextSearch = buildQuery(...mockedProps[1]);
|
|
16
|
+
const withSearchAndRange = buildQuery(...mockedProps[2]);
|
|
22
17
|
|
|
23
18
|
it('should always return a string', () => {
|
|
24
19
|
expect(typeof simpleExample).toBe('string');
|
|
@@ -29,22 +24,10 @@ describe('buildUrlQuery helper function', () => {
|
|
|
29
24
|
});
|
|
30
25
|
|
|
31
26
|
it('should return new query string with search term if available', () => {
|
|
32
|
-
expect(withTextSearch).toEqual('search_term=new
|
|
27
|
+
expect(withTextSearch).toEqual('search_term=new%20search%20value');
|
|
33
28
|
});
|
|
34
29
|
|
|
35
30
|
it('should return new query string with search text and all other available query values', () => {
|
|
36
|
-
expect(withSearchAndRange).toEqual('search_term=new
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('should return new query string listName if passed', () => {
|
|
40
|
-
expect(withListName).toEqual(
|
|
41
|
-
'pb[listName][search_term]=new search value&pb[listName][rangeFilter]=2-10'
|
|
42
|
-
);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('should return new query string with unaltered bits from other query', () => {
|
|
46
|
-
expect(withListNameAndOtherQueryBits).toEqual(
|
|
47
|
-
'pb[listName][search_term]=new search value&pb[listName][rangeFilter]=2-10&sort=asc&anotherQuery=123'
|
|
48
|
-
);
|
|
31
|
+
expect(withSearchAndRange).toEqual('search_term=new%20search%20value&rangeFilter=2-10');
|
|
49
32
|
});
|
|
50
33
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import getInitialFilterValues from '../../../../../../src/components/SearchFilter/helpers/get-initial-filter-values';
|
|
2
2
|
import { SEARCH_TERM } from '../../../../../../src/components/SearchFilter/constants';
|
|
3
3
|
|
|
4
4
|
const filters = [
|
|
@@ -16,24 +16,25 @@ const mockedProps = [
|
|
|
16
16
|
[{ rangeFilter: { min: 5, max: 10 }, checkboxFilter: {}, emptySelect: {} }, filters, query]
|
|
17
17
|
];
|
|
18
18
|
|
|
19
|
-
describe('
|
|
20
|
-
const withNoValue =
|
|
21
|
-
const withValues =
|
|
19
|
+
describe('getInitialFilterValues helper function', () => {
|
|
20
|
+
const withNoValue = getInitialFilterValues(...mockedProps[0]);
|
|
21
|
+
const withValues = getInitialFilterValues(...mockedProps[1]);
|
|
22
22
|
|
|
23
23
|
it('should return init filter values based on query and filterData', () => {
|
|
24
|
-
expect(withNoValue).toEqual({
|
|
24
|
+
expect(withNoValue).toEqual({ dataNotSet: false, search_term: '' });
|
|
25
25
|
expect(withValues).toEqual({
|
|
26
|
+
dataNotSet: false,
|
|
26
27
|
search_term: query[SEARCH_TERM],
|
|
27
28
|
rangeFilter: { max: 10, maxValue: 8, min: 5, minValue: 7, step: 1 },
|
|
28
29
|
checkboxFilter: ['check1', 'check2'],
|
|
29
|
-
emptySelect: null
|
|
30
|
-
dataNotSet: false
|
|
30
|
+
emptySelect: null
|
|
31
31
|
});
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
it('should return init filter values without filterData', () => {
|
|
35
|
-
const withNoData =
|
|
35
|
+
const withNoData = getInitialFilterValues(null, filters, query);
|
|
36
36
|
expect(withNoData).toEqual({
|
|
37
|
+
dataNotSet: true,
|
|
37
38
|
search_term: query[SEARCH_TERM],
|
|
38
39
|
rangeFilter: {
|
|
39
40
|
max: 8,
|
|
@@ -43,8 +44,7 @@ describe('getFilterValues helper function', () => {
|
|
|
43
44
|
step: 1
|
|
44
45
|
},
|
|
45
46
|
checkboxFilter: query.checkboxFilter,
|
|
46
|
-
emptySelect: null
|
|
47
|
-
dataNotSet: true
|
|
47
|
+
emptySelect: null
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
50
|
});
|
|
@@ -5,11 +5,8 @@ import { render } from '@blaze-cms/tools/test-helpers/test-functions';
|
|
|
5
5
|
import '@testing-library/jest-dom/extend-expect';
|
|
6
6
|
import SearchFilterSort from '../../../../../src/components/SearchFilterSort/SearchFilterSort';
|
|
7
7
|
|
|
8
|
-
jest.mock('next/router', () => ({
|
|
9
|
-
useRouter: jest.fn(() => ({ asPath: 'test-url' }))
|
|
10
|
-
}));
|
|
11
|
-
|
|
12
8
|
const props = {
|
|
9
|
+
router: { asPath: 'some-path' },
|
|
13
10
|
filters: [{ label: 'label1', propsToDisplay: ['name'], sort: 'ascending' }],
|
|
14
11
|
label: 'someLabel',
|
|
15
12
|
id: '123456'
|
|
@@ -1,50 +1,43 @@
|
|
|
1
1
|
import handleSortUpdate from '../../../../../../src/components/SearchFilterSort/helpers/handle-sort-update';
|
|
2
2
|
|
|
3
3
|
const routerPushResultMock = () => ({ then: jest.fn() });
|
|
4
|
-
// router, value, query, url, selectLabel, listComponentName
|
|
5
4
|
const mockedProps = [
|
|
6
|
-
{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
router: { asPath: 'asPath', push: jest.fn(routerPushResultMock) },
|
|
22
|
-
value: 'name:desc',
|
|
23
|
-
query: { someOther: 'ott' },
|
|
24
|
-
url: 'url',
|
|
25
|
-
selectLabel: 'defaultOption'
|
|
26
|
-
}
|
|
5
|
+
[{ push: jest.fn(routerPushResultMock) }, 'defaultOption', {}, 'url', 'defaultOption'],
|
|
6
|
+
[
|
|
7
|
+
{ push: jest.fn(routerPushResultMock) },
|
|
8
|
+
'defaultOption',
|
|
9
|
+
{ sort: 'asc', sortby: 'name', type: 'big' },
|
|
10
|
+
'baseurl',
|
|
11
|
+
'defaultOption'
|
|
12
|
+
],
|
|
13
|
+
[
|
|
14
|
+
{ push: jest.fn(routerPushResultMock) },
|
|
15
|
+
'name:desc',
|
|
16
|
+
{ someOther: 'ott' },
|
|
17
|
+
'url',
|
|
18
|
+
'defaultOption'
|
|
19
|
+
]
|
|
27
20
|
];
|
|
28
21
|
|
|
29
22
|
describe('handleSortUpdate helper function', () => {
|
|
30
|
-
mockedProps.forEach(props => handleSortUpdate(
|
|
23
|
+
mockedProps.forEach(props => handleSortUpdate(...props));
|
|
31
24
|
|
|
32
25
|
it('should navigate to url with no sort if default value is selected', () => {
|
|
33
|
-
expect(mockedProps[0].
|
|
26
|
+
expect(mockedProps[0][0].push).toHaveBeenLastCalledWith('/Resolver', 'url', {
|
|
34
27
|
shallow: true,
|
|
35
28
|
scroll: false
|
|
36
29
|
});
|
|
37
30
|
});
|
|
38
31
|
|
|
39
32
|
it('should navigate to url with no sort with previous querys if default value is selected', () => {
|
|
40
|
-
expect(mockedProps[1].
|
|
33
|
+
expect(mockedProps[1][0].push).toHaveBeenLastCalledWith('/Resolver', 'baseurl?type=big', {
|
|
41
34
|
shallow: true,
|
|
42
35
|
scroll: false
|
|
43
36
|
});
|
|
44
37
|
});
|
|
45
38
|
|
|
46
39
|
it('should navigate to url with new sort if selected', () => {
|
|
47
|
-
expect(mockedProps[2].
|
|
40
|
+
expect(mockedProps[2][0].push).toHaveBeenLastCalledWith(
|
|
48
41
|
'/Resolver',
|
|
49
42
|
'url?someOther=ott&sort=desc&sortby=name',
|
|
50
43
|
{ shallow: true, scroll: false }
|
|
@@ -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,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require("core-js/modules/es.object.define-property.js");
|
|
4
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
-
require("core-js/modules/es.array.find.js");
|
|
12
|
-
require("core-js/modules/es.object.to-string.js");
|
|
13
|
-
require("core-js/modules/es.array.index-of.js");
|
|
14
|
-
require("core-js/modules/es.object.keys.js");
|
|
15
|
-
require("core-js/modules/es.array.is-array.js");
|
|
16
|
-
require("core-js/modules/es.array.for-each.js");
|
|
17
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
|
18
|
-
var getUpdatedItemsToDisplay = function getUpdatedItemsToDisplay(_ref) {
|
|
19
|
-
var parentSchema = _ref.parentSchema,
|
|
20
|
-
parentEntityData = _ref.parentEntityData,
|
|
21
|
-
_ref$itemsToDisplay = _ref.itemsToDisplay,
|
|
22
|
-
itemsToDisplay = _ref$itemsToDisplay === void 0 ? [] : _ref$itemsToDisplay,
|
|
23
|
-
_ref$inheritedFilters = _ref.inheritedFilters,
|
|
24
|
-
inheritedFilters = _ref$inheritedFilters === void 0 ? [] : _ref$inheritedFilters;
|
|
25
|
-
var idProp = inheritedFilters.find(function (filter) {
|
|
26
|
-
return filter.indexOf('id/') === 0;
|
|
27
|
-
});
|
|
28
|
-
if (!idProp || !parentSchema || !parentEntityData) return itemsToDisplay;
|
|
29
|
-
var properties = parentSchema.properties;
|
|
30
|
-
var _idProp$split = idProp.split('/'),
|
|
31
|
-
_idProp$split2 = (0, _slicedToArray2["default"])(_idProp$split, 2),
|
|
32
|
-
entityKey = _idProp$split2[1];
|
|
33
|
-
if (!properties || !entityKey) return itemsToDisplay;
|
|
34
|
-
var queryValue = Object.keys(properties).find(function (propKey) {
|
|
35
|
-
return properties[propKey] && properties[propKey].relation && properties[propKey].relation.entityIdentifier === entityKey;
|
|
36
|
-
});
|
|
37
|
-
var parentValues = parentEntityData[queryValue];
|
|
38
|
-
if (!parentValues) return itemsToDisplay;
|
|
39
|
-
var updatedItemsToDisplay = (0, _toConsumableArray2["default"])(itemsToDisplay);
|
|
40
|
-
if (Array.isArray(parentValues)) {
|
|
41
|
-
parentValues.forEach(function (value) {
|
|
42
|
-
updatedItemsToDisplay.push({
|
|
43
|
-
displayItems: [value]
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
} else {
|
|
47
|
-
updatedItemsToDisplay.push({
|
|
48
|
-
displayItems: [parentValues]
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
return updatedItemsToDisplay;
|
|
52
|
-
};
|
|
53
|
-
var _default = getUpdatedItemsToDisplay;
|
|
54
|
-
exports["default"] = _default;
|
|
55
|
-
//# sourceMappingURL=get-updated-items-to-display.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-updated-items-to-display.js","names":["getUpdatedItemsToDisplay","_ref","parentSchema","parentEntityData","_ref$itemsToDisplay","itemsToDisplay","_ref$inheritedFilters","inheritedFilters","idProp","find","filter","indexOf","properties","_idProp$split","split","_idProp$split2","_slicedToArray2","entityKey","queryValue","Object","keys","propKey","relation","entityIdentifier","parentValues","updatedItemsToDisplay","_toConsumableArray2","Array","isArray","forEach","value","push","displayItems","_default","exports"],"sources":["../../../../src/components/Card/helpers/get-updated-items-to-display.js"],"sourcesContent":["const getUpdatedItemsToDisplay = ({\n parentSchema,\n parentEntityData,\n itemsToDisplay = [],\n inheritedFilters = []\n}) => {\n const idProp = inheritedFilters.find(filter => filter.indexOf('id/') === 0);\n\n if (!idProp || !parentSchema || !parentEntityData) return itemsToDisplay;\n const { properties } = parentSchema;\n const [, entityKey] = idProp.split('/');\n if (!properties || !entityKey) return itemsToDisplay;\n const queryValue = Object.keys(properties).find(\n propKey =>\n properties[propKey] &&\n properties[propKey].relation &&\n properties[propKey].relation.entityIdentifier === entityKey\n );\n const parentValues = parentEntityData[queryValue];\n if (!parentValues) return itemsToDisplay;\n const updatedItemsToDisplay = [...itemsToDisplay];\n if (Array.isArray(parentValues)) {\n parentValues.forEach(value => {\n updatedItemsToDisplay.push({ displayItems: [value] });\n });\n } else {\n updatedItemsToDisplay.push({ displayItems: [parentValues] });\n }\n return updatedItemsToDisplay;\n};\n\nexport default getUpdatedItemsToDisplay;\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAMA,wBAAwB,GAAG,SAA3BA,wBAAwBA,CAAAC,IAAA,EAKxB;EAAA,IAJJC,YAAY,GAAAD,IAAA,CAAZC,YAAY;IACZC,gBAAgB,GAAAF,IAAA,CAAhBE,gBAAgB;IAAAC,mBAAA,GAAAH,IAAA,CAChBI,cAAc;IAAdA,cAAc,GAAAD,mBAAA,cAAG,EAAE,GAAAA,mBAAA;IAAAE,qBAAA,GAAAL,IAAA,CACnBM,gBAAgB;IAAhBA,gBAAgB,GAAAD,qBAAA,cAAG,EAAE,GAAAA,qBAAA;EAErB,IAAME,MAAM,GAAGD,gBAAgB,CAACE,IAAI,CAAC,UAAAC,MAAM;IAAA,OAAIA,MAAM,CAACC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;EAAA,EAAC;EAE3E,IAAI,CAACH,MAAM,IAAI,CAACN,YAAY,IAAI,CAACC,gBAAgB,EAAE,OAAOE,cAAc;EACxE,IAAQO,UAAU,GAAKV,YAAY,CAA3BU,UAAU;EAClB,IAAAC,aAAA,GAAsBL,MAAM,CAACM,KAAK,CAAC,GAAG,CAAC;IAAAC,cAAA,OAAAC,eAAA,aAAAH,aAAA;IAA9BI,SAAS,GAAAF,cAAA;EAClB,IAAI,CAACH,UAAU,IAAI,CAACK,SAAS,EAAE,OAAOZ,cAAc;EACpD,IAAMa,UAAU,GAAGC,MAAM,CAACC,IAAI,CAACR,UAAU,CAAC,CAACH,IAAI,CAC7C,UAAAY,OAAO;IAAA,OACLT,UAAU,CAACS,OAAO,CAAC,IACnBT,UAAU,CAACS,OAAO,CAAC,CAACC,QAAQ,IAC5BV,UAAU,CAACS,OAAO,CAAC,CAACC,QAAQ,CAACC,gBAAgB,KAAKN,SAAS;EAAA,CAC/D,CAAC;EACD,IAAMO,YAAY,GAAGrB,gBAAgB,CAACe,UAAU,CAAC;EACjD,IAAI,CAACM,YAAY,EAAE,OAAOnB,cAAc;EACxC,IAAMoB,qBAAqB,OAAAC,mBAAA,aAAOrB,cAAc,CAAC;EACjD,IAAIsB,KAAK,CAACC,OAAO,CAACJ,YAAY,CAAC,EAAE;IAC/BA,YAAY,CAACK,OAAO,CAAC,UAAAC,KAAK,EAAI;MAC5BL,qBAAqB,CAACM,IAAI,CAAC;QAAEC,YAAY,EAAE,CAACF,KAAK;MAAE,CAAC,CAAC;IACvD,CAAC,CAAC;EACJ,CAAC,MAAM;IACLL,qBAAqB,CAACM,IAAI,CAAC;MAAEC,YAAY,EAAE,CAACR,YAAY;IAAE,CAAC,CAAC;EAC9D;EACA,OAAOC,qBAAqB;AAC9B,CAAC;AAAC,IAAAQ,QAAA,GAEajC,wBAAwB;AAAAkC,OAAA,cAAAD,QAAA"}
|