@symply.io/basic-components 1.4.4 → 1.4.5-alpha.1

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.
@@ -10,7 +10,7 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
- import { cloneElement, createContext, useContext, useState, useCallback } from "react";
13
+ import { cloneElement, createContext, useRef, useContext, useEffect, useState, useCallback } from "react";
14
14
  import Grid from "@mui/material/Grid";
15
15
  import HeaderBar from "./HeaderBar";
16
16
  var HeaderContext = createContext({
@@ -20,6 +20,7 @@ var HeaderContext = createContext({
20
20
  });
21
21
  export function HeaderProvider(props) {
22
22
  var children = props.children, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, _a = props.sx, sx = _a === void 0 ? {} : _a;
23
+ var headerContainer = useRef(null);
23
24
  var _b = useState(false), visible = _b[0], setVisible = _b[1];
24
25
  var _c = useState({ title: "" }), headerProps = _c[0], setHeaderProps = _c[1];
25
26
  var _d = useState(0), height = _d[0], setHeight = _d[1];
@@ -32,11 +33,24 @@ export function HeaderProvider(props) {
32
33
  var onHide = useCallback(function () {
33
34
  setVisible(false);
34
35
  }, []);
35
- var measureRef = useCallback(function (node) {
36
- if (node && headerProps) {
37
- setHeight(node.getBoundingClientRect().height);
36
+ var measureRef = useCallback(function (instance) {
37
+ if (instance && headerProps) {
38
+ headerContainer.current = instance;
39
+ setHeight(instance.getBoundingClientRect().height);
38
40
  }
39
41
  }, [headerProps]);
42
+ useEffect(function () {
43
+ var resetHeight = function () {
44
+ if (headerContainer.current) {
45
+ setHeight(headerContainer.current.getBoundingClientRect().height);
46
+ }
47
+ };
48
+ window.addEventListener("resize", resetHeight);
49
+ return function () {
50
+ window.removeEventListener("resize", resetHeight);
51
+ headerContainer.current = null;
52
+ };
53
+ }, []);
40
54
  return (_jsx(HeaderContext.Provider, __assign({ value: { onInit: onInit, onHide: onHide, onShow: onShow } }, { children: _jsxs(_Fragment, { children: [visible ? (_jsx(Grid, __assign({ container: true, direction: "row", sx: __assign({}, sx), ref: measureRef }, { children: _jsx(Grid, __assign({ item: true, xs: 12 }, { children: _jsx(HeaderBar, __assign({}, headerProps, { primaryColor: primaryColor, secondaryColor: secondaryColor })) })) }))) : (_jsx(_Fragment, {})), _jsx(Grid, __assign({ sx: {
41
55
  p: 3,
42
56
  py: 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symply.io/basic-components",
3
- "version": "1.4.4",
3
+ "version": "1.4.5-alpha.1",
4
4
  "description": "Basic and reusable components for all frontend of Symply apps",
5
5
  "keywords": [
6
6
  "react",