@sohanemon/utils 4.1.0 → 4.1.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.
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/index.js +5 -2
- package/package.json +1 -1
package/dist/hooks/index.d.ts
CHANGED
|
@@ -98,10 +98,11 @@ type CalculationProps = {
|
|
|
98
98
|
blockIds: string[];
|
|
99
99
|
dynamic?: boolean | string;
|
|
100
100
|
margin?: number;
|
|
101
|
+
substract?: boolean;
|
|
101
102
|
};
|
|
102
103
|
/**
|
|
103
104
|
* Hook to calculate the height of an element based on viewport and other block heights.
|
|
104
105
|
* @param params - Configuration object for height calculation.
|
|
105
106
|
* @returns The calculated height.
|
|
106
107
|
*/
|
|
107
|
-
export declare const useHeightCalculation: ({ blockIds, margin, dynamic, }: CalculationProps) => number;
|
|
108
|
+
export declare const useHeightCalculation: ({ blockIds, margin, substract, dynamic, }: CalculationProps) => number;
|
package/dist/hooks/index.js
CHANGED
|
@@ -264,11 +264,14 @@ export function useCopyToClipboard({ timeout = 2000 }) {
|
|
|
264
264
|
* @param params - Configuration object for height calculation.
|
|
265
265
|
* @returns The calculated height.
|
|
266
266
|
*/
|
|
267
|
-
export const useHeightCalculation = ({ blockIds = [], margin = 0, dynamic = false, }) => {
|
|
267
|
+
export const useHeightCalculation = ({ blockIds = [], margin = 0, substract = true, dynamic = false, }) => {
|
|
268
268
|
const [height, setTableHeight] = React.useState(500);
|
|
269
269
|
const handleResize = () => {
|
|
270
270
|
const blockHeight = blockIds.reduce((prevHeight, id) => prevHeight + (document.getElementById(id)?.clientHeight || 0), 0);
|
|
271
|
-
|
|
271
|
+
const height = substract
|
|
272
|
+
? window.innerHeight - blockHeight - margin
|
|
273
|
+
: blockHeight + margin;
|
|
274
|
+
setTableHeight(height);
|
|
272
275
|
};
|
|
273
276
|
useIsomorphicEffect(() => {
|
|
274
277
|
handleResize();
|