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

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 (112) hide show
  1. package/dist/Context/withMapping.js +1 -6
  2. package/dist/components/Accordion/AccordionItem/index.js +0 -5
  3. package/dist/components/Accordion/AccordionItemVariant/index.js +0 -5
  4. package/dist/components/Accordion/index.js +0 -2
  5. package/dist/components/ApiAutocomplete/index.js +6 -12
  6. package/dist/components/Button/index.js +4 -10
  7. package/dist/components/Cookie/Checkbox/index.js +0 -2
  8. package/dist/components/Cookie/index.js +39 -34
  9. package/dist/components/FontSizeSwitcher/index.js +2 -8
  10. package/dist/components/Form/Checkbox/index.js +1 -4
  11. package/dist/components/Form/Checkbox/stories.js +0 -2
  12. package/dist/components/Form/Checkboxes/index.js +1 -7
  13. package/dist/components/Form/Checkboxes/index.test.js +8 -4
  14. package/dist/components/Form/Checkboxes/stories.js +1 -4
  15. package/dist/components/Form/Date/index.js +1 -4
  16. package/dist/components/Form/Date/stories.js +0 -2
  17. package/dist/components/Form/DatePicker/index.js +0 -2
  18. package/dist/components/Form/DatePicker/stories.js +0 -2
  19. package/dist/components/Form/DateSelect/index.js +110 -85
  20. package/dist/components/Form/DateSelect/stories.js +24 -15
  21. package/dist/components/Form/DateSelect/style.scss +10 -4
  22. package/dist/components/Form/Email/index.js +1 -4
  23. package/dist/components/Form/Email/stories.js +0 -2
  24. package/dist/components/Form/FormikWrapper/index.js +9 -15
  25. package/dist/components/Form/GenericFormElement/index.js +0 -2
  26. package/dist/components/Form/Number/index.js +1 -10
  27. package/dist/components/Form/Number/stories.js +0 -2
  28. package/dist/components/Form/RadioButtons/index.js +1 -7
  29. package/dist/components/Form/RadioButtons/index.test.js +8 -4
  30. package/dist/components/Form/RadioButtons/stories.js +1 -4
  31. package/dist/components/Form/SearchField/index.js +0 -2
  32. package/dist/components/Form/Select/Input/index.js +4 -14
  33. package/dist/components/Form/Select/index.js +1 -4
  34. package/dist/components/Form/Select/stories.js +0 -4
  35. package/dist/components/Form/TextField/index.js +0 -6
  36. package/dist/components/Form/TextField/index.test.js +8 -4
  37. package/dist/components/Form/TextField/stories.js +1 -4
  38. package/dist/components/Form/Textarea/index.js +0 -2
  39. package/dist/components/Form/Textarea/stories.js +0 -2
  40. package/dist/components/Hamburger/index.js +0 -2
  41. package/dist/components/Header/index.js +4 -9
  42. package/dist/components/Image/Background/index.js +1 -7
  43. package/dist/components/Image/LazyLoadWrapper/index.js +0 -12
  44. package/dist/components/Image/Picture/index.js +4 -19
  45. package/dist/components/Image/index.js +0 -4
  46. package/dist/components/InlineMenu/index.js +0 -9
  47. package/dist/components/Layout/Container/index.js +1 -4
  48. package/dist/components/Layout/Container/stories.js +0 -3
  49. package/dist/components/Layout/QuickLayout/Auto/index.js +0 -2
  50. package/dist/components/Layout/QuickLayout/Center/index.js +0 -2
  51. package/dist/components/Layout/QuickLayout/Clamp/index.js +0 -2
  52. package/dist/components/Layout/QuickLayout/Sidebar/index.js +0 -2
  53. package/dist/components/Layout/QuickLayout/SpaceBetween/index.js +0 -2
  54. package/dist/components/Layout/QuickLayout/Stack/index.js +1 -4
  55. package/dist/components/Layout/QuickLayout/Wrap/index.js +0 -2
  56. package/dist/components/Layout/QuickLayout/index.js +0 -9
  57. package/dist/components/Lottie/LottieAnimation/index.js +12 -17
  58. package/dist/components/Lottie/LottieAnimationWithMousePosition.js +8 -9
  59. package/dist/components/Lottie/index.js +3 -3
  60. package/dist/components/Lottie/stories.js +10 -5
  61. package/dist/components/MagicLine/index.js +0 -14
  62. package/dist/components/MagicLine/stories.js +0 -2
  63. package/dist/components/NavigationScroll/index.js +2 -12
  64. package/dist/components/Pagination/index.js +0 -7
  65. package/dist/components/SearchKit/Facets/ChipFacet/index.js +0 -2
  66. package/dist/components/SearchKit/Facets/HierarchicalFilterFacet/index.js +0 -2
  67. package/dist/components/SearchKit/Facets/HierarchicalMenuFacet/index.js +0 -2
  68. package/dist/components/SearchKit/Facets/SelectFacet/index.js +0 -6
  69. package/dist/components/SearchKit/Query/index.js +3 -6
  70. package/dist/components/SearchKit/SearchFacets/index.js +0 -7
  71. package/dist/components/SearchKit/SearchField/index.js +0 -9
  72. package/dist/components/SearchKit/SearchLoadMore/index.js +0 -7
  73. package/dist/components/SearchKit/SearchPage/index.js +3 -9
  74. package/dist/components/SearchKit/SearchPagination/index.js +0 -5
  75. package/dist/components/SearchKit/SearchReset/index.js +0 -2
  76. package/dist/components/SearchKit/SearchResults/index.js +6 -11
  77. package/dist/components/SearchKit/SearchSelectedFilters/index.js +0 -4
  78. package/dist/components/SearchKit/SearchSorting/index.js +0 -2
  79. package/dist/components/SearchKit/index.js +0 -3
  80. package/dist/components/SearchKit/stories.js +2 -7
  81. package/dist/components/Share/index.js +0 -3
  82. package/dist/components/Sliders/SliderRelated/index.js +1 -6
  83. package/dist/components/Sliders/SliderRelated/stories.js +1 -4
  84. package/dist/components/Webform/WebformActions/index.js +0 -2
  85. package/dist/components/Webform/WebformCheckbox/index.js +1 -8
  86. package/dist/components/Webform/WebformCheckboxes/index.js +1 -9
  87. package/dist/components/Webform/WebformContainer/index.js +5 -6
  88. package/dist/components/Webform/WebformDate/index.js +12 -18
  89. package/dist/components/Webform/WebformMapper/index.js +1 -18
  90. package/dist/components/Webform/WebformNumber/index.js +1 -4
  91. package/dist/components/Webform/WebformRadioButtons/index.js +1 -9
  92. package/dist/components/Webform/WebformSelect/index.js +1 -9
  93. package/dist/components/Webform/WebformTextField/index.js +1 -8
  94. package/dist/components/Webform/WebformTextarea/index.js +1 -8
  95. package/dist/components/Webform/WebformWizardPage/index.js +6 -8
  96. package/dist/components/Webform/index.js +1 -8
  97. package/dist/components/Webform/withStates.js +6 -19
  98. package/dist/components/WysiwygField/index.js +1 -8
  99. package/dist/components/WysiwygField/stories.js +0 -3
  100. package/dist/config/constants.js +3 -4
  101. package/dist/config/i18next/index.js +23 -0
  102. package/dist/config/i18next/locales/en.json +22 -0
  103. package/dist/config/i18next/locales/nl.json +22 -0
  104. package/dist/helpers/gtm.js +11 -15
  105. package/dist/helpers/link.js +0 -4
  106. package/dist/helpers/useValueForCurrentViewPort.js +20 -14
  107. package/dist/hooks/useOnScreen.js +2 -2
  108. package/dist/hooks/usePrevious.js +3 -2
  109. package/dist/hooks/useScrollPosition.js +0 -3
  110. package/dist/hooks/useWindowDimensions.js +0 -3
  111. package/package.json +14 -5
  112. package/dist/pages/api/graphql.js +0 -25
@@ -4,17 +4,16 @@ export const DEFAULT_LANGUAGE = 'nl';
4
4
  export const SITE_NAME = 'Unc Inc';
5
5
  export const MAPBOX_API_TOKEN = 'pk.eyJ1IjoidW5jaW5jYnYiLCJhIjoiY2pxeHhxd2FlMDMyeTQzbWp1a3hleHRscCJ9.QMfmlryTLEyrSyjU7FfBiw';
6
6
  let API_URL = 'https://content.uncinc.nl';
7
-
8
7
  if (APP_ENV === 'development') {
9
8
  API_URL = 'http://uncinc.docker.localhost';
10
9
  } else if (APP_ENV === 'staging') {
11
10
  API_URL = 'https://staging.uncinc.nl';
12
11
  }
13
-
14
12
  export const IS_SERVER = !(typeof window !== 'undefined' && window.document && window.document.createElement);
15
- export const IS_CLIENT = !IS_SERVER; // The value is where the breakpoint starts (mobile-first).
16
- // These values are taken from '/src/shared/styles/assets/_variables.scss'.
13
+ export const IS_CLIENT = !IS_SERVER;
17
14
 
15
+ // The value is where the breakpoint starts (mobile-first).
16
+ // These values are taken from '/src/shared/styles/assets/_variables.scss'.
18
17
  export const SCREEN_MOBILE = 0;
19
18
  export const SCREEN_TABLET = 768;
20
19
  export const SCREEN_NORMAL = 992;
@@ -0,0 +1,23 @@
1
+ import i18n from 'i18next';
2
+ import LanguageDetector from 'i18next-browser-languagedetector';
3
+ import { initReactI18next } from 'react-i18next';
4
+ import NL from './locales/nl.json';
5
+ import EN from './locales/en.json';
6
+ const resources = {
7
+ nl: {
8
+ translation: NL
9
+ },
10
+ en: {
11
+ translation: EN
12
+ }
13
+ };
14
+ i18n.use(LanguageDetector).use(initReactI18next).init({
15
+ resources,
16
+ lng: 'nl',
17
+ fallbackLng: 'nl',
18
+ debug: true,
19
+ interpolation: {
20
+ escapeValue: false
21
+ }
22
+ });
23
+ export default i18n;
@@ -0,0 +1,22 @@
1
+ {
2
+ "dateselect": {
3
+ "months": {
4
+ "jan": "January",
5
+ "feb": "February",
6
+ "mar": "March",
7
+ "apr": "April",
8
+ "may": "May",
9
+ "jun": "June",
10
+ "jul": "Juli",
11
+ "aug": "August",
12
+ "sep": "September",
13
+ "oct": "October",
14
+ "nov": "November",
15
+ "dec": "December"
16
+ }
17
+ },
18
+ "form": {
19
+ "required": "required",
20
+ "optional": "optional"
21
+ }
22
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "dateselect" : {
3
+ "months": {
4
+ "jan": "Januari",
5
+ "feb": "Februari",
6
+ "mar": "Maart",
7
+ "apr": "April",
8
+ "may": "Mei",
9
+ "jun": "Juni",
10
+ "jul": "Juli",
11
+ "aug": "Augustus",
12
+ "sep": "September",
13
+ "oct": "Oktober",
14
+ "nov": "November",
15
+ "dec": "December"
16
+ }
17
+ },
18
+ "form": {
19
+ "required": "vereist",
20
+ "optional": "optioneel"
21
+ }
22
+ }
@@ -5,7 +5,9 @@ const gtm = {
5
5
  // If GTM is not loaded we will push all events to this variable. Once GTM is
6
6
  // loaded we will concat this array with the GTM dataLayer variable.
7
7
  tempDataLayer: []
8
- }; // -----------------------------------------------------------------------------
8
+ };
9
+
10
+ // -----------------------------------------------------------------------------
9
11
  //
10
12
  // Define our internal helper functions.
11
13
  //
@@ -19,10 +21,10 @@ const gtm = {
19
21
  * @return {bool}
20
22
  * A boolean wether the GTM is loaded or not.
21
23
  */
22
-
23
24
  gtm.loaded = () => {
24
25
  return typeof window.google_tag_manager !== 'undefined';
25
26
  };
27
+
26
28
  /**
27
29
  * gtm.register
28
30
  *
@@ -35,17 +37,15 @@ gtm.loaded = () => {
35
37
  * The callback of the function being registered.
36
38
  * @return {void}
37
39
  */
38
-
39
-
40
40
  gtm.register = (fn, callback) => {
41
41
  gtm[fn] = (...args) => {
42
42
  if (__DEBUG__) {
43
43
  console.info(`GTM Event: ${fn}() with args`, args);
44
44
  }
45
-
46
45
  callback(...args);
47
46
  };
48
47
  };
48
+
49
49
  /**
50
50
  * gtm.push
51
51
  *
@@ -56,17 +56,15 @@ gtm.register = (fn, callback) => {
56
56
  * @return {array|bool}
57
57
  * An array containing the new dataLayer result or `false`.
58
58
  */
59
-
60
-
61
59
  gtm.push = data => {
62
60
  if (gtm.loaded()) {
63
61
  return window.dataLayer.push(data);
64
62
  } else {
65
63
  gtm.tempDataLayer.push(data);
66
64
  }
67
-
68
65
  return false;
69
66
  };
67
+
70
68
  /**
71
69
  * gtm.attachEventListeners
72
70
  *
@@ -74,26 +72,23 @@ gtm.push = data => {
74
72
  * Attach event listeners related to GTM.
75
73
  * @return {void}
76
74
  */
77
-
78
-
79
75
  gtm.attachEventListeners = () => {
80
76
  if (IS_CLIENT && !gtm.hasEventsAttached) {
81
77
  window.addEventListener('GTM-Loaded', () => {
82
78
  for (let i = 0, len = gtm.tempDataLayer.length; i < len; i++) {
83
79
  window.dataLayer.push(gtm.tempDataLayer[i]);
84
80
  }
85
-
86
81
  gtm.tempDataLayer = [];
87
82
  });
88
83
  gtm.hasEventsAttached = true;
89
84
  }
90
- }; // -----------------------------------------------------------------------------
85
+ };
86
+
87
+ // -----------------------------------------------------------------------------
91
88
  //
92
89
  // Register our wrapper functions. We will use these throughout the app.
93
90
  //
94
91
  // -----------------------------------------------------------------------------
95
-
96
-
97
92
  gtm.register('trackPage', url => {
98
93
  if (url) {
99
94
  gtm.push({
@@ -115,7 +110,8 @@ gtm.register('loadConsentRequiredTags', () => {
115
110
  gtm.push({
116
111
  event: 'Cookie consent: load tags on consent'
117
112
  });
118
- }); // Initialize GTM.
113
+ });
119
114
 
115
+ // Initialize GTM.
120
116
  gtm.attachEventListeners();
121
117
  export default gtm;
@@ -1,19 +1,15 @@
1
1
  import config from 'react-global-configuration';
2
2
  export function isExternalLink(uri = '') {
3
3
  const value = uri.trim().replace(/\/$/, '');
4
-
5
4
  if (/^(https?|mailto|tel):/g.test(value)) {
6
5
  return true;
7
6
  }
8
-
9
7
  return false;
10
8
  }
11
9
  export function normalizeLink(link) {
12
10
  const API_URL = config.get('API_URL');
13
-
14
11
  if (/^\//g.test(link)) {
15
12
  return `${API_URL}${link}`;
16
13
  }
17
-
18
14
  return link;
19
15
  }
@@ -7,29 +7,35 @@ export default function useValueForCurrentViewPort(val1, val2, val3, val4, val5)
7
7
  function handleResize() {
8
8
  const {
9
9
  innerWidth: width
10
- } = window; // 0 & 768
10
+ } = window;
11
11
 
12
+ // 0 & 768
12
13
  if (width >= viewportContext.screenSizes.SCREEN_MOBILE && width <= viewportContext.screenSizes.SCREEN_TABLET) {
13
14
  setValueForCurrentViewPort(val1);
14
15
  return;
15
- } // 768 & 992
16
+ }
17
+
18
+ // 768 & 992
16
19
  else if (width >= viewportContext.screenSizes.SCREEN_TABLET && width <= viewportContext.screenSizes.SCREEN_NORMAL) {
17
- setValueForCurrentViewPort(val2);
18
- return;
19
- } // 992 & 1240
20
- else if (width >= viewportContext.screenSizes.SCREEN_NORMAL && width <= viewportContext.screenSizes.SCREEN_WIDE) {
21
- setValueForCurrentViewPort(val3);
22
- return;
23
- } // 1240 & 2000
24
- else if (width >= viewportContext.screenSizes.SCREEN_WIDE && width <= viewportContext.screenSizes.SCREEN_HUGE) {
25
- setValueForCurrentViewPort(val4);
26
- return;
27
- } // SCREEN_HUGE and larger
20
+ setValueForCurrentViewPort(val2);
21
+ return;
22
+ }
23
+
24
+ // 992 & 1240
25
+ else if (width >= viewportContext.screenSizes.SCREEN_NORMAL && width <= viewportContext.screenSizes.SCREEN_WIDE) {
26
+ setValueForCurrentViewPort(val3);
27
+ return;
28
+ }
28
29
 
30
+ // 1240 & 2000
31
+ else if (width >= viewportContext.screenSizes.SCREEN_WIDE && width <= viewportContext.screenSizes.SCREEN_HUGE) {
32
+ setValueForCurrentViewPort(val4);
33
+ return;
34
+ }
29
35
 
36
+ // SCREEN_HUGE and larger
30
37
  setValueForCurrentViewPort(val5);
31
38
  }
32
-
33
39
  window.addEventListener('resize', handleResize);
34
40
  handleResize();
35
41
  return () => window.removeEventListener('resize', handleResize);
@@ -3,8 +3,8 @@ export default function useOnScreen(ref) {
3
3
  const [isIntersecting, setIntersecting] = useState(false);
4
4
  const observer = new IntersectionObserver(([entry]) => setIntersecting(entry.isIntersecting));
5
5
  useEffect(() => {
6
- observer.observe(ref.current); // Remove the observer as soon as the component is unmounted
7
-
6
+ observer.observe(ref.current);
7
+ // Remove the observer as soon as the component is unmounted
8
8
  return () => observer.disconnect();
9
9
  }, [observer, ref]);
10
10
  return isIntersecting;
@@ -2,13 +2,14 @@ import { useEffect, useRef } from 'react';
2
2
  export default function usePrevious(value) {
3
3
  // The ref object is a generic container whose current property is mutable ...
4
4
  // ... and can hold any value, similar to an instance property on a class
5
- const ref = useRef(); // Store current value in ref
5
+ const ref = useRef();
6
6
 
7
+ // Store current value in ref
7
8
  useEffect(() => {
8
9
  ref.current = value;
9
10
  }, [value]); // Only re-run if value changes
10
- // Return previous value (happens before update in useEffect above)
11
11
 
12
+ // Return previous value (happens before update in useEffect above)
12
13
  return ref.current;
13
14
  }
14
15
  ;
@@ -1,17 +1,14 @@
1
1
  import { useEffect, useState } from 'react';
2
-
3
2
  const useScrollPosition = () => {
4
3
  const [scrollPosition, setScrollPosition] = useState(0);
5
4
  useEffect(() => {
6
5
  const updatePosition = () => {
7
6
  setScrollPosition(window.pageYOffset);
8
7
  };
9
-
10
8
  window.addEventListener('scroll', updatePosition);
11
9
  updatePosition();
12
10
  return () => window.removeEventListener('scroll', updatePosition);
13
11
  }, []);
14
12
  return scrollPosition;
15
13
  };
16
-
17
14
  export default useScrollPosition;
@@ -1,5 +1,4 @@
1
1
  import { useState, useEffect } from 'react';
2
-
3
2
  function getWindowDimensions() {
4
3
  const {
5
4
  innerWidth: width,
@@ -10,14 +9,12 @@ function getWindowDimensions() {
10
9
  height
11
10
  };
12
11
  }
13
-
14
12
  export default function useWindowDimensions() {
15
13
  const [windowDimensions, setWindowDimensions] = useState(getWindowDimensions());
16
14
  useEffect(() => {
17
15
  function handleResize() {
18
16
  setWindowDimensions(getWindowDimensions());
19
17
  }
20
-
21
18
  window.addEventListener('resize', handleResize);
22
19
  return () => window.removeEventListener('resize', handleResize);
23
20
  }, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uncinc/uncinc-react-kitchen-sink",
3
- "version": "2.3.3",
3
+ "version": "2.3.4",
4
4
  "description": "Default React components that are easily extended.",
5
5
  "author": "uncinc",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  "scripts": {
25
25
  "start": "yarn run storybook",
26
26
  "build": "react-scripts build",
27
- "test": "react-scripts test",
27
+ "test": "jest",
28
28
  "eject": "react-scripts eject",
29
29
  "prepare": "yarn run publish:npm",
30
30
  "storybook": "start-storybook -p 9009 -s public",
@@ -40,11 +40,15 @@
40
40
  "@loadable/component": "^5.15.0",
41
41
  "@searchkit/client": "^3.0.0-canary.45",
42
42
  "@searchkit/elastic-ui": "^3.0.0-canary.45",
43
+ "@uncinc/react-drupal-core": "^2.3.4",
43
44
  "apollo-server-micro": "^3.4.0",
44
45
  "bootstrap": "^4",
45
46
  "fork-ts-checker-webpack-plugin-alt": "0.4.14",
46
47
  "formik": "^2.2.6",
47
48
  "graphql": "^15.7.0",
49
+ "i18next": "^22.4.13",
50
+ "i18next-browser-languagedetector": "^7.0.1",
51
+ "i18next-http-backend": "^2.2.0",
48
52
  "immutable": "^4.0.0-rc.15",
49
53
  "js-cookie": "^3.0.1",
50
54
  "lottie-web": "^5.7.7",
@@ -60,7 +64,7 @@
60
64
  "react-dom": "^16 || ^17 || ^18",
61
65
  "react-global-configuration": "^1.4.0",
62
66
  "react-html-parser": "^2.0.2",
63
- "react-i18next": "^11.5.0",
67
+ "react-i18next": "^12.2.0",
64
68
  "react-immutable-proptypes": "^2.2.0",
65
69
  "react-lazyload": "^3.0.0",
66
70
  "react-paginate": "^7.1.3",
@@ -80,6 +84,8 @@
80
84
  "@babel/cli": "^7.0.0-beta.44",
81
85
  "@babel/helper-define-map": "^7.14.5",
82
86
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
87
+ "@babel/preset-env": "^7.20.2",
88
+ "@babel/preset-react": "^7.18.6",
83
89
  "@babel/runtime": "^7.9.6",
84
90
  "@storybook/addon-actions": "^6.2.8",
85
91
  "@storybook/addon-info": "^5.3.21",
@@ -90,15 +96,18 @@
90
96
  "@testing-library/jest-dom": "^4.2.4",
91
97
  "@testing-library/react": "^9.3.2",
92
98
  "@testing-library/user-event": "^7.1.2",
99
+ "babel-jest": "^29.4.3",
93
100
  "chai": "^4.2.0",
94
101
  "cross-env": "^7.0.2",
95
102
  "enzyme": "^3.11.0",
96
103
  "enzyme-adapter-react-16": "^1.15.2",
104
+ "jest": "^29.4.3",
97
105
  "react-scripts": "3.4.1",
98
- "react-test-renderer": "^16.13.1",
106
+ "react-test-renderer": "^18.2.0",
99
107
  "sinon": "^9.0.2",
100
108
  "sinon-chai": "^3.5.0",
101
- "storybook-addon-export-stories": "^1.0.0"
109
+ "storybook-addon-export-stories": "^1.0.0",
110
+ "storybook-react-i18next": "^1.1.3"
102
111
  },
103
112
  "eslintConfig": {
104
113
  "extends": "react-app"
@@ -1,25 +0,0 @@
1
- import { ApolloServer, gql } from 'apollo-server-micro';
2
- export const config = {
3
- api: {
4
- bodyParser: false
5
- }
6
- };
7
- const typeDefs = [gql`
8
- type Query {
9
- root: String
10
- }
11
-
12
- type Mutation {
13
- root: String
14
- }
15
- `];
16
- const server = new ApolloServer({
17
- typeDefs,
18
- resolvers: {},
19
- introspection: true,
20
- playground: true,
21
- context: {}
22
- });
23
- export default server.createHandler({
24
- path: '/api/graphql'
25
- });