@devbonnysid/ui-kit-default 1.5.1 → 1.6.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.
@@ -0,0 +1,28 @@
1
+ import { ReactNode } from 'react';
2
+ import { UsePaginationReturn, UseSortReturn } from './hooks';
3
+ import { RowKeyFn, TableColumnType } from './types';
4
+ export type TableProps<D> = {
5
+ columns: TableColumnType<D>[];
6
+ data?: D[];
7
+ emptyPlug?: ReactNode;
8
+ emptyPlugTitle?: string;
9
+ emptyPlugText?: string;
10
+ loadingPlug?: ReactNode;
11
+ loadingPlugTitle?: string;
12
+ loadingPlugText?: string;
13
+ pagination?: UsePaginationReturn;
14
+ sort?: UseSortReturn<D>;
15
+ isLoading?: boolean;
16
+ isFetching?: boolean;
17
+ sticky?: boolean;
18
+ isEmpty?: boolean;
19
+ withoutWrapper?: boolean;
20
+ onRowClick?: (item: D) => void;
21
+ rowKey: RowKeyFn<D>;
22
+ onReset?: () => void;
23
+ };
24
+ declare const TableComponent: <D>({ columns, emptyPlug, emptyPlugTitle, emptyPlugText, sticky, isEmpty, isFetching, isLoading, loadingPlug, loadingPlugTitle, loadingPlugText, sort, pagination, withoutWrapper, onRowClick, rowKey, data, onReset, }: TableProps<D>) => import("react/jsx-runtime").JSX.Element;
25
+ export declare const Table: typeof TableComponent & {
26
+ displayName: string;
27
+ };
28
+ export {};
@@ -0,0 +1,14 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+ import { ColumnAlignVariants, ColumnFixedVariants } from '../../types';
3
+ export type CellProps = PropsWithChildren<{
4
+ className?: string;
5
+ fixed?: ColumnFixedVariants;
6
+ align?: ColumnAlignVariants;
7
+ paddingLeft?: number;
8
+ left?: number;
9
+ right?: number;
10
+ withBorder?: boolean;
11
+ withShadow?: boolean;
12
+ isHead?: boolean;
13
+ }>;
14
+ export declare const Cell: FC<CellProps>;
@@ -0,0 +1 @@
1
+ export * from './Cell';
@@ -0,0 +1,14 @@
1
+ import { FC, ReactNode } from 'react';
2
+ import { Sort } from '../../types';
3
+ import { CellProps } from '../Cell';
4
+ type Props = Omit<CellProps, 'isHead'> & {
5
+ onClick?: () => void;
6
+ sortable?: boolean;
7
+ isActive?: boolean;
8
+ disabled?: boolean;
9
+ tooltip?: ReactNode;
10
+ withTooltipIcon?: boolean;
11
+ sortDirection?: Sort<string>['order'];
12
+ };
13
+ export declare const HeadCell: FC<Props>;
14
+ export {};
@@ -0,0 +1 @@
1
+ export * from './HeadCell';
@@ -0,0 +1,9 @@
1
+ import { FC } from 'react';
2
+ import { UsePaginationReturn } from '../../hooks';
3
+ type PaginationProps = {
4
+ pagination: UsePaginationReturn;
5
+ sticky?: boolean;
6
+ disabled?: boolean;
7
+ };
8
+ export declare const Pagination: FC<PaginationProps>;
9
+ export {};
@@ -0,0 +1 @@
1
+ export * from './Pagination';
@@ -0,0 +1,26 @@
1
+ import { RowKeyFn, Sort, TableColumnType } from '../../types';
2
+ export declare enum RowVariants {
3
+ HEAD_ROW = "head",
4
+ ROW = "row"
5
+ }
6
+ type Props<D> = {
7
+ columns: TableColumnType<D>[];
8
+ item?: D;
9
+ className?: string;
10
+ variant?: RowVariants;
11
+ sort?: Sort<D>;
12
+ onChangeSort?: (column: TableColumnType<D>) => void;
13
+ level?: number;
14
+ hasItemsWithChildren?: boolean;
15
+ hasScroll?: boolean;
16
+ disabled?: boolean;
17
+ onRowClick?: (item: D) => void;
18
+ rowKey: RowKeyFn<D>;
19
+ parentKey?: string;
20
+ rowIndex?: number;
21
+ };
22
+ declare const RowComponent: <D>({ className, onRowClick, item, hasItemsWithChildren, hasScroll, columns, variant, sort, disabled, onChangeSort, rowKey, level, parentKey, rowIndex, }: Props<D>) => import("react/jsx-runtime").JSX.Element;
23
+ export declare const Row: typeof RowComponent & {
24
+ displayName: string;
25
+ };
26
+ export {};
@@ -0,0 +1 @@
1
+ export * from './Row';
@@ -0,0 +1,4 @@
1
+ export * from './Cell';
2
+ export * from './HeadCell';
3
+ export * from './Row';
4
+ export * from './Pagination';
@@ -0,0 +1,2 @@
1
+ export * from './usePagination';
2
+ export * from './useSort';
@@ -0,0 +1,19 @@
1
+ export type UsePaginationProps = {
2
+ initialPage?: number;
3
+ initialPageSize?: number;
4
+ totalItems: number;
5
+ };
6
+ export declare const usePagination: ({ totalItems, initialPageSize, initialPage, }: UsePaginationProps) => {
7
+ page: number;
8
+ apiPage: number;
9
+ pageSize: number;
10
+ totalItems: number;
11
+ totalPages: number;
12
+ hasPrevious: boolean;
13
+ hasNext: boolean;
14
+ onChangePage: (newPage: number) => void;
15
+ onChangePageSize: (newPageSize: number) => void;
16
+ onNextPage: () => void;
17
+ onPrevPage: () => void;
18
+ };
19
+ export type UsePaginationReturn = ReturnType<typeof usePagination>;
@@ -0,0 +1,9 @@
1
+ import { Sort } from '../types';
2
+ export type UseSortProps<D = string> = {
3
+ initialSort?: Sort<D>;
4
+ };
5
+ export type UseSortReturn<D> = {
6
+ value?: Sort<D>;
7
+ onChange: (column: string) => void;
8
+ };
9
+ export declare const useSort: <D>({ initialSort }: UseSortProps<D>) => UseSortReturn<D>;
@@ -0,0 +1,4 @@
1
+ export * from './Table';
2
+ export * from './components';
3
+ export * from './types';
4
+ export * from './hooks';
@@ -0,0 +1,48 @@
1
+ import { ReactNode } from 'react';
2
+ export declare enum ColumnFixedVariants {
3
+ LEFT = "left",
4
+ RIGHT = "right"
5
+ }
6
+ export declare enum ColumnAlignVariants {
7
+ LEFT = "left",
8
+ CENTER = "center",
9
+ RIGHT = "right"
10
+ }
11
+ export declare enum SortDirectionsVariants {
12
+ ASC = "asc",
13
+ DESC = "desc"
14
+ }
15
+ export type Sort<D = string> = {
16
+ column: keyof D;
17
+ order: SortDirectionsVariants;
18
+ };
19
+ export type ColumnWidthType = string | number | undefined;
20
+ export type ColumnClassname<D> = string | ((record: D) => string);
21
+ export type DefaultColumnType<D> = {
22
+ title?: ReactNode;
23
+ sortable?: boolean;
24
+ fixed?: ColumnFixedVariants;
25
+ align?: ColumnAlignVariants;
26
+ width?: ColumnWidthType;
27
+ maxWidth?: ColumnWidthType;
28
+ minWidth?: ColumnWidthType;
29
+ tooltip?: ReactNode;
30
+ withTooltipIcon?: boolean;
31
+ className?: ColumnClassname<D>;
32
+ };
33
+ export type KnownColumnType<D, K extends keyof D = keyof D> = DefaultColumnType<D> & {
34
+ key: K;
35
+ render?: (value: D[K], record: D, index: number) => ReactNode;
36
+ };
37
+ export type CustomColumnType<D> = DefaultColumnType<D> & {
38
+ key: `custom-column-${string}`;
39
+ render?: (value: undefined, record: D, index: number) => ReactNode;
40
+ };
41
+ export type TableColumnKey<D> = KnownColumnType<D>['key'] | CustomColumnType<D>['key'];
42
+ export type TableColumnType<D> = {
43
+ [K in keyof D]: KnownColumnType<D, K>;
44
+ }[keyof D] | CustomColumnType<D>;
45
+ export type RowKeyFn<D> = (item: D) => string;
46
+ export type TableDataItem<D> = D & {
47
+ children?: D[];
48
+ };
@@ -0,0 +1,2 @@
1
+ import { ColumnWidthType } from '../types';
2
+ export declare const formatWidth: (width: ColumnWidthType) => string | undefined;
@@ -0,0 +1 @@
1
+ export * from './formatWidth';
@@ -13,6 +13,7 @@ export * from './Popover';
13
13
  export * from './Portal';
14
14
  export * from './Select';
15
15
  export * from './Tab';
16
+ export * from './Table';
16
17
  export * from './Textarea';
17
18
  export * from './TextShorter';
18
19
  export * from './Tooltip';
@@ -7,6 +7,13 @@ export declare const uiKitResources: {
7
7
  resetAll: string;
8
8
  search: string;
9
9
  selectAll: string;
10
+ NoData: string;
11
+ LoadingData: string;
12
+ pagination: {
13
+ itemsOnPage: string;
14
+ ofPages: string;
15
+ currentItems: string;
16
+ };
10
17
  };
11
18
  };
12
19
  readonly ru: {
@@ -15,6 +22,13 @@ export declare const uiKitResources: {
15
22
  resetAll: string;
16
23
  search: string;
17
24
  selectAll: string;
25
+ NoDate: string;
26
+ LoadingData: string;
27
+ pagination: {
28
+ itemsOnPage: string;
29
+ ofPages: string;
30
+ currentItems: string;
31
+ };
18
32
  };
19
33
  };
20
34
  };