@codeleap/web 3.12.2 → 3.12.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/web",
3
- "version": "3.12.2",
3
+ "version": "3.12.4",
4
4
  "main": "src/index.ts",
5
5
  "repository": {
6
6
  "url": "https://github.com/codeleap-uk/internal-libs-monorepo.git",
@@ -25,7 +25,7 @@ export const Overlay = <T extends NativeHTMLElement>(overlayProps:OverlayProps<T
25
25
  responsiveVariants,
26
26
  variants,
27
27
  styles,
28
- scrollLocked = true,
28
+ scrollLocked = false,
29
29
  ...props
30
30
  } = overlayProps
31
31
 
@@ -1,6 +1,6 @@
1
1
  import React from 'react'
2
2
  import { useWindowSize } from '@react-hook/window-size'
3
- import { AnyFunction, onUpdate, usePrevious } from '@codeleap/common'
3
+ import { AnyFunction, onUpdate, usePrevious, useState } from '@codeleap/common'
4
4
 
5
5
  import {
6
6
  useMasonry,
@@ -11,6 +11,7 @@ import {
11
11
  MasonryProps,
12
12
  RenderComponentProps,
13
13
  } from 'masonic'
14
+ import { EmptyPlaceholder } from '../components/EmptyPlaceholder'
14
15
 
15
16
  export type ItemMasonryProps<T> = RenderComponentProps<T>
16
17
 
@@ -22,21 +23,19 @@ export type ListMasonryProps<T> = MasonryProps<T> & {
22
23
  export function ListMasonry<Item>(props: ListMasonryProps<Item>) {
23
24
  const data = props?.items || []
24
25
 
26
+ const [reloadingLayout, setReloadingLayout] = useState(false)
27
+
25
28
  const dataPreviousLength = usePrevious(data?.length)
26
29
 
27
- const masonryUpdater = React.useMemo(() => {
30
+ onUpdate(() => {
28
31
  if (data?.length < dataPreviousLength) {
29
- return data?.length
30
- } else {
31
- return false
32
- }
33
- }, [dataPreviousLength, data?.length])
32
+ setReloadingLayout(true)
34
33
 
35
- onUpdate(() => {
36
- if (!!masonryUpdater && !!props?.itemsRehydrateIndicator) {
37
- props?.onRefreshItems?.(() => null)
34
+ setTimeout(() => {
35
+ setReloadingLayout(false)
36
+ }, 3000)
38
37
  }
39
- }, [masonryUpdater])
38
+ }, [data?.length])
40
39
 
41
40
  const containerRef = React.useRef(null)
42
41
 
@@ -65,12 +64,16 @@ export function ListMasonry<Item>(props: ListMasonryProps<Item>) {
65
64
  columnCount: listProps?.columnCount,
66
65
  maxColumnCount: listProps?.columnCount,
67
66
  rowGutter: listProps?.rowGutter
68
- }, [masonryUpdater])
67
+ }, [reloadingLayout])
69
68
 
70
69
  const { scrollTop, isScrolling } = useScroller(listProps?.offset, listProps?.scrollFps)
71
70
 
72
71
  listProps.resizeObserver = useResizeObserver(listProps.positioner)
73
72
 
73
+ if (reloadingLayout) {
74
+ return <EmptyPlaceholder loading={true} title={''} description={null} />
75
+ }
76
+
74
77
  return useMasonry({
75
78
  ...listProps,
76
79
  scrollTop,