@uncinc/uncinc-react-kitchen-sink 2.4.0 → 2.4.2

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 (168) hide show
  1. package/dist/Context/KitchenSinkComponentMapperContext.js +11 -3
  2. package/dist/Context/ViewportContext.js +27 -14
  3. package/dist/Context/withMapping.js +26 -15
  4. package/dist/components/AbbreviationAnnotation/index.js +49 -27
  5. package/dist/components/AbbreviationAnnotation/stories.js +37 -22
  6. package/dist/components/Accordion/AccordionItem/index.js +55 -36
  7. package/dist/components/Accordion/AccordionItemVariant/index.js +47 -25
  8. package/dist/components/Accordion/index.js +17 -10
  9. package/dist/components/Accordion/stories.js +38 -24
  10. package/dist/components/ApiAutocomplete/index.js +79 -51
  11. package/dist/components/ApiAutocomplete/stories.js +18 -9
  12. package/dist/components/Button/index.js +48 -33
  13. package/dist/components/Button/stories.js +31 -49
  14. package/dist/components/Button/stories.scss +7 -5
  15. package/dist/components/Cookie/Checkbox/index.js +23 -16
  16. package/dist/components/Cookie/index.js +146 -115
  17. package/dist/components/Cookie/stories.js +90 -40
  18. package/dist/components/Dialog/index.d.ts +38 -0
  19. package/dist/components/Dialog/index.js +63 -56
  20. package/dist/components/Dialog/stories.js +35 -18
  21. package/dist/components/FontSizeSwitcher/index.js +58 -32
  22. package/dist/components/FontSizeSwitcher/stories.js +23 -9
  23. package/dist/components/Form/Checkbox/index.js +43 -37
  24. package/dist/components/Form/Checkbox/stories.js +20 -11
  25. package/dist/components/Form/Checkboxes/index.js +62 -57
  26. package/dist/components/Form/Checkboxes/index.test.js +113 -62
  27. package/dist/components/Form/Checkboxes/stories.js +23 -12
  28. package/dist/components/Form/Date/index.js +13 -5
  29. package/dist/components/Form/Date/stories.js +18 -9
  30. package/dist/components/Form/DatePicker/index.js +40 -33
  31. package/dist/components/Form/DatePicker/stories.js +18 -9
  32. package/dist/components/Form/DateSelect/index.js +99 -62
  33. package/dist/components/Form/DateSelect/stories.js +32 -11
  34. package/dist/components/Form/Email/index.js +13 -5
  35. package/dist/components/Form/Email/stories.js +18 -9
  36. package/dist/components/Form/FormikWrapper/index.js +52 -45
  37. package/dist/components/Form/GenericFormElement/index.js +39 -34
  38. package/dist/components/Form/Number/index.js +23 -18
  39. package/dist/components/Form/Number/stories.js +18 -9
  40. package/dist/components/Form/RadioButtons/index.js +53 -49
  41. package/dist/components/Form/RadioButtons/index.test.js +106 -57
  42. package/dist/components/Form/RadioButtons/stories.js +23 -12
  43. package/dist/components/Form/SearchField/index.js +37 -30
  44. package/dist/components/Form/Select/Input/index.js +56 -49
  45. package/dist/components/Form/Select/index.js +33 -24
  46. package/dist/components/Form/Select/stories.js +25 -15
  47. package/dist/components/Form/TextField/index.js +39 -33
  48. package/dist/components/Form/TextField/index.test.js +104 -56
  49. package/dist/components/Form/TextField/stories.js +22 -11
  50. package/dist/components/Form/Textarea/index.js +35 -27
  51. package/dist/components/Form/Textarea/stories.js +18 -9
  52. package/dist/components/Hamburger/index.js +30 -19
  53. package/dist/components/Hamburger/stories.js +42 -16
  54. package/dist/components/Header/index.js +67 -39
  55. package/dist/components/Header/stories.js +48 -28
  56. package/dist/components/Image/Background/index.js +36 -21
  57. package/dist/components/Image/LazyLoadWrapper/index.js +101 -64
  58. package/dist/components/Image/Picture/index.js +83 -65
  59. package/dist/components/Image/index.js +21 -15
  60. package/dist/components/Image/stories.js +87 -64
  61. package/dist/components/InlineMenu/index.js +60 -38
  62. package/dist/components/InlineMenu/stories.js +66 -55
  63. package/dist/components/Layout/Container/index.js +29 -21
  64. package/dist/components/Layout/Container/stories.js +94 -84
  65. package/dist/components/Layout/QuickLayout/Auto/index.js +19 -12
  66. package/dist/components/Layout/QuickLayout/Center/index.js +17 -10
  67. package/dist/components/Layout/QuickLayout/Clamp/index.js +20 -13
  68. package/dist/components/Layout/QuickLayout/Sidebar/index.js +20 -13
  69. package/dist/components/Layout/QuickLayout/SpaceBetween/index.js +20 -13
  70. package/dist/components/Layout/QuickLayout/Stack/index.js +21 -11
  71. package/dist/components/Layout/QuickLayout/Wrap/index.js +21 -14
  72. package/dist/components/Layout/QuickLayout/index.js +31 -21
  73. package/dist/components/Layout/QuickLayout/stories.js +102 -70
  74. package/dist/components/Lottie/LottieAnimation/index.js +55 -56
  75. package/dist/components/Lottie/LottieAnimationWithMousePosition.js +31 -18
  76. package/dist/components/Lottie/index.js +47 -35
  77. package/dist/components/Lottie/stories.js +56 -31
  78. package/dist/components/MagicLine/index.js +50 -27
  79. package/dist/components/MagicLine/stories.js +60 -46
  80. package/dist/components/NavigationScroll/index.js +71 -49
  81. package/dist/components/NavigationScroll/stories.js +19 -8
  82. package/dist/components/Pagination/index.js +49 -41
  83. package/dist/components/Pagination/stories.js +46 -17
  84. package/dist/components/SearchKit/Facets/ChipFacet/index.js +24 -16
  85. package/dist/components/SearchKit/Facets/ListFacet/index.js +23 -15
  86. package/dist/components/SearchKit/Facets/SelectFacet/index.js +39 -30
  87. package/dist/components/SearchKit/Query/index.js +41 -23
  88. package/dist/components/SearchKit/SearchFacets/index.js +36 -23
  89. package/dist/components/SearchKit/SearchField/index.js +49 -25
  90. package/dist/components/SearchKit/SearchLoadMore/index.js +22 -15
  91. package/dist/components/SearchKit/SearchPage/index.js +22 -14
  92. package/dist/components/SearchKit/SearchPagination/index.js +17 -10
  93. package/dist/components/SearchKit/SearchReset/index.js +25 -16
  94. package/dist/components/SearchKit/SearchResults/index.js +108 -59
  95. package/dist/components/SearchKit/SearchSelectedFilters/Filters/CustomValue/index.js +17 -10
  96. package/dist/components/SearchKit/SearchSelectedFilters/Filters/DateRange/index.js +18 -11
  97. package/dist/components/SearchKit/SearchSelectedFilters/Filters/NumericRange/index.js +18 -11
  98. package/dist/components/SearchKit/SearchSelectedFilters/Filters/Value/index.js +22 -12
  99. package/dist/components/SearchKit/SearchSelectedFilters/index.js +34 -28
  100. package/dist/components/SearchKit/SearchSorting/index.js +29 -19
  101. package/dist/components/SearchKit/index.js +72 -53
  102. package/dist/components/SearchKit/stories.js +144 -187
  103. package/dist/components/Share/index.js +48 -40
  104. package/dist/components/Share/stories.js +16 -5
  105. package/dist/components/Sliders/SliderRelated/index.js +32 -25
  106. package/dist/components/Sliders/SliderRelated/stories.js +75 -57
  107. package/dist/components/Webform/WebformActions/index.js +19 -13
  108. package/dist/components/Webform/WebformCheckbox/index.js +32 -24
  109. package/dist/components/Webform/WebformCheckboxes/index.js +37 -29
  110. package/dist/components/Webform/WebformContainer/index.js +17 -11
  111. package/dist/components/Webform/WebformDate/index.js +76 -48
  112. package/dist/components/Webform/WebformMapper/index.js +53 -38
  113. package/dist/components/Webform/WebformNumber/index.js +31 -22
  114. package/dist/components/Webform/WebformRadioButtons/index.js +37 -29
  115. package/dist/components/Webform/WebformSelect/index.js +37 -29
  116. package/dist/components/Webform/WebformTextField/index.js +34 -26
  117. package/dist/components/Webform/WebformTextarea/index.js +32 -24
  118. package/dist/components/Webform/WebformWizardPage/index.js +56 -43
  119. package/dist/components/Webform/index.js +42 -20
  120. package/dist/components/Webform/stories.actions.js +19 -8
  121. package/dist/components/Webform/stories.checkboxes.js +19 -8
  122. package/dist/components/Webform/stories.checked.js +20 -9
  123. package/dist/components/Webform/stories.container.js +19 -8
  124. package/dist/components/Webform/stories.date.js +19 -8
  125. package/dist/components/Webform/stories.filled.js +20 -9
  126. package/dist/components/Webform/stories.number.js +19 -8
  127. package/dist/components/Webform/stories.radiobuttons.js +19 -8
  128. package/dist/components/Webform/stories.select.js +19 -8
  129. package/dist/components/Webform/stories.textarea.js +19 -8
  130. package/dist/components/Webform/stories.textfield.js +19 -8
  131. package/dist/components/Webform/stories.wizard.js +19 -8
  132. package/dist/components/Webform/withStates.js +49 -28
  133. package/dist/components/WysiwygField/index.js +30 -20
  134. package/dist/components/WysiwygField/stories.js +39 -29
  135. package/dist/components/index.js +111 -15
  136. package/dist/config/constants.js +38 -18
  137. package/dist/config/i18next/index.js +19 -11
  138. package/dist/helpers/date.js +25 -5
  139. package/dist/helpers/gtm.js +27 -17
  140. package/dist/helpers/link.js +15 -6
  141. package/dist/helpers/useValueForCurrentViewPort.js +27 -10
  142. package/dist/hooks/useBoolean.d.ts +8 -0
  143. package/dist/hooks/useBoolean.js +38 -0
  144. package/dist/hooks/useClickOutside.d.ts +8 -0
  145. package/dist/hooks/useClickOutside.js +35 -0
  146. package/dist/hooks/useDialog.d.ts +10 -0
  147. package/dist/hooks/useDialog.js +39 -0
  148. package/dist/hooks/useDialogHelpers.d.ts +20 -0
  149. package/dist/hooks/{useDialogHelpers.ts → useDialogHelpers.js} +33 -43
  150. package/dist/hooks/useEscape.d.ts +6 -0
  151. package/dist/hooks/useEscape.js +24 -0
  152. package/dist/hooks/useOnScreen.js +27 -6
  153. package/dist/hooks/usePrevious.js +10 -4
  154. package/dist/hooks/useScrollPosition.js +25 -7
  155. package/dist/hooks/useTrapFocus.d.ts +10 -0
  156. package/dist/hooks/useTrapFocus.js +63 -0
  157. package/dist/hooks/useWindowDimensions.js +27 -11
  158. package/dist/index.js +398 -56
  159. package/dist/setupTests.js +9 -5
  160. package/dist/styles/assets/_base.scss +0 -3
  161. package/dist/styles/assets/_fonts.scss +17 -17
  162. package/dist/styles/assets/_icons.scss +2 -2
  163. package/package.json +6 -3
  164. package/dist/hooks/useBoolean.ts +0 -20
  165. package/dist/hooks/useClickOutside.ts +0 -38
  166. package/dist/hooks/useDialog.ts +0 -29
  167. package/dist/hooks/useEscape.ts +0 -26
  168. package/dist/hooks/useTrapFocus.ts +0 -80
@@ -1,24 +1,44 @@
1
- export const APP_ENV = process.env.REACT_APP_ENV;
2
- export const __DEBUG__ = APP_ENV !== 'production';
3
- export const DEFAULT_LANGUAGE = 'nl';
4
- export const SITE_NAME = 'Unc Inc';
5
- export const MAPBOX_API_TOKEN = 'pk.eyJ1IjoidW5jaW5jYnYiLCJhIjoiY2pxeHhxd2FlMDMyeTQzbWp1a3hleHRscCJ9.QMfmlryTLEyrSyjU7FfBiw';
6
- let API_URL = 'https://content.uncinc.nl';
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.__DEBUG__ = exports.VIEW_ACTION_REPLACE = exports.VIEW_ACTION_APPEND = exports.SITE_NAME = exports.SCREEN_WIDE = exports.SCREEN_TABLET = exports.SCREEN_NORMAL = exports.SCREEN_MOBILE = exports.SCREEN_HUGE = exports.MAPBOX_API_TOKEN = exports.IS_SERVER = exports.IS_CLIENT = exports.DEFAULT_LANGUAGE = exports.APP_ENV = exports.API_URL = void 0;
7
+ var APP_ENV = process.env.REACT_APP_ENV;
8
+ exports.APP_ENV = APP_ENV;
9
+ var __DEBUG__ = APP_ENV !== 'production';
10
+ exports.__DEBUG__ = __DEBUG__;
11
+ var DEFAULT_LANGUAGE = 'nl';
12
+ exports.DEFAULT_LANGUAGE = DEFAULT_LANGUAGE;
13
+ var SITE_NAME = 'Unc Inc';
14
+ exports.SITE_NAME = SITE_NAME;
15
+ var MAPBOX_API_TOKEN = 'pk.eyJ1IjoidW5jaW5jYnYiLCJhIjoiY2pxeHhxd2FlMDMyeTQzbWp1a3hleHRscCJ9.QMfmlryTLEyrSyjU7FfBiw';
16
+ exports.MAPBOX_API_TOKEN = MAPBOX_API_TOKEN;
17
+ var API_URL = 'https://content.uncinc.nl';
18
+ exports.API_URL = API_URL;
7
19
  if (APP_ENV === 'development') {
8
- API_URL = 'http://uncinc.docker.localhost';
20
+ exports.API_URL = API_URL = 'http://uncinc.docker.localhost';
9
21
  } else if (APP_ENV === 'staging') {
10
- API_URL = 'https://staging.uncinc.nl';
22
+ exports.API_URL = API_URL = 'https://staging.uncinc.nl';
11
23
  }
12
- export const IS_SERVER = !(typeof window !== 'undefined' && window.document && window.document.createElement);
13
- export const IS_CLIENT = !IS_SERVER;
24
+ var IS_SERVER = !(typeof window !== 'undefined' && window.document && window.document.createElement);
25
+ exports.IS_SERVER = IS_SERVER;
26
+ var IS_CLIENT = !IS_SERVER;
14
27
 
15
28
  // The value is where the breakpoint starts (mobile-first).
16
29
  // These values are taken from '/src/shared/styles/assets/_variables.scss'.
17
- export const SCREEN_MOBILE = 0;
18
- export const SCREEN_TABLET = 768;
19
- export const SCREEN_NORMAL = 992;
20
- export const SCREEN_WIDE = 1240;
21
- export const SCREEN_HUGE = 2000;
22
- export const VIEW_ACTION_REPLACE = 'replace';
23
- export const VIEW_ACTION_APPEND = 'append';
24
- export { API_URL };
30
+ exports.IS_CLIENT = IS_CLIENT;
31
+ var SCREEN_MOBILE = 0;
32
+ exports.SCREEN_MOBILE = SCREEN_MOBILE;
33
+ var SCREEN_TABLET = 768;
34
+ exports.SCREEN_TABLET = SCREEN_TABLET;
35
+ var SCREEN_NORMAL = 992;
36
+ exports.SCREEN_NORMAL = SCREEN_NORMAL;
37
+ var SCREEN_WIDE = 1240;
38
+ exports.SCREEN_WIDE = SCREEN_WIDE;
39
+ var SCREEN_HUGE = 2000;
40
+ exports.SCREEN_HUGE = SCREEN_HUGE;
41
+ var VIEW_ACTION_REPLACE = 'replace';
42
+ exports.VIEW_ACTION_REPLACE = VIEW_ACTION_REPLACE;
43
+ var VIEW_ACTION_APPEND = 'append';
44
+ exports.VIEW_ACTION_APPEND = VIEW_ACTION_APPEND;
@@ -1,18 +1,25 @@
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 = {
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _i18next = _interopRequireDefault(require("i18next"));
8
+ var _i18nextBrowserLanguagedetector = _interopRequireDefault(require("i18next-browser-languagedetector"));
9
+ var _reactI18next = require("react-i18next");
10
+ var _nl = _interopRequireDefault(require("./locales/nl.json"));
11
+ var _en = _interopRequireDefault(require("./locales/en.json"));
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ var resources = {
7
14
  nl: {
8
- translation: NL
15
+ translation: _nl.default
9
16
  },
10
17
  en: {
11
- translation: EN
18
+ translation: _en.default
12
19
  }
13
20
  };
14
- i18n.use(LanguageDetector).use(initReactI18next).init({
15
- resources,
21
+ _i18next.default.use(_i18nextBrowserLanguagedetector.default).use(_reactI18next.initReactI18next).init({
22
+ resources: resources,
16
23
  lng: 'nl',
17
24
  fallbackLng: 'nl',
18
25
  debug: true,
@@ -20,4 +27,5 @@ i18n.use(LanguageDetector).use(initReactI18next).init({
20
27
  escapeValue: false
21
28
  }
22
29
  });
23
- export default i18n;
30
+ var _default = _i18next.default;
31
+ exports.default = _default;
@@ -1,8 +1,28 @@
1
- export const parseDateWithTimezoneOffset = date => {
2
- const offset = date.getTimezoneOffset();
3
- const dateWithTimezoneOffset = new Date(date.getTime() - offset * 60 * 1000);
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.parseDateWithTimezoneOffset = exports.isValidDate = exports.doubleDigits = void 0;
7
+ var parseDateWithTimezoneOffset = function parseDateWithTimezoneOffset(date) {
8
+ var offset = date.getTimezoneOffset();
9
+ var dateWithTimezoneOffset = new Date(date.getTime() - offset * 60 * 1000);
4
10
  return dateWithTimezoneOffset.toISOString();
5
11
  };
6
- export const isValidDate = date => {
12
+ exports.parseDateWithTimezoneOffset = parseDateWithTimezoneOffset;
13
+ var isValidDate = function isValidDate(date) {
7
14
  return date instanceof Date && !Number.isNaN(date);
8
- };
15
+ };
16
+
17
+ /**
18
+ * Make a time string double digit. So make 9 in to 09.
19
+ *
20
+ * @param {int} number - The number.
21
+ *
22
+ * @returns {int} The double digit number.
23
+ */
24
+ exports.isValidDate = isValidDate;
25
+ var doubleDigits = function doubleDigits(number) {
26
+ return "0".concat(number).slice(-2);
27
+ };
28
+ exports.doubleDigits = doubleDigits;
@@ -1,5 +1,11 @@
1
- import { IS_CLIENT, __DEBUG__ } from '../config/constants';
2
- const gtm = {
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _constants = require("../config/constants");
8
+ var gtm = {
3
9
  // Track wether events are binded already or not.
4
10
  hasEventsAttached: false,
5
11
  // If GTM is not loaded we will push all events to this variable. Once GTM is
@@ -21,7 +27,7 @@ const gtm = {
21
27
  * @return {bool}
22
28
  * A boolean wether the GTM is loaded or not.
23
29
  */
24
- gtm.loaded = () => {
30
+ gtm.loaded = function () {
25
31
  return typeof window.google_tag_manager !== 'undefined';
26
32
  };
27
33
 
@@ -37,12 +43,15 @@ gtm.loaded = () => {
37
43
  * The callback of the function being registered.
38
44
  * @return {void}
39
45
  */
40
- gtm.register = (fn, callback) => {
41
- gtm[fn] = (...args) => {
42
- if (__DEBUG__) {
43
- console.info(`GTM Event: ${fn}() with args`, args);
46
+ gtm.register = function (fn, callback) {
47
+ gtm[fn] = function () {
48
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
49
+ args[_key] = arguments[_key];
50
+ }
51
+ if (_constants.__DEBUG__) {
52
+ console.info("GTM Event: ".concat(fn, "() with args"), args);
44
53
  }
45
- callback(...args);
54
+ callback.apply(void 0, args);
46
55
  };
47
56
  };
48
57
 
@@ -56,7 +65,7 @@ gtm.register = (fn, callback) => {
56
65
  * @return {array|bool}
57
66
  * An array containing the new dataLayer result or `false`.
58
67
  */
59
- gtm.push = data => {
68
+ gtm.push = function (data) {
60
69
  if (gtm.loaded()) {
61
70
  return window.dataLayer.push(data);
62
71
  } else {
@@ -72,10 +81,10 @@ gtm.push = data => {
72
81
  * Attach event listeners related to GTM.
73
82
  * @return {void}
74
83
  */
75
- gtm.attachEventListeners = () => {
76
- if (IS_CLIENT && !gtm.hasEventsAttached) {
77
- window.addEventListener('GTM-Loaded', () => {
78
- for (let i = 0, len = gtm.tempDataLayer.length; i < len; i++) {
84
+ gtm.attachEventListeners = function () {
85
+ if (_constants.IS_CLIENT && !gtm.hasEventsAttached) {
86
+ window.addEventListener('GTM-Loaded', function () {
87
+ for (var i = 0, len = gtm.tempDataLayer.length; i < len; i++) {
79
88
  window.dataLayer.push(gtm.tempDataLayer[i]);
80
89
  }
81
90
  gtm.tempDataLayer = [];
@@ -89,7 +98,7 @@ gtm.attachEventListeners = () => {
89
98
  // Register our wrapper functions. We will use these throughout the app.
90
99
  //
91
100
  // -----------------------------------------------------------------------------
92
- gtm.register('trackPage', url => {
101
+ gtm.register('trackPage', function (url) {
93
102
  if (url) {
94
103
  gtm.push({
95
104
  event: 'Track page',
@@ -97,7 +106,7 @@ gtm.register('trackPage', url => {
97
106
  });
98
107
  }
99
108
  });
100
- gtm.register('trackUserEvent', (category, action, label, value) => {
109
+ gtm.register('trackUserEvent', function (category, action, label, value) {
101
110
  gtm.push({
102
111
  event: 'Track user event',
103
112
  eventCategory: category,
@@ -106,7 +115,7 @@ gtm.register('trackUserEvent', (category, action, label, value) => {
106
115
  eventValue: value
107
116
  });
108
117
  });
109
- gtm.register('loadConsentRequiredTags', () => {
118
+ gtm.register('loadConsentRequiredTags', function () {
110
119
  gtm.push({
111
120
  event: 'Cookie consent: load tags on consent'
112
121
  });
@@ -114,4 +123,5 @@ gtm.register('loadConsentRequiredTags', () => {
114
123
 
115
124
  // Initialize GTM.
116
125
  gtm.attachEventListeners();
117
- export default gtm;
126
+ var _default = gtm;
127
+ exports.default = _default;
@@ -1,15 +1,24 @@
1
- import config from 'react-global-configuration';
2
- export function isExternalLink(uri = '') {
3
- const value = uri.trim().replace(/\/$/, '');
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isExternalLink = isExternalLink;
7
+ exports.normalizeLink = normalizeLink;
8
+ var _reactGlobalConfiguration = _interopRequireDefault(require("react-global-configuration"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function isExternalLink() {
11
+ var uri = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
12
+ var value = uri.trim().replace(/\/$/, '');
4
13
  if (/^(https?|mailto|tel):/g.test(value)) {
5
14
  return true;
6
15
  }
7
16
  return false;
8
17
  }
9
- export function normalizeLink(link) {
10
- const API_URL = config.get('API_URL');
18
+ function normalizeLink(link) {
19
+ var API_URL = _reactGlobalConfiguration.default.get('API_URL');
11
20
  if (/^\//g.test(link)) {
12
- return `${API_URL}${link}`;
21
+ return "".concat(API_URL).concat(link);
13
22
  }
14
23
  return link;
15
24
  }
@@ -1,13 +1,28 @@
1
- import { useState, useEffect, useContext } from 'react';
2
- import ViewportContext from '../Context/ViewportContext';
3
- export default function useValueForCurrentViewPort(val1, val2, val3, val4, val5) {
4
- const viewportContext = useContext(ViewportContext);
5
- const [ValueForCurrentViewPort, setValueForCurrentViewPort] = useState(val1);
6
- useEffect(() => {
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useValueForCurrentViewPort;
7
+ var _react = require("react");
8
+ var _ViewportContext = _interopRequireDefault(require("../Context/ViewportContext"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
15
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
+ function useValueForCurrentViewPort(val1, val2, val3, val4, val5) {
17
+ var viewportContext = (0, _react.useContext)(_ViewportContext.default);
18
+ var _useState = (0, _react.useState)(val1),
19
+ _useState2 = _slicedToArray(_useState, 2),
20
+ ValueForCurrentViewPort = _useState2[0],
21
+ setValueForCurrentViewPort = _useState2[1];
22
+ (0, _react.useEffect)(function () {
7
23
  function handleResize() {
8
- const {
9
- innerWidth: width
10
- } = window;
24
+ var _window = window,
25
+ width = _window.innerWidth;
11
26
 
12
27
  // 0 & 768
13
28
  if (width >= viewportContext.screenSizes.SCREEN_MOBILE && width <= viewportContext.screenSizes.SCREEN_TABLET) {
@@ -38,7 +53,9 @@ export default function useValueForCurrentViewPort(val1, val2, val3, val4, val5)
38
53
  }
39
54
  window.addEventListener('resize', handleResize);
40
55
  handleResize();
41
- return () => window.removeEventListener('resize', handleResize);
56
+ return function () {
57
+ return window.removeEventListener('resize', handleResize);
58
+ };
42
59
  }, [viewportContext, val1, val2, val3, val4, val5]);
43
60
  return ValueForCurrentViewPort;
44
61
  }
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ export default function useBoolean(defaultValue?: boolean): {
3
+ readonly value: boolean;
4
+ readonly setValue: import("react").Dispatch<import("react").SetStateAction<boolean>>;
5
+ readonly setTrue: () => void;
6
+ readonly setFalse: () => void;
7
+ readonly toggle: () => void;
8
+ };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useBoolean;
7
+ var _react = require("react");
8
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
9
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
11
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
12
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
13
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
+ function useBoolean() {
15
+ var defaultValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
16
+ var _useState = (0, _react.useState)(defaultValue),
17
+ _useState2 = _slicedToArray(_useState, 2),
18
+ value = _useState2[0],
19
+ setValue = _useState2[1];
20
+ var toggle = (0, _react.useCallback)(function () {
21
+ setValue(function (current) {
22
+ return !current;
23
+ });
24
+ }, [setValue]);
25
+ var setTrue = (0, _react.useCallback)(function () {
26
+ setValue(true);
27
+ }, []);
28
+ var setFalse = (0, _react.useCallback)(function () {
29
+ setValue(false);
30
+ }, []);
31
+ return {
32
+ value: value,
33
+ setValue: setValue,
34
+ setTrue: setTrue,
35
+ setFalse: setFalse,
36
+ toggle: toggle
37
+ };
38
+ }
@@ -0,0 +1,8 @@
1
+ import { MutableRefObject } from 'react';
2
+ interface UseClickOutsideOptions {
3
+ refs: MutableRefObject<HTMLElement>[] | MutableRefObject<HTMLElement>;
4
+ unless?: boolean | ((e: globalThis.MouseEvent) => boolean);
5
+ onClick: (e: globalThis.MouseEvent) => void;
6
+ }
7
+ export default function useClickOutside({ refs, unless, onClick, }: UseClickOutsideOptions): void;
8
+ export {};
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useClickOutside;
7
+ var _react = require("react");
8
+ function useClickOutside(_ref) {
9
+ var refs = _ref.refs,
10
+ _ref$unless = _ref.unless,
11
+ unless = _ref$unless === void 0 ? false : _ref$unless,
12
+ onClick = _ref.onClick;
13
+ var refsAsArray = Array.isArray(refs) ? refs : [refs];
14
+ (0, _react.useEffect)(function () {
15
+ function handleOutsideClick(e) {
16
+ var allRefsHaveCurrent = refsAsArray.every(function (ref) {
17
+ return !!ref.current;
18
+ });
19
+ var shouldNotExecute = typeof unless === 'function' ? unless(e) : unless;
20
+ if (!allRefsHaveCurrent || shouldNotExecute) {
21
+ return;
22
+ }
23
+ var isOutsideClick = refsAsArray.every(function (ref) {
24
+ return !ref.current.contains(e.target);
25
+ });
26
+ if (isOutsideClick) {
27
+ onClick(e);
28
+ }
29
+ }
30
+ document.addEventListener('mousedown', handleOutsideClick);
31
+ return function () {
32
+ document.removeEventListener('mousedown', handleOutsideClick);
33
+ };
34
+ }, [unless, onClick, refs]);
35
+ }
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ export default function useDialog(): {
3
+ readonly dialogIsOpen: boolean;
4
+ readonly openDialog: () => void;
5
+ readonly closeDialog: () => void;
6
+ readonly DialogComponent: ({ children, ...props }: {
7
+ [x: string]: any;
8
+ children: any;
9
+ }) => React.FunctionComponentElement<any>;
10
+ };
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = useDialog;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _Dialog = _interopRequireDefault(require("../components/Dialog"));
10
+ var _useBoolean2 = _interopRequireDefault(require("./useBoolean"));
11
+ var _excluded = ["children"];
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
14
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
15
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
17
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
18
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
19
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
20
+ function useDialog() {
21
+ var _useBoolean = (0, _useBoolean2.default)(),
22
+ dialogIsOpen = _useBoolean.value,
23
+ openDialog = _useBoolean.setTrue,
24
+ closeDialog = _useBoolean.setFalse;
25
+ var DialogComponent = function DialogComponent(_ref) {
26
+ var children = _ref.children,
27
+ props = _objectWithoutProperties(_ref, _excluded);
28
+ return /*#__PURE__*/_react.default.createElement(_Dialog.default, _objectSpread(_objectSpread({}, props), {}, {
29
+ isOpen: dialogIsOpen,
30
+ closeFunction: closeDialog
31
+ }), children);
32
+ };
33
+ return {
34
+ dialogIsOpen: dialogIsOpen,
35
+ openDialog: openDialog,
36
+ closeDialog: closeDialog,
37
+ DialogComponent: DialogComponent
38
+ };
39
+ }
@@ -0,0 +1,20 @@
1
+ import { MutableRefObject } from 'react';
2
+ export interface UseDialogHelpersOptions<T extends HTMLElement> {
3
+ id?: string;
4
+ wrapperElement: MutableRefObject<T>;
5
+ closeFunction: () => void;
6
+ isOpen: boolean;
7
+ }
8
+ /**
9
+ * Hook to allow you to implement your own Dialog component.
10
+ * This takes care of focus, and closing the Dialog by
11
+ * click outside it, or hitting Escape.
12
+ */
13
+ export default function useDialogHelpers<T extends HTMLElement>(options: UseDialogHelpersOptions<T>): {
14
+ readonly id: any;
15
+ readonly labelId: string;
16
+ readonly dialogHelpersProps: {
17
+ 'aria-role': string;
18
+ 'aria-labelledby': string;
19
+ };
20
+ };
@@ -1,76 +1,68 @@
1
- import { useEffect, MutableRefObject } from 'react';
2
- import { v4 as uuidv4 } from 'uuid';
3
-
4
- import useClickOutside from './useClickOutside';
5
- import useEscape from './useEscape';
6
- import useTrapFocus from './useTrapFocus';
7
-
8
- export interface UseDialogHelpersOptions<T extends HTMLElement> {
9
- id?: string;
10
- wrapperElement: MutableRefObject<T>;
11
- closeFunction: () => void;
12
- isOpen: boolean;
13
- }
1
+ "use strict";
14
2
 
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useDialogHelpers;
7
+ var _react = require("react");
8
+ var _uuid = require("uuid");
9
+ var _useClickOutside = _interopRequireDefault(require("./useClickOutside"));
10
+ var _useEscape = _interopRequireDefault(require("./useEscape"));
11
+ var _useTrapFocus = _interopRequireDefault(require("./useTrapFocus"));
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
13
  /**
16
14
  * Hook to allow you to implement your own Dialog component.
17
15
  * This takes care of focus, and closing the Dialog by
18
16
  * click outside it, or hitting Escape.
19
17
  */
20
- export default function useDialogHelpers<T extends HTMLElement>(
21
- options: UseDialogHelpersOptions<T>,
22
- ) {
23
- const {
24
- id = uuidv4(),
25
- wrapperElement,
26
- closeFunction,
27
- isOpen,
28
- } = options;
18
+ function useDialogHelpers(options) {
19
+ var _options$id = options.id,
20
+ id = _options$id === void 0 ? (0, _uuid.v4)() : _options$id,
21
+ wrapperElement = options.wrapperElement,
22
+ closeFunction = options.closeFunction,
23
+ isOpen = options.isOpen;
29
24
 
30
25
  /**
31
26
  * Close the Dialog by pressing Escape.
32
27
  */
33
- useClickOutside({
28
+ (0, _useClickOutside.default)({
34
29
  refs: [wrapperElement],
35
- onClick: closeFunction,
30
+ onClick: closeFunction
36
31
  });
37
32
 
38
33
  /**
39
34
  * Close the Dialog by pressing Escape.
40
35
  */
41
- useEscape({
42
- onPress: closeFunction,
36
+ (0, _useEscape.default)({
37
+ onPress: closeFunction
43
38
  });
44
39
 
45
40
  /**
46
41
  * Make sure focus does not leave the Dialog while it's open.
47
42
  */
48
- useTrapFocus({
43
+ (0, _useTrapFocus.default)({
49
44
  ref: wrapperElement,
50
- isActive: isOpen,
45
+ isActive: isOpen
51
46
  });
52
47
 
53
48
  /**
54
49
  * Sets focus on the popup so that screen readers announce
55
50
  * that the user is currently on a dialog.
56
51
  */
57
- useEffect(() => {
52
+ (0, _react.useEffect)(function () {
58
53
  if (isOpen && wrapperElement.current) {
59
54
  wrapperElement.current.setAttribute('tabindex', '-1');
60
55
  wrapperElement.current.focus();
61
56
  }
62
-
63
57
  function removeFocusProperties() {
64
58
  if (wrapperElement.current) {
65
59
  wrapperElement.current.removeAttribute('tabindex');
66
60
  }
67
61
  }
68
-
69
62
  if (wrapperElement.current) {
70
63
  wrapperElement.current.addEventListener('blur', removeFocusProperties);
71
64
  }
72
-
73
- return () => {
65
+ return function () {
74
66
  if (wrapperElement.current) {
75
67
  wrapperElement.current.removeEventListener('blur', removeFocusProperties);
76
68
  }
@@ -80,16 +72,14 @@ export default function useDialogHelpers<T extends HTMLElement>(
80
72
  /**
81
73
  * Create a labelId for A11Y
82
74
  */
83
- const labelId = `${id}-label`;
84
-
85
- const dialogHelpersProps = {
75
+ var labelId = "".concat(id, "-label");
76
+ var dialogHelpersProps = {
86
77
  'aria-role': 'dialog',
87
- 'aria-labelledby': labelId,
78
+ 'aria-labelledby': labelId
88
79
  };
89
-
90
80
  return {
91
- id,
92
- labelId,
93
- dialogHelpersProps,
94
- } as const;
95
- }
81
+ id: id,
82
+ labelId: labelId,
83
+ dialogHelpersProps: dialogHelpersProps
84
+ };
85
+ }
@@ -0,0 +1,6 @@
1
+ interface UseEscapeOption {
2
+ unless?: boolean | ((e: KeyboardEvent) => boolean);
3
+ onPress: (e: KeyboardEvent) => void;
4
+ }
5
+ export default function useEscape({ unless, onPress }: UseEscapeOption): void;
6
+ export {};
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useEscape;
7
+ var _react = require("react");
8
+ function useEscape(_ref) {
9
+ var unless = _ref.unless,
10
+ onPress = _ref.onPress;
11
+ (0, _react.useEffect)(function () {
12
+ function handleOnPress(e) {
13
+ var shouldNotExecute = typeof unless === 'function' ? unless(e) : unless;
14
+ if (shouldNotExecute || e.key !== 'Escape') {
15
+ return;
16
+ }
17
+ onPress(e);
18
+ }
19
+ document.addEventListener('keyup', handleOnPress);
20
+ return function () {
21
+ document.removeEventListener('keyup', handleOnPress);
22
+ };
23
+ }, [unless]);
24
+ }