@dhis2-ui/transfer 10.10.2 → 10.12.0
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/build/cjs/__e2e__/notify_at_end_of_list.e2e.stories.js +46 -3
- package/build/cjs/end-intersection-detector.js +5 -4
- package/build/cjs/features/notify_at_end_of_list/index.js +35 -0
- package/build/cjs/features/notify_at_end_of_list.feature +35 -0
- package/build/cjs/options-container.js +14 -8
- package/build/cjs/transfer/index.js +11 -0
- package/build/cjs/transfer/use-options-key-monitor.js +42 -0
- package/build/cjs/transfer.js +41 -14
- package/build/cjs/transfer.prod.stories.js +25 -37
- package/build/es/__e2e__/notify_at_end_of_list.e2e.stories.js +42 -1
- package/build/es/end-intersection-detector.js +4 -3
- package/build/es/features/notify_at_end_of_list/index.js +35 -0
- package/build/es/features/notify_at_end_of_list.feature +35 -0
- package/build/es/options-container.js +14 -8
- package/build/es/transfer/index.js +2 -1
- package/build/es/transfer/use-options-key-monitor.js +35 -0
- package/build/es/transfer.js +39 -14
- package/build/es/transfer.prod.stories.js +26 -38
- package/package.json +7 -7
- package/types/index.d.ts +6 -0
- package/build/cjs/picked-options.js +0 -44
- package/build/cjs/source-options.js +0 -44
- package/build/cjs/use-resize-counter.js +0 -36
- package/build/es/picked-options.js +0 -36
- package/build/es/source-options.js +0 -36
- package/build/es/use-resize-counter.js +0 -30
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* The initial call is irrelevant as there has been
|
|
5
|
-
* no resize yet that we want to react to
|
|
6
|
-
* So we start with -1 with will returned as 0 by this hook
|
|
7
|
-
*
|
|
8
|
-
* @param {Element} element
|
|
9
|
-
* @returns {number}
|
|
10
|
-
*/
|
|
11
|
-
export const useResizeCounter = element => {
|
|
12
|
-
const [counter, setCounter] = useState(-1);
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
// using an internal counter as using the one from `useState`
|
|
15
|
-
// would cause an infinite loop as this `useEffect` would
|
|
16
|
-
// both depend on that value as well as change it every time
|
|
17
|
-
// it's executed as the callback passed to `ResizeObserver`
|
|
18
|
-
// will be executed on construction
|
|
19
|
-
let internalCounter = counter;
|
|
20
|
-
if (element) {
|
|
21
|
-
const observer = new ResizeObserver(() => {
|
|
22
|
-
++internalCounter;
|
|
23
|
-
setCounter(internalCounter);
|
|
24
|
-
});
|
|
25
|
-
observer.observe(element);
|
|
26
|
-
return () => observer.disconnect();
|
|
27
|
-
}
|
|
28
|
-
}, [element, setCounter]);
|
|
29
|
-
return counter < 1 ? 0 : counter;
|
|
30
|
-
};
|