zaravand-ui 3.0.2 → 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.
- package/dist/components/Table/Table.constants.d.ts +7 -2
- package/dist/components/Table/Table.d.ts +4 -0
- package/dist/components/Table/Table.interface.d.ts +40 -2
- package/dist/components/Table/Table.utils.d.ts +4 -1
- package/dist/components/Table/Table.variant.d.ts +6 -2
- package/dist/components/Table/hooks/useTablePagination.d.ts +2 -1
- package/dist/components/Table/hooks/useTableSort.d.ts +15 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3002 -2869
- package/package.json +69 -69
|
@@ -10,8 +10,8 @@ export declare const deleteButtonLabel = "\u062D\u0630\u0641";
|
|
|
10
10
|
export declare const actionIconClassName = "zui:size-4";
|
|
11
11
|
export declare const pagingToggleIconClassName = "zui:size-6";
|
|
12
12
|
export declare const rowActionButtonClassName = "zui:cursor-pointer zui:border-0 zui:bg-transparent zui:shadow-none zui:hover:bg-transparent zui:hover:shadow-none zui:active:bg-transparent zui:focus-visible:ring-0 zui:disabled:cursor-not-allowed";
|
|
13
|
-
export declare const actionsColumnClassName = "zui:px-3
|
|
14
|
-
export declare const rowNumberColumnClassName = "zui:px-3
|
|
13
|
+
export declare const actionsColumnClassName = "zui:px-3";
|
|
14
|
+
export declare const rowNumberColumnClassName = "zui:px-3";
|
|
15
15
|
export declare const searchInputPlaceholder = "\u062C\u0633\u062A\u062C\u0648 \u06A9\u0646\u06CC\u062F";
|
|
16
16
|
export declare const searchInputAriaLabel = "\u062C\u0633\u062A\u062C\u0648\u06CC \u062C\u062F\u0648\u0644";
|
|
17
17
|
export declare const switchToInfiniteModeLabel = "\u062A\u063A\u06CC\u06CC\u0631 \u0628\u0647 \u067E\u06CC\u0645\u0627\u06CC\u0634 \u0628\u06CC\u200C\u0646\u0647\u0627\u06CC\u062A";
|
|
@@ -33,4 +33,9 @@ export declare const infiniteReadyStatusLabel = "\u0628\u0631\u0627\u06CC \u0628
|
|
|
33
33
|
export declare const infiniteCompletedStatusLabel = "\u0647\u0645\u0647 \u0631\u062F\u06CC\u0641\u200C\u0647\u0627 \u0646\u0645\u0627\u06CC\u0634 \u062F\u0627\u062F\u0647 \u0634\u062F.";
|
|
34
34
|
export declare const defaultLoadingRowsCount = 6;
|
|
35
35
|
export declare const maxLoadingRowsCount = 12;
|
|
36
|
+
export declare const sortIconClassName = "zui:size-4";
|
|
37
|
+
export declare const sortToggleButtonClassName = "zui:inline-flex zui:cursor-pointer zui:items-center zui:justify-center zui:rounded zui:border-0 zui:bg-transparent zui:p-0 zui:text-[var(--zui-theme-text-primary)] zui:transition-transform zui:duration-200 zui:ease-out zui:hover:scale-125 zui:focus-visible:outline-none zui:focus-visible:ring-2 zui:focus-visible:ring-[var(--zui-theme-action-secondary)]";
|
|
38
|
+
export declare const sortAscendingLabel = "\u0635\u0639\u0648\u062F\u06CC";
|
|
39
|
+
export declare const sortDescendingLabel = "\u0646\u0632\u0648\u0644\u06CC";
|
|
40
|
+
export declare const sortTooltipPrefixLabel = "\u0645\u0631\u062A\u0628\u200C\u0633\u0627\u0632\u06CC \u0628\u0631 \u0627\u0633\u0627\u0633";
|
|
36
41
|
export declare const tablePersianDateFormatter: Intl.DateTimeFormat;
|
|
@@ -23,10 +23,14 @@ declare const TableRow: React.ForwardRefExoticComponent<{
|
|
|
23
23
|
declare const TableHead: React.ForwardRefExoticComponent<{
|
|
24
24
|
className?: string;
|
|
25
25
|
children?: React.ReactNode;
|
|
26
|
+
align?: import("./Table.interface").TableColumnAlign;
|
|
27
|
+
} & {
|
|
28
|
+
ariaSort?: "ascending" | "descending" | "none";
|
|
26
29
|
} & React.RefAttributes<HTMLTableCellElement>>;
|
|
27
30
|
declare const TableCell: React.ForwardRefExoticComponent<{
|
|
28
31
|
className?: string;
|
|
29
32
|
children?: React.ReactNode;
|
|
33
|
+
align?: import("./Table.interface").TableColumnAlign;
|
|
30
34
|
} & React.RefAttributes<HTMLTableCellElement>>;
|
|
31
35
|
export { TableBody, TableCell, TableFooter, TableHead, TableHeader, TableRow, };
|
|
32
36
|
export default Table;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as React from "react";
|
|
2
2
|
import type { SelectProps } from "../Select/Select.interface";
|
|
3
|
-
export type TableFieldType = 'text' | 'number' | 'textarea' | 'select' | 'checkbox' | 'radio' | 'date';
|
|
3
|
+
export type TableFieldType = 'text' | 'number' | 'textarea' | 'select' | 'checkbox' | 'radio' | 'date' | 'money';
|
|
4
4
|
type TableFieldValueByType = {
|
|
5
5
|
text: string;
|
|
6
6
|
number: number;
|
|
@@ -9,11 +9,14 @@ type TableFieldValueByType = {
|
|
|
9
9
|
checkbox: boolean;
|
|
10
10
|
radio: string;
|
|
11
11
|
date: Date | string;
|
|
12
|
+
money: number | string;
|
|
12
13
|
};
|
|
14
|
+
export type TableColumnAlign = 'start' | 'center' | 'end';
|
|
13
15
|
export type TableFieldValue = TableFieldValueByType[TableFieldType];
|
|
14
16
|
export type DynamicTableRow = Record<string, TableFieldValue | null | undefined>;
|
|
15
17
|
export type TableRowId = string | number;
|
|
16
18
|
export type TablePagingMode = 'pagination' | 'infinite';
|
|
19
|
+
export type TableSortDirection = 'asc' | 'desc';
|
|
17
20
|
export type TablePaginationToken = number | 'ellipsis-start' | 'ellipsis-end';
|
|
18
21
|
export type TableMutationHookResult = boolean | void | Promise<boolean | void>;
|
|
19
22
|
export type TableRowActionInput = {
|
|
@@ -63,6 +66,37 @@ export type TableSchemaColumn = {
|
|
|
63
66
|
* with the other un-sized columns.
|
|
64
67
|
*/
|
|
65
68
|
width?: number | string;
|
|
69
|
+
/**
|
|
70
|
+
* Text alignment applied to both the column's header and its body cells.
|
|
71
|
+
* Defaults to `"start"` (right in RTL). Has no effect on the row-number or
|
|
72
|
+
* actions columns, which are always center-aligned.
|
|
73
|
+
*/
|
|
74
|
+
align?: TableColumnAlign;
|
|
75
|
+
/**
|
|
76
|
+
* When true, renders a clickable sort-toggle chevron in this column's
|
|
77
|
+
* header. See `TableSchema.sort` for controlling/observing the active
|
|
78
|
+
* sort key and direction.
|
|
79
|
+
*/
|
|
80
|
+
sortable?: boolean;
|
|
81
|
+
};
|
|
82
|
+
export type TableSchemaSort = {
|
|
83
|
+
/**
|
|
84
|
+
* The currently active sort column key. Only meaningful for remote sort
|
|
85
|
+
* (when `onSortChange` is provided) — in local/uncontrolled sort the table
|
|
86
|
+
* tracks this itself.
|
|
87
|
+
*/
|
|
88
|
+
sortKey?: string;
|
|
89
|
+
/**
|
|
90
|
+
* The currently active sort direction. Only meaningful for remote sort.
|
|
91
|
+
*/
|
|
92
|
+
sortDirection?: TableSortDirection;
|
|
93
|
+
/**
|
|
94
|
+
* Provided for remote sorting: called with the clicked column's key and
|
|
95
|
+
* the direction it should now sort by. When provided, the table stops
|
|
96
|
+
* sorting rows itself and expects the parent to fetch/re-order `data`
|
|
97
|
+
* accordingly (same contract as `TableSchemaPagination.onPageChange`).
|
|
98
|
+
*/
|
|
99
|
+
onSortChange?: (sortKey: string, direction: TableSortDirection) => void;
|
|
66
100
|
};
|
|
67
101
|
export type TableSchemaPagination = {
|
|
68
102
|
page: number;
|
|
@@ -85,6 +119,7 @@ export type TableSchema = {
|
|
|
85
119
|
columns: TableSchemaColumn[];
|
|
86
120
|
searchable?: boolean;
|
|
87
121
|
pagination?: TableSchemaPagination;
|
|
122
|
+
sort?: TableSchemaSort;
|
|
88
123
|
};
|
|
89
124
|
export type TableVisibleRow = {
|
|
90
125
|
row: DynamicTableRow;
|
|
@@ -134,8 +169,11 @@ export type TableRowProps = TableSectionProps & {
|
|
|
134
169
|
type TableCellElementProps = {
|
|
135
170
|
className?: string;
|
|
136
171
|
children?: React.ReactNode;
|
|
172
|
+
align?: TableColumnAlign;
|
|
173
|
+
};
|
|
174
|
+
export type TableHeadProps = TableCellElementProps & {
|
|
175
|
+
ariaSort?: 'ascending' | 'descending' | 'none';
|
|
137
176
|
};
|
|
138
|
-
export type TableHeadProps = TableCellElementProps;
|
|
139
177
|
export type TableCellProps = TableCellElementProps;
|
|
140
178
|
export type TablePaginationControlsProps = {
|
|
141
179
|
shouldRenderInfiniteMode: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as React from 'react';
|
|
2
|
-
import type { DynamicTableRow, TablePaginationToken, TableRowId, TableRowIdResolver, TableSchemaColumn } from './Table.interface';
|
|
2
|
+
import type { DynamicTableRow, TablePaginationToken, TableRowId, TableRowIdResolver, TableSchemaColumn, TableSortDirection } from './Table.interface';
|
|
3
3
|
export declare function resolveColumnWidthPercentages(visibleColumns: TableSchemaColumn[], shouldShowRowNumbers: boolean, hasRowActions: boolean): {
|
|
4
4
|
rowNumberColumnStyle: React.CSSProperties | undefined;
|
|
5
5
|
columnStyleByKey: Record<string, React.CSSProperties>;
|
|
@@ -9,9 +9,12 @@ export declare function resolveLoadingRowsCount(pageSize: number | undefined, da
|
|
|
9
9
|
export declare function resolveLoadingCellSkeletonClassName(column: TableSchemaColumn, rowIndex: number): string;
|
|
10
10
|
export declare function buildPaginationTokens(currentPage: number, totalPages: number): TablePaginationToken[];
|
|
11
11
|
export declare function isEmptyCellValue(value: unknown): boolean;
|
|
12
|
+
export declare function resolveMoneyValue(value: unknown): number | null;
|
|
13
|
+
export declare function formatMoneyValue(value: number): string;
|
|
12
14
|
export declare function resolveDateValue(value: unknown): Date | null;
|
|
13
15
|
export declare function resolvePlaceholder(column: TableSchemaColumn): string;
|
|
14
16
|
export declare function formatCellValue(value: unknown, column: TableSchemaColumn): string;
|
|
15
17
|
export declare function resolveSafeRowId(row: DynamicTableRow, index: number, getRowId?: TableRowIdResolver): TableRowId | undefined;
|
|
16
18
|
export declare function findRowIndexByIdentifier(rows: DynamicTableRow[], targetRowIndex: number, targetRowId: TableRowId | undefined, getRowId?: TableRowIdResolver): number;
|
|
19
|
+
export declare function compareTableRowsByColumn(rowA: DynamicTableRow, rowB: DynamicTableRow, column: TableSchemaColumn, direction: TableSortDirection): number;
|
|
17
20
|
export declare function replaceRowByIdentifier(rows: DynamicTableRow[], targetRowIndex: number, targetRowId: TableRowId | undefined, getRowId: TableRowIdResolver | undefined, nextRow: DynamicTableRow): DynamicTableRow[];
|
|
@@ -10,5 +10,9 @@ export declare const tableHeaderVariants: (props?: import("class-variance-author
|
|
|
10
10
|
export declare const tableBodyVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
11
11
|
export declare const tableFooterVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
12
12
|
export declare const tableRowVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
13
|
-
export declare const tableHeadVariants: (props?:
|
|
14
|
-
|
|
13
|
+
export declare const tableHeadVariants: (props?: ({
|
|
14
|
+
align?: "center" | "end" | "start" | null | undefined;
|
|
15
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
16
|
+
export declare const tableCellVariants: (props?: ({
|
|
17
|
+
align?: "center" | "end" | "start" | null | undefined;
|
|
18
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
@@ -7,6 +7,7 @@ type UseTablePaginationInput = {
|
|
|
7
7
|
loading: boolean;
|
|
8
8
|
isRowActionBusy: boolean;
|
|
9
9
|
searchKey: string;
|
|
10
|
+
sortKey: string;
|
|
10
11
|
maxVisibleRowsBeforeScroll?: number;
|
|
11
12
|
};
|
|
12
13
|
type UseTablePaginationResult = {
|
|
@@ -33,5 +34,5 @@ type UseTablePaginationResult = {
|
|
|
33
34
|
handleTableScrollViewport: (event: React.UIEvent<HTMLDivElement>) => void;
|
|
34
35
|
isInfiniteRequestPending: boolean;
|
|
35
36
|
};
|
|
36
|
-
export declare function useTablePagination({ hasChildren, filteredRows, paginationConfig, loading, isRowActionBusy, searchKey, maxVisibleRowsBeforeScroll, }: UseTablePaginationInput): UseTablePaginationResult;
|
|
37
|
+
export declare function useTablePagination({ hasChildren, filteredRows, paginationConfig, loading, isRowActionBusy, searchKey, sortKey, maxVisibleRowsBeforeScroll, }: UseTablePaginationInput): UseTablePaginationResult;
|
|
37
38
|
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TableSchemaColumn, TableSchemaSort, TableSortDirection, TableVisibleRow } from '../Table.interface';
|
|
2
|
+
type UseTableSortInput = {
|
|
3
|
+
rows: TableVisibleRow[];
|
|
4
|
+
columns: TableSchemaColumn[];
|
|
5
|
+
sortConfig?: TableSchemaSort;
|
|
6
|
+
};
|
|
7
|
+
type UseTableSortResult = {
|
|
8
|
+
sortedRows: TableVisibleRow[];
|
|
9
|
+
activeSortKey: string | undefined;
|
|
10
|
+
activeSortDirection: TableSortDirection;
|
|
11
|
+
isRemoteSort: boolean;
|
|
12
|
+
handleSortToggle: (columnKey: string) => void;
|
|
13
|
+
};
|
|
14
|
+
export declare function useTableSort({ rows, columns, sortConfig }: UseTableSortInput): UseTableSortResult;
|
|
15
|
+
export {};
|