@autoguru/overdrive 4.15.0 → 4.15.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.
@@ -1 +1 @@
1
- {"version":3,"file":"FillHeightBox.d.ts","sourceRoot":"","sources":["../../../lib/components/FillHeightBox/FillHeightBox.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1D,OAA4B,EAC3B,wBAAwB,EACxB,MAAM,qDAAqD,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,KAAK,KAAK,GAAG,IAAI,CAAC,wBAAwB,EAAE,cAAc,CAAC,GAC1D,cAAc,CAAC,OAAO,UAAU,CAAC,CAAC;AAEnC,eAAO,MAAM,aAAa,EAAE,iBAAiB,CAAC,KAAK,CAsBlD,CAAC"}
1
+ {"version":3,"file":"FillHeightBox.d.ts","sourceRoot":"","sources":["../../../lib/components/FillHeightBox/FillHeightBox.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1D,OAA4B,EAC3B,wBAAwB,EACxB,MAAM,qDAAqD,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,KAAK,KAAK,GAAG,IAAI,CAAC,wBAAwB,EAAE,cAAc,CAAC,GAC1D,cAAc,CAAC,OAAO,UAAU,CAAC,CAAC;AAEnC,eAAO,MAAM,aAAa,EAAE,iBAAiB,CAAC,KAAK,CAwBlD,CAAC"}
@@ -2,7 +2,7 @@
2
2
 
3
3
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
- const _excluded = ["includeMobile", "bottomGap", "serverVhFallback", "style"];
5
+ const _excluded = ["includeMobile", "bottomGap", "serverVhFallback", "observedElementRef", "style"];
6
6
  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; }
7
7
  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; }
8
8
  import * as React from 'react';
@@ -14,6 +14,7 @@ export const FillHeightBox = _ref => {
14
14
  includeMobile,
15
15
  bottomGap,
16
16
  serverVhFallback,
17
+ observedElementRef,
17
18
  style
18
19
  } = _ref,
19
20
  scrollPaneProps = _objectWithoutProperties(_ref, _excluded);
@@ -21,6 +22,7 @@ export const FillHeightBox = _ref => {
21
22
  const containerHeight = useWindowHeightFill({
22
23
  containerRef,
23
24
  includeMobile,
25
+ observedElementRef,
24
26
  bottomGap,
25
27
  serverVhFallback
26
28
  });
@@ -4,8 +4,10 @@ export interface UseWindowHeightFillProps {
4
4
  bottomGap?: keyof Tokens['space'];
5
5
  serverVhFallback?: number;
6
6
  includeMobile?: boolean;
7
+ observeDomChanges?: boolean;
7
8
  containerRef: RefObject<HTMLDivElement>;
9
+ observedElementRef?: RefObject<HTMLDivElement>;
8
10
  }
9
- export declare const useWindowHeightFill: ({ bottomGap, includeMobile, serverVhFallback, containerRef, }: UseWindowHeightFillProps) => string;
11
+ export declare const useWindowHeightFill: ({ bottomGap, includeMobile, serverVhFallback, containerRef, observedElementRef, }: UseWindowHeightFillProps) => string;
10
12
  export default useWindowHeightFill;
11
13
  //# sourceMappingURL=useWindowHeightFill.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useWindowHeightFill.d.ts","sourceRoot":"","sources":["../../../lib/hooks/useWindowHeightFill/useWindowHeightFill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA6B,MAAM,OAAO,CAAC;AAI7D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,MAAM,WAAW,wBAAwB;IACxC,SAAS,CAAC,EAAE,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;IAClC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;CACxC;AAED,eAAO,MAAM,mBAAmB,kEAK7B,wBAAwB,KAAG,MAiD7B,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"useWindowHeightFill.d.ts","sourceRoot":"","sources":["../../../lib/hooks/useWindowHeightFill/useWindowHeightFill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAqC,MAAM,OAAO,CAAC;AAIrE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,MAAM,WAAW,wBAAwB;IACxC,SAAS,CAAC,EAAE,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;IAClC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,YAAY,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IACxC,kBAAkB,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;CAC/C;AAED,eAAO,MAAM,mBAAmB,sFAM7B,wBAAwB,KAAG,MA8D7B,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- import { useLayoutEffect, useState } from 'react';
3
+ import { useLayoutEffect, useRef, useState } from 'react';
4
4
  import { useResponsiveValue, useTheme } from "../../index.js";
5
5
  import { themeContractVars } from "../../themes/theme.css.js";
6
6
  import { getThemeTokenValue } from "../../utils/css.js";
@@ -10,23 +10,36 @@ export const useWindowHeightFill = _ref => {
10
10
  bottomGap = 'none',
11
11
  includeMobile = false,
12
12
  serverVhFallback = 100,
13
- containerRef
13
+ containerRef,
14
+ observedElementRef
14
15
  } = _ref;
15
16
  const cappedHeight = useResponsiveValue([includeMobile,, true]);
16
17
  const {
17
18
  themeClass
18
19
  } = useTheme();
19
20
  const [containerHeight, setContainerHeight] = useState("".concat(serverVhFallback, "vh"));
21
+ const containerHeightRef = useRef(containerHeight);
20
22
  useLayoutEffect(() => {
21
23
  var _window, _document;
22
24
  if (!(containerRef !== null && containerRef !== void 0 && containerRef.current) || !((_window = window) !== null && _window !== void 0 && _window.innerHeight) || !((_document = document) !== null && _document !== void 0 && _document.body)) return void 0;
23
25
  const resize = () => {
24
26
  const gap = getThemeTokenValue(themeClass, themeContractVars.space[bottomGap]) || '0px';
25
27
  const availableHeight = window.innerHeight - containerRef.current.getBoundingClientRect().top;
26
- setContainerHeight(gap ? "calc(".concat(availableHeight, "px - ").concat(gap, ")") : "".concat(availableHeight, "px"));
28
+ const newHeight = gap ? "calc(".concat(availableHeight, "px - ").concat(gap, ")") : "".concat(availableHeight, "px");
29
+ if (containerHeightRef.current !== newHeight) {
30
+ setContainerHeight(newHeight);
31
+ containerHeightRef.current = newHeight;
32
+ }
27
33
  };
34
+ const mutationObserver = new MutationObserver(resize);
35
+ mutationObserver.observe((observedElementRef === null || observedElementRef === void 0 ? void 0 : observedElementRef.current) || document.body, {
36
+ childList: true,
37
+ subtree: true,
38
+ attributes: false,
39
+ characterData: false
40
+ });
28
41
  const resizeObserver = new ResizeObserver(resize);
29
- resizeObserver.observe(document.body);
42
+ resizeObserver.observe((observedElementRef === null || observedElementRef === void 0 ? void 0 : observedElementRef.current) || document.body);
30
43
  window.removeEventListener('resize', resize);
31
44
  window.addEventListener('resize', resize, {
32
45
  passive: true
@@ -34,6 +47,7 @@ export const useWindowHeightFill = _ref => {
34
47
  resize();
35
48
  return () => {
36
49
  window.removeEventListener('resize', resize);
50
+ mutationObserver.disconnect();
37
51
  resizeObserver.disconnect();
38
52
  };
39
53
  }, [containerRef === null || containerRef === void 0 ? void 0 : containerRef.current, (_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.innerHeight, (_document2 = document) === null || _document2 === void 0 ? void 0 : _document2.body, themeClass, bottomGap]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autoguru/overdrive",
3
- "version": "4.15.0",
3
+ "version": "4.15.2",
4
4
  "description": "Overdrive is a product component library, and design system for AutoGuru.",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",