@livechat/design-system-react-components 2.10.0 → 2.11.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.
- package/dist/components/Avatar/Avatar.d.ts +4 -0
- package/dist/components/SelectableCard/SelectableCard.d.ts +4 -0
- package/dist/components/SelectableCard/components/GallerySelectableCard/GallerySelectableCard.components.d.ts +12 -0
- package/dist/components/SelectableCard/components/GallerySelectableCard/GallerySelectableCard.d.ts +4 -0
- package/dist/components/SelectableCard/components/GallerySelectableCard/types.d.ts +30 -0
- package/dist/components/SelectableCard/components/InteractiveSelectableCard/InteractiveGrid/InteractiveGrid.d.ts +9 -0
- package/dist/components/SelectableCard/components/InteractiveSelectableCard/InteractiveGrid/index.d.ts +1 -0
- package/dist/components/SelectableCard/components/InteractiveSelectableCard/InteractiveSelectableCard.components.d.ts +10 -0
- package/dist/components/SelectableCard/components/InteractiveSelectableCard/InteractiveSelectableCard.d.ts +4 -0
- package/dist/components/SelectableCard/components/InteractiveSelectableCard/types.d.ts +4 -0
- package/dist/components/SelectableCard/components/ThumbnailSelectableCard/ThumbnailSelectableCard.components.d.ts +14 -0
- package/dist/components/SelectableCard/components/ThumbnailSelectableCard/ThumbnailSelectableCard.d.ts +4 -0
- package/dist/components/SelectableCard/components/ThumbnailSelectableCard/types.d.ts +20 -0
- package/dist/components/SelectableCard/components/index.d.ts +4 -0
- package/dist/components/SelectableCard/index.d.ts +2 -0
- package/dist/components/SelectableCard/types.d.ts +26 -0
- package/dist/components/Table/Table.d.ts +3 -0
- package/dist/components/Table/TableBody.d.ts +13 -0
- package/dist/components/Table/TableHeader.d.ts +18 -0
- package/dist/components/Table/TableRow.d.ts +13 -0
- package/dist/components/Table/hooks.d.ts +14 -0
- package/dist/components/Table/index.d.ts +3 -0
- package/dist/components/Table/stories-constants.d.ts +4 -0
- package/dist/components/Table/stories-helpers.d.ts +3 -0
- package/dist/components/Table/types.d.ts +102 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/types.d.ts +7 -0
- package/dist/hooks/useInteractive.d.ts +3 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3755 -3253
- package/dist/style.css +1 -1
- package/dist/utils/types.d.ts +6 -2
- package/package.json +2 -2
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface IRadioCardsProps {
|
|
3
|
+
withIcon: boolean;
|
|
4
|
+
withCustomElement: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const RadioCards: React.FC<IRadioCardsProps>;
|
|
7
|
+
interface ICheckboxCardsProps {
|
|
8
|
+
withIcon: boolean;
|
|
9
|
+
withCustomElement: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const CheckboxCards: React.FC<ICheckboxCardsProps>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ISelectableCardCoreProps } from '../../types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
type BaseProps = {
|
|
4
|
+
/**
|
|
5
|
+
* The label of the card
|
|
6
|
+
*/
|
|
7
|
+
label?: string;
|
|
8
|
+
};
|
|
9
|
+
type WithIcon = BaseProps & {
|
|
10
|
+
/**
|
|
11
|
+
* The icon of the card
|
|
12
|
+
*/
|
|
13
|
+
icon: React.ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* The custom element of the card
|
|
16
|
+
*/
|
|
17
|
+
customElement?: never;
|
|
18
|
+
};
|
|
19
|
+
type WithCustomElement = BaseProps & {
|
|
20
|
+
/**
|
|
21
|
+
* The icon of the card
|
|
22
|
+
*/
|
|
23
|
+
icon?: never;
|
|
24
|
+
/**
|
|
25
|
+
* The custom element of the card
|
|
26
|
+
*/
|
|
27
|
+
customElement: React.ReactNode;
|
|
28
|
+
};
|
|
29
|
+
export type IGallerySelectableCardProps = (WithIcon | WithCustomElement) & Omit<ISelectableCardCoreProps, 'children'>;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ComponentCoreProps } from '../../../../../utils/types';
|
|
3
|
+
|
|
4
|
+
interface IGridComponentProps extends ComponentCoreProps {
|
|
5
|
+
}
|
|
6
|
+
export declare const GridWrapper: FC<IGridComponentProps>;
|
|
7
|
+
export declare const GridRow: FC<IGridComponentProps>;
|
|
8
|
+
export declare const GridCol: FC<IGridComponentProps>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { GridCol, GridRow, GridWrapper } from './InteractiveGrid';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface IRadioCardsProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
}
|
|
5
|
+
export declare const RadioCards: React.FC<IRadioCardsProps>;
|
|
6
|
+
interface ICheckboxCardsProps {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare const CheckboxCards: React.FC<ICheckboxCardsProps>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface IRadioCardsProps {
|
|
3
|
+
withDescription?: boolean;
|
|
4
|
+
withIcon?: boolean;
|
|
5
|
+
withCustomElement?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const RadioCards: React.FC<IRadioCardsProps>;
|
|
8
|
+
interface ICheckboxCardsProps {
|
|
9
|
+
withDescription?: boolean;
|
|
10
|
+
withIcon?: boolean;
|
|
11
|
+
withCustomElement?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare const CheckboxCards: React.FC<ICheckboxCardsProps>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ISelectableCardCoreProps } from '../../types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export interface IThumbnailSelectableCardProps extends Omit<ISelectableCardCoreProps, 'children'> {
|
|
4
|
+
/**
|
|
5
|
+
* The label of the card
|
|
6
|
+
*/
|
|
7
|
+
label: string;
|
|
8
|
+
/**
|
|
9
|
+
* The description of the card
|
|
10
|
+
*/
|
|
11
|
+
description?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The icon of the card
|
|
14
|
+
*/
|
|
15
|
+
icon?: React.ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* The custom element of the card
|
|
18
|
+
*/
|
|
19
|
+
customElement?: React.ReactNode;
|
|
20
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { ThumbnailSelectableCard } from './ThumbnailSelectableCard/ThumbnailSelectableCard';
|
|
2
|
+
export { GallerySelectableCard } from './GallerySelectableCard/GallerySelectableCard';
|
|
3
|
+
export { InteractiveSelectableCard } from './InteractiveSelectableCard/InteractiveSelectableCard';
|
|
4
|
+
export { GridWrapper, GridCol, GridRow, } from './InteractiveSelectableCard/InteractiveGrid';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ComponentCoreProps } from '../../utils/types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export interface ISelectableCardCoreProps extends ComponentCoreProps {
|
|
4
|
+
/**
|
|
5
|
+
* The CSS class name for card content
|
|
6
|
+
*/
|
|
7
|
+
contentClassName?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Set the selection type of the card
|
|
10
|
+
*/
|
|
11
|
+
selectionType: 'radio' | 'checkbox';
|
|
12
|
+
/**
|
|
13
|
+
* Set the card selection state
|
|
14
|
+
*/
|
|
15
|
+
isSelected?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Set the card onClick handler
|
|
18
|
+
*/
|
|
19
|
+
onClick: (e?: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
20
|
+
}
|
|
21
|
+
export interface ISelectableCardProps extends ISelectableCardCoreProps {
|
|
22
|
+
/**
|
|
23
|
+
* Set the card type
|
|
24
|
+
*/
|
|
25
|
+
kind?: 'thumbnail' | 'gallery' | 'interactive';
|
|
26
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ITableProps } from './types';
|
|
2
|
+
|
|
3
|
+
export declare const Table: <T>({ data, columns, stripped, size, pin, selectable, getRowId, resizable, selectedRows, onSelectionChange, rowSelectionMessage, rowActions, testId, }: ITableProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Column } from './types';
|
|
2
|
+
|
|
3
|
+
interface TableBodyProps<T> {
|
|
4
|
+
data: T[];
|
|
5
|
+
columns: Column<T>[];
|
|
6
|
+
getRowId: (row: T) => string | number;
|
|
7
|
+
columnWidths: (number | undefined)[];
|
|
8
|
+
selectable?: boolean;
|
|
9
|
+
isSelected: (id: string | number) => boolean;
|
|
10
|
+
toggleRowSelection: (id: string | number) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const TableBody: <T>({ data, columns, getRowId, columnWidths, selectable, isSelected, toggleRowSelection, }: TableBodyProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Column, SortOrder } from './types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
interface TableHeaderProps<T> {
|
|
4
|
+
columns: Column<T>[];
|
|
5
|
+
sortConfig: {
|
|
6
|
+
key: keyof T | null;
|
|
7
|
+
direction: SortOrder;
|
|
8
|
+
};
|
|
9
|
+
handleSort: (key: keyof T) => void;
|
|
10
|
+
resizable?: boolean;
|
|
11
|
+
handleMouseDown: (index: number, event: React.MouseEvent) => void;
|
|
12
|
+
columnRefs: React.RefObject<(HTMLTableCellElement | null)[]>;
|
|
13
|
+
selectable?: boolean;
|
|
14
|
+
hoveredColumnIndex: number | null;
|
|
15
|
+
setHoveredColumnIndex: (index: number | null) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare const TableHeader: <T>({ columns, sortConfig, handleSort, resizable, handleMouseDown, columnRefs, selectable, hoveredColumnIndex, setHoveredColumnIndex, }: TableHeaderProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Column } from './types';
|
|
2
|
+
|
|
3
|
+
interface TableRowProps<T> {
|
|
4
|
+
row: T;
|
|
5
|
+
columns: Column<T>[];
|
|
6
|
+
columnWidths: (number | undefined)[];
|
|
7
|
+
selectable?: boolean;
|
|
8
|
+
isSelected: (id: string | number) => boolean;
|
|
9
|
+
toggleRowSelection: (id: string | number) => void;
|
|
10
|
+
rowId: string | number;
|
|
11
|
+
}
|
|
12
|
+
export declare const TableRow: <T>({ row, columns, columnWidths, selectable, isSelected, toggleRowSelection, rowId, }: TableRowProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface UseTableProps<T> {
|
|
2
|
+
data: T[];
|
|
3
|
+
getRowId: (row: T) => string | number;
|
|
4
|
+
selectedRows?: Set<string | number>;
|
|
5
|
+
onSelectionChange?: (selectedIds: Set<string | number>) => void;
|
|
6
|
+
}
|
|
7
|
+
interface IUseTable {
|
|
8
|
+
isSelected: (id: string | number) => boolean;
|
|
9
|
+
toggleRowSelection: (id: string | number) => void;
|
|
10
|
+
toggleSelectAll: () => void;
|
|
11
|
+
selectedCount?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const useTable: <T>({ data, getRowId, selectedRows, onSelectionChange, }: UseTableProps<T>) => IUseTable;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type Column<T> = {
|
|
3
|
+
key: keyof T;
|
|
4
|
+
header: string;
|
|
5
|
+
sortable?: boolean;
|
|
6
|
+
sortValue?: (item: T) => string | number;
|
|
7
|
+
};
|
|
8
|
+
export type TableSize = 'small' | 'medium' | 'large';
|
|
9
|
+
export type PinOptions = 'header' | 'leftColumn';
|
|
10
|
+
export type StrippedOptions = 'rows' | 'columns';
|
|
11
|
+
export declare enum SortOrder {
|
|
12
|
+
Ascending = "asc",
|
|
13
|
+
Descending = "desc",
|
|
14
|
+
None = "none"
|
|
15
|
+
}
|
|
16
|
+
export interface ITableProps<T> {
|
|
17
|
+
/**
|
|
18
|
+
* The data to be displayed in the table. Each item represents a row.
|
|
19
|
+
*/
|
|
20
|
+
data: T[];
|
|
21
|
+
/**
|
|
22
|
+
* The configuration for table columns, including keys, headers, and optional sorting logic.
|
|
23
|
+
*/
|
|
24
|
+
columns: Column<T>[];
|
|
25
|
+
/**
|
|
26
|
+
* The parameter allows you to customize alternating background colors for rows
|
|
27
|
+
* or columns in the table, enhancing readability and visual separation. Allowed values
|
|
28
|
+
* are 'rows' or 'columns'
|
|
29
|
+
*/
|
|
30
|
+
stripped?: StrippedOptions;
|
|
31
|
+
/**
|
|
32
|
+
* Specifies the size of the table, which affects row height and spacing.
|
|
33
|
+
* Options: 'small', 'medium', 'large'.
|
|
34
|
+
*/
|
|
35
|
+
size?: TableSize;
|
|
36
|
+
/**
|
|
37
|
+
* Determines if certain table features, like the header, should remain pinned.
|
|
38
|
+
* Currently supports only `header` and `leftColumn` pinning.
|
|
39
|
+
*/
|
|
40
|
+
pin?: PinOptions;
|
|
41
|
+
/**
|
|
42
|
+
* A function that returns a unique identifier for each row, used for selection and key assignment.
|
|
43
|
+
* @param item - The data item representing a row.
|
|
44
|
+
* @returns A unique identifier (string or number) for the row.
|
|
45
|
+
*/
|
|
46
|
+
getRowId: (item: T) => string | number;
|
|
47
|
+
/**
|
|
48
|
+
* Enables or disables the ability to resize columns by dragging the edges of headers.
|
|
49
|
+
*/
|
|
50
|
+
resizable?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Enables row selection mode, adding checkboxes to each row and the header for selection.
|
|
53
|
+
*/
|
|
54
|
+
selectable?: true;
|
|
55
|
+
/**
|
|
56
|
+
* A set of currently selected row IDs. Useful for controlling the selection state externally.
|
|
57
|
+
*/
|
|
58
|
+
selectedRows?: Set<string | number>;
|
|
59
|
+
/**
|
|
60
|
+
* A callback function triggered when the selected rows change.
|
|
61
|
+
* @param selectedIds - A set of selected row IDs.
|
|
62
|
+
*/
|
|
63
|
+
onSelectionChange?: (selectedIds: Set<string | number>) => void;
|
|
64
|
+
/**
|
|
65
|
+
* Defines a customizable message to display the count of selected rows in the table. By default,
|
|
66
|
+
* the message appears as "{count} selected items".
|
|
67
|
+
*/
|
|
68
|
+
rowSelectionMessage?: string | React.ReactNode;
|
|
69
|
+
/**
|
|
70
|
+
* Allows you to define a custom action bar that appears when rows are selected. The action bar
|
|
71
|
+
* can contain buttons or other UI elements for performing bulk operations on the selected rows,
|
|
72
|
+
* such as "Delete All" or "Export."
|
|
73
|
+
*/
|
|
74
|
+
rowActions?: React.ReactNode;
|
|
75
|
+
/**
|
|
76
|
+
* Sets the `data-testid` attribute, allowing the table to be easily selected in automated tests.
|
|
77
|
+
*/
|
|
78
|
+
testId?: string;
|
|
79
|
+
}
|
|
80
|
+
export interface SortConfig<T> {
|
|
81
|
+
key: keyof T | null;
|
|
82
|
+
direction: SortOrder;
|
|
83
|
+
}
|
|
84
|
+
export type Data = {
|
|
85
|
+
id: number;
|
|
86
|
+
name: string;
|
|
87
|
+
age: number;
|
|
88
|
+
role: string;
|
|
89
|
+
action: React.ReactNode;
|
|
90
|
+
};
|
|
91
|
+
export interface DataForPinningExample {
|
|
92
|
+
userId: number;
|
|
93
|
+
fullName: string;
|
|
94
|
+
years: number;
|
|
95
|
+
jobTitle: string;
|
|
96
|
+
team: string;
|
|
97
|
+
office: string;
|
|
98
|
+
availability: string;
|
|
99
|
+
workExperience: string;
|
|
100
|
+
income: string;
|
|
101
|
+
controls: React.ReactNode;
|
|
102
|
+
}
|
package/dist/hooks/index.d.ts
CHANGED
package/dist/hooks/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
export type NODE = HTMLDivElement | null;
|
|
2
3
|
export type CALLBACK = (newSize: DOMRectReadOnly) => void;
|
|
3
4
|
export interface IUseHeightResizer {
|
|
@@ -11,3 +12,9 @@ export interface IUseMobileViewDetector {
|
|
|
11
12
|
isMobile: boolean;
|
|
12
13
|
handleResizeRef: (node: NODE) => void;
|
|
13
14
|
}
|
|
15
|
+
export interface UseInteractiveProps {
|
|
16
|
+
onClick: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
17
|
+
}
|
|
18
|
+
export interface IUseInteractive {
|
|
19
|
+
handleInteractiveClick: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
20
|
+
}
|