zaravand-ui 3.0.3 → 3.1.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.
- package/dist/components/Table/Table.constants.d.ts +5 -0
- package/dist/components/Table/Table.d.ts +2 -0
- package/dist/components/Table/Table.interface.d.ts +30 -1
- package/dist/components/Table/Table.utils.d.ts +2 -1
- 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 +592 -498
- package/package.json +69 -69
|
@@ -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;
|
|
@@ -24,6 +24,8 @@ declare const TableHead: React.ForwardRefExoticComponent<{
|
|
|
24
24
|
className?: string;
|
|
25
25
|
children?: React.ReactNode;
|
|
26
26
|
align?: import("./Table.interface").TableColumnAlign;
|
|
27
|
+
} & {
|
|
28
|
+
ariaSort?: "ascending" | "descending" | "none";
|
|
27
29
|
} & React.RefAttributes<HTMLTableCellElement>>;
|
|
28
30
|
declare const TableCell: React.ForwardRefExoticComponent<{
|
|
29
31
|
className?: string;
|
|
@@ -16,6 +16,7 @@ export type TableFieldValue = TableFieldValueByType[TableFieldType];
|
|
|
16
16
|
export type DynamicTableRow = Record<string, TableFieldValue | null | undefined>;
|
|
17
17
|
export type TableRowId = string | number;
|
|
18
18
|
export type TablePagingMode = 'pagination' | 'infinite';
|
|
19
|
+
export type TableSortDirection = 'asc' | 'desc';
|
|
19
20
|
export type TablePaginationToken = number | 'ellipsis-start' | 'ellipsis-end';
|
|
20
21
|
export type TableMutationHookResult = boolean | void | Promise<boolean | void>;
|
|
21
22
|
export type TableRowActionInput = {
|
|
@@ -71,6 +72,31 @@ export type TableSchemaColumn = {
|
|
|
71
72
|
* actions columns, which are always center-aligned.
|
|
72
73
|
*/
|
|
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;
|
|
74
100
|
};
|
|
75
101
|
export type TableSchemaPagination = {
|
|
76
102
|
page: number;
|
|
@@ -93,6 +119,7 @@ export type TableSchema = {
|
|
|
93
119
|
columns: TableSchemaColumn[];
|
|
94
120
|
searchable?: boolean;
|
|
95
121
|
pagination?: TableSchemaPagination;
|
|
122
|
+
sort?: TableSchemaSort;
|
|
96
123
|
};
|
|
97
124
|
export type TableVisibleRow = {
|
|
98
125
|
row: DynamicTableRow;
|
|
@@ -144,7 +171,9 @@ type TableCellElementProps = {
|
|
|
144
171
|
children?: React.ReactNode;
|
|
145
172
|
align?: TableColumnAlign;
|
|
146
173
|
};
|
|
147
|
-
export type TableHeadProps = TableCellElementProps
|
|
174
|
+
export type TableHeadProps = TableCellElementProps & {
|
|
175
|
+
ariaSort?: 'ascending' | 'descending' | 'none';
|
|
176
|
+
};
|
|
148
177
|
export type TableCellProps = TableCellElementProps;
|
|
149
178
|
export type TablePaginationControlsProps = {
|
|
150
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>;
|
|
@@ -16,4 +16,5 @@ export declare function resolvePlaceholder(column: TableSchemaColumn): string;
|
|
|
16
16
|
export declare function formatCellValue(value: unknown, column: TableSchemaColumn): string;
|
|
17
17
|
export declare function resolveSafeRowId(row: DynamicTableRow, index: number, getRowId?: TableRowIdResolver): TableRowId | undefined;
|
|
18
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;
|
|
19
20
|
export declare function replaceRowByIdentifier(rows: DynamicTableRow[], targetRowIndex: number, targetRowId: TableRowId | undefined, getRowId: TableRowIdResolver | undefined, nextRow: DynamicTableRow): DynamicTableRow[];
|
|
@@ -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 {};
|