@up42/up-components 3.0.3 → 3.1.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.
@@ -54,5 +54,6 @@ export { formatDate } from './utils/helpers/formatDate';
54
54
  export { formatFileSize } from './utils/helpers/formatFileSize';
55
55
  export { useQueryParams } from './utils/hooks/useQueryParams';
56
56
  export { useRemotePagination, type PaginatedResponse } from './utils/hooks/useRemotePagination';
57
+ export { useCursorPagination, type CursorPaginatedResponse } from './utils/hooks/useCursorPagination';
57
58
  export { useDebounce } from './utils/hooks/useDebounce';
58
59
  export { useAlert, type CreateAlertProps, type CreateSnackbarProps, } from './global/providers/AlertProvider/AlertProvider';
@@ -0,0 +1,34 @@
1
+ export interface CursorPaginatedResponse<T> {
2
+ content: T[];
3
+ nextCursor: number | null;
4
+ prevCursor: number | null;
5
+ }
6
+ type UseCursorPaginationResponse = {
7
+ pageSize: number;
8
+ page: number;
9
+ data: any[];
10
+ isLoading: boolean;
11
+ refetch: () => Promise<any>;
12
+ isRefetching: boolean;
13
+ setPage: (page: number) => void;
14
+ setPageSize: (pageSize: number) => void;
15
+ handlePageChange: (page: number, pageSize: number) => void;
16
+ cursor: number;
17
+ setCursor: (cursor: number) => void;
18
+ };
19
+ /**
20
+ * Returns cursor-based pagination data and and helper functions.
21
+ *
22
+ * Documentation: https://up-components.up42.com/?path=/docs/utils--docs#usecursorpagination
23
+ */
24
+ export declare const useCursorPagination: (fetchingHook: ({ params }: {
25
+ params: string;
26
+ }) => {
27
+ data: CursorPaginatedResponse<any> | undefined;
28
+ isLoading: boolean;
29
+ refetch: () => Promise<any>;
30
+ isRefetching: boolean;
31
+ }, searchParams?: {
32
+ [paramName: string]: string;
33
+ } | undefined) => UseCursorPaginationResponse;
34
+ export {};
package/dist/index.d.ts CHANGED
@@ -5023,6 +5023,40 @@ declare const useRemotePagination: (fetchingHook: ({ params }: {
5023
5023
  [paramName: string]: string;
5024
5024
  } | undefined) => UseRemotePaginationResponse;
5025
5025
 
5026
+ interface CursorPaginatedResponse<T> {
5027
+ content: T[];
5028
+ nextCursor: number | null;
5029
+ prevCursor: number | null;
5030
+ }
5031
+ type UseCursorPaginationResponse = {
5032
+ pageSize: number;
5033
+ page: number;
5034
+ data: any[];
5035
+ isLoading: boolean;
5036
+ refetch: () => Promise<any>;
5037
+ isRefetching: boolean;
5038
+ setPage: (page: number) => void;
5039
+ setPageSize: (pageSize: number) => void;
5040
+ handlePageChange: (page: number, pageSize: number) => void;
5041
+ cursor: number;
5042
+ setCursor: (cursor: number) => void;
5043
+ };
5044
+ /**
5045
+ * Returns cursor-based pagination data and and helper functions.
5046
+ *
5047
+ * Documentation: https://up-components.up42.com/?path=/docs/utils--docs#usecursorpagination
5048
+ */
5049
+ declare const useCursorPagination: (fetchingHook: ({ params }: {
5050
+ params: string;
5051
+ }) => {
5052
+ data: CursorPaginatedResponse<any> | undefined;
5053
+ isLoading: boolean;
5054
+ refetch: () => Promise<any>;
5055
+ isRefetching: boolean;
5056
+ }, searchParams?: {
5057
+ [paramName: string]: string;
5058
+ } | undefined) => UseCursorPaginationResponse;
5059
+
5026
5060
  /**
5027
5061
  * useDebounce is a generic React Hook that returns a debounced version of a given value.
5028
5062
  * @param {T} value - The value to debounce.
@@ -5084,4 +5118,4 @@ type ContextState = {
5084
5118
  */
5085
5119
  declare const useAlert: () => ContextState;
5086
5120
 
5087
- export { Alert, type AlertProps, Avatar, type AvatarProps, Badge, type BadgeProps, Banner, type BannerProps, Button, type ButtonProps, Checkbox, type CheckboxProps, CodeInline, type CodeInlineProps, CodeSnippet, type CodeSnippetItemProps, type CodeSnippetProps, ContactBox, type ContactBoxProps, ControlButton, type ControlButtonProps, CopyButton, type CopyButtonProps, type CreateAlertProps, type CreateSnackbarProps, DataGrid, type DataGridProps, type DatePickerDateType, DateTime, type DateTimeProps, Divider, type DividerProps, DocumentationPopover, type DocumentationPopoverProps, EmptyState, type EmptyStateProps, FormCheckbox, type FormCheckboxProps, FormDatePicker, type FormDatePickerProps, FormDateRangePicker, type FormDateRangePickerProps, FormInput, type FormInputProps, FormRadio, type FormRadioProps, FormSelect, type FormSelectProps, FormSwitch, type FormSwitchProps, GridContainer, type GridContainerProps, GridItem, type GridItemProps, Icon, type IconProps, Illustration, type IllustrationProps, InfoCard, type InfoCardProps, InfoModal, type InfoModalProps, InfoPopover, type InfoPopoverProps, Input, type InputProps, Link, type LinkProps, Loading, type LoadingProps, NotFound, type NotFoundProps, PageContainer, type PageContainerProps, PageHeader, type PageHeaderProps, type PaginatedResponse, Radio, type RadioProps, Select, type SelectProps, Slider, type SliderProps, Switch, type SwitchProps, Tab, TabGroup, type TabGroupProps, type TabProps, Table, TableBody, type TableBodyProps, TableCell, type TableCellProps, TableContainer, type TableContainerProps, TableFooter, type TableFooterProps, TableHead, type TableHeadProps, TablePagination, type TablePaginationProps, type TableProps, TableRow, type TableRowProps, TableSortLabel, type TableSortLabelProps, Tabs, type TabsProps, Tag, type TagProps, Typography, type TypographyProps, UpComponentsProvider, capitalize, copyToClipboard, formatDate, formatFileSize, formatNumber, theme, useAlert, useDebounce, useQueryParams, useRemotePagination };
5121
+ export { Alert, type AlertProps, Avatar, type AvatarProps, Badge, type BadgeProps, Banner, type BannerProps, Button, type ButtonProps, Checkbox, type CheckboxProps, CodeInline, type CodeInlineProps, CodeSnippet, type CodeSnippetItemProps, type CodeSnippetProps, ContactBox, type ContactBoxProps, ControlButton, type ControlButtonProps, CopyButton, type CopyButtonProps, type CreateAlertProps, type CreateSnackbarProps, type CursorPaginatedResponse, DataGrid, type DataGridProps, type DatePickerDateType, DateTime, type DateTimeProps, Divider, type DividerProps, DocumentationPopover, type DocumentationPopoverProps, EmptyState, type EmptyStateProps, FormCheckbox, type FormCheckboxProps, FormDatePicker, type FormDatePickerProps, FormDateRangePicker, type FormDateRangePickerProps, FormInput, type FormInputProps, FormRadio, type FormRadioProps, FormSelect, type FormSelectProps, FormSwitch, type FormSwitchProps, GridContainer, type GridContainerProps, GridItem, type GridItemProps, Icon, type IconProps, Illustration, type IllustrationProps, InfoCard, type InfoCardProps, InfoModal, type InfoModalProps, InfoPopover, type InfoPopoverProps, Input, type InputProps, Link, type LinkProps, Loading, type LoadingProps, NotFound, type NotFoundProps, PageContainer, type PageContainerProps, PageHeader, type PageHeaderProps, type PaginatedResponse, Radio, type RadioProps, Select, type SelectProps, Slider, type SliderProps, Switch, type SwitchProps, Tab, TabGroup, type TabGroupProps, type TabProps, Table, TableBody, type TableBodyProps, TableCell, type TableCellProps, TableContainer, type TableContainerProps, TableFooter, type TableFooterProps, TableHead, type TableHeadProps, TablePagination, type TablePaginationProps, type TableProps, TableRow, type TableRowProps, TableSortLabel, type TableSortLabelProps, Tabs, type TabsProps, Tag, type TagProps, Typography, type TypographyProps, UpComponentsProvider, capitalize, copyToClipboard, formatDate, formatFileSize, formatNumber, theme, useAlert, useCursorPagination, useDebounce, useQueryParams, useRemotePagination };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@up42/up-components",
3
- "version": "3.0.3",
3
+ "version": "3.1.0",
4
4
  "description": "UP42 Component Library",
5
5
  "author": "Axel Fuhrmann axel.fuhrmann@up42.com",
6
6
  "license": "ISC",