@jetbrains/ring-ui 8.0.0-beta.3 → 8.0.0-beta.4
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/components/checkbox/checkbox.d.ts +1 -1
- package/components/collapsible-group/collapsible-group.css +138 -0
- package/components/collapsible-group/collapsible-group.d.ts +20 -0
- package/components/collapsible-group/collapsible-group.js +73 -0
- package/components/editable-heading/editable-heading.js +14 -14
- package/components/expand/collapsible-group.css +23 -89
- package/components/expand/collapsible-group.d.ts +8 -20
- package/components/expand/collapsible-group.js +14 -73
- package/components/global/compose-refs.d.ts +2 -1
- package/components/global/compose-refs.js +24 -8
- package/components/global/focus-with-temporary-tabindex.d.ts +11 -0
- package/components/global/focus-with-temporary-tabindex.js +21 -0
- package/components/global/intersection-observer-context.d.ts +29 -9
- package/components/global/intersection-observer-context.js +43 -24
- package/components/global/is-within-interactive-element.d.ts +6 -0
- package/components/global/is-within-interactive-element.js +26 -0
- package/components/global/is-within-navigable-element.d.ts +6 -0
- package/components/global/is-within-navigable-element.js +27 -0
- package/components/global/parse-css-duration.d.ts +5 -0
- package/components/global/parse-css-duration.js +13 -0
- package/components/global/schedule-with-cleanup.d.ts +12 -0
- package/components/global/schedule-with-cleanup.js +34 -0
- package/components/global/table-selection.js +1 -1
- package/components/input/input.d.ts +1 -1
- package/components/legacy-table/row.d.ts +1 -1
- package/components/popup/popup.d.ts +2 -0
- package/components/popup/popup.js +2 -2
- package/components/select/select-popup.d.ts +1 -1
- package/components/select/select.d.ts +1 -1
- package/components/table/default-item-renderer.d.ts +23 -10
- package/components/table/default-item-renderer.js +40 -19
- package/components/table/internal/column-animation.d.ts +16 -0
- package/components/table/internal/column-animation.js +45 -0
- package/components/table/internal/table-header.d.ts +4 -0
- package/components/table/internal/table-header.js +357 -0
- package/components/table/internal/virtual-items.d.ts +34 -0
- package/components/table/{table-virtualize.js → internal/virtual-items.js} +68 -33
- package/components/table/item-virtualization.d.ts +35 -0
- package/components/table/item-virtualization.js +28 -0
- package/components/table/table-const.d.ts +40 -6
- package/components/table/table-const.js +14 -5
- package/components/table/table-primitives.d.ts +9 -16
- package/components/table/table-primitives.js +6 -60
- package/components/table/table-props.d.ts +280 -0
- package/components/table/table-props.js +1 -0
- package/components/table/table.css +171 -66
- package/components/table/table.d.ts +205 -209
- package/components/table/table.js +298 -2
- package/components/util-stories.d.ts +26 -0
- package/components/util-stories.js +61 -0
- package/package.json +29 -30
- package/components/date-picker/use-intersection-observer.d.ts +0 -6
- package/components/date-picker/use-intersection-observer.js +0 -48
- package/components/global/composeRefs.d.ts +0 -6
- package/components/global/composeRefs.js +0 -7
- package/components/table/table-component.d.ts +0 -80
- package/components/table/table-component.js +0 -130
- package/components/table/table-row-focus.d.ts +0 -4
- package/components/table/table-row-focus.js +0 -42
- package/components/table/table-virtualize.d.ts +0 -32
|
@@ -1,8 +1,42 @@
|
|
|
1
|
-
import type { TableProps } from './table';
|
|
1
|
+
import type { TableProps } from './table-props';
|
|
2
|
+
/**
|
|
3
|
+
* Use anywhere inside the table to get access to the props passed to it.
|
|
4
|
+
* Cast to `Context<TableProps<T>>` in usage place.
|
|
5
|
+
*/
|
|
2
6
|
export declare const TablePropsContext: import("react").Context<TableProps<unknown> | null>;
|
|
3
|
-
|
|
4
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Information about a column reorder animation.
|
|
9
|
+
*
|
|
10
|
+
* Available through {@link ColumnAnimationContext} to allow custom cell
|
|
11
|
+
* renderers to animate reordered columns consistently with the default
|
|
12
|
+
* table renderer.
|
|
13
|
+
*/
|
|
14
|
+
export interface ColumnAnimation {
|
|
15
|
+
/**
|
|
16
|
+
* Index of the column being animated.
|
|
17
|
+
*/
|
|
18
|
+
columnIndex: number;
|
|
19
|
+
/**
|
|
20
|
+
* Current animation phase.
|
|
21
|
+
*/
|
|
22
|
+
phase: 'initial' | 'fade-out';
|
|
23
|
+
/**
|
|
24
|
+
* CSS class to apply to the animated cell or another element used to
|
|
25
|
+
* render the animation.
|
|
26
|
+
*
|
|
27
|
+
* The class only defines the `background-color` and `transition`
|
|
28
|
+
* properties.
|
|
29
|
+
*/
|
|
30
|
+
cellClassName: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Provides information about the currently animated column.
|
|
34
|
+
*
|
|
35
|
+
* Use in a custom cell renderer to animate reordered columns
|
|
36
|
+
* consistently with the default table renderer.
|
|
37
|
+
*/
|
|
38
|
+
export declare const ColumnAnimationContext: import("react").Context<ColumnAnimation | null>;
|
|
39
|
+
/**
|
|
40
|
+
* When a row only contains unformatted single-line text, it will be exactly of this height.
|
|
41
|
+
*/
|
|
5
42
|
export declare const defaultRowHeight = 37;
|
|
6
|
-
export declare const defaultLookaheadPx = 400;
|
|
7
|
-
export declare const defaultRetentionMarginPx = 450;
|
|
8
|
-
export declare const defaultMinScrollAndResizeDeltaPx = 50;
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Use anywhere inside the table to get access to the props passed to it.
|
|
4
|
+
* Cast to `Context<TableProps<T>>` in usage place.
|
|
5
|
+
*/
|
|
2
6
|
export const TablePropsContext = createContext(null);
|
|
3
|
-
|
|
4
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Provides information about the currently animated column.
|
|
9
|
+
*
|
|
10
|
+
* Use in a custom cell renderer to animate reordered columns
|
|
11
|
+
* consistently with the default table renderer.
|
|
12
|
+
*/
|
|
13
|
+
export const ColumnAnimationContext = createContext(null);
|
|
14
|
+
/**
|
|
15
|
+
* When a row only contains unformatted single-line text, it will be exactly of this height.
|
|
16
|
+
*/
|
|
5
17
|
export const defaultRowHeight = 37;
|
|
6
|
-
export const defaultLookaheadPx = 400;
|
|
7
|
-
export const defaultRetentionMarginPx = 450;
|
|
8
|
-
export const defaultMinScrollAndResizeDeltaPx = 50;
|
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/**
|
|
3
|
-
* Include it in a column header to make the column sortable.
|
|
4
|
-
* Handle clicks with {@link TableProps.onSort}.
|
|
5
|
-
*/
|
|
6
|
-
export declare function SortButton<T>({ className, children, onClick, ...restProps }: ComponentPropsWithRef<'button'>): import("react").JSX.Element | null;
|
|
7
|
-
/**
|
|
8
|
-
* Include it in a column header to make the column deletable.
|
|
9
|
-
* Beware that `column.name ?? String(column.key)` is used in the aria-label.
|
|
10
|
-
* Handle clicks with {@link TableProps.onColumnDelete}.
|
|
11
|
-
*/
|
|
12
|
-
export declare function DeleteColumnButton<T>({ className, onClick, ...restProps }: ComponentPropsWithRef<'button'>): import("react").JSX.Element | null;
|
|
1
|
+
import type { ComponentPropsWithRef } from 'react';
|
|
13
2
|
export interface TableRowProps {
|
|
14
3
|
/**
|
|
15
4
|
* @see DefaultItemRendererProps.keyboardFocusable
|
|
@@ -17,12 +6,16 @@ export interface TableRowProps {
|
|
|
17
6
|
keyboardFocusable?: boolean;
|
|
18
7
|
}
|
|
19
8
|
/**
|
|
20
|
-
*
|
|
21
|
-
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare const keyboardFocusableAttrName = "data-keyboard-focusable";
|
|
12
|
+
/**
|
|
13
|
+
* A helper `<tr>` component for custom {@link TableProps.renderItem} implementations.
|
|
14
|
+
* Applies the standard row class names.
|
|
22
15
|
*/
|
|
23
16
|
export declare function TableRow(props: TableRowProps & ComponentPropsWithRef<'tr'>): import("react").JSX.Element;
|
|
24
17
|
/**
|
|
25
|
-
* A helper `<td>` component for
|
|
26
|
-
* Applies the standard cell
|
|
18
|
+
* A helper `<td>` component for custom {@link TableProps.renderItem} implementations.
|
|
19
|
+
* Applies the standard cell class names, but not data-dependent `tdClassName`.
|
|
27
20
|
*/
|
|
28
21
|
export declare function TableCell(props: ComponentPropsWithRef<'td'>): import("react").JSX.Element;
|
|
@@ -1,66 +1,12 @@
|
|
|
1
|
-
import { use, useCallback } from 'react';
|
|
2
1
|
import classNames from 'classnames';
|
|
3
|
-
import unsortedIcon from '@jetbrains/icons/unsorted-12px';
|
|
4
|
-
import arrowDownIcon from '@jetbrains/icons/arrow-12px-down';
|
|
5
|
-
import arrowUpIcon from '@jetbrains/icons/arrow-12px-up';
|
|
6
|
-
import trashIcon from '@jetbrains/icons/trash-12px';
|
|
7
|
-
import Icon from '../icon/icon';
|
|
8
|
-
import { ColumnIndexContext, TablePropsContext } from './table-const';
|
|
9
|
-
import { keyboardFocusableAttrName } from './table-row-focus';
|
|
10
2
|
import styles from './table.css';
|
|
11
3
|
/**
|
|
12
|
-
*
|
|
13
|
-
* Handle clicks with {@link TableProps.onSort}.
|
|
4
|
+
* @internal
|
|
14
5
|
*/
|
|
15
|
-
export
|
|
16
|
-
const tableProps = use(TablePropsContext);
|
|
17
|
-
const columnIndex = use(ColumnIndexContext);
|
|
18
|
-
const column = tableProps?.columns[columnIndex];
|
|
19
|
-
const sortOrder = column?.sortOrder ?? 'none';
|
|
20
|
-
// eslint-disable-next-line no-nested-ternary, prettier/prettier
|
|
21
|
-
const glyph = sortOrder === 'none' ? unsortedIcon
|
|
22
|
-
: sortOrder === 'ascending' ? arrowUpIcon
|
|
23
|
-
: arrowDownIcon;
|
|
24
|
-
const handleClick = useCallback((e) => {
|
|
25
|
-
onClick?.(e);
|
|
26
|
-
if (!e.defaultPrevented) {
|
|
27
|
-
const sequence = ['none', 'ascending', 'descending'];
|
|
28
|
-
const nextOrder = sequence[(sequence.indexOf(sortOrder) + 1) % sequence.length];
|
|
29
|
-
tableProps.onSort?.(columnIndex, nextOrder, tableProps.columns);
|
|
30
|
-
}
|
|
31
|
-
}, [columnIndex, onClick, sortOrder, tableProps]);
|
|
32
|
-
if (!tableProps || !column) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
return (<button type='button' className={classNames(styles.headerButton, className)} onClick={handleClick} {...restProps}>
|
|
36
|
-
{children} <Icon glyph={glyph} aria-hidden/>
|
|
37
|
-
</button>);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Include it in a column header to make the column deletable.
|
|
41
|
-
* Beware that `column.name ?? String(column.key)` is used in the aria-label.
|
|
42
|
-
* Handle clicks with {@link TableProps.onColumnDelete}.
|
|
43
|
-
*/
|
|
44
|
-
export function DeleteColumnButton({ className, onClick, ...restProps }) {
|
|
45
|
-
const tableProps = use(TablePropsContext);
|
|
46
|
-
const columnIndex = use(ColumnIndexContext);
|
|
47
|
-
const column = tableProps?.columns[columnIndex];
|
|
48
|
-
const handleClick = useCallback((e) => {
|
|
49
|
-
onClick?.(e);
|
|
50
|
-
if (!e.defaultPrevented) {
|
|
51
|
-
tableProps.onColumnDelete?.(columnIndex, tableProps.columns);
|
|
52
|
-
}
|
|
53
|
-
}, [columnIndex, onClick, tableProps]);
|
|
54
|
-
if (!tableProps || !column) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
return (<button type='button' className={classNames(styles.headerButton, styles.deleteColumnButton, className)} onClick={handleClick} aria-label={`Delete column ${column.name ?? String(column.key)}`} {...restProps}>
|
|
58
|
-
<Icon glyph={trashIcon}/>
|
|
59
|
-
</button>);
|
|
60
|
-
}
|
|
6
|
+
export const keyboardFocusableAttrName = 'data-keyboard-focusable';
|
|
61
7
|
/**
|
|
62
|
-
* A helper `<tr>` component for
|
|
63
|
-
* Applies the standard row
|
|
8
|
+
* A helper `<tr>` component for custom {@link TableProps.renderItem} implementations.
|
|
9
|
+
* Applies the standard row class names.
|
|
64
10
|
*/
|
|
65
11
|
export function TableRow(props) {
|
|
66
12
|
const { keyboardFocusable, className, ...restProps } = props;
|
|
@@ -69,8 +15,8 @@ export function TableRow(props) {
|
|
|
69
15
|
return <tr className={classes} {...trRestProps}/>;
|
|
70
16
|
}
|
|
71
17
|
/**
|
|
72
|
-
* A helper `<td>` component for
|
|
73
|
-
* Applies the standard cell
|
|
18
|
+
* A helper `<td>` component for custom {@link TableProps.renderItem} implementations.
|
|
19
|
+
* Applies the standard cell class names, but not data-dependent `tdClassName`.
|
|
74
20
|
*/
|
|
75
21
|
export function TableCell(props) {
|
|
76
22
|
const { className, ...restProps } = props;
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import type { AriaAttributes, ReactNode, RefObject } from 'react';
|
|
2
|
+
export interface TableProps<T> {
|
|
3
|
+
/**
|
|
4
|
+
* The data items to render. `null` and `undefined` items are not supported.
|
|
5
|
+
* Referentially identical items are not supported either.
|
|
6
|
+
*/
|
|
7
|
+
data: readonly T[];
|
|
8
|
+
/**
|
|
9
|
+
* Column definitions.
|
|
10
|
+
*/
|
|
11
|
+
columns: readonly Column<T>[];
|
|
12
|
+
/**
|
|
13
|
+
* Used as a key in the items list.
|
|
14
|
+
*/
|
|
15
|
+
getKey: (item: T, index: number, items: readonly T[]) => React.Key;
|
|
16
|
+
/**
|
|
17
|
+
* If `true`, the table header will not be rendered.
|
|
18
|
+
*
|
|
19
|
+
* Note that this may impact accessibility. If necessary, provide additional
|
|
20
|
+
* information via `aria-label` or `aria-description` on the `Table` element.
|
|
21
|
+
*/
|
|
22
|
+
noHeader?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* If true, renders a sticky header.
|
|
25
|
+
*/
|
|
26
|
+
stickyHeader?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Called when the user clicks the sort button in a column header.
|
|
29
|
+
* The client is expected to update the `columns` prop with the new
|
|
30
|
+
* sort order for the corresponding column, and update the data accordingly.
|
|
31
|
+
*/
|
|
32
|
+
onSort?: (columnIndex: number, newOrder: SortOrder, columns: readonly Column<T>[]) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Called when the user clicks on a column delete button in the header.
|
|
35
|
+
* The client is expected to update the `columns` prop with the column removed.
|
|
36
|
+
*/
|
|
37
|
+
onColumnDelete?: (columnIndex: number, columns: readonly Column<T>[]) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Called when the user reorders columns by dragging a column.
|
|
40
|
+
* The `insertionIndex` parameter represents an insertion position in the original,
|
|
41
|
+
* unchanged `columns` array before the column is removed.
|
|
42
|
+
*
|
|
43
|
+
* One possible implementation is:
|
|
44
|
+
*
|
|
45
|
+
* ```ts
|
|
46
|
+
* const [moved] = columns.splice(fromIndex, 1);
|
|
47
|
+
* columns.splice(fromIndex < insertionIndex ? insertionIndex - 1 : insertionIndex, 0, moved);
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* The callback is not called when the reorder operation would not change the
|
|
51
|
+
* column order, i.e. when
|
|
52
|
+
* `insertionIndex === fromIndex || insertionIndex === fromIndex + 1`.
|
|
53
|
+
*/
|
|
54
|
+
onColumnReorder?: (fromIndex: number, insertionIndex: number, columns: readonly Column<T>[]) => void;
|
|
55
|
+
/**
|
|
56
|
+
* By default, when a column is reordered, the moved column is highlighted
|
|
57
|
+
* with a temporary background color. Set `true` to disable this animation.
|
|
58
|
+
*/
|
|
59
|
+
noColumnReorderAnimation?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Customizes how an item is rendered.
|
|
62
|
+
*
|
|
63
|
+
* Return `DefaultItemRenderer` to configure row-specific behavior such as
|
|
64
|
+
* `clickable`, `keyboardFocusable`, event handlers, `className`, or `ref`.
|
|
65
|
+
*
|
|
66
|
+
* You can also return custom row(s) instead. See the `Table` documentation
|
|
67
|
+
* for details.
|
|
68
|
+
*/
|
|
69
|
+
renderItem?: (item: T, index: number, items: readonly T[]) => ReactNode;
|
|
70
|
+
/**
|
|
71
|
+
* Only renders rows near the viewport.
|
|
72
|
+
*
|
|
73
|
+
* Rows may transition between two states:
|
|
74
|
+
* - materialized: rendered as actual table rows. This happens when
|
|
75
|
+
* the corresponding spacer approaches the viewport, as specified by
|
|
76
|
+
* `lookaheadPx`.
|
|
77
|
+
* - virtualized: replaced with spacer rows of the same height. This happens
|
|
78
|
+
* when the row moves sufficiently far from the viewport, as specified by
|
|
79
|
+
* `retentionMarginPx`.
|
|
80
|
+
*
|
|
81
|
+
* Toggling this prop should normally work as expected, but a seamless
|
|
82
|
+
* transition is not guaranteed: the scroll position may reset to the top.
|
|
83
|
+
* However, if row height estimates are accurate and the data has not
|
|
84
|
+
* changed, the browser may apply scroll anchoring, resulting in a smoother
|
|
85
|
+
* transition, possibly with brief flickering but without scroll jumps.
|
|
86
|
+
*/
|
|
87
|
+
virtualizeRows?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Used with `virtualizeRows` as the source of scroll events, the target of
|
|
90
|
+
* `ResizeObserver`, and the root of `IntersectionObserver`. Required when
|
|
91
|
+
* the scrollable container is not the whole document.
|
|
92
|
+
*
|
|
93
|
+
* If not set:
|
|
94
|
+
* - the scroll listener is attached to `window`
|
|
95
|
+
* - `ResizeObserver` observes `document.body`
|
|
96
|
+
* - `IntersectionObserver` has no root (i.e. the viewport is used)
|
|
97
|
+
*
|
|
98
|
+
* Note that if this scroller is nested inside another scrollable container,
|
|
99
|
+
* the outer container is not tracked. As a result, items may not materialize
|
|
100
|
+
* until the inner scroller is scrolled.
|
|
101
|
+
*
|
|
102
|
+
* Support for nested scroll containers may be added in the future.
|
|
103
|
+
*/
|
|
104
|
+
scrollerRef?: RefObject<HTMLElement | null>;
|
|
105
|
+
/**
|
|
106
|
+
* Used with `virtualizeRows` to estimate the height of items that have not
|
|
107
|
+
* been rendered yet. The function should be fast and side-effect free.
|
|
108
|
+
* Do not measure the DOM here. Once a row is rendered, its actual height
|
|
109
|
+
* will be measured and used instead of this estimate.
|
|
110
|
+
*
|
|
111
|
+
* Note the effects of imprecise estimates:
|
|
112
|
+
* - When the height is underestimated, the table may materialize more rows
|
|
113
|
+
* than specified by `lookaheadPx`. If the resulting rows extend beyond
|
|
114
|
+
* `retentionMarginPx`, they will be virtualized again. If this causes
|
|
115
|
+
* relayout flickering, increase `retentionMarginPx`.
|
|
116
|
+
* - When the height is overestimated, the table may materialize fewer rows
|
|
117
|
+
* than specified by `lookaheadPx`, which may leave a spacer partially
|
|
118
|
+
* visible. To avoid this, increase `lookaheadPx` (and `retentionMarginPx`
|
|
119
|
+
* accordingly, since it should be greater than `lookaheadPx`).
|
|
120
|
+
*
|
|
121
|
+
* Default: 37px = 16px padding + 20px line height + 1px border.
|
|
122
|
+
*/
|
|
123
|
+
estimateHeight?: (item: T, index: number, items: readonly T[]) => number;
|
|
124
|
+
/**
|
|
125
|
+
* When using `virtualizeRows`, the number of pixels above and below
|
|
126
|
+
* the viewport to materialize in advance.
|
|
127
|
+
*
|
|
128
|
+
* Increase this value if blank space becomes visible during fast scrolling.
|
|
129
|
+
*
|
|
130
|
+
* Default: 400px.
|
|
131
|
+
*/
|
|
132
|
+
lookaheadPx?: number;
|
|
133
|
+
/**
|
|
134
|
+
* Used with `virtualizeRows`. Additional margin around the viewport before
|
|
135
|
+
* materialized rows become eligible for virtualization.
|
|
136
|
+
*
|
|
137
|
+
* Increasing this value reduces row churn when heights are underestimated.
|
|
138
|
+
* In that case, the table may materialize more rows than needed and then
|
|
139
|
+
* immediately virtualize them again. A larger margin keeps such rows
|
|
140
|
+
* rendered for longer, at the cost of rendering more rows overall.
|
|
141
|
+
*
|
|
142
|
+
* This value should be greater than `lookaheadPx`. Increase it if you notice
|
|
143
|
+
* table relayouts during initial render or scrolling.
|
|
144
|
+
*
|
|
145
|
+
* Default: 450px.
|
|
146
|
+
*/
|
|
147
|
+
retentionMarginPx?: number;
|
|
148
|
+
/**
|
|
149
|
+
* When using `virtualizeRows`, ignore scroll and resize position changes
|
|
150
|
+
* smaller than this value.
|
|
151
|
+
*
|
|
152
|
+
* Measurement inaccuracies and rounding artifacts may slightly change the
|
|
153
|
+
* table layout during materialization and virtualization. With scroll
|
|
154
|
+
* anchoring enabled (the default browser behavior), the browser may then
|
|
155
|
+
* adjust the scroll position, triggering additional scroll or resize events.
|
|
156
|
+
* Small deltas are ignored to prevent such feedback loops from causing
|
|
157
|
+
* oscillations at virtualization boundaries.
|
|
158
|
+
*
|
|
159
|
+
* Increase if you expect high inaccuracy in height measurements, or if you
|
|
160
|
+
* notice oscillations at virtualization boundaries.
|
|
161
|
+
*
|
|
162
|
+
* Default: 50px.
|
|
163
|
+
*/
|
|
164
|
+
minScrollAndResizeDeltaPx?: number;
|
|
165
|
+
/**
|
|
166
|
+
* "Column editing mode" is a mode in which controls that are normally hidden
|
|
167
|
+
* become visible, such as column reorder and delete buttons.
|
|
168
|
+
*
|
|
169
|
+
* When this prop is `undefined`, the component manages the mode internally.
|
|
170
|
+
* Users can toggle it by tapping the table header on mobile or by clicking
|
|
171
|
+
* the column edit button, if enabled. Since tapping the table header is not
|
|
172
|
+
* discoverable by assistive technologies, it's recommended to enable
|
|
173
|
+
* `columnEditButton` when using the internal mode.
|
|
174
|
+
*
|
|
175
|
+
* Alternatively, pass `true` or `false` to control the mode externally.
|
|
176
|
+
*/
|
|
177
|
+
columnEditing?: boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Called when the user requests to enter or leave column editing mode.
|
|
180
|
+
*
|
|
181
|
+
* The `source` parameter indicates what triggered the request.
|
|
182
|
+
*
|
|
183
|
+
* When `columnEditing` is not controlled, the component automatically
|
|
184
|
+
* applies the requested change internally.
|
|
185
|
+
*
|
|
186
|
+
* When `columnEditing` is controlled externally and you still want to
|
|
187
|
+
* respond to user requests, use this callback to decide whether to
|
|
188
|
+
* update the mode.
|
|
189
|
+
*/
|
|
190
|
+
onColumnEditingRequest?: (editing: boolean, source: 'header' | 'edit-button') => void;
|
|
191
|
+
/**
|
|
192
|
+
* Whether to show a small gear button in the top-right corner that
|
|
193
|
+
* toggles column editing mode.
|
|
194
|
+
*
|
|
195
|
+
* For accessibility, it's recommended to enable this button unless you
|
|
196
|
+
* provide an external control for toggling column editing mode.
|
|
197
|
+
*/
|
|
198
|
+
columnEditButton?: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Applied to the `<thead>` element.
|
|
201
|
+
*/
|
|
202
|
+
theadClassName?: string;
|
|
203
|
+
/**
|
|
204
|
+
* Applied to the only `<tr>` element within the `<thead>`.
|
|
205
|
+
*/
|
|
206
|
+
theadTrClassName?: string;
|
|
207
|
+
/**
|
|
208
|
+
* Applied to the `<tbody>` element.
|
|
209
|
+
*/
|
|
210
|
+
tbodyClassName?: string;
|
|
211
|
+
}
|
|
212
|
+
export type SortOrder = Extract<AriaAttributes['aria-sort'], 'none' | 'ascending' | 'descending'>;
|
|
213
|
+
/**
|
|
214
|
+
* The column specification.
|
|
215
|
+
*/
|
|
216
|
+
export interface Column<T> {
|
|
217
|
+
/**
|
|
218
|
+
* Used as a key in the columns list.
|
|
219
|
+
*/
|
|
220
|
+
key: React.Key;
|
|
221
|
+
/**
|
|
222
|
+
* Used in `aria-label`s of column controls which do not contain text,
|
|
223
|
+
* such as the delete column button. If not set, the `String(key)` is used.
|
|
224
|
+
*/
|
|
225
|
+
name?: string;
|
|
226
|
+
/**
|
|
227
|
+
* Renders the content of the column header, excluding controls such as
|
|
228
|
+
* the sort and delete buttons. If not specified, the default behavior is
|
|
229
|
+
* `name ?? String(key)`.
|
|
230
|
+
*/
|
|
231
|
+
renderHeader?: () => ReactNode;
|
|
232
|
+
/**
|
|
233
|
+
* Renders the value of a single cell. If not specified, the default
|
|
234
|
+
* behavior is:
|
|
235
|
+
*
|
|
236
|
+
* - If `item` is an `Array`, renders `String(item[columnIndex])`
|
|
237
|
+
* - If `item` is an `Object`, renders `String(item[String(columnKey)])`
|
|
238
|
+
* - Otherwise:
|
|
239
|
+
* - The first column renders `String(item)`
|
|
240
|
+
* - Other columns render an empty string
|
|
241
|
+
*/
|
|
242
|
+
renderCell?: (item: T, index: number, items: readonly T[]) => ReactNode;
|
|
243
|
+
/**
|
|
244
|
+
* If the column gets an indent when `DefaultItemRendererProps.level` returns
|
|
245
|
+
* a positive number.
|
|
246
|
+
*/
|
|
247
|
+
indent?: boolean;
|
|
248
|
+
/**
|
|
249
|
+
* If set, displays sort button and includes `aria-sort` in the column header.
|
|
250
|
+
* Handle clicks with {@link TableProps.onSort}.
|
|
251
|
+
*/
|
|
252
|
+
sortOrder?: AriaAttributes['aria-sort'];
|
|
253
|
+
/**
|
|
254
|
+
* Whether to display a delete button in the column header.
|
|
255
|
+
* Handle delete requests with {@link TableProps.onColumnDelete}.
|
|
256
|
+
* Make sure {@link Column.name} or {@link Column.key} is meaningful,
|
|
257
|
+
* as it will be included in the `aria-label` of the delete button.
|
|
258
|
+
*/
|
|
259
|
+
deletable?: boolean;
|
|
260
|
+
/**
|
|
261
|
+
* Displays a reorder handle in the column header.
|
|
262
|
+
* Handle reorder requests with {@link TableProps.onColumnReorder}.
|
|
263
|
+
* If a function is provided, it determines whether the column may be moved
|
|
264
|
+
* to the specified insertion position.
|
|
265
|
+
*
|
|
266
|
+
* Make sure {@link Column.name} or {@link Column.key} is meaningful,
|
|
267
|
+
* as it will be included in the `aria-label` of the reorder button.
|
|
268
|
+
*/
|
|
269
|
+
canReorder?: boolean | ((insertionIndex: number, columns: readonly Column<T>[]) => boolean);
|
|
270
|
+
/**
|
|
271
|
+
* The class name to apply to the `th` element inside `table > thead`.
|
|
272
|
+
*/
|
|
273
|
+
thClassName?: string;
|
|
274
|
+
/**
|
|
275
|
+
* The class name to apply to the `td` element inside `table > tbody`.
|
|
276
|
+
* If a custom `TableProps.renderItem` is provided, this prop is not used,
|
|
277
|
+
* unless the custom renderer falls back to the `DefaultItemRenderer`.
|
|
278
|
+
*/
|
|
279
|
+
tdClassName?: string | ((item: T, index: number, items: readonly T[]) => string | undefined);
|
|
280
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|