@datacrest/dcuikit 0.1.6 → 1.0.1

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.
@@ -1,2 +1,3 @@
1
1
  import Dropdown from './Dropdown';
2
2
  export { Dropdown };
3
+ export * from './types';
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { MessageProps } from './Message.types';
3
- declare const MessageComponent: ({ id, destroy, title, description, variant, duration, animationDuration, icon, dataTestId, }: MessageProps) => React.JSX.Element;
3
+ declare const MessageComponent: ({ id, destroy, title, description, variant, position, duration, animationDuration, icon, dataTestId, }: MessageProps) => React.JSX.Element;
4
4
  export default MessageComponent;
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { MessageProps, MessageVariants, MessagePosition } from './Message.types';
3
3
  declare const _default: {
4
4
  title: string;
5
- component: ({ id, destroy, title, description, variant, duration, animationDuration, icon, dataTestId, }: MessageProps) => React.JSX.Element;
5
+ component: ({ id, destroy, title, description, variant, position, duration, animationDuration, icon, dataTestId, }: MessageProps) => React.JSX.Element;
6
6
  argTypes: {
7
7
  variant: {
8
8
  control: "select";
@@ -1,4 +1,6 @@
1
- import { MessagePosition, MessageProps, MessageVariants } from './Message.types';
1
+ import MessageComponent from './Message';
2
+ import { MessageProps } from './Message.types';
2
3
  import { message, MessageOptions } from './MessageManager';
3
- export { message, MessageVariants, MessagePosition };
4
+ export * from './Message.types';
4
5
  export type { MessageProps, MessageOptions };
6
+ export { MessageComponent, message };
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import { JSX } from 'react';
2
2
  import { TableProps } from './Table.types';
3
- declare const Table: React.FC<TableProps>;
3
+ declare const Table: <T extends Record<string, unknown>>({ columns, data, sortable, pagination, searchable, currentPage, pageSize, onSort, onPageChange, actions, showCustomCells, useBuiltInStatus, swapPaginationLayout, selectable, onSelectionChange, }: TableProps<T>) => JSX.Element;
4
4
  export default Table;
@@ -1,5 +1,19 @@
1
- import { StoryFn, Meta } from '@storybook/react';
2
- import { TableProps } from './Table.types';
1
+ import { Meta } from '@storybook/react';
2
+ import { PAGE_SIZES } from './const';
3
3
  declare const _default: Meta;
4
4
  export default _default;
5
- export declare const Table: StoryFn<TableProps>;
5
+ interface TableStoryProps {
6
+ sortable: boolean;
7
+ pagination: boolean;
8
+ searchable: boolean;
9
+ currentPage: number;
10
+ pageSize: (typeof PAGE_SIZES)[number];
11
+ showCustomCells: boolean;
12
+ showActions: boolean;
13
+ useBuiltInStatus: boolean;
14
+ swapPaginationLayout: boolean;
15
+ selectable: boolean;
16
+ enableTextTruncation: boolean;
17
+ maxWords: number;
18
+ }
19
+ export declare const Table: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, TableStoryProps>;
@@ -1,19 +1,52 @@
1
+ import { FilterFn } from '@tanstack/react-table';
2
+ import { ReactNode } from 'react';
1
3
  export declare enum TableColumnAlign {
2
4
  Left = "left",
3
5
  Center = "center",
4
6
  Right = "right"
5
7
  }
6
- export interface TableColumn {
8
+ export declare enum PaginationPosition {
9
+ Left = "left",
10
+ Right = "right",
11
+ Center = "center"
12
+ }
13
+ export type PageSizeOptions = 5 | 10 | 20 | 50;
14
+ export declare enum CellType {
15
+ Text = "text",
16
+ Date = "date",
17
+ Status = "status",
18
+ Custom = "custom"
19
+ }
20
+ export interface DateFormat {
21
+ input?: string;
22
+ output: string;
23
+ }
24
+ export interface TruncationOptions {
25
+ enableTruncation?: boolean;
26
+ maxWords?: number;
27
+ }
28
+ export interface TableColumn<T extends Record<string, unknown>> {
7
29
  key: string;
8
30
  title: string;
9
31
  width?: string;
10
32
  sortable?: boolean;
11
33
  align?: TableColumnAlign;
34
+ type?: CellType | string;
35
+ dateFormat?: DateFormat;
36
+ filterFn?: FilterFn<T>;
37
+ customCell?: (value: unknown, row: T) => ReactNode;
38
+ customHeader?: (column: ColumnInfo<T>) => ReactNode;
39
+ maxWords?: number;
12
40
  }
13
- export type PageSizeOptions = 5 | 10 | 20 | 50;
14
- export interface TableProps {
15
- columns: TableColumn[];
16
- data: Record<string, any>[];
41
+ export interface ColumnInfo<T> {
42
+ toggleSorting: (desc?: boolean) => void;
43
+ getIsSorted: () => false | 'asc' | 'desc';
44
+ key: string;
45
+ data: T[];
46
+ }
47
+ export interface TableProps<T extends Record<string, unknown>> {
48
+ columns: TableColumn<T>[];
49
+ data: T[];
17
50
  sortable?: boolean;
18
51
  pagination?: boolean;
19
52
  searchable?: boolean;
@@ -21,4 +54,10 @@ export interface TableProps {
21
54
  pageSize?: PageSizeOptions;
22
55
  onSort?: (key: string, direction: 'asc' | 'desc') => void;
23
56
  onPageChange?: (page: number) => void;
57
+ actions?: (row: T) => ReactNode;
58
+ showCustomCells?: boolean;
59
+ useBuiltInStatus?: boolean;
60
+ swapPaginationLayout?: boolean;
61
+ selectable?: boolean;
62
+ onSelectionChange?: (selectedRows: T[]) => void;
24
63
  }
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { TableColumn } from './Table.types';
3
+ declare const TableCell: <T extends Record<string, unknown>>(column: TableColumn<T>, row: T, showCustomCells: boolean, useBuiltInStatus: boolean) => React.JSX.Element;
4
+ export default TableCell;
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ import { TableColumn as TableColumnType, TableColumnAlign, TruncationOptions } from './Table.types';
3
+ import { PersonData } from './const';
4
+ export declare const createTextColumn: <T extends Record<string, unknown>>(key: string, title: string, options?: {
5
+ width?: string;
6
+ sortable?: boolean;
7
+ align?: TableColumnAlign;
8
+ customCell?: (value: unknown, row: T) => React.ReactNode;
9
+ maxWords?: number;
10
+ }) => TableColumnType<T>;
11
+ export declare const createDateColumn: <T extends Record<string, unknown>>(key: string, title: string, options?: {
12
+ width?: string;
13
+ sortable?: boolean;
14
+ align?: TableColumnAlign;
15
+ inputFormat?: string;
16
+ outputFormat?: string;
17
+ customCell?: (value: unknown, row: T) => React.ReactNode;
18
+ }) => TableColumnType<T>;
19
+ export declare const createStatusColumn: <T extends Record<string, unknown>>(key: string, title: string, options?: {
20
+ width?: string;
21
+ sortable?: boolean;
22
+ align?: TableColumnAlign;
23
+ customCell?: (value: unknown, row: T) => React.ReactNode;
24
+ }) => TableColumnType<T>;
25
+ export declare const createPersonDataColumns: (showCustomCells: boolean, truncationOptions?: TruncationOptions) => TableColumnType<PersonData>[];
26
+ declare const TableColumn: {
27
+ createTextColumn: <T extends Record<string, unknown>>(key: string, title: string, options?: {
28
+ width?: string;
29
+ sortable?: boolean;
30
+ align?: TableColumnAlign;
31
+ customCell?: (value: unknown, row: T) => React.ReactNode;
32
+ maxWords?: number;
33
+ }) => TableColumnType<T>;
34
+ createDateColumn: <T extends Record<string, unknown>>(key: string, title: string, options?: {
35
+ width?: string;
36
+ sortable?: boolean;
37
+ align?: TableColumnAlign;
38
+ inputFormat?: string;
39
+ outputFormat?: string;
40
+ customCell?: (value: unknown, row: T) => React.ReactNode;
41
+ }) => TableColumnType<T>;
42
+ createStatusColumn: <T extends Record<string, unknown>>(key: string, title: string, options?: {
43
+ width?: string;
44
+ sortable?: boolean;
45
+ align?: TableColumnAlign;
46
+ customCell?: (value: unknown, row: T) => React.ReactNode;
47
+ }) => TableColumnType<T>;
48
+ createPersonDataColumns: (showCustomCells: boolean, truncationOptions?: TruncationOptions) => TableColumnType<PersonData>[];
49
+ };
50
+ export default TableColumn;
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import { TableColumn, ColumnInfo } from './Table.types';
3
+ export declare const renderSortIcon: <T extends Record<string, unknown>>(column: TableColumn<T>, sortConfig: {
4
+ key: string;
5
+ direction: "asc" | "desc";
6
+ } | null) => React.JSX.Element;
7
+ export declare const renderHeader: <T extends Record<string, unknown>>(column: TableColumn<T>, columnInfoFn: (key: string) => ColumnInfo<T>, handleSort: (column: TableColumn<T>) => void, sortable: boolean, sortConfig: {
8
+ key: string;
9
+ direction: "asc" | "desc";
10
+ } | null) => string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
11
+ export declare const renderTableHeader: <T extends Record<string, unknown>>(column: TableColumn<T>, getColumnInfo: (key: string) => ColumnInfo<T>, handleSort: (column: TableColumn<T>) => void, sortable: boolean, sortConfig: {
12
+ key: string;
13
+ direction: "asc" | "desc";
14
+ } | null) => string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
15
+ declare const TableHeader: {
16
+ renderSortIcon: <T extends Record<string, unknown>>(column: TableColumn<T>, sortConfig: {
17
+ key: string;
18
+ direction: "asc" | "desc";
19
+ } | null) => React.JSX.Element;
20
+ renderHeader: <T extends Record<string, unknown>>(column: TableColumn<T>, columnInfoFn: (key: string) => ColumnInfo<T>, handleSort: (column: TableColumn<T>) => void, sortable: boolean, sortConfig: {
21
+ key: string;
22
+ direction: "asc" | "desc";
23
+ } | null) => string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
24
+ renderTableHeader: <T extends Record<string, unknown>>(column: TableColumn<T>, getColumnInfo: (key: string) => ColumnInfo<T>, handleSort: (column: TableColumn<T>) => void, sortable: boolean, sortConfig: {
25
+ key: string;
26
+ direction: "asc" | "desc";
27
+ } | null) => string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
28
+ };
29
+ export default TableHeader;
@@ -0,0 +1,18 @@
1
+ export interface PersonData extends Record<string, unknown> {
2
+ name?: string;
3
+ email?: string;
4
+ joinDate?: string;
5
+ status?: string;
6
+ description?: string;
7
+ }
8
+ export declare const SAMPLE_DATA: PersonData[];
9
+ export declare const PAGE_SIZES: readonly [5, 10, 20, 50];
10
+ export declare const STATUS_COLOR_MAP: Record<string, string>;
11
+ export declare const DEFAULT_COLUMN_CONFIG: {
12
+ NAME_KEY: string;
13
+ NAME_WIDTH: string;
14
+ EMAIL_KEY: string;
15
+ JOIN_DATE_KEY: string;
16
+ STATUS_KEY: string;
17
+ DESCRIPTION_KEY: string;
18
+ };
@@ -1,3 +1,7 @@
1
1
  import Table from './Table';
2
- export { Table };
3
- export type { TableProps, TableColumn, TableColumnAlign } from './Table.types';
2
+ import TableCell from './TableCell';
3
+ import TableHeader, { renderSortIcon, renderHeader, renderTableHeader } from './TableHeader';
4
+ export { Table, TableCell, TableHeader, renderSortIcon, renderHeader, renderTableHeader, };
5
+ export * from './Table.types';
6
+ export * from './TableColumn';
7
+ export * from './utils';
@@ -0,0 +1,24 @@
1
+ import { TableColumn, TableColumnAlign, ColumnInfo, PaginationPosition } from './Table.types';
2
+ import React from 'react';
3
+ export declare const getFlexAlignment: (align?: TableColumnAlign) => string;
4
+ export declare const columnInfo: <T extends Record<string, unknown>>(key: string, columns: TableColumn<T>[], onSort: ((key: string, direction: "asc" | "desc") => void) | undefined, paginatedData: T[], sortConfig: {
5
+ key: string;
6
+ direction: "asc" | "desc";
7
+ } | null, setSortConfig: React.Dispatch<React.SetStateAction<{
8
+ key: string;
9
+ direction: "asc" | "desc";
10
+ } | null>>) => ColumnInfo<T>;
11
+ export declare const getColumnInfo: <T extends Record<string, unknown>>(key: string, columns: TableColumn<T>[], onSort: ((key: string, direction: "asc" | "desc") => void) | undefined, paginatedData: T[], sortConfig: {
12
+ key: string;
13
+ direction: "asc" | "desc";
14
+ } | null, setSortConfig: React.Dispatch<React.SetStateAction<{
15
+ key: string;
16
+ direction: "asc" | "desc";
17
+ } | null>>) => ColumnInfo<T>;
18
+ export declare const getShowingEntriesPositionClass: (showingEntriesPosition: PaginationPosition) => "ml-auto order-2" | "mx-auto" | "order-1";
19
+ export declare const getPaginationContainerClass: (paginationPosition: PaginationPosition) => "ml-auto order-2" | "mx-auto" | "order-1";
20
+ export declare const getEffectivePositions: (swapPaginationLayout?: boolean) => {
21
+ effectivePaginationPosition: PaginationPosition;
22
+ effectiveEntriesPosition: PaginationPosition;
23
+ };
24
+ export declare const truncateText: (text: string, maxWords?: number) => string;
@@ -0,0 +1,7 @@
1
+ import { FC } from 'react';
2
+ interface Props {
3
+ text: string;
4
+ className?: string;
5
+ }
6
+ declare const TruncatedText: FC<Props>;
7
+ export default TruncatedText;
@@ -0,0 +1,5 @@
1
+ declare const useTruncatedText: () => {
2
+ textRef: import("react").RefObject<HTMLSpanElement | null>;
3
+ isTruncated: boolean;
4
+ };
5
+ export default useTruncatedText;