@jetbrains/ring-ui 7.0.115 → 8.0.0-beta.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.
Files changed (54) hide show
  1. package/components/data-list/data-list.d.ts +4 -4
  2. package/components/data-list/data-list.js +2 -2
  3. package/components/data-list/data-list.mock.d.ts +1 -1
  4. package/components/data-list/item.d.ts +1 -1
  5. package/components/data-list/selection.d.ts +1 -1
  6. package/components/data-list/selection.js +1 -1
  7. package/components/date-picker/month.d.ts +0 -2
  8. package/components/date-picker/month.js +5 -5
  9. package/components/date-picker/months.js +8 -7
  10. package/components/date-picker/years.js +11 -10
  11. package/components/global/intersection-observer-context.d.ts +26 -0
  12. package/components/global/intersection-observer-context.js +72 -0
  13. package/components/{table → legacy-table}/selection.d.ts +2 -2
  14. package/components/{table → legacy-table}/selection.js +1 -1
  15. package/components/legacy-table/table.css +260 -0
  16. package/components/legacy-table/table.d.ts +109 -0
  17. package/components/legacy-table/table.js +191 -0
  18. package/components/table/default-item-renderer.d.ts +25 -0
  19. package/components/table/default-item-renderer.js +64 -0
  20. package/components/table/table-base.d.ts +24 -0
  21. package/components/table/table-base.js +79 -0
  22. package/components/table/table-component.d.ts +53 -0
  23. package/components/table/table-component.js +101 -0
  24. package/components/table/table-const.d.ts +8 -0
  25. package/components/table/table-const.js +8 -0
  26. package/components/table/table-virtualize.d.ts +32 -0
  27. package/components/table/table-virtualize.js +150 -0
  28. package/components/table/table.css +76 -199
  29. package/components/table/table.d.ts +221 -104
  30. package/components/table/table.js +2 -191
  31. package/package.json +1 -1
  32. /package/components/{table → legacy-table}/cell.d.ts +0 -0
  33. /package/components/{table → legacy-table}/cell.js +0 -0
  34. /package/components/{table → legacy-table}/disable-hover-hoc.d.ts +0 -0
  35. /package/components/{table → legacy-table}/disable-hover-hoc.js +0 -0
  36. /package/components/{table → legacy-table}/header-cell.d.ts +0 -0
  37. /package/components/{table → legacy-table}/header-cell.js +0 -0
  38. /package/components/{table → legacy-table}/header.d.ts +0 -0
  39. /package/components/{table → legacy-table}/header.js +0 -0
  40. /package/components/{table → legacy-table}/multitable.d.ts +0 -0
  41. /package/components/{table → legacy-table}/multitable.js +0 -0
  42. /package/components/{table → legacy-table}/row-with-focus-sensor.d.ts +0 -0
  43. /package/components/{table → legacy-table}/row-with-focus-sensor.js +0 -0
  44. /package/components/{table → legacy-table}/row.d.ts +0 -0
  45. /package/components/{table → legacy-table}/row.js +0 -0
  46. /package/components/{table → legacy-table}/selection-adapter.d.ts +0 -0
  47. /package/components/{table → legacy-table}/selection-adapter.js +0 -0
  48. /package/components/{table → legacy-table}/selection-shortcuts-hoc.d.ts +0 -0
  49. /package/components/{table → legacy-table}/selection-shortcuts-hoc.js +0 -0
  50. /package/components/{table → legacy-table}/simple-table.d.ts +0 -0
  51. /package/components/{table → legacy-table}/simple-table.js +0 -0
  52. /package/components/{table → legacy-table}/smart-table.d.ts +0 -0
  53. /package/components/{table → legacy-table}/smart-table.js +0 -0
  54. /package/components/{table → legacy-table}/table.examples2.json +0 -0
@@ -1,109 +1,226 @@
1
- /**
2
- * @name Table
3
- */
4
- import { Component, PureComponent, type ReactNode, type SyntheticEvent } from 'react';
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> {
1
+ import Table from './table-component';
2
+ import type { ReactNode, RefObject } from 'react';
3
+ import type Selection from '../legacy-table/selection';
4
+ export default Table;
5
+ export interface TableProps<T> {
6
+ /**
7
+ * The data items to render. `null` and `undefined` as an item is not supported.
8
+ * Referentially same items are not supported either.
9
+ */
13
10
  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;
11
+ /**
12
+ * Columns specification.
13
+ */
14
+ columns: Column<T>[];
15
+ /**
16
+ * Used to render a row key, e.g. `<tr key={getKey(item, index)}>`.
17
+ */
18
+ getKey: (item: T, index: number) => React.Key;
19
+ /**
20
+ * Displays the selection and focus state.
21
+ */
22
+ selection?: Selection<T>;
23
+ /**
24
+ * If true, the item can be focused by keyboard up/down arrows.
25
+ * Note that `false` doesn't prevent from `selection.focus()`.
26
+ */
27
+ isItemKeyboardFocusable?: (item: T, index: number, items: T[]) => boolean;
28
+ /**
29
+ * When the item should get focused by keyboard navigation.
30
+ * The client is expected to update `selection`.
31
+ */
32
+ onItemFocus?: (item: T | null, index: number, items: T[]) => void;
33
+ /**
34
+ * Called when the client moves a row by dragging it.
35
+ */
36
+ onItemMove?: (item: T, fromIndex: number, toIndex: number, items: T[]) => void;
37
+ /**
38
+ * Called when the client clicks on SortButton in a column header.
39
+ */
40
+ onSort?: (columnIndex: number, newOrder: SortOrder) => void;
41
+ /**
42
+ * Called when the client clicks on a column delete button in the header.
43
+ */
44
+ onColumnDelete?: (columnIndex: number) => void;
45
+ /**
46
+ * Called when the client moves a column.
47
+ */
48
+ onColumnMove?: (fromIndex: number, toIndex: number) => void;
49
+ /**
50
+ * Implement to specify props like `clickable`, handlers like `onClick`,
51
+ * a custom `className`, a `ref` etc., or to provide a custom renderer.
52
+ *
53
+ * ```tsx
54
+ * <Table
55
+ * renderItem={(item, index) => (
56
+ * <DefaultItemRenderer
57
+ * index={index}
58
+ * className='my-row'
59
+ * clickable
60
+ * onClick={() => setSelection(selection.focus(item))}
61
+ * />
62
+ * )}
63
+ * />
64
+ * ```
65
+ *
66
+ * In your custom implementation, use `TableRow` and `TableCell` base components to apply the
67
+ * standard classnames, but beware that `tdClassName` won't be applied.
68
+ *
69
+ * You can also use `DefaultItemRenderer` in combination with your custom rows.
70
+ */
71
+ renderItem?: (item: T, index: number, items: T[]) => ReactNode;
72
+ /**
73
+ * Only renders rows near the viewport.
74
+ *
75
+ * Rows may transition between two states:
76
+ * - materialized: rendered as actual table rows. This happens when the corresponding
77
+ * spacer approaches the viewport, as specified by `lookaheadPx`.
78
+ * - virtualized: replaced with spacer rows of the same height. This happens when the row
79
+ * moves sufficiently far from the viewport, as specified by `retentionMarginPx`.
80
+ */
81
+ virtualizeRows?: boolean;
82
+ /**
83
+ * Used with `virtualizeRows` as a source of scroll events, as a target for ResizeObserver,
84
+ * and as the root for IntersectionObserver. Required when the scrollable container is not
85
+ * the whole document.
86
+ *
87
+ * If not set:
88
+ * - scroll listener is attached to `window`
89
+ * - ResizeObserver observes `document.body`
90
+ * - IntersectionObserver has no root (i.e. the viewport is used)
91
+ */
92
+ scrollerRef?: React.RefObject<HTMLElement | null>;
93
+ /**
94
+ * Used with `virtualizeRows` to estimate the height of items that have not been rendered yet.
95
+ * The function should be fast and side-effect free. Do not measure the DOM here.
96
+ * Once a row is rendered, its actual height will be measured and used instead of this estimate.
97
+ *
98
+ * Note the effects of imprecise estimates:
99
+ * - When the height is underestimated, the table may materialize more rows than specified by `lookaheadPx`.
100
+ * If the resulting rows extend beyond `retentionMarginPx`, they will be virtualized again.
101
+ * If this causes relayout flickering, increase `retentionMarginPx`.
102
+ * - When the height is overestimated, the table may materialize fewer rows than specified by `lookaheadPx`,
103
+ * which may leave a spacer partially visible. To avoid this, increase `lookaheadPx` (and
104
+ * `retentionMarginPx` accordingly, since it should be greater than `lookaheadPx`).
105
+ *
106
+ * Default: 37px = 16px padding + 20px line height + 1px border.
107
+ */
108
+ estimateHeight?: (index: number) => number;
109
+ /**
110
+ * When using `virtualizeRows`, the number of pixels above and below the viewport
111
+ * to materialize in advance.
112
+ *
113
+ * Increase this value if blank space becomes visible during fast scrolling.
114
+ *
115
+ * Default: 400px.
116
+ */
117
+ lookaheadPx?: number;
118
+ /**
119
+ * Used with `virtualizeRows`. Additional margin around the viewport before
120
+ * materialized rows become eligible for virtualization.
121
+ *
122
+ * Increasing this value reduces row churn when heights are underestimated.
123
+ * In that case, the table may materialize more rows than needed and then immediately
124
+ * virtualize them again. A larger margin keeps such rows rendered for longer,
125
+ * at the cost of rendering more rows overall.
126
+ *
127
+ * This value should be greater than `lookaheadPx`.
128
+ * Increase it if you notice table relayouts during initial render or scrolling.
129
+ *
130
+ * Default: 450px.
131
+ */
132
+ retentionMarginPx?: number;
133
+ /**
134
+ * When using `virtualizeRows`, ignore scroll and resize position changes
135
+ * smaller than this value.
136
+ *
137
+ * Measurement inaccuracies and rounding artifacts may slightly change the
138
+ * table layout during materialization and virtualization. With scroll
139
+ * anchoring enabled (the default browser behavior), the browser may then
140
+ * adjust the scroll position, triggering additional scroll or resize events.
141
+ * Small deltas are ignored to prevent such feedback loops from causing
142
+ * oscillations at virtualization boundaries.
143
+ *
144
+ * Increase if you expect high inaccuracy in height measurements, or if you
145
+ * notice oscillations at virtualization boundaries.
146
+ *
147
+ * Default: 50px.
148
+ */
149
+ minScrollAndResizeDeltaPx?: number;
150
+ /**
151
+ * Whether to show a small gear button at the top right corner.
152
+ */
153
+ columnEditButton?: 'everywhere' | 'mobileOnly';
154
+ /**
155
+ * Optional ref to install on the table element.
156
+ */
157
+ ref?: RefObject<HTMLTableElement | null>;
158
+ /**
159
+ * Applied to the `<thead>` element.
160
+ */
161
+ theadClassName?: string;
162
+ /**
163
+ * Applied to the only `<tr>` element within the `<thead>`.
164
+ */
165
+ theadTrClassName?: string;
166
+ /**
167
+ * Applied to the `<tbody>` element.
168
+ */
169
+ tbodyClassName?: string;
56
170
  }
171
+ export type SortOrder = 'none' | 'ascending' | 'descending';
57
172
  /**
58
- * Interactive table with selection and keyboard navigation support.
173
+ * The column specification.
59
174
  */
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;
175
+ export interface Column<T> {
176
+ /**
177
+ * Used to render a row key, e.g. `<thead><tr><td key={getKey(item, index)}...</td></tr></thead>`.
178
+ */
179
+ key: React.Key;
180
+ /**
181
+ * Used in aria-labels of controls which do not contain text,
182
+ * e.g. `DeleteColumnButton`. If not set, the `String(key)` is used.
183
+ */
184
+ name?: string;
185
+ /**
186
+ * Default: name ?? String(key)
187
+ */
188
+ renderHeader?: () => ReactNode;
189
+ /**
190
+ * Renders a single cell value for a column.
191
+ * Default:
192
+ * - If item is an Array, renders `String(item[columnIndex])`
193
+ * - If item is an Object, renders `Object.values(item)[columnIndex]`
194
+ * - Otherwise:
195
+ * - The first column renders `String(item)`
196
+ * - Other columns render empty value
197
+ */
198
+ renderCell?: (item: T, index: number, items: T[]) => ReactNode;
199
+ /**
200
+ * If the column gets an indent when `TableProps.getItemLevel()` returns
201
+ * a positive number.
202
+ */
203
+ indent?: boolean;
204
+ /**
205
+ * The current sort order displayed by `SortButton` and indicated
206
+ * by `aria-sort` in `th`.
207
+ *
208
+ * - `undefined` or not set means that the column is not sortable,
209
+ * and it shouldn't have a `SortButton`.
210
+ * - `none` means that the column is sortable, but currently not sorted.
211
+ * It should include a `SortButton`.
212
+ * - `ascending` and `descending` mean that the column is sorted
213
+ * in the corresponding order, and it should include a `SortButton`.
214
+ */
215
+ sortOrder?: SortOrder;
216
+ /**
217
+ * The classname to apply to the `th` element inside `table / thead`.
218
+ */
219
+ thClassName?: string;
220
+ /**
221
+ * The classname to apply to the `td` element inside `table / tbody`.
222
+ * If a custom `TableProps.renderItem` is provided, this prop is not used,
223
+ * unless the custom renderer falls back to `DefaultItemRenderer`.
224
+ */
225
+ tdClassName?: (item: T, index: number, items: T[]) => string | undefined;
109
226
  }
@@ -1,191 +1,2 @@
1
- /**
2
- * @name Table
3
- */
4
- import { Component, PureComponent } from 'react';
5
- import * as React from 'react';
6
- import classNames from 'classnames';
7
- import { arrayMove, List } from 'react-movable';
8
- import focusSensorHOC from '../global/focus-sensor-hoc';
9
- import getUID from '../global/get-uid';
10
- import Shortcuts from '../shortcuts/shortcuts';
11
- import Loader from '../loader/loader';
12
- import Header from './header';
13
- import selectionShortcutsHOC from './selection-shortcuts-hoc';
14
- import disableHoverHOC from './disable-hover-hoc';
15
- import Row from './row-with-focus-sensor';
16
- import style from './table.css';
17
- /**
18
- * Interactive table with selection and keyboard navigation support.
19
- */
20
- export class Table extends PureComponent {
21
- static defaultProps = {
22
- isItemSelectable: () => true,
23
- loading: false,
24
- onSort: () => { },
25
- onReorder: () => { },
26
- getItemKey: (item) => {
27
- // Default behavior stays backward compatible: use item's "id" if present
28
- if ('id' in item) {
29
- return item.id;
30
- }
31
- // If there's no id provided on item and no getKey supplied, fail fast with a clear message
32
- throw new Error('Table: getItemKey is required when items have no "id" property');
33
- },
34
- sortKey: 'id',
35
- sortOrder: true,
36
- draggable: false,
37
- alwaysShowDragHandle: false,
38
- stickyHeader: true,
39
- getItemLevel: () => 0,
40
- getItemClassName: () => null,
41
- getMetaColumnClassName: () => null,
42
- getItemDataTest: () => null,
43
- isItemCollapsible: () => false,
44
- isParentCollapsible: () => false,
45
- isItemCollapsed: () => false,
46
- onItemCollapse: () => { },
47
- onItemExpand: () => { },
48
- onItemDoubleClick: () => { },
49
- onItemClick: () => { },
50
- remoteSelection: false,
51
- isDisabledSelectionVisible: () => false,
52
- getCheckboxTooltip: () => undefined,
53
- RowComponent: Row,
54
- wideFirstColumn: false,
55
- };
56
- state = {
57
- shortcutsScope: getUID('ring-table-'),
58
- userSelectNone: false,
59
- };
60
- componentDidMount() {
61
- document.addEventListener('mouseup', this.onMouseUp);
62
- }
63
- componentDidUpdate({ data, selection, onSelect, selectable, remoteSelection }) {
64
- if (data !== this.props.data && remoteSelection) {
65
- onSelect(selection.cloneWith({ data: this.props.data }));
66
- }
67
- if (!this.props.selectable && this.props.selectable !== selectable) {
68
- onSelect(selection.resetSelection());
69
- }
70
- }
71
- componentWillUnmount() {
72
- document.removeEventListener('mouseup', this.onMouseUp);
73
- }
74
- onMouseDown = (e) => {
75
- if (e.shiftKey) {
76
- this.setState({ userSelectNone: true });
77
- }
78
- };
79
- onMouseUp = () => {
80
- if (this.state.userSelectNone) {
81
- this.setState({ userSelectNone: false });
82
- }
83
- };
84
- onRowFocus = (row) => {
85
- const { selection, onSelect } = this.props;
86
- onSelect(selection.focus(row));
87
- };
88
- onRowSelect = (row, selected) => {
89
- const { selection, onSelect } = this.props;
90
- if (selected) {
91
- onSelect(selection.select(row));
92
- }
93
- else {
94
- onSelect(selection.deselect(row));
95
- }
96
- };
97
- onSortEnd = ({ oldIndex, newIndex }) => {
98
- const data = arrayMove(this.props.data, oldIndex, newIndex);
99
- this.props.onReorder({ data, oldIndex, newIndex });
100
- };
101
- onCheckboxChange = (e) => {
102
- const { checked } = e.currentTarget;
103
- const { selection, onSelect } = this.props;
104
- if (checked) {
105
- onSelect(selection.selectAll());
106
- }
107
- else {
108
- onSelect(selection.reset());
109
- }
110
- this.restoreFocusWithoutScroll();
111
- };
112
- restoreFocusWithoutScroll = () => {
113
- const { scrollX, scrollY } = window;
114
- this.props.onFocusRestore();
115
- window.scrollTo(scrollX, scrollY);
116
- };
117
- render() {
118
- const { data, selection, columns, caption, getItemKey, selectable, focused, isItemSelectable, getItemLevel, getItemClassName, getMetaColumnClassName, getItemDataTest, draggable, alwaysShowDragHandle, dragHandleTitle, loading, onSort, sortKey, sortOrder, loaderClassName, stickyHeader, stickyHeaderOffset, isItemCollapsible, isParentCollapsible, isItemCollapsed, onItemCollapse, onItemExpand, isDisabledSelectionVisible, getCheckboxTooltip, onItemDoubleClick, onItemClick, renderEmpty, RowComponent, renderLoader, } = this.props;
119
- // NOTE: Do not construct new object per render because it causes all rows rerendering
120
- const columnsArray = typeof columns === 'function' ? columns(null) : columns;
121
- const headerProps = {
122
- caption,
123
- selectable,
124
- draggable,
125
- columns: columnsArray,
126
- onSort,
127
- sortKey,
128
- sortOrder,
129
- sticky: stickyHeader,
130
- topStickOffset: stickyHeaderOffset,
131
- className: this.props.headerClassName,
132
- };
133
- const selectedSize = selection.getSelected().size;
134
- const allSelectedSize = selection.selectAll().getSelected().size;
135
- headerProps.checked = selectedSize > 0 && selectedSize === allSelectedSize;
136
- headerProps.onCheckboxChange = this.onCheckboxChange;
137
- headerProps.checkboxDisabled = this.props.data.length === 0;
138
- const wrapperClasses = classNames(style.tableWrapper, this.props.wrapperClassName);
139
- const classes = classNames(this.props.className, {
140
- [style.table]: true,
141
- [style.wideFirstColumn]: this.props.wideFirstColumn,
142
- [style.userSelectNone]: this.state.userSelectNone,
143
- [style.disabledHover]: this.props.disabledHover,
144
- });
145
- const renderList = ({ children, props }) => {
146
- const empty = (<tr>
147
- <td colSpan={columnsArray.length || 1} className={style.tableMessage}>
148
- {renderEmpty ? renderEmpty() : null}
149
- </td>
150
- </tr>);
151
- const tbody = Array.isArray(children) && children.length > 0 ? children : empty;
152
- return (<table className={classes} data-test='ring-table'>
153
- <Header {...headerProps}/>
154
- <tbody {...props} data-test='ring-table-body'>
155
- {tbody}
156
- </tbody>
157
- </table>);
158
- };
159
- const renderItem = ({ value, props = {}, isDragged }) => {
160
- if (value === null || value === undefined) {
161
- return null;
162
- }
163
- const { ref, ...restProps } = props;
164
- const row = (<RowComponent innerRef={ref} level={getItemLevel(value)} item={value} showFocus={selection.isFocused(value)} autofocus={selection.isFocused(value)} focused={focused && selection.isFocused(value)} selectable={selectable && isItemSelectable(value)} selected={selectable && selection.isSelected(value)} onFocus={this.onRowFocus} onSelect={this.onRowSelect} onDoubleClick={onItemDoubleClick} onClick={onItemClick} collapsible={isItemCollapsible(value)} parentCollapsible={isParentCollapsible(value)} collapsed={isItemCollapsed(value)} onCollapse={onItemCollapse} onExpand={onItemExpand} showDisabledSelection={isDisabledSelectionVisible(value)} checkboxTooltip={getCheckboxTooltip(value)} className={classNames(getItemClassName(value), { [style.draggingRow]: isDragged })} metaColumnClassName={getMetaColumnClassName(value)} draggable={draggable} alwaysShowDragHandle={alwaysShowDragHandle} dragHandleTitle={dragHandleTitle} columns={columns} data-test={getItemDataTest(value)} cellClassName={this.props.cellClassName} {...restProps} key={restProps.key ?? getItemKey(value)}/>);
165
- return isDragged ? (<table style={{ ...props.style }} className={style.draggingTable}>
166
- <tbody>{row}</tbody>
167
- </table>) : (row);
168
- };
169
- return (<div className={wrapperClasses} data-test='ring-table-wrapper' ref={this.props.innerRef}>
170
- {focused && <Shortcuts map={this.props.shortcutsMap} scope={this.state.shortcutsScope}/>}
171
-
172
- {/* Handler detects that user holds Shift key */}
173
- <div role='presentation' onMouseDown={this.onMouseDown}>
174
- {draggable ? (<List values={data} renderList={renderList} renderItem={renderItem} onChange={this.onSortEnd}/>) : (renderList({ children: data.map((value, index) => renderItem({ value, index })) }))}
175
- </div>
176
-
177
- {loading && (<div className={style.loadingOverlay}>
178
- {renderLoader ? renderLoader(loaderClassName) : <Loader className={loaderClassName}/>}
179
- </div>)}
180
- </div>);
181
- }
182
- }
183
- const getContainer = () => disableHoverHOC(selectionShortcutsHOC(focusSensorHOC(Table)));
184
- // eslint-disable-next-line react/no-multi-comp
185
- export default class TableContainer extends Component {
186
- // https://stackoverflow.com/a/53882322/6304152
187
- Table = getContainer();
188
- render() {
189
- return <this.Table {...this.props}/>;
190
- }
191
- }
1
+ import Table from './table-component';
2
+ export default Table;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetbrains/ring-ui",
3
- "version": "7.0.115",
3
+ "version": "8.0.0-beta.1",
4
4
  "description": "JetBrains UI library",
5
5
  "author": {
6
6
  "name": "JetBrains"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes