@uncinc/uncinc-react-kitchen-sink 2.3.3 → 2.3.5

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.
Files changed (118) hide show
  1. package/dist/Context/withMapping.js +1 -6
  2. package/dist/components/AbbreviationAnnotation/index.js +47 -0
  3. package/dist/components/AbbreviationAnnotation/stories.js +23 -0
  4. package/dist/components/AbbreviationAnnotation/stories.scss +39 -0
  5. package/dist/components/AbbreviationAnnotation/style.scss +33 -0
  6. package/dist/components/Accordion/AccordionItem/index.js +0 -5
  7. package/dist/components/Accordion/AccordionItemVariant/index.js +0 -5
  8. package/dist/components/Accordion/index.js +0 -2
  9. package/dist/components/ApiAutocomplete/index.js +6 -12
  10. package/dist/components/Button/index.js +4 -10
  11. package/dist/components/Cookie/Checkbox/index.js +0 -2
  12. package/dist/components/Cookie/index.js +39 -34
  13. package/dist/components/FontSizeSwitcher/index.js +2 -8
  14. package/dist/components/Form/Checkbox/index.js +1 -4
  15. package/dist/components/Form/Checkbox/stories.js +0 -2
  16. package/dist/components/Form/Checkboxes/index.js +1 -7
  17. package/dist/components/Form/Checkboxes/index.test.js +8 -4
  18. package/dist/components/Form/Checkboxes/stories.js +1 -4
  19. package/dist/components/Form/Date/index.js +1 -4
  20. package/dist/components/Form/Date/stories.js +0 -2
  21. package/dist/components/Form/DatePicker/index.js +0 -2
  22. package/dist/components/Form/DatePicker/stories.js +0 -2
  23. package/dist/components/Form/DateSelect/index.js +110 -85
  24. package/dist/components/Form/DateSelect/stories.js +24 -15
  25. package/dist/components/Form/DateSelect/style.scss +10 -4
  26. package/dist/components/Form/Email/index.js +1 -4
  27. package/dist/components/Form/Email/stories.js +0 -2
  28. package/dist/components/Form/FormikWrapper/index.js +9 -15
  29. package/dist/components/Form/GenericFormElement/index.js +0 -2
  30. package/dist/components/Form/Number/index.js +12 -13
  31. package/dist/components/Form/Number/stories.js +0 -2
  32. package/dist/components/Form/RadioButtons/index.js +1 -7
  33. package/dist/components/Form/RadioButtons/index.test.js +8 -4
  34. package/dist/components/Form/RadioButtons/stories.js +1 -4
  35. package/dist/components/Form/SearchField/index.js +0 -2
  36. package/dist/components/Form/Select/Input/index.js +6 -14
  37. package/dist/components/Form/Select/index.js +1 -4
  38. package/dist/components/Form/Select/stories.js +0 -4
  39. package/dist/components/Form/TextField/index.js +0 -6
  40. package/dist/components/Form/TextField/index.test.js +8 -4
  41. package/dist/components/Form/TextField/stories.js +1 -4
  42. package/dist/components/Form/Textarea/index.js +0 -2
  43. package/dist/components/Form/Textarea/stories.js +0 -2
  44. package/dist/components/Hamburger/index.js +0 -2
  45. package/dist/components/Header/index.js +4 -9
  46. package/dist/components/Image/Background/index.js +1 -7
  47. package/dist/components/Image/LazyLoadWrapper/index.js +0 -12
  48. package/dist/components/Image/Picture/index.js +4 -19
  49. package/dist/components/Image/index.js +0 -4
  50. package/dist/components/InlineMenu/index.js +0 -9
  51. package/dist/components/Layout/Container/index.js +1 -4
  52. package/dist/components/Layout/Container/stories.js +0 -3
  53. package/dist/components/Layout/QuickLayout/Auto/index.js +0 -2
  54. package/dist/components/Layout/QuickLayout/Center/index.js +0 -2
  55. package/dist/components/Layout/QuickLayout/Clamp/index.js +0 -2
  56. package/dist/components/Layout/QuickLayout/Sidebar/index.js +0 -2
  57. package/dist/components/Layout/QuickLayout/SpaceBetween/index.js +0 -2
  58. package/dist/components/Layout/QuickLayout/Stack/index.js +1 -4
  59. package/dist/components/Layout/QuickLayout/Wrap/index.js +0 -2
  60. package/dist/components/Layout/QuickLayout/index.js +0 -9
  61. package/dist/components/Lottie/LottieAnimation/index.js +12 -17
  62. package/dist/components/Lottie/LottieAnimationWithMousePosition.js +8 -9
  63. package/dist/components/Lottie/index.js +3 -3
  64. package/dist/components/Lottie/stories.js +10 -5
  65. package/dist/components/MagicLine/index.js +0 -14
  66. package/dist/components/MagicLine/stories.js +0 -2
  67. package/dist/components/NavigationScroll/index.js +2 -12
  68. package/dist/components/Pagination/index.js +0 -7
  69. package/dist/components/SearchKit/Facets/ChipFacet/index.js +0 -2
  70. package/dist/components/SearchKit/Facets/HierarchicalFilterFacet/index.js +0 -2
  71. package/dist/components/SearchKit/Facets/HierarchicalMenuFacet/index.js +0 -2
  72. package/dist/components/SearchKit/Facets/SelectFacet/index.js +0 -6
  73. package/dist/components/SearchKit/Query/index.js +3 -6
  74. package/dist/components/SearchKit/SearchFacets/index.js +0 -7
  75. package/dist/components/SearchKit/SearchField/index.js +0 -9
  76. package/dist/components/SearchKit/SearchLoadMore/index.js +0 -7
  77. package/dist/components/SearchKit/SearchPage/index.js +3 -9
  78. package/dist/components/SearchKit/SearchPagination/index.js +0 -5
  79. package/dist/components/SearchKit/SearchReset/index.js +0 -2
  80. package/dist/components/SearchKit/SearchResults/index.js +9 -16
  81. package/dist/components/SearchKit/SearchSelectedFilters/index.js +0 -4
  82. package/dist/components/SearchKit/SearchSorting/index.js +2 -4
  83. package/dist/components/SearchKit/index.js +0 -3
  84. package/dist/components/SearchKit/stories.js +2 -7
  85. package/dist/components/Share/index.js +0 -3
  86. package/dist/components/Sliders/SliderRelated/index.js +1 -6
  87. package/dist/components/Sliders/SliderRelated/stories.js +1 -4
  88. package/dist/components/Webform/WebformActions/index.js +0 -2
  89. package/dist/components/Webform/WebformCheckbox/index.js +1 -8
  90. package/dist/components/Webform/WebformCheckboxes/index.js +1 -9
  91. package/dist/components/Webform/WebformContainer/index.js +5 -6
  92. package/dist/components/Webform/WebformDate/index.js +12 -18
  93. package/dist/components/Webform/WebformMapper/index.js +1 -18
  94. package/dist/components/Webform/WebformNumber/index.js +1 -4
  95. package/dist/components/Webform/WebformRadioButtons/index.js +1 -9
  96. package/dist/components/Webform/WebformSelect/index.js +1 -9
  97. package/dist/components/Webform/WebformTextField/index.js +1 -8
  98. package/dist/components/Webform/WebformTextarea/index.js +1 -8
  99. package/dist/components/Webform/WebformWizardPage/index.js +6 -8
  100. package/dist/components/Webform/index.js +1 -8
  101. package/dist/components/Webform/withStates.js +6 -19
  102. package/dist/components/WysiwygField/index.js +1 -8
  103. package/dist/components/WysiwygField/stories.js +4 -14
  104. package/dist/config/constants.js +3 -4
  105. package/dist/config/i18next/index.js +23 -0
  106. package/dist/config/i18next/locales/en.json +22 -0
  107. package/dist/config/i18next/locales/nl.json +22 -0
  108. package/dist/helpers/gtm.js +11 -15
  109. package/dist/helpers/link.js +0 -4
  110. package/dist/helpers/useValueForCurrentViewPort.js +20 -14
  111. package/dist/hooks/useOnScreen.js +2 -2
  112. package/dist/hooks/usePrevious.js +3 -2
  113. package/dist/hooks/useScrollPosition.js +0 -3
  114. package/dist/hooks/useWindowDimensions.js +0 -3
  115. package/dist/index.js +2 -1
  116. package/dist/styles/assets/_base.scss +0 -1
  117. package/package.json +14 -5
  118. package/dist/pages/api/graphql.js +0 -25
@@ -2,7 +2,6 @@ import React, { useState, useEffect, useRef } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import PropTypes from 'prop-types';
4
4
  import './style.scss';
5
-
6
5
  const NavigationScroll = props => {
7
6
  const node = useRef(null);
8
7
  const [state, setState] = useState({
@@ -18,41 +17,34 @@ const NavigationScroll = props => {
18
17
  window.removeEventListener('scroll', handleScroll);
19
18
  };
20
19
  });
21
-
22
20
  const getScrollPos = element => {
23
21
  if (typeof element.pageYOffset !== 'undefined') {
24
22
  return element.pageYOffset;
25
23
  }
26
-
27
24
  return element.scrollTop;
28
25
  };
29
-
30
26
  const getElementHeight = element => {
31
27
  let deductHeight = 0;
32
-
33
28
  if (document.getElementsByClassName('Header__subMenu').length !== 0) {
34
29
  deductHeight = document.getElementsByClassName('Header__subMenu')[0].clientHeight;
35
30
  }
36
-
37
31
  return element.offsetHeight - deductHeight;
38
32
  };
39
-
40
33
  const handleScroll = () => {
41
34
  const scrollPos = getScrollPos(window);
42
35
  let elementHeight = getElementHeight(node.current);
43
36
  let newPos = 0;
44
-
45
37
  if (scrollPos > 0) {
46
38
  const diff = state._previousPos - scrollPos;
47
39
  newPos = state.pos + diff;
48
40
  newPos = Math.max(-elementHeight, Math.min(0, newPos));
49
41
  }
50
-
51
42
  const isVisible = newPos > -elementHeight;
52
43
  const hasReachedTop = scrollPos < 5 && isVisible;
53
44
  const hasReachedBottom = Math.round(scrollPos + window.innerHeight) >= document.body.clientHeight;
54
45
  const scrolledPastNavHeight = scrollPos > elementHeight;
55
- setState(prevState => ({ ...prevState,
46
+ setState(prevState => ({
47
+ ...prevState,
56
48
  pos: hasReachedBottom ? 0 : newPos,
57
49
  reachedTop: hasReachedTop,
58
50
  scrolledPastNavHeight,
@@ -60,7 +52,6 @@ const NavigationScroll = props => {
60
52
  _previousPos: scrollPos
61
53
  }));
62
54
  };
63
-
64
55
  const {
65
56
  reachedTop,
66
57
  reachedBottom,
@@ -85,7 +76,6 @@ const NavigationScroll = props => {
85
76
  }
86
77
  }, children);
87
78
  };
88
-
89
79
  NavigationScroll.propTypes = {
90
80
  children: PropTypes.element.isRequired,
91
81
  onUpdate: PropTypes.func
@@ -4,7 +4,6 @@ import c from 'classnames';
4
4
  import './style.scss';
5
5
  import PropTypes from 'prop-types';
6
6
  import withMapping from '../../Context/withMapping';
7
-
8
7
  const Pagination = ({
9
8
  currentPage,
10
9
  totalPages,
@@ -24,19 +23,15 @@ const Pagination = ({
24
23
  setCurrentPage(data.selected + 1);
25
24
  }
26
25
  };
27
-
28
26
  if (totalPages === 0) {
29
27
  return null;
30
28
  }
31
-
32
29
  if (totalPages === 1 && !showWhenOnePage) {
33
30
  return null;
34
31
  }
35
-
36
32
  if (currentPage > totalPages) {
37
33
  currentPage = totalPages;
38
34
  }
39
-
40
35
  if (!previousLabel || !nextLabel) {
41
36
  previousLabel = /*#__PURE__*/React.createElement("a", {
42
37
  className: "Pagination__previous__icon"
@@ -45,7 +40,6 @@ const Pagination = ({
45
40
  className: "Pagination__next__icon"
46
41
  });
47
42
  }
48
-
49
43
  const containerClasses = c('Pagination__container', containerClassName);
50
44
  const breakClasses = c('Pagination__break', breakClassName);
51
45
  const disabledClasses = c('disabled', disabledClassName);
@@ -67,7 +61,6 @@ const Pagination = ({
67
61
  activeClassName: activeClasses
68
62
  }));
69
63
  };
70
-
71
64
  Pagination.propTypes = {
72
65
  currentPage: PropTypes.number.isRequired,
73
66
  totalPages: PropTypes.number.isRequired,
@@ -2,11 +2,9 @@ import React from 'react';
2
2
  import { useSearchkit } from '@searchkit/client';
3
3
  import Button from '../../../Button';
4
4
  import classNames from 'classnames';
5
-
6
5
  const makeSafeForCSS = value => {
7
6
  return encodeURIComponent(value).replace(/\.|%[0-9a-z]{2}/gi, '');
8
7
  };
9
-
10
8
  export const ChipFacet = ({
11
9
  facet
12
10
  }) => {
@@ -1,7 +1,6 @@
1
1
  import React, { Fragment, useRef } from 'react';
2
2
  import { EuiFacetGroup, EuiTitle, EuiFacetButton } from '@elastic/eui';
3
3
  import { useSearchkit, FilterLink } from '@searchkit/client';
4
-
5
4
  const EntriesList = ({
6
5
  entries,
7
6
  loading,
@@ -48,7 +47,6 @@ const EntriesList = ({
48
47
  });
49
48
  return /*#__PURE__*/React.createElement(EuiFacetGroup, null, entriesElements);
50
49
  };
51
-
52
50
  export const HierarchicalFilterFacet = ({
53
51
  facet,
54
52
  loading
@@ -1,7 +1,6 @@
1
1
  import React, { Fragment, useRef } from 'react';
2
2
  import { EuiFacetGroup, EuiTitle, EuiFacetButton } from '@elastic/eui';
3
3
  import { useSearchkit, FilterLink } from '@searchkit/client';
4
-
5
4
  const EntriesList = ({
6
5
  entries,
7
6
  loading,
@@ -48,7 +47,6 @@ const EntriesList = ({
48
47
  });
49
48
  return /*#__PURE__*/React.createElement(EuiFacetGroup, null, entriesElements);
50
49
  };
51
-
52
50
  export const HierarchicalMenuFacet = ({
53
51
  facet,
54
52
  loading
@@ -4,20 +4,16 @@ import Select from '../../../Form/Select';
4
4
  import FormikWrapper from '../../../Form/FormikWrapper';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import classNames from 'classnames';
7
-
8
7
  const useInitialValues = () => {
9
8
  const parsed = useSearchkitVariables();
10
9
  const filters = {};
11
-
12
10
  if (parsed.filters) {
13
11
  parsed.filters.forEach(filter => {
14
12
  filters[filter.identifier] = filter.value;
15
13
  });
16
14
  }
17
-
18
15
  return filters;
19
16
  };
20
-
21
17
  export const SelectFacet = ({
22
18
  facet
23
19
  }) => {
@@ -49,14 +45,12 @@ export const SelectFacet = ({
49
45
  api.setPage({
50
46
  from: 0
51
47
  });
52
-
53
48
  if (value) {
54
49
  api.addFilter({
55
50
  identifier: facet.identifier,
56
51
  value: value
57
52
  });
58
53
  }
59
-
60
54
  api.search();
61
55
  }
62
56
  })));
@@ -2,7 +2,6 @@ import React, { useMemo, useState, useEffect } from 'react';
2
2
  import { gql, useQuery } from '@apollo/client';
3
3
  import { useSearchkitVariables } from '@searchkit/client';
4
4
  import SearchPage from '../SearchPage';
5
-
6
5
  function Query({
7
6
  query,
8
7
  useRouting,
@@ -21,21 +20,19 @@ function Query({
21
20
  loading
22
21
  } = useQuery(graphQuery, {
23
22
  variables
24
- }); // In between searches, Searchkit will empty it's results, resulting
25
- // in a re-render with an empty screen. Use a local state to prevent this.
23
+ });
26
24
 
25
+ // In between searches, Searchkit will empty it's results, resulting
26
+ // in a re-render with an empty screen. Use a local state to prevent this.
27
27
  const [dataLoaded, setDataLoaded] = useState(null);
28
28
  useEffect(() => {
29
29
  if (data) {
30
30
  setDataLoaded(data);
31
31
  }
32
32
  }, [data]);
33
-
34
33
  if (!useRouting) {
35
34
  return /*#__PURE__*/React.createElement("div", null, children(dataLoaded, loading));
36
35
  }
37
-
38
36
  return /*#__PURE__*/React.createElement(SearchPage, null, children(dataLoaded, loading));
39
37
  }
40
-
41
38
  export default Query;
@@ -4,7 +4,6 @@ import { ListFacet } from '../Facets/ListFacet';
4
4
  import { ChipFacet } from '../Facets/ChipFacet';
5
5
  import { HierarchicalFilterFacet } from '../Facets/HierarchicalFilterFacet';
6
6
  import { HierarchicalMenuFacet } from '../Facets/HierarchicalMenuFacet';
7
-
8
7
  const FacetList = (components = []) => {
9
8
  const FacetsMapper = [HierarchicalFilterFacet, HierarchicalMenuFacet, SelectFacet, ChipFacet, ListFacet, ...components].reduce((sum, component) => {
10
9
  sum[component.DISPLAY] = component;
@@ -18,11 +17,9 @@ const FacetList = (components = []) => {
18
17
  className: "SearchFacets"
19
18
  }, data && data.facets && data.facets.map(facet => {
20
19
  const Facet = FacetsMapper[facet.display];
21
-
22
20
  if (!Facet) {
23
21
  throw new Error(facet.display + ' not available');
24
22
  }
25
-
26
23
  return /*#__PURE__*/React.createElement(Facet, {
27
24
  facet: facet,
28
25
  loading: loading
@@ -30,18 +27,15 @@ const FacetList = (components = []) => {
30
27
  }));
31
28
  };
32
29
  };
33
-
34
30
  const SearchFacets = ({
35
31
  data,
36
32
  loading,
37
33
  facets
38
34
  }) => {
39
35
  const Facets = FacetList(facets);
40
-
41
36
  if (!data) {
42
37
  return null;
43
38
  }
44
-
45
39
  return /*#__PURE__*/React.createElement("div", {
46
40
  className: "SearchFacets"
47
41
  }, /*#__PURE__*/React.createElement(Facets, {
@@ -49,7 +43,6 @@ const SearchFacets = ({
49
43
  loading: loading
50
44
  }));
51
45
  };
52
-
53
46
  SearchFacets.defaultProps = {
54
47
  data: null,
55
48
  loading: false,
@@ -3,7 +3,6 @@ import { useSearchkit, useSearchkitQueryValue } from "@searchkit/client";
3
3
  import FormikWrapper from '../../Form/FormikWrapper';
4
4
  import Button from '../../Button';
5
5
  import TextField from '../../Form/TextField';
6
-
7
6
  const SearchField = ({
8
7
  timeout,
9
8
  autoSearch = true,
@@ -14,35 +13,28 @@ const SearchField = ({
14
13
  const api = useSearchkit();
15
14
  const timeoutRef = useRef();
16
15
  const fieldLabel = false;
17
-
18
16
  const searchQuery = query => {
19
17
  setQuery(query);
20
18
  api.setQuery(query);
21
19
  api.search();
22
20
  };
23
-
24
21
  const onSubmit = (values, form) => {
25
22
  searchQuery(values.query);
26
23
  };
27
-
28
24
  const onChange = e => {
29
25
  e.persist();
30
-
31
26
  if (timeoutRef.current) {
32
27
  clearTimeout(timeoutRef.current);
33
28
  }
34
-
35
29
  timeoutRef.current = setTimeout(() => {
36
30
  searchQuery(e.target.value);
37
31
  }, timeout);
38
32
  };
39
-
40
33
  const handleEnter = event => {
41
34
  if (event.key === 'Enter') {
42
35
  onSubmit();
43
36
  }
44
37
  };
45
-
46
38
  return /*#__PURE__*/React.createElement(FormikWrapper, {
47
39
  initialValues: {
48
40
  query: query
@@ -60,7 +52,6 @@ const SearchField = ({
60
52
  primary: true
61
53
  }, buttonText));
62
54
  };
63
-
64
55
  SearchField.defaultProps = {
65
56
  timeout: 1000,
66
57
  autoSearch: true,
@@ -1,18 +1,15 @@
1
1
  import React from 'react';
2
2
  import { useSearchkit } from '@searchkit/client';
3
3
  import Button from '../../Button';
4
-
5
4
  const SearchLoadMore = ({
6
5
  data,
7
6
  label,
8
7
  className
9
8
  }) => {
10
9
  const api = useSearchkit();
11
-
12
10
  if (!data) {
13
11
  return null;
14
12
  }
15
-
16
13
  const setNextPage = () => {
17
14
  if (data) {
18
15
  api.setPage({
@@ -22,19 +19,15 @@ const SearchLoadMore = ({
22
19
  api.search();
23
20
  }
24
21
  };
25
-
26
22
  const currentPage = data.results.hits.page.pageNumber;
27
23
  const lastPage = data.results.hits.page.totalPages;
28
-
29
24
  if (currentPage + 1 >= lastPage) {
30
25
  return null;
31
26
  }
32
-
33
27
  return /*#__PURE__*/React.createElement("div", {
34
28
  className: className
35
29
  }, /*#__PURE__*/React.createElement(Button, {
36
30
  onClick: setNextPage
37
31
  }, label));
38
32
  };
39
-
40
33
  export default SearchLoadMore;
@@ -1,11 +1,9 @@
1
1
  import React from 'react';
2
2
  import { withSearchkitRouting } from '@searchkit/client';
3
3
  import { EuiPage } from '@elastic/eui';
4
-
5
4
  const SearchPage = ({
6
5
  children
7
6
  }) => /*#__PURE__*/React.createElement(EuiPage, null, children);
8
-
9
7
  export const routeToStateFn = routeState => {
10
8
  const value = {
11
9
  query: routeState.query || '',
@@ -15,37 +13,33 @@ export const routeToStateFn = routeState => {
15
13
  size: Number(routeState.size) || 10,
16
14
  from: Number(routeState.from) || 0
17
15
  }
18
- }; // Map Number values for min and max filters. By default they
16
+ };
17
+
18
+ // Map Number values for min and max filters. By default they
19
19
  // are parsed as strings, which does not comply to the schema.
20
20
  // The 'qs' package is at fault here.
21
21
  // @see https://github.com/ljharb/qs/issues/91
22
-
23
22
  value.filters = value.filters.map(item => {
24
23
  if (item.min) {
25
24
  item.min = Number(item.min);
26
25
  }
27
-
28
26
  if (item.max) {
29
27
  item.max = Number(item.max);
30
28
  }
31
-
32
29
  if (item.boolValue) {
33
30
  item.boolValue = !!item.boolValue;
34
31
  }
35
-
36
32
  if (item.geoBoundingBox) {
37
33
  item.geoBoundingBox.topLeft.lat = Number(item.geoBoundingBox.topLeft.lat);
38
34
  item.geoBoundingBox.topLeft.lon = Number(item.geoBoundingBox.topLeft.lon);
39
35
  item.geoBoundingBox.bottomRight.lat = Number(item.geoBoundingBox.bottomRight.lat);
40
36
  item.geoBoundingBox.bottomRight.lon = Number(item.geoBoundingBox.bottomRight.lon);
41
37
  }
42
-
43
38
  if (item.geoRadius) {
44
39
  item.geoRadius.radius = Number(item.geoRadius.radius);
45
40
  item.geoRadius.center.lat = Number(item.geoRadius.center.lat);
46
41
  item.geoRadius.center.lon = Number(item.geoRadius.center.lon);
47
42
  }
48
-
49
43
  return item;
50
44
  });
51
45
  return value;
@@ -1,16 +1,13 @@
1
1
  import React from 'react';
2
2
  import { useSearchkit } from '@searchkit/client';
3
3
  import Pagination from '../../Pagination';
4
-
5
4
  const SearchPagination = ({
6
5
  data
7
6
  }) => {
8
7
  const api = useSearchkit();
9
-
10
8
  if (!data) {
11
9
  return null;
12
10
  }
13
-
14
11
  const setCurrentPage = page => {
15
12
  if (data && page) {
16
13
  api.setPage({
@@ -20,12 +17,10 @@ const SearchPagination = ({
20
17
  api.search();
21
18
  }
22
19
  };
23
-
24
20
  return /*#__PURE__*/React.createElement(Pagination, {
25
21
  setCurrentPage: setCurrentPage,
26
22
  totalPages: data.results.hits.page.totalPages,
27
23
  currentPage: data.results.hits.page.pageNumber + 1
28
24
  });
29
25
  };
30
-
31
26
  export default SearchPagination;
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import { ResetSearchButton } from '@searchkit/elastic-ui';
3
-
4
3
  const SearchReset = ({
5
4
  data,
6
5
  loading
@@ -11,5 +10,4 @@ const SearchReset = ({
11
10
  loading: loading
12
11
  }));
13
12
  };
14
-
15
13
  export default SearchReset;
@@ -2,15 +2,12 @@ import React, { useState, useEffect } from 'react';
2
2
  import usePrevious from '../../../hooks/usePrevious';
3
3
  import { useSearchkitVariables } from '@searchkit/client';
4
4
  import PropTypes from 'prop-types';
5
-
6
5
  const SearchResultItemDefault = ({
7
6
  item
8
7
  }) => /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h3", null, item.fields.title[0]));
9
-
10
8
  const SearchResultHeaderDefault = ({
11
9
  data
12
10
  }) => /*#__PURE__*/React.createElement("h2", null, data.results.summary.total, " Results");
13
-
14
11
  const SearchResults = ({
15
12
  data,
16
13
  renderItem,
@@ -37,12 +34,10 @@ const SearchResults = ({
37
34
  setPreviousSortBy(variables.sortBy);
38
35
  setPreviousActiveFilters(variables.filters);
39
36
  setCurrentData(JSON.stringify(data));
40
-
41
37
  if (!appendResults) {
42
38
  // Set items directly if not appendResults
43
39
  return setItems([...data.results.hits.items]);
44
40
  }
45
-
46
41
  const currentPageNumber = data.results.hits.page.pageNumber;
47
42
  const currentQuery = variables.query;
48
43
  const currentFiltersLength = variables.filters.length;
@@ -52,8 +47,9 @@ const SearchResults = ({
52
47
  const filtersChanged = previousActiveFilters.length !== currentFiltersLength;
53
48
  const sortByChanged = currentSortBy !== previousSortBy;
54
49
  const pageChanged = currentPageNumber !== previousPage;
55
- const dataChanged = currentData !== newData; // Determine if we have to reset the results, or should append them to the results
50
+ const dataChanged = currentData !== newData;
56
51
 
52
+ // Determine if we have to reset the results, or should append them to the results
57
53
  if (dataChanged && (queryChanged || filtersChanged || pageChanged || sortByChanged)) {
58
54
  if (typeof previousItems === 'undefined' || queryChanged || filtersChanged || sortByChanged) {
59
55
  // Overwrite data when Query, Filters or SortBy has changed
@@ -63,36 +59,33 @@ const SearchResults = ({
63
59
  setItems([...previousItems, ...data.results.hits.items]);
64
60
  }
65
61
  }
66
- }, [data, appendResults, variables]); // Set the search results when items have changed
62
+ }, [data, appendResults, variables]);
67
63
 
64
+ // Set the search results when items have changed
68
65
  useEffect(() => {
69
66
  setSearchResultItems(items.map(item => /*#__PURE__*/React.createElement(SearchResultItem, {
70
67
  key: item.id,
71
68
  item: item
72
69
  })));
73
- }, [items]); // Scroll to top on every page.
70
+ }, [items]);
74
71
 
72
+ // Scroll to top on every page.
75
73
  useEffect(() => {
76
- if (!currentData) {
77
- return;
78
- }
79
-
80
- const currentPageNumber = currentData.results.hits.page.pageNumber;
81
-
74
+ if (typeof data.results === 'undefined') return;
75
+ const currentPageNumber = data?.results?.hits?.page?.pageNumber;
82
76
  if (appendResults === false && scrollView && scrollView.current && currentPageNumber !== 0) {
83
77
  scrollView.current.scrollIntoView({
84
78
  behavior: 'smooth',
85
79
  block: 'start'
86
80
  });
87
81
  }
88
- }, [currentData]);
82
+ }, [data, appendResults, scrollView]);
89
83
  return /*#__PURE__*/React.createElement("div", {
90
84
  className: "SearchResults"
91
85
  }, data && /*#__PURE__*/React.createElement(SearchResultHeader, {
92
86
  data: data
93
87
  }), searchResultItems);
94
88
  };
95
-
96
89
  SearchResults.defaultProps = {
97
90
  renderItem: SearchResultItemDefault,
98
91
  renderHeader: SearchResultHeaderDefault,
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import { useSearchkit } from '@searchkit/client';
3
3
  import { SelectedFilters } from '@searchkit/elastic-ui';
4
4
  import Button from '../../Button';
5
-
6
5
  const SearchSelectedFilters = ({
7
6
  data,
8
7
  loading
@@ -19,11 +18,9 @@ const SearchSelectedFilters = ({
19
18
  }
20
19
  }, filter.label, ": ", filter.value);
21
20
  };
22
-
23
21
  if (!data) {
24
22
  return null;
25
23
  }
26
-
27
24
  return /*#__PURE__*/React.createElement("div", {
28
25
  className: "SearchSelectedFilters"
29
26
  }, /*#__PURE__*/React.createElement(SelectedFilters, {
@@ -37,5 +34,4 @@ const SearchSelectedFilters = ({
37
34
  }
38
35
  }));
39
36
  };
40
-
41
37
  export default SearchSelectedFilters;
@@ -1,16 +1,13 @@
1
1
  import { useSearchkit, useSearchkitVariables } from '@searchkit/client';
2
- import React, { useState, useEffect } from 'react';
3
- import SelectStyled from 'react-select';
2
+ import React from 'react';
4
3
  import FormikWrapper from '../../Form/FormikWrapper';
5
4
  import Select from '../../Form/Select';
6
-
7
5
  const useInitialValues = () => {
8
6
  const parsed = useSearchkitVariables();
9
7
  return {
10
8
  'sortBy': parsed.sortBy
11
9
  };
12
10
  };
13
-
14
11
  export const SearchSorting = ({
15
12
  data,
16
13
  loading
@@ -26,6 +23,7 @@ export const SearchSorting = ({
26
23
  }, /*#__PURE__*/React.createElement(Select, {
27
24
  fieldName: "sortBy",
28
25
  isClearable: false,
26
+ isSearchable: false,
29
27
  options: options,
30
28
  isLoading: loading,
31
29
  onChange: value => {
@@ -8,7 +8,6 @@ import SearchPagination from './SearchPagination';
8
8
  import SearchResults from './SearchResults';
9
9
  import SearchFacets from './SearchFacets';
10
10
  import SearchSelectedFilters from './SearchFacets';
11
-
12
11
  const defaultChildren = (data, loading) => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SearchField, null), /*#__PURE__*/React.createElement(SearchFacets, {
13
12
  data: data,
14
13
  loading: loading
@@ -20,7 +19,6 @@ const defaultChildren = (data, loading) => /*#__PURE__*/React.createElement(Reac
20
19
  }), /*#__PURE__*/React.createElement(SearchPagination, {
21
20
  data: data
22
21
  }));
23
-
24
22
  const SearchKit = ({
25
23
  query,
26
24
  uri,
@@ -60,7 +58,6 @@ const SearchKit = ({
60
58
  useRouting: useRouting
61
59
  }, (data, loading) => children ? children(data, loading) : defaultChildren(data, loading))));
62
60
  };
63
-
64
61
  SearchKit.propTypes = {
65
62
  queryString: PropTypes.string,
66
63
  uri: PropTypes.string,
@@ -91,15 +91,12 @@ const query = `
91
91
  }
92
92
  }
93
93
  `;
94
-
95
94
  const SearchItem = ({
96
95
  item
97
96
  }) => /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h3", null, item.fields.title[0]));
98
-
99
97
  const SearchHeader = ({
100
98
  data
101
99
  }) => /*#__PURE__*/React.createElement("h2", null, data.results.summary.total, " Resultaten");
102
-
103
100
  export const Default = () => /*#__PURE__*/React.createElement(SearchKit, {
104
101
  uri: "http://localhost:4000/api/graphql",
105
102
  query: query
@@ -121,7 +118,6 @@ export const Default = () => /*#__PURE__*/React.createElement(SearchKit, {
121
118
  }), /*#__PURE__*/React.createElement(SearchPagination, {
122
119
  data: data
123
120
  })));
124
-
125
121
  const ListFacet = ({
126
122
  facet
127
123
  }) => {
@@ -153,7 +149,6 @@ const ListFacet = ({
153
149
  }, "- ", entry.label, " (", entry.count, ")"));
154
150
  })));
155
151
  };
156
-
157
152
  ListFacet.DISPLAY = 'ListFacet';
158
153
  export const CustomFacets = () => {
159
154
  const customFacets = [ListFacet];
@@ -221,7 +216,8 @@ export const LoadMore = () => {
221
216
  const api = useSearchkit();
222
217
  return /*#__PURE__*/React.createElement(SearchKit, {
223
218
  uri: "http://localhost:4000/api/graphql",
224
- query: query // useRouting={false}
219
+ query: query
220
+ // useRouting={false}
225
221
  ,
226
222
  pageSize: 5
227
223
  }, (data, loading) => {
@@ -232,7 +228,6 @@ export const LoadMore = () => {
232
228
  });
233
229
  api.search();
234
230
  };
235
-
236
231
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
237
232
  onClick: toggleFilter
238
233
  }, "Toggle"), /*#__PURE__*/React.createElement(SearchResults, {