@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,47 +1,53 @@
1
- import React, { useEffect, useCallback, useRef } from 'react';
2
- import c from 'classnames';
3
- import lottie from 'lottie-web';
4
- import './style.scss';
5
- const LottieAnimation = /*#__PURE__*/React.forwardRef((props, ref) => {
6
- const {
7
- id,
8
- className,
9
- ariaLabel,
10
- data
11
- } = props;
12
- const DIRECTION_FORWARD = 1;
13
- const DIRECTION_BACKWARDS = -1;
14
- const lottieClasses = c('Lottie', className);
15
- const refInternal = useRef(null);
16
- const lottieAnimation = ref || refInternal;
17
- const lottieId = id || (data ? data.nm : null);
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 = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _classnames = _interopRequireDefault(require("classnames"));
10
+ var _lottieWeb = _interopRequireDefault(require("lottie-web"));
11
+ require("./style.scss");
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
14
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
+ var LottieAnimation = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
16
+ var id = props.id,
17
+ className = props.className,
18
+ ariaLabel = props.ariaLabel,
19
+ data = props.data;
20
+ var DIRECTION_FORWARD = 1;
21
+ var DIRECTION_BACKWARDS = -1;
22
+ var lottieClasses = (0, _classnames.default)('Lottie', className);
23
+ var refInternal = (0, _react.useRef)(null);
24
+ var lottieAnimation = ref || refInternal;
25
+ var lottieId = id || (data ? data.nm : null);
18
26
 
19
27
  /*
20
28
  * Initial load of the Lottie animation
21
29
  */
22
- const loadAnimation = useCallback(() => {
23
- const {
24
- renderer,
25
- rendererSettings,
26
- direction,
27
- loop,
28
- autoPlay,
29
- path,
30
- speed,
31
- segments,
32
- activateOnHover,
33
- startPosition,
34
- onInit
35
- } = props;
36
- lottieAnimation.current = lottie.loadAnimation({
30
+ var loadAnimation = (0, _react.useCallback)(function () {
31
+ var renderer = props.renderer,
32
+ rendererSettings = props.rendererSettings,
33
+ direction = props.direction,
34
+ loop = props.loop,
35
+ autoPlay = props.autoPlay,
36
+ path = props.path,
37
+ speed = props.speed,
38
+ segments = props.segments,
39
+ activateOnHover = props.activateOnHover,
40
+ startPosition = props.startPosition,
41
+ onInit = props.onInit;
42
+ lottieAnimation.current = _lottieWeb.default.loadAnimation({
37
43
  animationData: data,
38
- container: document.getElementById(`lottie--${lottieId}`),
44
+ container: document.getElementById("lottie--".concat(lottieId)),
39
45
  renderer: renderer,
40
- rendererSettings,
46
+ rendererSettings: rendererSettings,
41
47
  direction: direction,
42
48
  loop: activateOnHover ? false : loop,
43
49
  autoplay: activateOnHover ? false : autoPlay,
44
- path
50
+ path: path
45
51
  });
46
52
  onInit(lottieAnimation.current);
47
53
 
@@ -53,7 +59,7 @@ const LottieAnimation = /*#__PURE__*/React.forwardRef((props, ref) => {
53
59
  }
54
60
  // If startPosition is defined use it as a starting frame, startPosition should be between 0 and 1.
55
61
  if (startPosition) {
56
- const startingFrame = Math.round(lottieAnimation.current.totalFrames * startPosition);
62
+ var startingFrame = Math.round(lottieAnimation.current.totalFrames * startPosition);
57
63
  lottieAnimation.current.goToAndStop(startingFrame, true);
58
64
  }
59
65
  }, [data, lottieAnimation, lottieId, props]);
@@ -61,10 +67,8 @@ const LottieAnimation = /*#__PURE__*/React.forwardRef((props, ref) => {
61
67
  /*
62
68
  * Reverse direction on Mouse enter.
63
69
  */
64
- const onMouseEnter = e => {
65
- const {
66
- activateOnHover
67
- } = props;
70
+ var onMouseEnter = function onMouseEnter(e) {
71
+ var activateOnHover = props.activateOnHover;
68
72
  if (activateOnHover) {
69
73
  lottieAnimation.current.setDirection(DIRECTION_FORWARD);
70
74
  lottieAnimation.current.play();
@@ -74,10 +78,8 @@ const LottieAnimation = /*#__PURE__*/React.forwardRef((props, ref) => {
74
78
  /*
75
79
  * Reverse direction on Mouse leave
76
80
  */
77
- const onMouseLeave = () => {
78
- const {
79
- activateOnHover
80
- } = props;
81
+ var onMouseLeave = function onMouseLeave() {
82
+ var activateOnHover = props.activateOnHover;
81
83
  if (activateOnHover) {
82
84
  lottieAnimation.current.setDirection(DIRECTION_BACKWARDS);
83
85
  lottieAnimation.current.play();
@@ -87,10 +89,8 @@ const LottieAnimation = /*#__PURE__*/React.forwardRef((props, ref) => {
87
89
  /*
88
90
  * Toggle the animation on click
89
91
  */
90
- const onClick = () => {
91
- const {
92
- pauseOnClick
93
- } = props;
92
+ var onClick = function onClick() {
93
+ var pauseOnClick = props.pauseOnClick;
94
94
  if (pauseOnClick) {
95
95
  if (lottieAnimation.current.isPaused) {
96
96
  lottieAnimation.current.play();
@@ -101,12 +101,10 @@ const LottieAnimation = /*#__PURE__*/React.forwardRef((props, ref) => {
101
101
  };
102
102
 
103
103
  // Init the Lottie animation.
104
- useEffect(() => {
105
- const {
106
- onDestroy
107
- } = props;
104
+ (0, _react.useEffect)(function () {
105
+ var onDestroy = props.onDestroy;
108
106
  loadAnimation();
109
- return () => {
107
+ return function () {
110
108
  onDestroy(lottieAnimation.current);
111
109
  lottieAnimation.current.destroy();
112
110
  };
@@ -114,15 +112,16 @@ const LottieAnimation = /*#__PURE__*/React.forwardRef((props, ref) => {
114
112
  return (
115
113
  /*#__PURE__*/
116
114
  // eslint-disable-next-line jsx-a11y/interactive-supports-focus
117
- React.createElement("div", {
115
+ _react.default.createElement("div", {
118
116
  onMouseEnter: onMouseEnter,
119
117
  onMouseLeave: onMouseLeave,
120
118
  onClick: onClick,
121
119
  className: lottieClasses,
122
- id: `lottie--${lottieId}`,
120
+ id: "lottie--".concat(lottieId),
123
121
  "aria-label": ariaLabel,
124
122
  role: "button"
125
123
  })
126
124
  );
127
125
  });
128
- export default LottieAnimation;
126
+ var _default = LottieAnimation;
127
+ exports.default = _default;
@@ -1,41 +1,54 @@
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 = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _ola = _interopRequireDefault(require("ola"));
10
+ var _ = _interopRequireDefault(require("."));
11
+ var _excluded = ["olaTime"];
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
14
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
1
15
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
- import React, { useRef } from 'react';
3
- import Ola from 'ola';
4
- import Lottie from '.';
5
- const LottieAnimationWithMousePosition = ({
6
- olaTime,
7
- ...props
8
- }) => {
16
+ 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; }
17
+ 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; }
18
+ var LottieAnimationWithMousePosition = function LottieAnimationWithMousePosition(_ref) {
19
+ var olaTime = _ref.olaTime,
20
+ props = _objectWithoutProperties(_ref, _excluded);
9
21
  // Create our own ref that we pass to the component so that we can use lottie functions.
10
- const ref = useRef(null);
22
+ var ref = (0, _react.useRef)(null);
11
23
 
12
24
  // Create an Ola instance for frame interpolation.
13
- const interpolatedFrame = Ola(0, olaTime);
25
+ var interpolatedFrame = (0, _ola.default)(0, olaTime);
14
26
 
15
27
  /*
16
28
  * Follow mouse position for animation on Mouse move.
17
29
  */
18
- const onMouseMove = e => {
30
+ var onMouseMove = function onMouseMove(e) {
19
31
  if (ref && ref.current) {
20
32
  // Determine the mouse position relative to the current Lottie.
21
- const clientRect = ref.current.wrapper.getBoundingClientRect();
22
- const mousePositionRelative = e.type === 'touchmove' ? (e.touches[0].clientX - clientRect.left) / clientRect.width : (e.clientX - clientRect.left) / clientRect.width;
23
- const lottiePosition = Math.max(0, Math.min(1, mousePositionRelative));
33
+ var clientRect = ref.current.wrapper.getBoundingClientRect();
34
+ var mousePositionRelative = e.type === 'touchmove' ? (e.touches[0].clientX - clientRect.left) / clientRect.width : (e.clientX - clientRect.left) / clientRect.width;
35
+ var lottiePosition = Math.max(0, Math.min(1, mousePositionRelative));
24
36
 
25
37
  // Round the frame, clamp it, and pass it to Ola for frame interpolation.
26
- const rawFrame = Math.round(ref.current.totalFrames * lottiePosition);
27
- const frame = Math.min(ref.current.totalFrames - 1, Math.max(1, rawFrame));
38
+ var rawFrame = Math.round(ref.current.totalFrames * lottiePosition);
39
+ var frame = Math.min(ref.current.totalFrames - 1, Math.max(1, rawFrame));
28
40
  interpolatedFrame.set(frame);
29
41
 
30
42
  // Go to the frame we just calculated using the Ola value.
31
43
  ref.current.goToAndStop(interpolatedFrame.value, true);
32
44
  }
33
45
  };
34
- return /*#__PURE__*/React.createElement("div", {
46
+ return /*#__PURE__*/_react.default.createElement("div", {
35
47
  onMouseMove: onMouseMove,
36
48
  onTouchMove: onMouseMove
37
- }, /*#__PURE__*/React.createElement(Lottie, _extends({
49
+ }, /*#__PURE__*/_react.default.createElement(_.default, _extends({
38
50
  ref: ref
39
51
  }, props)));
40
52
  };
41
- export default LottieAnimationWithMousePosition;
53
+ var _default = LottieAnimationWithMousePosition;
54
+ exports.default = _default;
@@ -1,46 +1,57 @@
1
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
- import React from 'react';
3
- import PropTypes from 'prop-types';
4
- import loadable from '@loadable/component';
1
+ "use strict";
5
2
 
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _component = _interopRequireDefault(require("@loadable/component"));
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ 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); }
12
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
13
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
14
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
6
15
  // Lazy-load Lottie animations with a delay.
7
- const Lottie = /*#__PURE__*/React.forwardRef((props, ref) => {
8
- const {
9
- delay
10
- } = props;
11
- const LottieAnimation = loadable(() => {
12
- return new Promise(resolve => {
13
- setTimeout(() => resolve(import('./LottieAnimation')), delay);
16
+ var Lottie = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
17
+ var delay = props.delay;
18
+ var LottieAnimation = (0, _component.default)(function () {
19
+ return new Promise(function (resolve) {
20
+ setTimeout(function () {
21
+ return resolve(Promise.resolve().then(function () {
22
+ return _interopRequireWildcard(require('./LottieAnimation'));
23
+ }));
24
+ }, delay);
14
25
  });
15
26
  });
16
- return /*#__PURE__*/React.createElement(LottieAnimation, _extends({
27
+ return /*#__PURE__*/_react.default.createElement(LottieAnimation, _extends({
17
28
  ref: ref
18
29
  }, props));
19
30
  });
20
31
  Lottie.propTypes = {
21
- id: PropTypes.string,
22
- className: PropTypes.string,
23
- renderer: PropTypes.string,
24
- rendererSettings: PropTypes.shape({
25
- preserveAspectRatio: PropTypes.string
32
+ id: _propTypes.default.string,
33
+ className: _propTypes.default.string,
34
+ renderer: _propTypes.default.string,
35
+ rendererSettings: _propTypes.default.shape({
36
+ preserveAspectRatio: _propTypes.default.string
26
37
  }),
27
- data: PropTypes.object,
28
- path: PropTypes.string,
29
- segments: PropTypes.array,
38
+ data: _propTypes.default.object,
39
+ path: _propTypes.default.string,
40
+ segments: _propTypes.default.array,
30
41
  // Events
31
- onInit: PropTypes.func,
32
- onDestroy: PropTypes.func,
42
+ onInit: _propTypes.default.func,
43
+ onDestroy: _propTypes.default.func,
33
44
  // Options
34
- delay: PropTypes.number,
35
- autoPlay: PropTypes.bool,
36
- loop: PropTypes.bool,
37
- speed: PropTypes.number,
38
- direction: PropTypes.number,
39
- activateOnHover: PropTypes.bool,
40
- pauseOnClick: PropTypes.bool,
41
- olaTime: PropTypes.number,
42
- startPosition: PropTypes.number,
43
- ariaLabel: PropTypes.string
45
+ delay: _propTypes.default.number,
46
+ autoPlay: _propTypes.default.bool,
47
+ loop: _propTypes.default.bool,
48
+ speed: _propTypes.default.number,
49
+ direction: _propTypes.default.number,
50
+ activateOnHover: _propTypes.default.bool,
51
+ pauseOnClick: _propTypes.default.bool,
52
+ olaTime: _propTypes.default.number,
53
+ startPosition: _propTypes.default.number,
54
+ ariaLabel: _propTypes.default.string
44
55
  };
45
56
  Lottie.defaultProps = {
46
57
  id: null,
@@ -53,8 +64,8 @@ Lottie.defaultProps = {
53
64
  path: null,
54
65
  segments: null,
55
66
  // Events
56
- onInit: () => {},
57
- onDestroy: () => {},
67
+ onInit: function onInit() {},
68
+ onDestroy: function onDestroy() {},
58
69
  // Options
59
70
  delay: null,
60
71
  autoPlay: true,
@@ -67,4 +78,5 @@ Lottie.defaultProps = {
67
78
  olaTime: 300,
68
79
  startPosition: null
69
80
  };
70
- export default Lottie;
81
+ var _default = Lottie;
82
+ exports.default = _default;
@@ -1,41 +1,66 @@
1
- import React from 'react';
2
- import Lottie from '.';
3
- import LottieAnimationWithMousePosition from './LottieAnimationWithMousePosition';
4
- import exampleLottie from '../../assets/lottie/example.json';
5
- import exampleLottieEspero from '../../assets/lottie/data.json';
6
- export default {
7
- title: 'Atoms/Lottie'
8
- };
1
+ "use strict";
9
2
 
10
- // Default animation
11
- export const DefaultAnimation = () => /*#__PURE__*/React.createElement(Lottie, {
12
- id: "example",
13
- data: exampleLottie,
14
- onInit: lottie => console.log(lottie)
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
15
5
  });
6
+ exports.playAnimationOnMousePosition = exports.pauseOnClickAnimation = exports.default = exports.activateOnHoverAnimation = exports.PathLoad = exports.DefaultAnimation = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _ = _interopRequireDefault(require("."));
9
+ var _LottieAnimationWithMousePosition = _interopRequireDefault(require("./LottieAnimationWithMousePosition"));
10
+ var _example = _interopRequireDefault(require("../../assets/lottie/example.json"));
11
+ var _data = _interopRequireDefault(require("../../assets/lottie/data.json"));
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
14
+ var _default = {
15
+ title: 'Atoms/Lottie',
16
+ component: _.default
17
+ }; // Default animation
18
+ exports.default = _default;
19
+ var DefaultAnimation = function DefaultAnimation(args) {
20
+ return /*#__PURE__*/_react.default.createElement(_.default, _extends({
21
+ id: "example",
22
+ data: _example.default,
23
+ onInit: function onInit(lottie) {
24
+ return console.log(lottie);
25
+ }
26
+ }, args));
27
+ };
16
28
 
17
29
  // Animation active on hover
18
- export const activateOnHoverAnimation = () => /*#__PURE__*/React.createElement(Lottie, {
19
- data: exampleLottie,
20
- activateOnHover: true
21
- });
30
+ exports.DefaultAnimation = DefaultAnimation;
31
+ var activateOnHoverAnimation = function activateOnHoverAnimation(args) {
32
+ return /*#__PURE__*/_react.default.createElement(_.default, _extends({
33
+ data: _example.default,
34
+ activateOnHover: true
35
+ }, args));
36
+ };
22
37
 
23
38
  // Animation plays on mouse position
24
- export const playAnimationOnMousePosition = () => /*#__PURE__*/React.createElement(LottieAnimationWithMousePosition, {
25
- loop: false,
26
- autoplay: false,
27
- data: exampleLottieEspero,
28
- olaTime: 100,
29
- startPosition: 0.5
30
- });
39
+ exports.activateOnHoverAnimation = activateOnHoverAnimation;
40
+ var playAnimationOnMousePosition = function playAnimationOnMousePosition(args) {
41
+ return /*#__PURE__*/_react.default.createElement(_LottieAnimationWithMousePosition.default, _extends({
42
+ loop: false,
43
+ autoplay: false,
44
+ data: _data.default,
45
+ olaTime: 100,
46
+ startPosition: 0.5
47
+ }, args));
48
+ };
31
49
 
32
50
  // Pause animation on click
33
- export const pauseOnClickAnimation = () => /*#__PURE__*/React.createElement(Lottie, {
34
- data: exampleLottie,
35
- pauseOnClick: true
36
- });
51
+ exports.playAnimationOnMousePosition = playAnimationOnMousePosition;
52
+ var pauseOnClickAnimation = function pauseOnClickAnimation(args) {
53
+ return /*#__PURE__*/_react.default.createElement(_.default, _extends({
54
+ data: _example.default,
55
+ pauseOnClick: true
56
+ }, args));
57
+ };
37
58
 
38
59
  // Via path load
39
- export const PathLoad = () => /*#__PURE__*/React.createElement(Lottie, {
40
- path: "https://maxst.icons8.com/vue-static/landings/animated-icons/icons/checkmark-ok/checkmark-ok.json"
41
- });
60
+ exports.pauseOnClickAnimation = pauseOnClickAnimation;
61
+ var PathLoad = function PathLoad(args) {
62
+ return /*#__PURE__*/_react.default.createElement(_.default, _extends({
63
+ path: "https://maxst.icons8.com/vue-static/landings/animated-icons/icons/checkmark-ok/checkmark-ok.json"
64
+ }, args));
65
+ };
66
+ exports.PathLoad = PathLoad;
@@ -1,64 +1,87 @@
1
- import React, { useRef, useState, useEffect } from 'react';
2
- import c from 'classnames';
3
- const MagicLine = ({
4
- activeClassName = 'Menu__item--active',
5
- children
6
- }) => {
7
- const magicLineParentRef = useRef(null);
8
- const magicLineRef = useRef(null);
9
- const currentActiveItem = useRef(null);
10
- const [loaded, setLoaded] = useState(false);
11
- const [activeItemInNavigation, _setActiveItemInNavigation] = useState(false);
12
- const setActiveItemInNavigation = value => {
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 = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _classnames = _interopRequireDefault(require("classnames"));
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14
+ 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."); }
15
+ 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); }
16
+ 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; }
17
+ 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; } }
18
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
+ var MagicLine = function MagicLine(_ref) {
20
+ var _ref$activeClassName = _ref.activeClassName,
21
+ activeClassName = _ref$activeClassName === void 0 ? 'Menu__item--active' : _ref$activeClassName,
22
+ children = _ref.children;
23
+ var magicLineParentRef = (0, _react.useRef)(null);
24
+ var magicLineRef = (0, _react.useRef)(null);
25
+ var currentActiveItem = (0, _react.useRef)(null);
26
+ var _useState = (0, _react.useState)(false),
27
+ _useState2 = _slicedToArray(_useState, 2),
28
+ loaded = _useState2[0],
29
+ setLoaded = _useState2[1];
30
+ var _useState3 = (0, _react.useState)(false),
31
+ _useState4 = _slicedToArray(_useState3, 2),
32
+ activeItemInNavigation = _useState4[0],
33
+ _setActiveItemInNavigation = _useState4[1];
34
+ var setActiveItemInNavigation = function setActiveItemInNavigation(value) {
13
35
  if (value !== activeItemInNavigation) {
14
36
  _setActiveItemInNavigation(value);
15
37
  }
16
38
  };
17
- const MagicLineRefClasses = c('MagicLine__magic_line', {
39
+ var MagicLineRefClasses = (0, _classnames.default)('MagicLine__magic_line', {
18
40
  'MagicLine__magic_line--visible': activeItemInNavigation && loaded
19
41
  });
20
- const alignMagicLine = () => {
42
+ var alignMagicLine = function alignMagicLine() {
21
43
  if (magicLineRef.current && currentActiveItem.current) {
22
- const left = currentActiveItem.current.getBoundingClientRect().left - magicLineParentRef.current.getBoundingClientRect().left;
23
- const right = magicLineParentRef.current.getBoundingClientRect().width - left - currentActiveItem.current.getBoundingClientRect().width;
24
- magicLineRef.current.style.left = `${left}px`;
25
- magicLineRef.current.style.right = `${right}px`;
44
+ var left = currentActiveItem.current.getBoundingClientRect().left - magicLineParentRef.current.getBoundingClientRect().left;
45
+ var right = magicLineParentRef.current.getBoundingClientRect().width - left - currentActiveItem.current.getBoundingClientRect().width;
46
+ magicLineRef.current.style.left = "".concat(left, "px");
47
+ magicLineRef.current.style.right = "".concat(right, "px");
26
48
  setLoaded(true);
27
49
  }
28
50
  };
29
- const hoverMagicLine = e => {
51
+ var hoverMagicLine = function hoverMagicLine(e) {
30
52
  currentActiveItem.current = e.target;
31
53
  _setActiveItemInNavigation(true);
32
54
  alignMagicLine();
33
55
  };
34
- const setInitialMagicLine = () => {
56
+ var setInitialMagicLine = function setInitialMagicLine() {
35
57
  currentActiveItem.current = document.getElementsByClassName(activeClassName)[0];
36
58
  if (!currentActiveItem.current) {
37
59
  _setActiveItemInNavigation(false);
38
60
  }
39
61
  alignMagicLine();
40
62
  };
41
- useEffect(() => {
42
- const initialize = () => {
63
+ (0, _react.useEffect)(function () {
64
+ var initialize = function initialize() {
43
65
  setInitialMagicLine();
44
66
  };
45
- const handleResize = () => {
67
+ var handleResize = function handleResize() {
46
68
  alignMagicLine();
47
69
  };
48
70
  document.fonts.ready.then(initialize);
49
71
  window.addEventListener('load', initialize);
50
72
  window.addEventListener('resize', handleResize);
51
- return () => {
73
+ return function () {
52
74
  window.removeEventListener('load', initialize);
53
75
  window.removeEventListener('resize', handleResize);
54
76
  };
55
77
  }, []);
56
- return /*#__PURE__*/React.createElement("div", {
78
+ return /*#__PURE__*/_react.default.createElement("div", {
57
79
  ref: magicLineParentRef,
58
80
  className: "MagicLine"
59
- }, /*#__PURE__*/React.createElement("div", {
81
+ }, /*#__PURE__*/_react.default.createElement("div", {
60
82
  ref: magicLineRef,
61
83
  className: MagicLineRefClasses
62
84
  }), children(setInitialMagicLine, hoverMagicLine, setActiveItemInNavigation));
63
85
  };
64
- export default MagicLine;
86
+ var _default = MagicLine;
87
+ exports.default = _default;