@nextelco/common-ui 1.7.51 → 1.7.52

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.
@@ -0,0 +1,18 @@
1
+ import React, { ReactNode } from 'react';
2
+ interface LazyLoaderProps<T> {
3
+ endpoint: string;
4
+ params?: Record<string, unknown>;
5
+ children: (items: T[], loading: boolean, error: ReactNode | null) => ReactNode;
6
+ scrollableTarget?: string;
7
+ className?: string;
8
+ style?: React.CSSProperties;
9
+ height?: number | string;
10
+ scrollThreshold?: number | string;
11
+ pageSize?: number;
12
+ initialPage?: number;
13
+ responseType?: 'blob';
14
+ }
15
+ export declare const LazyLoader: <T extends {
16
+ id: string | number;
17
+ }>({ endpoint, params, children, scrollableTarget, className, style, height, scrollThreshold, pageSize, initialPage, responseType, }: LazyLoaderProps<T>) => React.JSX.Element;
18
+ export {};
@@ -6,5 +6,5 @@ type Props = {
6
6
  handleLogout: () => void;
7
7
  notifications?: ReactNode;
8
8
  };
9
- declare const Profile: ({ user, handleLogout, notifications }: Props) => React.JSX.Element;
10
- export default Profile;
9
+ export declare const Profile: ({ user, handleLogout, notifications }: Props) => React.JSX.Element;
10
+ export {};
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ type Props = {};
3
+ declare const Selector: (props: Props) => React.JSX.Element;
4
+ export default Selector;
@@ -1 +1,2 @@
1
- export { default as Profile } from '../components/organisms/Profile/Profile';
1
+ export { Profile } from '../components/organisms/Profile/Profile';
2
+ export { LazyLoader } from '../components/organisms/LazyLoader/LazyLoader';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextelco/common-ui",
3
- "version": "1.7.51",
3
+ "version": "1.7.52",
4
4
  "description": "",
5
5
  "main": "dist/bundle.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -1,77 +0,0 @@
1
- /**
2
- import React, { useEffect } from 'react'
3
- import InfiniteScroll from 'react-infinite-scroll-component'
4
- import { useApi } from '../../../hooks/useApi'
5
-
6
- interface LazyLoadListProps {
7
- items: any[]
8
- setItems: (items: any[]) => void
9
- page: number
10
- limit: number
11
- setPage: (page: number) => void
12
- hasMore: boolean
13
- setHasMore: (hasMore: boolean) => void
14
- filters: { [key: string]: string }
15
- }
16
-
17
- const LazyLoadList: React.FC<LazyLoadListProps> = ({
18
- items,
19
- setItems,
20
- page,
21
- limit,
22
- setPage,
23
- hasMore,
24
- setHasMore,
25
- filters,
26
- }) => {
27
- const { request, errors, loading } = useApi()
28
-
29
- const fetchData = async (pageNum: number) => {
30
- const response = await request({
31
- method: 'get',
32
- url: `/api/items`,
33
- params: { page: pageNum, limit, ...filters },
34
- })
35
-
36
- if (response) {
37
- if (response.length === 0) {
38
- setHasMore(false)
39
- return
40
- }
41
- setItems([...items, ...response])
42
- }
43
- }
44
-
45
- useEffect(() => {
46
- fetchData(page)
47
- }, [page, filters])
48
-
49
- const loadMore = () => {
50
- setPage(page + 1)
51
- }
52
-
53
- return (
54
- <div>
55
- {errors && errors}
56
- <InfiniteScroll
57
- dataLength={items.length}
58
- next={loadMore}
59
- hasMore={hasMore}
60
- loader={<h4>Loading...</h4>}
61
- endMessage={<p>No more items to load</p>}
62
- >
63
- {items.map((item, index) => (
64
- <div
65
- key={index}
66
- style={{ padding: '20px', borderBottom: '1px solid #ccc' }}
67
- >
68
- {item.name || `Item ${index}`}{' '}
69
- </div>
70
- ))}
71
- </InfiniteScroll>
72
- </div>
73
- )
74
- }
75
-
76
- export default LazyLoadList
77
- */