@codeleap/web 3.12.3 → 3.12.5

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.3",
3
+ "version": "3.12.5",
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
 
@@ -10,11 +10,8 @@ import {
10
10
  useResizeObserver,
11
11
  MasonryProps,
12
12
  RenderComponentProps,
13
- MasonryScroller,
14
13
  } from 'masonic'
15
14
 
16
- import { EmptyPlaceholder } from '../components/EmptyPlaceholder'
17
-
18
15
  export type ItemMasonryProps<T> = RenderComponentProps<T>
19
16
 
20
17
  export type ListMasonryProps<T> = MasonryProps<T> & {
@@ -23,37 +20,30 @@ export type ListMasonryProps<T> = MasonryProps<T> & {
23
20
  }
24
21
 
25
22
  export function ListMasonry<Item>(props: ListMasonryProps<Item>) {
26
- const {
27
- columnCount,
28
- columnGutter,
29
- rowGutter,
30
- items,
31
- render,
32
- } = props
33
-
34
- const data = items || []
23
+ const data = props?.items || []
35
24
 
36
25
  const [reloadingLayout, setReloadingLayout] = useState(false)
37
26
 
38
27
  const dataPreviousLength = usePrevious(data?.length)
39
28
 
40
- const masonryUpdater = React.useMemo(() => {
41
- if (data?.length < dataPreviousLength) {
42
- return data?.length
43
- } else {
44
- return false
45
- }
46
- }, [dataPreviousLength, data?.length])
47
-
48
29
  onUpdate(() => {
49
- if (!!masonryUpdater && !!props?.itemsRehydrateIndicator) {
30
+ console.log({
31
+ dataPreviousLength,
32
+ length: data?.length
33
+ })
34
+
35
+ if (dataPreviousLength > data?.length) {
50
36
  setReloadingLayout(true)
51
37
 
38
+ console.log({
39
+ reloaded: true,
40
+ })
41
+
52
42
  setTimeout(() => {
53
43
  setReloadingLayout(false)
54
44
  }, 3000)
55
45
  }
56
- }, [masonryUpdater])
46
+ }, [data?.length, dataPreviousLength])
57
47
 
58
48
  const containerRef = React.useRef(null)
59
49
 
@@ -64,42 +54,40 @@ export function ListMasonry<Item>(props: ListMasonryProps<Item>) {
64
54
 
65
55
  const containerPosition = useContainerPosition(containerRef, windowSize)
66
56
 
67
- const listProps = {
68
- offset: containerPosition?.offset,
69
- width: containerPosition?.width || containerRef?.current?.clientWidth || windowSize?.[0],
70
- height: windowSize?.[1],
71
- containerRef,
72
- scrollFps: props?.scrollFps || 12,
73
- }
57
+ const listProps = Object.assign(
58
+ {
59
+ offset: containerPosition?.offset,
60
+ width: containerPosition?.width || containerRef?.current?.clientWidth || windowSize?.[0],
61
+ height: windowSize?.[1],
62
+ containerRef,
63
+ scrollFps: props?.scrollFps || 12,
64
+ },
65
+ props
66
+ ) as any
74
67
 
75
68
  const positioner = usePositioner({
76
69
  width: listProps?.width,
77
- columnGutter: columnGutter,
78
- columnCount: columnCount,
79
- maxColumnCount: columnCount,
80
- rowGutter: rowGutter
81
- }, [masonryUpdater, reloadingLayout])
70
+ columnGutter: listProps?.columnGutter,
71
+ columnWidth: listProps?.columnWidth,
72
+ columnCount: listProps?.columnCount,
73
+ maxColumnCount: listProps?.columnCount,
74
+ rowGutter: listProps?.rowGutter
75
+ }, [reloadingLayout])
76
+
77
+ const { scrollTop, isScrolling } = useScroller(listProps?.offset, listProps?.scrollFps)
82
78
 
83
79
  const resizeObserver = useResizeObserver(positioner)
84
80
 
85
81
  if (reloadingLayout) {
86
- return (
87
- <EmptyPlaceholder loading={true} />
88
- )
82
+ return <div><p>Loading</p></div>
89
83
  }
90
84
 
91
- return (
92
- <MasonryScroller
93
- // {...props}
94
- positioner={positioner}
95
- resizeObserver={resizeObserver}
96
- containerRef={containerRef}
97
- items={data}
98
- height={listProps?.height}
99
- offset={listProps?.offset}
100
- overscanBy={6}
101
- render={render}
102
- scrollFps={listProps?.scrollFps}
103
- />
104
- )
85
+ return useMasonry({
86
+ ...listProps,
87
+ resizeObserver,
88
+ positioner,
89
+ scrollTop,
90
+ isScrolling,
91
+ items: data,
92
+ })
105
93
  }