@jetbrains/ring-ui 7.0.124 → 8.0.0-beta.10
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/babel.config.js +1 -9
- package/components/auth-dialog-service/auth-dialog-service.js +2 -2
- package/components/avatar/avatar-info.js +0 -2
- package/components/avatar/avatar-size.d.ts +0 -4
- package/components/avatar/avatar-size.js +0 -4
- package/components/avatar/avatar.js +0 -6
- package/components/avatar/fallback-avatar.js +0 -28
- package/components/avatar-stack/avatar-stack.js +1 -1
- package/components/button/button.css +4 -4
- package/components/button/button.d.ts +0 -4
- package/components/button/button.js +2 -7
- package/components/button-group/button-group.css +23 -23
- package/components/button-toolbar/button-toolbar.css +2 -2
- package/components/checkbox/checkbox.d.ts +1 -1
- package/components/collapse/collapse-content.js +7 -16
- package/components/collapse/collapse-context.d.ts +1 -0
- package/components/collapse/collapse-context.js +1 -0
- package/components/collapse/collapse-control.js +2 -2
- package/components/collapse/collapse.css +8 -2
- package/components/collapse/collapse.js +10 -2
- package/components/collapsible-group/collapsible-group.css +1 -1
- package/components/collapsible-group/collapsible-group.d.ts +5 -1
- package/components/collapsible-group/collapsible-group.js +13 -22
- package/components/confirm-service/confirm-service.js +2 -2
- package/components/contenteditable/contenteditable.js +1 -2
- package/components/data-list/data-list.d.ts +4 -4
- package/components/data-list/data-list.js +2 -2
- package/components/data-list/data-list.mock.d.ts +1 -1
- package/components/data-list/item.d.ts +1 -1
- package/components/data-list/selection.d.ts +1 -1
- package/components/data-list/selection.js +1 -1
- package/components/date-picker/month.d.ts +0 -2
- package/components/date-picker/month.js +5 -5
- package/components/date-picker/months.js +8 -7
- package/components/date-picker/use-scroll-behavior.js +5 -6
- package/components/date-picker/years.js +11 -10
- package/components/dialog/dialog.d.ts +2 -2
- package/components/dialog/dialog.js +2 -2
- package/components/dropdown-menu/dropdown-menu.d.ts +4 -4
- package/components/dropdown-menu/dropdown-menu.js +4 -4
- package/components/editable-heading/editable-heading.d.ts +1 -2
- package/components/editable-heading/editable-heading.js +5 -6
- package/components/global/compose-refs.d.ts +2 -1
- package/components/global/compose-refs.js +24 -8
- package/components/global/configuration.d.ts +0 -5
- package/components/global/configuration.js +0 -7
- package/components/global/create-stateful-context.js +5 -5
- 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 +46 -0
- package/components/global/intersection-observer-context.js +91 -0
- 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/rerender-hoc.d.ts +4 -2
- package/components/global/rerender-hoc.js +4 -4
- package/components/global/schedule-with-cleanup.d.ts +12 -0
- package/components/global/schedule-with-cleanup.js +34 -0
- package/components/{table/selection.d.ts → global/table-selection.d.ts} +15 -15
- package/components/{table/selection.js → global/table-selection.js} +3 -3
- package/components/global/theme.d.ts +4 -3
- package/components/global/theme.js +8 -8
- package/components/global/variables.css +0 -10
- package/components/global/variables.interface.d.ts +0 -4
- package/components/global/variables_dark.css +0 -7
- package/components/i18n/i18n-context.js +1 -1
- package/components/icon/icon-svg.js +2 -3
- package/components/icon/icon.css +0 -27
- package/components/icon/icon.d.ts +0 -1
- package/components/icon/icon.js +2 -4
- package/components/input/input.d.ts +1 -1
- package/components/island/adaptive-island-hoc.js +4 -4
- package/components/island/content.d.ts +7 -2
- package/components/island/content.js +5 -5
- package/components/{table → legacy-table}/cell.js +1 -1
- package/components/{table → legacy-table}/header-cell.js +1 -1
- package/components/{table → legacy-table}/header.js +1 -1
- package/components/legacy-table/legacy-table.css +260 -0
- package/components/{table → legacy-table}/multitable.d.ts +1 -1
- package/components/{table → legacy-table}/row.d.ts +1 -1
- package/components/{table → legacy-table}/row.js +1 -1
- package/components/legacy-table/selection-adapter.d.ts +6 -0
- package/components/{table → legacy-table}/selection-shortcuts-hoc.d.ts +5 -5
- package/components/{table → legacy-table}/simple-table.d.ts +2 -2
- package/components/{table → legacy-table}/simple-table.js +3 -3
- package/components/{table → legacy-table}/smart-table.d.ts +5 -5
- package/components/{table → legacy-table}/smart-table.js +3 -3
- package/components/legacy-table/table.d.ts +109 -0
- package/components/legacy-table/table.js +191 -0
- package/components/list/consts.d.ts +0 -1
- package/components/list/consts.js +0 -1
- package/components/list/list.d.ts +0 -4
- package/components/login-dialog/service.js +2 -2
- package/components/popup/popup.target.d.ts +3 -2
- package/components/popup/popup.target.js +4 -6
- package/components/query-assist/query-assist.d.ts +3 -1
- package/components/query-assist/query-assist.js +2 -2
- package/components/radio/radio-item.d.ts +3 -3
- package/components/radio/radio-item.js +3 -4
- package/components/radio/radio.d.ts +2 -2
- package/components/radio/radio.js +1 -1
- package/components/select/select-popup.d.ts +3 -2
- package/components/select/select-popup.js +3 -3
- package/components/select/select.d.ts +6 -2
- package/components/select/select.js +2 -4
- package/components/selection-toolbar/selection-toolbar.css +86 -0
- package/components/selection-toolbar/selection-toolbar.d.ts +11 -0
- package/components/selection-toolbar/selection-toolbar.js +23 -0
- package/components/slider/slider.js +4 -5
- package/components/tab-trap/tab-trap.d.ts +3 -3
- package/components/tab-trap/tab-trap.js +3 -5
- package/components/table/default-item-renderer.d.ts +55 -0
- package/components/table/default-item-renderer.js +77 -0
- package/components/table/internal/reorder-animation-context.d.ts +21 -0
- package/components/table/internal/reorder-animation-context.js +60 -0
- package/components/table/internal/reorder-handle.d.ts +9 -0
- package/components/table/internal/reorder-handle.js +334 -0
- package/components/table/internal/reorder-layout-context.d.ts +16 -0
- package/components/table/internal/reorder-layout-context.js +69 -0
- package/components/table/internal/table-header.d.ts +1 -0
- package/components/table/internal/table-header.js +143 -0
- package/components/table/internal/virtualization.d.ts +41 -0
- package/components/table/internal/virtualization.js +186 -0
- package/components/table/item-virtualization.d.ts +37 -0
- package/components/table/item-virtualization.js +26 -0
- package/components/table/reorder-animation.d.ts +37 -0
- package/components/table/reorder-animation.js +11 -0
- package/components/table/reorder-item-layout.d.ts +32 -0
- package/components/table/reorder-item-layout.js +23 -0
- package/components/table/table-const.d.ts +10 -0
- package/components/table/table-const.js +10 -0
- package/components/table/table-primitives.d.ts +64 -0
- package/components/table/table-primitives.js +34 -0
- package/components/table/table-props.d.ts +304 -0
- package/components/table/table-props.js +1 -0
- package/components/table/table.css +156 -167
- package/components/table/table.d.ts +231 -107
- package/components/table/table.js +319 -183
- package/components/tags-input/tags-input.d.ts +3 -1
- package/components/tooltip/tooltip.d.ts +2 -1
- package/components/tooltip/tooltip.js +6 -5
- package/components/upload/upload.d.ts +4 -3
- package/components/upload/upload.js +3 -7
- package/components/user-agreement/service.js +2 -2
- package/components/util-stories.d.ts +26 -0
- package/components/util-stories.js +61 -0
- package/package.json +45 -48
- package/components/content-layout/content-layout.css +0 -109
- package/components/content-layout/content-layout.d.ts +0 -20
- package/components/content-layout/content-layout.js +0 -40
- package/components/content-layout/sidebar.d.ts +0 -26
- package/components/content-layout/sidebar.js +0 -71
- package/components/date-picker/use-intersection-observer.d.ts +0 -6
- package/components/date-picker/use-intersection-observer.js +0 -48
- package/components/expand/collapsible-group.css +0 -76
- package/components/expand/collapsible-group.d.ts +0 -8
- package/components/expand/collapsible-group.js +0 -14
- package/components/global/composeRefs.d.ts +0 -6
- package/components/global/composeRefs.js +0 -7
- package/components/global/use-event-callback.d.ts +0 -4
- package/components/global/use-event-callback.js +0 -20
- package/components/grid/col.d.ts +0 -16
- package/components/grid/col.js +0 -35
- package/components/grid/grid.css +0 -920
- package/components/grid/grid.d.ts +0 -13
- package/components/grid/grid.js +0 -19
- package/components/grid/row.d.ts +0 -21
- package/components/grid/row.js +0 -41
- package/components/old-browsers-message/__mocks__/old-browsers-message.js +0 -1
- package/components/old-browsers-message/old-browsers-message-stop.d.ts +0 -1
- package/components/old-browsers-message/old-browsers-message-stop.js +0 -2
- package/components/old-browsers-message/old-browsers-message.css +0 -26
- package/components/old-browsers-message/old-browsers-message.d.ts +0 -5
- package/components/old-browsers-message/old-browsers-message.js +0 -86
- package/components/old-browsers-message/white-list.d.ts +0 -2
- package/components/old-browsers-message/white-list.js +0 -24
- package/components/table/selection-adapter.d.ts +0 -6
- /package/components/{table → legacy-table}/cell.d.ts +0 -0
- /package/components/{table → legacy-table}/disable-hover-hoc.d.ts +0 -0
- /package/components/{table → legacy-table}/disable-hover-hoc.js +0 -0
- /package/components/{table → legacy-table}/header-cell.d.ts +0 -0
- /package/components/{table → legacy-table}/header.d.ts +0 -0
- /package/components/{table → legacy-table}/multitable.js +0 -0
- /package/components/{table → legacy-table}/row-with-focus-sensor.d.ts +0 -0
- /package/components/{table → legacy-table}/row-with-focus-sensor.js +0 -0
- /package/components/{table → legacy-table}/selection-adapter.js +0 -0
- /package/components/{table → legacy-table}/selection-shortcuts-hoc.js +0 -0
- /package/components/{table → legacy-table}/table.examples2.json +0 -0
|
@@ -1,109 +1,233 @@
|
|
|
1
|
+
import React, { type ComponentPropsWithRef } from 'react';
|
|
2
|
+
import type { TableProps } from './table-props';
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
4
|
+
* Table component replacing the tables in the `legacy-table` folder.
|
|
5
|
+
*
|
|
6
|
+
* This documentation provides an overview of the most common usage patterns.
|
|
7
|
+
* See individual props and exported components for detailed behavior.
|
|
8
|
+
*
|
|
9
|
+
* ## Minimal usage
|
|
10
|
+
*
|
|
11
|
+
* You need the following props:
|
|
12
|
+
* - `data`
|
|
13
|
+
* - `getKey`
|
|
14
|
+
* - `columns`
|
|
15
|
+
* - `key`
|
|
16
|
+
* - `name` (optional but needed in most cases)
|
|
17
|
+
* - `renderCell` (optional but needed in most cases)
|
|
18
|
+
*
|
|
19
|
+
* ## Item rendering
|
|
20
|
+
*
|
|
21
|
+
* If `renderItem` is not specified, each item is rendered using
|
|
22
|
+
* `DefaultItemRenderer` (from `table/default-item-renderer`)
|
|
23
|
+
* as if the following code were used:
|
|
24
|
+
*
|
|
25
|
+
* ```tsx
|
|
26
|
+
* <Table
|
|
27
|
+
* renderItem={(_item, index, _items) => (
|
|
28
|
+
* <DefaultItemRenderer index={index} />
|
|
29
|
+
* )}
|
|
30
|
+
* />
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* `DefaultItemRenderer` renders a table row using the column definitions
|
|
34
|
+
* (`Column.renderCell`) and provides built-in support for features such as
|
|
35
|
+
* selection, keyboard navigation, and virtualization. It also accepts all
|
|
36
|
+
* standard `tr` attributes, including `ref`.
|
|
37
|
+
*
|
|
38
|
+
* Use `renderItem` to configure `DefaultItemRenderer` for each item:
|
|
39
|
+
*
|
|
40
|
+
* ```tsx
|
|
41
|
+
* <Table
|
|
42
|
+
* renderItem={(item, index, items) => (
|
|
43
|
+
* <DefaultItemRenderer
|
|
44
|
+
* index={index}
|
|
45
|
+
* keyboardFocusable
|
|
46
|
+
* className='my-item'
|
|
47
|
+
* onClick={e => handleClick(e, item, items)}
|
|
48
|
+
* />
|
|
49
|
+
* )}
|
|
50
|
+
* />
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* If you need complete control over rendering, `renderItem` can instead
|
|
54
|
+
* return your own table rows. See "Custom item rendering" below.
|
|
55
|
+
*
|
|
56
|
+
* ## Selection
|
|
57
|
+
*
|
|
58
|
+
* Selection is typically implemented using the following props
|
|
59
|
+
* of the `DefaultItemRenderer`:
|
|
60
|
+
*
|
|
61
|
+
* - `clickable`
|
|
62
|
+
* - `selected`
|
|
63
|
+
* - `onClick` or `onPointerUp`, etc.
|
|
64
|
+
*
|
|
65
|
+
* The following utilities (from `global`) may come in handy:
|
|
66
|
+
*
|
|
67
|
+
* - `TableSelection` class to manage selection state
|
|
68
|
+
* - An alternative approach is to keep a `selected` field on each item
|
|
69
|
+
* - `isWithinInteractiveElement()` to check if a click was made on a control
|
|
70
|
+
* or on "empty space"
|
|
71
|
+
*
|
|
72
|
+
* ```tsx
|
|
73
|
+
* <Table
|
|
74
|
+
* renderItem={(item, index) => (
|
|
75
|
+
* <DefaultItemRenderer
|
|
76
|
+
* index={index}
|
|
77
|
+
* clickable
|
|
78
|
+
* selected={selection.isSelected(item)}
|
|
79
|
+
* onClick={e => {
|
|
80
|
+
* if (!isWithinInteractiveElement(e)) {
|
|
81
|
+
* setSelection(selection.toggleSelection(item));
|
|
82
|
+
* }
|
|
83
|
+
* }}
|
|
84
|
+
* />
|
|
85
|
+
* )}
|
|
86
|
+
* />
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* Note that for accessibility reasons, you should have a cell with a checkbox
|
|
90
|
+
* to display and toggle item selection.
|
|
91
|
+
*
|
|
92
|
+
* ## Row focus
|
|
93
|
+
*
|
|
94
|
+
* The table implements the ["roving tabindex"](https://developer.mozilla.org/en-US/docs/Web/Accessibility/Guides/Keyboard-navigable_JavaScript_widgets#technique_1_roving_tabindex)
|
|
95
|
+
* technique to focus rows with the up/down arrow keys.
|
|
96
|
+
* Rows can also be focused on click or other pointer events.
|
|
97
|
+
* To support it, use the following props of the `DefaultItemRenderer`:
|
|
98
|
+
*
|
|
99
|
+
* - `keyboardFocusable`
|
|
100
|
+
* - `clickable`, if you want to react to hover
|
|
101
|
+
* - `onClick`, if you want to focus on click
|
|
102
|
+
*
|
|
103
|
+
* Useful utils:
|
|
104
|
+
* - `focusWithTemporaryTabIndex()` from `global` to focus a row temporarily
|
|
105
|
+
* patching its `tabindex`.
|
|
106
|
+
*
|
|
107
|
+
* ```tsx
|
|
108
|
+
* <Table
|
|
109
|
+
* renderItem={(item, index) => (
|
|
110
|
+
* <DefaultItemRenderer
|
|
111
|
+
* index={index}
|
|
112
|
+
* clickable
|
|
113
|
+
* keyboardFocusable
|
|
114
|
+
* onClick={e => {
|
|
115
|
+
* if (!isWithinInteractiveElement(e)) {
|
|
116
|
+
* focusWithTemporaryTabIndex(e.currentTarget);
|
|
117
|
+
* }
|
|
118
|
+
* }}
|
|
119
|
+
* />
|
|
120
|
+
* )}
|
|
121
|
+
* />
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* Note that the table does not implement standard accessibility patterns such
|
|
125
|
+
* as `grid` or `treegrid`, so row focus is not announced by screen readers.
|
|
126
|
+
* Make sure all essential actions remain available without row focus, for
|
|
127
|
+
* example via standard Tab navigation.
|
|
128
|
+
*
|
|
129
|
+
* ## Sorting
|
|
130
|
+
*
|
|
131
|
+
* You need the following to support sorting:
|
|
132
|
+
*
|
|
133
|
+
* - Set `Column.sortOrder` to `'none'`, `'ascending'` or `'descending'`
|
|
134
|
+
* to render the sort button, `aria-sort`, and indicate the current
|
|
135
|
+
* sort order.
|
|
136
|
+
* - Handle `TableProps.onSort` callback in the client code.
|
|
137
|
+
*
|
|
138
|
+
* ## Deleting columns
|
|
139
|
+
*
|
|
140
|
+
* You need the following to support deleting columns:
|
|
141
|
+
*
|
|
142
|
+
* - Set `Column.deletable` to `true`. This will render a delete button in the
|
|
143
|
+
* column header.
|
|
144
|
+
* - Make sure the `column` has a proper `name` or `key` prop, which will be
|
|
145
|
+
* automatically included in the aria-label of the column delete button.
|
|
146
|
+
* - Handle `TableProps.onColumnDelete` callback in the client code. It is
|
|
147
|
+
* expected to update `columns` by removing the corresponding column.
|
|
148
|
+
*
|
|
149
|
+
* ## Moving columns
|
|
150
|
+
*
|
|
151
|
+
* - Set `Column.canReorder` to `true` or to predicate specifying possible
|
|
152
|
+
* insertion targets.
|
|
153
|
+
* This will render a reorder button in the column header.
|
|
154
|
+
* - Make sure the `column` has a proper `name` or `key` prop, which will be
|
|
155
|
+
* automatically included in the aria-label of the column reorder button.
|
|
156
|
+
* - Handle `TableProps.onColumnReorder` callback in the client code. It is
|
|
157
|
+
* expected to update `columns` by moving the corresponding column to the
|
|
158
|
+
* new position.
|
|
159
|
+
*
|
|
160
|
+
* ## Item reorder
|
|
161
|
+
*
|
|
162
|
+
* To allow the user to reorder rows by dragging:
|
|
163
|
+
*
|
|
164
|
+
* - Place `ItemReorderHandle` (from `table/table-primitives`) anywhere inside
|
|
165
|
+
* a cell. It renders a drag icon button the user can grab to reorder the row.
|
|
166
|
+
* - Handle `TableProps.onItemReorder`. It is expected to update `data` by
|
|
167
|
+
* moving the item to the new position.
|
|
168
|
+
* - Optionally, set `TableProps.canReorderItem` to restrict which positions
|
|
169
|
+
* an item may be dropped into.
|
|
170
|
+
*
|
|
171
|
+
* By default, dragging shows a drag frame (a border around the dragged row)
|
|
172
|
+
* and an insertion indicator (a line between rows showing where the item will
|
|
173
|
+
* land). To implement fully custom drag visuals, set `noDragFrame` and
|
|
174
|
+
* `noHandleTranslate` on `ItemReorderHandle` and use its `onUserDrag` callback
|
|
175
|
+
* to track the drag lifecycle.
|
|
176
|
+
*
|
|
177
|
+
* ## Row virtualization
|
|
178
|
+
*
|
|
179
|
+
* To render only rows near the viewport while replacing off-screen rows with
|
|
180
|
+
* spacers, use:
|
|
181
|
+
*
|
|
182
|
+
* - `virtualizeRows` prop set to `true`
|
|
183
|
+
* - `scrollerRef` — required when the scrollable container is not the whole
|
|
184
|
+
* document
|
|
185
|
+
* - `estimateHeight` — recommended when rows are expected to be taller than
|
|
186
|
+
* the default height (e.g. multiline or custom content)
|
|
187
|
+
* - Fine-tuning props: `lookaheadPx`, `retentionMarginPx`,
|
|
188
|
+
* `minScrollAndResizeDeltaPx`
|
|
189
|
+
*
|
|
190
|
+
* ## Custom item rendering
|
|
191
|
+
*
|
|
192
|
+
* Use the `renderItem` prop to render an item in a completely custom way.
|
|
193
|
+
* The prop is expected to return one or more table rows for the item.
|
|
194
|
+
* Use `TableRow` and `TableCell` from `table/table-primitives` to apply
|
|
195
|
+
* the default row and cell styles.
|
|
196
|
+
*
|
|
197
|
+
* ### Focus
|
|
198
|
+
*
|
|
199
|
+
* Just like `DefaultItemRenderer`, `TableRow` accepts the
|
|
200
|
+
* `keyboardFocusable` prop.
|
|
201
|
+
*
|
|
202
|
+
* Focusable rows rendered by either component form a single keyboard
|
|
203
|
+
* navigation sequence.
|
|
204
|
+
*
|
|
205
|
+
* ### Virtualization
|
|
206
|
+
*
|
|
207
|
+
* If `Table.virtualizeRows` is set to `true`, you need to handle visibility
|
|
208
|
+
* for your custom-rendered component yourself with the
|
|
209
|
+
* `useItemVirtualization()` hook (from `table/item-virtualization`). The hook
|
|
210
|
+
* allows observing the intersection of one or multiple elements rendered for
|
|
211
|
+
* the item, and, based on their intersection status, reporting the item as
|
|
212
|
+
* eligible for virtualization.
|
|
213
|
+
*
|
|
214
|
+
* If you use `DefaultItemRenderer` as part of your custom row renderer,
|
|
215
|
+
* set the `noItemVirtualization` prop to `true`, otherwise it will also try
|
|
216
|
+
* to control the virtualization, possibly reporting incorrect item height.
|
|
217
|
+
*
|
|
218
|
+
* ### Item reorder
|
|
219
|
+
*
|
|
220
|
+
* If `TableProps.onItemReorder` is set and your item spans multiple rows, call
|
|
221
|
+
* `useReorderItemLayout()` (from `table/reorder-item-layout`) to register the
|
|
222
|
+
* item's boundaries so the insertion indicator and insertion point calculation
|
|
223
|
+
* are correct. If `DefaultItemRenderer` is included inside your custom renderer,
|
|
224
|
+
* set its `noReorderLayout` prop to `true` to prevent double registration.
|
|
225
|
+
*
|
|
226
|
+
* ### Reorder animation
|
|
227
|
+
*
|
|
228
|
+
* After a column or item is reordered, the table briefly highlights the moved
|
|
229
|
+
* element. To apply the same animation in your custom-rendered rows, use
|
|
230
|
+
* `useReorderAnimation()` (from `table/reorder-animation`) to get information
|
|
231
|
+
* about the currently animated column or item.
|
|
3
232
|
*/
|
|
4
|
-
|
|
5
|
-
import * as React from 'react';
|
|
6
|
-
import { type OnChangeMeta } from 'react-movable/lib/types';
|
|
7
|
-
import { type FocusSensorAddProps, type FocusSensorProps } from '../global/focus-sensor-hoc';
|
|
8
|
-
import { type SelectionShortcutsAddProps, type SelectionShortcutsProps } from './selection-shortcuts-hoc';
|
|
9
|
-
import { type DisableHoverAddProps, type DisableHoverProps } from './disable-hover-hoc';
|
|
10
|
-
import Row from './row-with-focus-sensor';
|
|
11
|
-
import { type Column, type SortParams } from './header-cell';
|
|
12
|
-
export interface ReorderParams<T> {
|
|
13
|
-
data: T[];
|
|
14
|
-
oldIndex: number;
|
|
15
|
-
newIndex: number;
|
|
16
|
-
}
|
|
17
|
-
export interface TableProps<T extends object> extends FocusSensorAddProps<HTMLTableRowElement>, SelectionShortcutsAddProps<T>, DisableHoverAddProps {
|
|
18
|
-
data: readonly T[];
|
|
19
|
-
columns: readonly Column<T>[] | ((item: T | null) => readonly Column<T>[]);
|
|
20
|
-
isItemSelectable: (item: T) => boolean;
|
|
21
|
-
loading: boolean;
|
|
22
|
-
onSort: (params: SortParams) => void;
|
|
23
|
-
onReorder: (params: ReorderParams<T>) => void;
|
|
24
|
-
getItemKey: (item: T) => string | number;
|
|
25
|
-
sortKey: string;
|
|
26
|
-
sortOrder: boolean;
|
|
27
|
-
draggable: boolean;
|
|
28
|
-
alwaysShowDragHandle: boolean;
|
|
29
|
-
dragHandleTitle?: string;
|
|
30
|
-
stickyHeader: boolean;
|
|
31
|
-
wideFirstColumn: boolean;
|
|
32
|
-
getItemLevel: (item: T) => number;
|
|
33
|
-
getItemClassName: (item: T) => string | null | undefined;
|
|
34
|
-
getMetaColumnClassName: (item: T) => string | null | undefined;
|
|
35
|
-
getItemDataTest: (item: T) => string | null | undefined;
|
|
36
|
-
isItemCollapsible: (item: T) => boolean;
|
|
37
|
-
isParentCollapsible: (item: T) => boolean;
|
|
38
|
-
isItemCollapsed: (item: T) => boolean;
|
|
39
|
-
onItemCollapse: (item: T) => void;
|
|
40
|
-
onItemExpand: (item: T) => void;
|
|
41
|
-
onItemDoubleClick: (item: T) => void;
|
|
42
|
-
onItemClick: (item: T, e: React.MouseEvent<HTMLTableRowElement>) => void;
|
|
43
|
-
remoteSelection: boolean;
|
|
44
|
-
isDisabledSelectionVisible: (item: T) => boolean;
|
|
45
|
-
getCheckboxTooltip: (item: T) => string | undefined;
|
|
46
|
-
className?: string | null | undefined;
|
|
47
|
-
wrapperClassName?: string | null | undefined;
|
|
48
|
-
headerClassName?: string | null | undefined;
|
|
49
|
-
cellClassName?: string | null | undefined;
|
|
50
|
-
loaderClassName?: string | undefined;
|
|
51
|
-
caption?: string | null | undefined;
|
|
52
|
-
stickyHeaderOffset?: string | undefined;
|
|
53
|
-
renderEmpty?: (() => ReactNode) | null | undefined;
|
|
54
|
-
RowComponent: typeof Row;
|
|
55
|
-
renderLoader?: ((loaderClassName?: string) => ReactNode) | null | undefined;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Interactive table with selection and keyboard navigation support.
|
|
59
|
-
*/
|
|
60
|
-
export declare class Table<T extends object> extends PureComponent<TableProps<T>> {
|
|
61
|
-
static defaultProps: {
|
|
62
|
-
isItemSelectable: () => boolean;
|
|
63
|
-
loading: boolean;
|
|
64
|
-
onSort: () => void;
|
|
65
|
-
onReorder: () => void;
|
|
66
|
-
getItemKey: (item: object) => string | number;
|
|
67
|
-
sortKey: string;
|
|
68
|
-
sortOrder: boolean;
|
|
69
|
-
draggable: boolean;
|
|
70
|
-
alwaysShowDragHandle: boolean;
|
|
71
|
-
stickyHeader: boolean;
|
|
72
|
-
getItemLevel: () => number;
|
|
73
|
-
getItemClassName: () => null;
|
|
74
|
-
getMetaColumnClassName: () => null;
|
|
75
|
-
getItemDataTest: () => null;
|
|
76
|
-
isItemCollapsible: () => boolean;
|
|
77
|
-
isParentCollapsible: () => boolean;
|
|
78
|
-
isItemCollapsed: () => boolean;
|
|
79
|
-
onItemCollapse: () => void;
|
|
80
|
-
onItemExpand: () => void;
|
|
81
|
-
onItemDoubleClick: () => void;
|
|
82
|
-
onItemClick: () => void;
|
|
83
|
-
remoteSelection: boolean;
|
|
84
|
-
isDisabledSelectionVisible: () => boolean;
|
|
85
|
-
getCheckboxTooltip: () => undefined;
|
|
86
|
-
RowComponent: typeof Row;
|
|
87
|
-
wideFirstColumn: boolean;
|
|
88
|
-
};
|
|
89
|
-
state: {
|
|
90
|
-
shortcutsScope: string;
|
|
91
|
-
userSelectNone: boolean;
|
|
92
|
-
};
|
|
93
|
-
componentDidMount(): void;
|
|
94
|
-
componentDidUpdate({ data, selection, onSelect, selectable, remoteSelection }: TableProps<T>): void;
|
|
95
|
-
componentWillUnmount(): void;
|
|
96
|
-
onMouseDown: (e: React.MouseEvent) => void;
|
|
97
|
-
onMouseUp: () => void;
|
|
98
|
-
onRowFocus: (row: T) => void;
|
|
99
|
-
onRowSelect: (row: T, selected: boolean) => void;
|
|
100
|
-
onSortEnd: ({ oldIndex, newIndex }: OnChangeMeta) => void;
|
|
101
|
-
onCheckboxChange: (e: SyntheticEvent<HTMLInputElement>) => void;
|
|
102
|
-
restoreFocusWithoutScroll: () => void;
|
|
103
|
-
render(): React.JSX.Element;
|
|
104
|
-
}
|
|
105
|
-
export type TableAttrs<T extends object> = DisableHoverProps<SelectionShortcutsProps<T, FocusSensorProps<TableProps<T>, HTMLTableRowElement, typeof Table>>>;
|
|
106
|
-
export default class TableContainer<T extends object> extends Component<TableAttrs<T>> {
|
|
107
|
-
Table: React.ComponentClass<DisableHoverProps<SelectionShortcutsProps<T, FocusSensorProps<TableProps<T>, HTMLTableRowElement, typeof Table>>>, any>;
|
|
108
|
-
render(): React.JSX.Element;
|
|
109
|
-
}
|
|
233
|
+
export default function Table<T>(props: TableProps<T> & ComponentPropsWithRef<'table'>): React.JSX.Element;
|