@admin-layout/client 3.0.0-alpha.126 → 3.0.0-alpha.134
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.
- package/lib/interfaces/layout/basic-layout.d.ts +1 -1
- package/lib/utils/componentSize.d.ts +7 -0
- package/lib/utils/componentSize.js +48 -0
- package/lib/utils/componentSize.js.map +1 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -0
- package/lib/utils/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -67,6 +67,6 @@ export type BasicLayoutProps = Partial<RouterTypes<Route>> & SiderMenuProps & He
|
|
|
67
67
|
* Use both content margin
|
|
68
68
|
*/
|
|
69
69
|
disableContentMargin?: boolean;
|
|
70
|
-
mainHeaderProps
|
|
70
|
+
mainHeaderProps?: MainHeaderPropsInterface;
|
|
71
71
|
};
|
|
72
72
|
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import { useState, useRef, useCallback, useLayoutEffect, useEffect } from 'react';
|
|
3
|
+
export const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
4
|
+
const getSize = (el) => {
|
|
5
|
+
if (!el) {
|
|
6
|
+
return {
|
|
7
|
+
width: 0,
|
|
8
|
+
height: 0
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
width: el.offsetWidth,
|
|
13
|
+
height: el.offsetHeight
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export const useComponentSize = () => {
|
|
17
|
+
let ref = useRef(null);
|
|
18
|
+
const [componentSize, setComponentSize] = useState(getSize(ref ? ref.current : {}));
|
|
19
|
+
const handleResize = useCallback(() => {
|
|
20
|
+
if (ref.current) {
|
|
21
|
+
setComponentSize(getSize(ref.current));
|
|
22
|
+
}
|
|
23
|
+
}, [ref]);
|
|
24
|
+
useIsomorphicLayoutEffect(() => {
|
|
25
|
+
if (!ref.current) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
handleResize();
|
|
29
|
+
if (typeof ResizeObserver === 'function') {
|
|
30
|
+
let resizeObserver = new ResizeObserver(() => {
|
|
31
|
+
handleResize();
|
|
32
|
+
});
|
|
33
|
+
resizeObserver.observe(ref.current);
|
|
34
|
+
return () => {
|
|
35
|
+
resizeObserver.disconnect();
|
|
36
|
+
resizeObserver = null;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
window.addEventListener('resize', handleResize);
|
|
41
|
+
return () => {
|
|
42
|
+
window.removeEventListener('resize', handleResize);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}, [ref.current]);
|
|
46
|
+
return Object.assign({ ref }, componentSize);
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=componentSize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentSize.js","sourceRoot":"","sources":["../../src/utils/componentSize.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElF,MAAM,CAAC,MAAM,yBAAyB,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC;AAErG,MAAM,OAAO,GAAG,CAAC,EAAE,EAAE,EAAE;IACrB,IAAI,CAAC,EAAE,EAAE;QACP,OAAO;YACL,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,CAAC;SACV,CAAC;KACH;IACD,OAAO;QACL,KAAK,EAAE,EAAE,CAAC,WAAW;QACrB,MAAM,EAAE,EAAE,CAAC,YAAY;KACxB,CAAC;AACJ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAC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sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@admin-layout/client",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.134",
|
|
4
4
|
"description": "Sample client for higher packages to depend on",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"typescript": {
|
|
35
35
|
"definition": "lib/index.d.ts"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "dfed17213b872a4185dd24f2da27c6fa040053b4"
|
|
38
38
|
}
|