@websolutespa/bom-mixer-ui 1.7.4 → 1.7.6

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 (73) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/index.js +149 -128
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/esm/components/backdrop/backdrop.js +6 -15
  5. package/dist/esm/components/backdrop/backdrop.js.map +1 -1
  6. package/dist/esm/components/breakpoint/breakpoint.js +52 -4
  7. package/dist/esm/components/breakpoint/breakpoint.js.map +1 -1
  8. package/dist/esm/components/drawer/drawer-wrapper.js +3 -8
  9. package/dist/esm/components/drawer/drawer-wrapper.js.map +1 -1
  10. package/dist/esm/components/drawer/drawer.js +2 -15
  11. package/dist/esm/components/drawer/drawer.js.map +1 -1
  12. package/dist/esm/components/modal/modal-button.js +4 -10
  13. package/dist/esm/components/modal/modal-button.js.map +1 -1
  14. package/dist/esm/components/modal/modal-close.js +3 -9
  15. package/dist/esm/components/modal/modal-close.js.map +1 -1
  16. package/dist/esm/components/modal/modal-content.js +1 -5
  17. package/dist/esm/components/modal/modal-content.js.map +1 -1
  18. package/dist/esm/components/modal/modal-subtitle.js +1 -5
  19. package/dist/esm/components/modal/modal-subtitle.js.map +1 -1
  20. package/dist/esm/components/modal/modal-wrapper.js +3 -8
  21. package/dist/esm/components/modal/modal-wrapper.js.map +1 -1
  22. package/dist/esm/components/modal/modal.js +9 -19
  23. package/dist/esm/components/modal/modal.js.map +1 -1
  24. package/dist/esm/components/svg-animation/svg-animation.js +62 -18
  25. package/dist/esm/components/svg-animation/svg-animation.js.map +1 -1
  26. package/dist/esm/components/transition/transition.js +6 -15
  27. package/dist/esm/components/transition/transition.js.map +1 -1
  28. package/dist/esm/index.js +1 -1
  29. package/dist/types/components/backdrop/backdrop.d.ts.map +1 -1
  30. package/dist/types/components/breadcrumb/breadcrumb.d.ts +6 -0
  31. package/dist/types/components/breadcrumb/breadcrumb.d.ts.map +1 -1
  32. package/dist/types/components/breakpoint/breakpoint.d.ts +7 -0
  33. package/dist/types/components/breakpoint/breakpoint.d.ts.map +1 -1
  34. package/dist/types/components/drawer/drawer-wrapper.d.ts.map +1 -1
  35. package/dist/types/components/drawer/drawer.d.ts +0 -7
  36. package/dist/types/components/drawer/drawer.d.ts.map +1 -1
  37. package/dist/types/components/google-map/google-map.d.ts +1 -1
  38. package/dist/types/components/grid/grid.d.ts +1 -1
  39. package/dist/types/components/modal/modal-button.d.ts.map +1 -1
  40. package/dist/types/components/modal/modal-close.d.ts.map +1 -1
  41. package/dist/types/components/modal/modal-content.d.ts.map +1 -1
  42. package/dist/types/components/modal/modal-subtitle.d.ts.map +1 -1
  43. package/dist/types/components/modal/modal-wrapper.d.ts.map +1 -1
  44. package/dist/types/components/modal/modal.d.ts +0 -10
  45. package/dist/types/components/modal/modal.d.ts.map +1 -1
  46. package/dist/types/components/reversable/reversable.d.ts.map +1 -1
  47. package/dist/types/components/svg-animation/svg-animation.d.ts +15 -3
  48. package/dist/types/components/svg-animation/svg-animation.d.ts.map +1 -1
  49. package/dist/types/components/transition/transition.d.ts.map +1 -1
  50. package/dist/types/forms/radio-card/radio-card-base.d.ts +2 -2
  51. package/dist/types/sections/auth/auth-form.d.ts +1 -1
  52. package/dist/types/sections/auth/auth-form.d.ts.map +1 -1
  53. package/dist/types/sections/products-detail-download/products-detail-download.d.ts +1 -1
  54. package/dist/types/sections/products-detail-download/products-detail-download.d.ts.map +1 -1
  55. package/dist/types/sections/products-detail-related/products-detail-related.d.ts +1 -1
  56. package/dist/types/sections/products-detail-related/products-detail-related.d.ts.map +1 -1
  57. package/dist/types/sections/products-detail-size-color/products-detail-size-color.d.ts +1 -1
  58. package/dist/types/sections/products-detail-size-color/products-detail-size-color.d.ts.map +1 -1
  59. package/dist/types/sections/shop-detail-related/shop-detail-related.d.ts +1 -1
  60. package/dist/types/sections/shop-detail-related/shop-detail-related.d.ts.map +1 -1
  61. package/package.json +6 -6
  62. package/src/components/backdrop/backdrop.tsx +7 -17
  63. package/src/components/breakpoint/breakpoint.tsx +45 -3
  64. package/src/components/drawer/drawer-wrapper.tsx +4 -10
  65. package/src/components/drawer/drawer.tsx +3 -9
  66. package/src/components/modal/modal-button.tsx +53 -55
  67. package/src/components/modal/modal-close.tsx +30 -36
  68. package/src/components/modal/modal-content.tsx +5 -7
  69. package/src/components/modal/modal-subtitle.tsx +5 -6
  70. package/src/components/modal/modal-wrapper.tsx +6 -11
  71. package/src/components/modal/modal.tsx +10 -20
  72. package/src/components/svg-animation/svg-animation.tsx +76 -18
  73. package/src/components/transition/transition.tsx +10 -16
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @websolutespa/bom-mixer-ui
2
2
 
3
+ ## 1.7.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Added: SvgAnimationStrategy
8
+ - Updated dependencies
9
+ - @websolutespa/bom-mixer-hooks@1.7.3
10
+
11
+ ## 1.7.5
12
+
13
+ ### Patch Changes
14
+
15
+ - Updating: dependencies
16
+ - Updated dependencies
17
+ - @websolutespa/bom-mixer-models@1.7.2
18
+ - @websolutespa/bom-mixer-forms@0.3.1
19
+ - @websolutespa/bom-mixer-hooks@1.7.2
20
+ - @websolutespa/bom-mixer-icons@0.2.3
21
+ - @websolutespa/bom-mixer-store@1.7.3
22
+ - @websolutespa/bom-core@1.7.3
23
+
3
24
  ## 1.7.4
4
25
 
5
26
  ### Patch Changes
package/dist/cjs/index.js CHANGED
@@ -1604,10 +1604,57 @@ const Breadcrumb = bomCore.withSchema(BreadcrumbBase, {
1604
1604
  displayName: 'Breadcrumb'
1605
1605
  });
1606
1606
 
1607
+ exports.BreakpointPlacement = void 0;
1608
+ (function (BreakpointPlacement) {
1609
+ BreakpointPlacement["TopLeft"] = "topLeft";
1610
+ BreakpointPlacement["TopRight"] = "topRight";
1611
+ BreakpointPlacement["BottomRight"] = "bottomRight";
1612
+ BreakpointPlacement["BottomLeft"] = "bottomLeft";
1613
+ })(exports.BreakpointPlacement || (exports.BreakpointPlacement = {}));
1614
+ const getPlacement = function (placement) {
1615
+ if (placement === void 0) {
1616
+ placement = exports.BreakpointPlacement.BottomLeft;
1617
+ }
1618
+ switch (placement) {
1619
+ case exports.BreakpointPlacement.TopLeft:
1620
+ {
1621
+ return styled.css`
1622
+ top: 6px;
1623
+ left: 6px;
1624
+ `;
1625
+ }
1626
+ case exports.BreakpointPlacement.TopRight:
1627
+ {
1628
+ return styled.css`
1629
+ top: 6px;
1630
+ right: 6px;
1631
+ `;
1632
+ }
1633
+ case exports.BreakpointPlacement.BottomRight:
1634
+ {
1635
+ return styled.css`
1636
+ bottom: 6px;
1637
+ right: 6px;
1638
+ `;
1639
+ }
1640
+ case exports.BreakpointPlacement.BottomLeft:
1641
+ {
1642
+ return styled.css`
1643
+ bottom: 6px;
1644
+ left: 6px;
1645
+ `;
1646
+ }
1647
+ default:
1648
+ {
1649
+ return styled.css`
1650
+ top: 6px;
1651
+ left: 6px;
1652
+ `;
1653
+ }
1654
+ }
1655
+ };
1607
1656
  const StyledBreakpoint = styled__default.default(framerMotion.motion.div)`
1608
1657
  position: fixed;
1609
- top: 6px;
1610
- left: 6px;
1611
1658
  padding: 0.3em 0.8em;
1612
1659
  background: var(--color-warning-500);
1613
1660
  color: var(--color-warning-900);
@@ -1618,6 +1665,7 @@ const StyledBreakpoint = styled__default.default(framerMotion.motion.div)`
1618
1665
  font-size: 0.8rem;
1619
1666
  line-height: 1;
1620
1667
  pointer-events: none;
1668
+ ${props => getPlacement(props.placement)}
1621
1669
  ${props => getCssResponsive(props)}
1622
1670
  `;
1623
1671
  const Breakpoint = props => {
@@ -1958,23 +2006,15 @@ const Divider = _a => {
1958
2006
  }));
1959
2007
  };
1960
2008
 
1961
- const defaultProps$8 = {
1962
- visible: false,
1963
- enterTime: 60,
1964
- leaveTime: 60,
1965
- clearTime: 60,
1966
- className: '',
1967
- name: 'transition'
1968
- };
1969
2009
  const Transition = _a => {
1970
2010
  var {
1971
2011
  children,
1972
- className,
1973
- visible,
1974
- enterTime,
1975
- leaveTime,
1976
- clearTime,
1977
- name
2012
+ className = '',
2013
+ visible = false,
2014
+ enterTime = 60,
2015
+ leaveTime = 60,
2016
+ clearTime = 60,
2017
+ name = 'transition'
1978
2018
  } = _a,
1979
2019
  props = __rest(_a, ["children", "className", "visible", "enterTime", "leaveTime", "clearTime", "name"]);
1980
2020
  const [classes, setClasses] = React.useState('');
@@ -2011,17 +2051,8 @@ const Transition = _a => {
2011
2051
  className: `${children.props.className} ${className} ${classes}`
2012
2052
  }));
2013
2053
  };
2014
- Transition.defaultProps = defaultProps$8;
2015
2054
  Transition.displayName = 'Transition';
2016
2055
 
2017
- const defaultProps$7 = {
2018
- onClick: () => {},
2019
- visible: false,
2020
- onContentClick: () => {},
2021
- backdropClassName: '',
2022
- positionClassName: '',
2023
- layerClassName: ''
2024
- };
2025
2056
  const StyledBackdrop = styled__default.default.div`
2026
2057
  box-sizing: border-box;
2027
2058
  position: fixed;
@@ -2098,13 +2129,13 @@ const StyledBackdrop = styled__default.default.div`
2098
2129
  const Backdrop = /*#__PURE__*/React__default.default.memo(_a => {
2099
2130
  var {
2100
2131
  children,
2101
- onClick,
2102
- visible,
2132
+ onClick = () => {},
2133
+ visible = false,
2103
2134
  width,
2104
- onContentClick,
2105
- backdropClassName,
2106
- layerClassName,
2107
- positionClassName
2135
+ onContentClick = () => {},
2136
+ backdropClassName = '',
2137
+ layerClassName = '',
2138
+ positionClassName = ''
2108
2139
  } = _a,
2109
2140
  props = __rest(_a, ["children", "onClick", "visible", "width", "onContentClick", "backdropClassName", "layerClassName", "positionClassName"]);
2110
2141
  const [, setIsContentMouseDown, IsContentMouseDownRef] = bomMixerHooks.useCurrentState(false);
@@ -2150,12 +2181,8 @@ const Backdrop = /*#__PURE__*/React__default.default.memo(_a => {
2150
2181
  }))
2151
2182
  });
2152
2183
  });
2153
- Backdrop.defaultProps = defaultProps$7;
2154
2184
  Backdrop.displayName = 'Backdrop';
2155
2185
 
2156
- const defaultProps$6 = {
2157
- className: ''
2158
- };
2159
2186
  const StyleContent = styled__default.default.div`
2160
2187
  position: relative;
2161
2188
  padding: 2rem 1rem;
@@ -2173,7 +2200,7 @@ const StyleContent = styled__default.default.div`
2173
2200
  `;
2174
2201
  const ModalContent = _a => {
2175
2202
  var {
2176
- className,
2203
+ className = '',
2177
2204
  children
2178
2205
  } = _a,
2179
2206
  props = __rest(_a, ["className", "children"]);
@@ -2184,12 +2211,8 @@ const ModalContent = _a => {
2184
2211
  children: children
2185
2212
  }));
2186
2213
  };
2187
- ModalContent.defaultProps = defaultProps$6;
2188
2214
  ModalContent.displayName = 'ModalContent';
2189
2215
 
2190
- const defaultProps$5 = {
2191
- className: ''
2192
- };
2193
2216
  const StyledSubtitle = styled__default.default.div`
2194
2217
  font-weight: normal;
2195
2218
  display: inline-block;
@@ -2203,7 +2226,7 @@ const StyledSubtitle = styled__default.default.div`
2203
2226
  `;
2204
2227
  const ModalSubtitle = _a => {
2205
2228
  var {
2206
- className,
2229
+ className = '',
2207
2230
  children
2208
2231
  } = _a,
2209
2232
  props = __rest(_a, ["className", "children"]);
@@ -2213,7 +2236,6 @@ const ModalSubtitle = _a => {
2213
2236
  children: children
2214
2237
  }));
2215
2238
  };
2216
- ModalSubtitle.defaultProps = defaultProps$5;
2217
2239
  ModalSubtitle.displayName = 'ModalSubtitle';
2218
2240
 
2219
2241
  const StyledTitle = styled__default.default.h2`
@@ -2267,10 +2289,6 @@ const getDrawerTransform = placement => {
2267
2289
  return translates[placement];
2268
2290
  };
2269
2291
 
2270
- const defaultProps$4 = {
2271
- className: '',
2272
- visible: false
2273
- };
2274
2292
  const StyledWrapper$1 = styled__default.default.div`
2275
2293
  position: fixed;
2276
2294
  top: 0;
@@ -2350,10 +2368,10 @@ const StyledWrapper$1 = styled__default.default.div`
2350
2368
  `;
2351
2369
  const DrawerWrapper = _a => {
2352
2370
  var {
2353
- className,
2371
+ className = '',
2354
2372
  children,
2355
- visible,
2356
- placement
2373
+ visible = false,
2374
+ placement = 'right'
2357
2375
  } = _a,
2358
2376
  props = __rest(_a, ["className", "children", "visible", "placement"]);
2359
2377
  const modalContent = React.useRef(null);
@@ -2414,26 +2432,13 @@ const DrawerWrapper = _a => {
2414
2432
  }))
2415
2433
  });
2416
2434
  };
2417
- DrawerWrapper.defaultProps = defaultProps$4;
2418
2435
  DrawerWrapper.displayName = 'DrawerWrapper';
2419
2436
 
2420
- const DrawerDefaultProps = {
2421
- wrapClassName: '',
2422
- keyboard: true,
2423
- disableBackdropClick: false,
2424
- placement: 'right'
2425
- };
2426
2437
  const DrawerBase = _a => {
2427
2438
  var {
2428
- /*
2429
2439
  wrapClassName = '',
2430
2440
  keyboard = true,
2431
2441
  disableBackdropClick = false,
2432
- placement = 'right' as DrawerPlacement,
2433
- */
2434
- wrapClassName,
2435
- keyboard,
2436
- disableBackdropClick,
2437
2442
  visible: customVisible,
2438
2443
  onClose,
2439
2444
  onContentClick,
@@ -2502,10 +2507,9 @@ const DrawerBase = _a => {
2502
2507
  const Drawer = bomCore.withSchema(DrawerBase, {
2503
2508
  Title: ModalTitle,
2504
2509
  Subtitle: ModalSubtitle,
2505
- Content: ModalContent,
2506
- displayName: 'Drawer',
2507
- defaultProps: DrawerDefaultProps
2510
+ Content: ModalContent
2508
2511
  });
2512
+ Drawer.displayName = 'Drawer';
2509
2513
 
2510
2514
  const defaultRect$2 = {
2511
2515
  top: -1000,
@@ -4777,11 +4781,6 @@ function useModalContext() {
4777
4781
  return React.useContext(ModalContext);
4778
4782
  }
4779
4783
 
4780
- const defaultProps$3 = {
4781
- className: '',
4782
- passive: false,
4783
- disabled: false
4784
- };
4785
4784
  const StyledButton$1 = styled__default.default(Button)`
4786
4785
  /*
4787
4786
  font-size: 0.75rem;
@@ -4808,11 +4807,11 @@ const StyledButton$1 = styled__default.default(Button)`
4808
4807
  `;
4809
4808
  const ModalButton = /*#__PURE__*/React__default.default.forwardRef((_a, ref) => {
4810
4809
  var {
4811
- className,
4810
+ className = '',
4812
4811
  children,
4813
4812
  onClick,
4814
- passive,
4815
- disabled
4813
+ passive = false,
4814
+ disabled = false
4816
4815
  } = _a,
4817
4816
  props = __rest(_a, ["className", "children", "onClick", "passive", "disabled"]);
4818
4817
  const btnRef = React.useRef(null);
@@ -4836,7 +4835,7 @@ const ModalButton = /*#__PURE__*/React__default.default.forwardRef((_a, ref) =>
4836
4835
  const color = useMemo(() => {
4837
4836
  return passive ? (theme as any).color.primary500 : (theme as any).color.neutral900;
4838
4837
  }, [(theme as any).color, passive, disabled]);
4839
- const bgColor = useMemo(() => {
4838
+ const bgColor = useMemo(() => {
4840
4839
  return disabled ? (theme as any).color.primary100 : (theme as any).color.neutral100;
4841
4840
  }, [(theme as any).color, disabled]);
4842
4841
  */
@@ -4855,14 +4854,8 @@ const ModalButton = /*#__PURE__*/React__default.default.forwardRef((_a, ref) =>
4855
4854
  children: children
4856
4855
  }));
4857
4856
  });
4858
- ModalButton.defaultProps = defaultProps$3;
4859
4857
  ModalButton.displayName = 'ModalButton';
4860
4858
 
4861
- const defaultProps$2 = {
4862
- className: '',
4863
- passive: false,
4864
- disabled: false
4865
- };
4866
4859
  const StyledButton = styled__default.default(Button)`
4867
4860
  position: absolute;
4868
4861
  top: 0.5rem;
@@ -4871,11 +4864,11 @@ const StyledButton = styled__default.default(Button)`
4871
4864
  `;
4872
4865
  const ModalClose = /*#__PURE__*/React__default.default.forwardRef((_a, ref) => {
4873
4866
  var {
4874
- className,
4867
+ className = '',
4875
4868
  children,
4876
4869
  onClick,
4877
- passive,
4878
- disabled
4870
+ passive = false,
4871
+ disabled = false
4879
4872
  } = _a,
4880
4873
  props = __rest(_a, ["className", "children", "onClick", "passive", "disabled"]);
4881
4874
  const btnRef = React.useRef(null);
@@ -4907,7 +4900,6 @@ const ModalClose = /*#__PURE__*/React__default.default.forwardRef((_a, ref) => {
4907
4900
  children: jsxRuntime.jsx(bomMixerIcons.IconX, {})
4908
4901
  }));
4909
4902
  });
4910
- ModalClose.defaultProps = defaultProps$2;
4911
4903
  ModalClose.displayName = 'ModalClose';
4912
4904
 
4913
4905
  const StyledFooter = styled__default.default(ButtonGroup)`
@@ -4949,10 +4941,6 @@ const ModalFooter_ = _a => {
4949
4941
  ModalFooter_.displayName = 'ModalFooter';
4950
4942
  const ModalFooter = /*#__PURE__*/React__default.default.memo(ModalFooter_);
4951
4943
 
4952
- const defaultProps$1 = {
4953
- className: '',
4954
- visible: false
4955
- };
4956
4944
  const StyledWrapper = styled__default.default.div`
4957
4945
  box-sizing: border-box;
4958
4946
  position: relative;
@@ -5005,11 +4993,11 @@ const StyledWrapper = styled__default.default.div`
5005
4993
  `;
5006
4994
  const ModalWrapper = _a => {
5007
4995
  var {
5008
- className,
5009
4996
  children,
5010
- visible
4997
+ className = '',
4998
+ visible = false
5011
4999
  } = _a,
5012
- props = __rest(_a, ["className", "children", "visible"]);
5000
+ props = __rest(_a, ["children", "className", "visible"]);
5013
5001
  const modalContent = React.useRef(null);
5014
5002
  const tabStart = React.useRef(null);
5015
5003
  const tabEnd = React.useRef(null);
@@ -5066,27 +5054,17 @@ const ModalWrapper = _a => {
5066
5054
  }))
5067
5055
  });
5068
5056
  };
5069
- ModalWrapper.defaultProps = defaultProps$1;
5070
5057
  ModalWrapper.displayName = 'ModalWrapper';
5071
5058
 
5072
- const defaultProps = {
5073
- width: '26rem',
5074
- backdropClassName: '',
5075
- positionClassName: '',
5076
- layerClassName: '',
5077
- wrapClassName: '',
5078
- disableBackdropClick: false,
5079
- keyboard: true
5080
- };
5081
5059
  const ModalBase = _ref => {
5082
5060
  let {
5083
- width,
5084
- backdropClassName,
5085
- positionClassName,
5086
- layerClassName,
5087
- wrapClassName,
5088
- disableBackdropClick,
5089
- keyboard,
5061
+ width = '26rem',
5062
+ backdropClassName = '',
5063
+ positionClassName = '',
5064
+ layerClassName = '',
5065
+ wrapClassName = '',
5066
+ disableBackdropClick = false,
5067
+ keyboard = true,
5090
5068
  visible: customVisible,
5091
5069
  onClose,
5092
5070
  children,
@@ -5169,10 +5147,9 @@ const Modal = bomCore.withSchema(ModalBase, {
5169
5147
  Subtitle: ModalSubtitle,
5170
5148
  Content: ModalContent,
5171
5149
  Button: ModalButton,
5172
- Close: ModalClose,
5173
- displayName: 'Modal',
5174
- defaultProps
5150
+ Close: ModalClose
5175
5151
  });
5152
+ Modal.displayName = 'Modal';
5176
5153
 
5177
5154
  const MediaGalleryButton = styled__default.default.button`
5178
5155
  border: none;
@@ -6686,10 +6663,19 @@ const Skeleton = _a => {
6686
6663
  }));
6687
6664
  };
6688
6665
 
6666
+ const SvgAnimationStrategy = {
6667
+ Default: 'default',
6668
+ Once: 'once',
6669
+ Scroll: 'scroll',
6670
+ Over: 'over',
6671
+ Controlled: 'controlled'
6672
+ };
6673
+ // export type SvgAnimationComponent<C extends React.ElementType = 'div'> = UIComponentWithRef<C, Props>;
6689
6674
  const StyledSvgAnimation = styled__default.default.div`
6690
6675
  display: flex;
6691
6676
  justify-content: center;
6692
6677
  align-items: center;
6678
+ background: transparent;
6693
6679
  & > div {
6694
6680
  object-fit: contain;
6695
6681
  width: 100%;
@@ -6700,25 +6686,22 @@ const StyledSvgAnimation = styled__default.default.div`
6700
6686
  const SvgAnimation = /*#__PURE__*/React.forwardRef((_a, forwardedRef) => {
6701
6687
  var {
6702
6688
  className,
6703
- as = 'div',
6704
6689
  href,
6705
6690
  animation,
6691
+ mode = SvgAnimationStrategy.Default,
6706
6692
  loop = false,
6707
6693
  scrollable = false,
6708
6694
  scrollableRef,
6709
6695
  width,
6710
6696
  height
6711
6697
  } = _a,
6712
- props = __rest(_a, ["className", "as", "href", "animation", "loop", "scrollable", "scrollableRef", "width", "height"]);
6698
+ props = __rest(_a, ["className", "href", "animation", "mode", "loop", "scrollable", "scrollableRef", "width", "height"]);
6713
6699
  if (!href && !animation) {
6714
6700
  throw 'SvgAnimation.error: please submit an animation loader or a href';
6715
6701
  }
6716
- const elementRef = React.useRef();
6717
- React.useImperativeHandle(forwardedRef, () => {
6718
- return elementRef.current;
6719
- }, [elementRef]);
6702
+ const elementRef = React.useRef(null);
6720
6703
  const isIntersecting = bomMixerHooks.useIntersectionObserver(elementRef, {
6721
- threshold: 0,
6704
+ threshold: mode === SvgAnimationStrategy.Once ? 0.5 : 0,
6722
6705
  root: null,
6723
6706
  rootMargin: '0px'
6724
6707
  });
@@ -6727,6 +6710,20 @@ const SvgAnimation = /*#__PURE__*/React.forwardRef((_a, forwardedRef) => {
6727
6710
  const [animationData, setAnimationData] = React.useState();
6728
6711
  const [animationPath, setAnimationPath] = React.useState();
6729
6712
  const [animationPosition, setAnimationPosition] = React.useState();
6713
+ React.useImperativeHandle(forwardedRef, () => {
6714
+ return {
6715
+ container: elementRef.current,
6716
+ play: () => {
6717
+ if (!playerRef.current) {
6718
+ return;
6719
+ }
6720
+ // console.log(playerRef.current.currentFrame, playerRef.current.totalFrames, playerRef.current.isPaused);
6721
+ if (playerRef.current.isPaused) {
6722
+ playerRef.current.goToAndPlay(0);
6723
+ }
6724
+ }
6725
+ };
6726
+ }, [elementRef]);
6730
6727
  // load animation on shouldLoad
6731
6728
  React.useEffect(() => {
6732
6729
  if (shouldLoad) {
@@ -6742,17 +6739,27 @@ const SvgAnimation = /*#__PURE__*/React.forwardRef((_a, forwardedRef) => {
6742
6739
  // handle intersection
6743
6740
  React.useEffect(() => {
6744
6741
  if (isIntersecting) {
6742
+ // on enter
6745
6743
  if (!shouldLoad) {
6746
6744
  setShouldLoad(true);
6747
6745
  } else {
6748
- if (!scrollable && playerRef.current) {
6749
- // console.log('SvgAnimation.play');
6746
+ if (!playerRef.current) {
6747
+ return;
6748
+ }
6749
+ // console.log(playerRef.current.currentFrame);
6750
+ if (mode === SvgAnimationStrategy.Default) {
6751
+ playerRef.current.goToAndPlay(0);
6752
+ }
6753
+ if (mode === SvgAnimationStrategy.Once && playerRef.current.currentFrame === 0) {
6750
6754
  playerRef.current.goToAndPlay(0);
6751
6755
  }
6752
6756
  }
6753
6757
  } else {
6754
- if (!scrollable && playerRef.current) {
6755
- // console.log('SvgAnimation.stop');
6758
+ // on exit
6759
+ if (!playerRef.current) {
6760
+ return;
6761
+ }
6762
+ if (mode === SvgAnimationStrategy.Default) {
6756
6763
  playerRef.current.stop();
6757
6764
  }
6758
6765
  }
@@ -6775,7 +6782,7 @@ const SvgAnimation = /*#__PURE__*/React.forwardRef((_a, forwardedRef) => {
6775
6782
  setAnimationPosition(frame);
6776
6783
  }
6777
6784
  };
6778
- if (scrollable) {
6785
+ if (mode === SvgAnimationStrategy.Scroll) {
6779
6786
  if (scrollElement) {
6780
6787
  scrollElement.addEventListener('scroll', onScroll, {
6781
6788
  passive: true
@@ -6783,13 +6790,27 @@ const SvgAnimation = /*#__PURE__*/React.forwardRef((_a, forwardedRef) => {
6783
6790
  }
6784
6791
  }
6785
6792
  return () => {
6786
- if (scrollable && scrollElement) {
6793
+ if (mode === SvgAnimationStrategy.Scroll && scrollElement) {
6787
6794
  scrollElement.removeEventListener('scroll', onScroll);
6788
6795
  }
6789
6796
  };
6790
- }, [scrollable, scrollableRef]);
6797
+ }, [mode, scrollableRef]);
6791
6798
  const onLoad = () => {
6792
- if (!scrollable && playerRef.current) {
6799
+ if (!playerRef.current) {
6800
+ return;
6801
+ }
6802
+ if (mode === SvgAnimationStrategy.Default || mode === SvgAnimationStrategy.Once) {
6803
+ playerRef.current.goToAndPlay(0);
6804
+ }
6805
+ };
6806
+ const onMouseOver = event => {
6807
+ if (typeof props.onMouseOver === 'function') {
6808
+ props.onMouseOver(event);
6809
+ }
6810
+ if (!playerRef.current) {
6811
+ return;
6812
+ }
6813
+ if (mode === SvgAnimationStrategy.Over && playerRef.current.isPaused) {
6793
6814
  playerRef.current.goToAndPlay(0);
6794
6815
  }
6795
6816
  };
@@ -6798,9 +6819,9 @@ const SvgAnimation = /*#__PURE__*/React.forwardRef((_a, forwardedRef) => {
6798
6819
  });
6799
6820
  return jsxRuntime.jsxs(StyledSvgAnimation, Object.assign({
6800
6821
  ref: elementRef,
6801
- className: classNames,
6802
- as: as
6822
+ className: classNames
6803
6823
  }, props, {
6824
+ onMouseOver: onMouseOver,
6804
6825
  children: [animationData && jsxRuntime.jsx(LottiePlayerLight__default.default, {
6805
6826
  ref: playerRef,
6806
6827
  animationData: animationData,