ublo-lib 1.3.0 → 1.3.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.
@@ -8,7 +8,8 @@ const ScrollSpy = ({
8
8
  children,
9
9
  currentClassName,
10
10
  Tag = "div",
11
- onUpdate
11
+ onUpdate,
12
+ unsetCurrent
12
13
  }) => {
13
14
  const [current, setCurrent] = React.useState();
14
15
  const callback = React.useCallback(entries => {
@@ -17,9 +18,12 @@ const ScrollSpy = ({
17
18
  const index = items.indexOf(entry.target.id);
18
19
  setCurrent(index);
19
20
  onUpdate?.(entry.target);
21
+ } else if (unsetCurrent && !entry.isVisible) {
22
+ setCurrent(undefined);
23
+ onUpdate?.(undefined);
20
24
  }
21
25
  }
22
- }, [items, onUpdate]);
26
+ }, [items, onUpdate, unsetCurrent]);
23
27
  React.useEffect(() => {
24
28
  const targets = items.length ? items.reduce((acc, item) => {
25
29
  const element = document.getElementById(item);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "peerDependencies": {
5
5
  "dt-design-system": "^2.1.0",
6
6
  "next": "^12.0.0",