@jetbrains/ring-ui-built 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/_helpers/heading.js +2 -2
- package/components/_helpers/table.js +1 -1
- package/components/_helpers/theme.js +1 -1
- package/components/alert/alert.js +1 -1
- package/components/auth/iframe-flow.js +1 -1
- package/components/checkbox/checkbox.d.ts +1 -1
- package/components/collapsible-group/collapsible-group.d.ts +20 -0
- package/components/collapsible-group/collapsible-group.js +382 -0
- package/components/components/util-stories.js +63 -1
- package/components/data-list/data-list.js +1 -1
- package/components/data-list/title.js +1 -1
- package/components/date-picker/date-popup.js +3 -3
- package/components/dropdown-menu/dropdown-menu.js +6 -6
- package/components/editable-heading/editable-heading.js +122 -109
- package/components/expand/collapsible-group.d.ts +8 -20
- package/components/expand/collapsible-group.js +34 -365
- package/components/global/compose-refs.d.ts +2 -1
- package/components/global/compose-refs.js +44 -8
- package/components/global/focus-sensor-hoc.js +1 -0
- package/components/global/focus-with-temporary-tabindex.d.ts +11 -0
- package/components/global/focus-with-temporary-tabindex.js +23 -0
- package/components/global/intersection-observer-context.d.ts +29 -9
- package/components/global/intersection-observer-context.js +50 -52
- package/components/global/is-within-interactive-element.d.ts +6 -0
- package/components/global/is-within-interactive-element.js +11 -0
- package/components/global/is-within-navigable-element.d.ts +6 -0
- package/components/global/is-within-navigable-element.js +11 -0
- package/components/global/parse-css-duration.d.ts +5 -0
- package/components/global/parse-css-duration.js +14 -0
- package/components/global/rerender-hoc.js +1 -0
- package/components/global/schedule-with-cleanup.d.ts +12 -0
- package/components/global/schedule-with-cleanup.js +36 -0
- package/components/global/table-selection.js +1 -1
- package/components/global/theme.js +1 -1
- package/components/header/header.js +1 -1
- package/components/heading/heading.js +3 -3
- package/components/input/input.d.ts +1 -1
- package/components/internal/column-animation.js +133 -0
- package/components/internal/table-header.js +1109 -0
- package/components/{table/table-virtualize.js → internal/virtual-items.js} +108 -84
- package/components/legacy-table/header-cell.js +2 -2
- package/components/legacy-table/row-with-focus-sensor.js +1 -1
- package/components/legacy-table/row.d.ts +1 -1
- package/components/legacy-table/simple-table.js +1 -1
- package/components/legacy-table/smart-table.js +1 -1
- package/components/legacy-table/table.js +1 -1
- package/components/markdown/markdown.js +2 -2
- package/components/message/message.js +1 -1
- package/components/old-browsers-message/white-list.js +2 -2
- package/components/popup/popup.d.ts +2 -0
- package/components/popup/popup.js +5 -1
- package/components/select/select-popup.d.ts +1 -1
- package/components/select/select.d.ts +1 -1
- package/components/style.css +1 -1
- package/components/table/default-item-renderer.d.ts +23 -10
- package/components/table/default-item-renderer.js +104 -98
- package/components/table/internal/column-animation.d.ts +16 -0
- package/components/table/internal/table-header.d.ts +4 -0
- package/components/table/internal/virtual-items.d.ts +34 -0
- package/components/table/item-virtualization.d.ts +35 -0
- package/components/table/item-virtualization.js +71 -0
- package/components/table/table-const.d.ts +40 -6
- package/components/table/table-const.js +15 -6
- package/components/table/table-primitives.d.ts +9 -16
- package/components/table/table-primitives.js +11 -211
- package/components/table/table-props.d.ts +280 -0
- package/components/table/table-props.js +1 -0
- package/components/table/table.d.ts +205 -209
- package/components/table/table.js +356 -15
- package/components/tooltip/tooltip.js +1 -1
- package/components/user-agreement/service.js +6 -6
- package/components/util-stories.d.ts +26 -0
- package/package.json +2 -2
- package/components/date-picker/use-intersection-observer.d.ts +0 -6
- package/components/date-picker/use-intersection-observer.js +0 -93
- package/components/global/composeRefs.d.ts +0 -6
- package/components/global/composeRefs.js +0 -9
- package/components/table/table-component.d.ts +0 -80
- package/components/table/table-component.js +0 -290
- package/components/table/table-row-focus.d.ts +0 -4
- package/components/table/table-row-focus.js +0 -41
- package/components/table/table-virtualize.d.ts +0 -32
|
@@ -5,13 +5,10 @@ export interface DefaultItemRendererProps {
|
|
|
5
5
|
*/
|
|
6
6
|
index: number;
|
|
7
7
|
/**
|
|
8
|
-
* If true
|
|
8
|
+
* If `true`, the row will be focusable with up/down arrow keys.
|
|
9
9
|
* Focus is implemented using the
|
|
10
10
|
* ["roving tabindex"](https://developer.mozilla.org/en-US/docs/Web/Accessibility/Guides/Keyboard-navigable_JavaScript_widgets#technique_1_roving_tabindex)
|
|
11
11
|
* technique, that is, only the focused row has `tabIndex={0}`.
|
|
12
|
-
*
|
|
13
|
-
* To focus the row on click or other user interaction, add e.g. `onClick()`
|
|
14
|
-
* and invoke `focusRow(e.currentTarget)` imported from `table-row-focus.ts`.
|
|
15
12
|
*/
|
|
16
13
|
keyboardFocusable?: boolean;
|
|
17
14
|
/**
|
|
@@ -20,17 +17,33 @@ export interface DefaultItemRendererProps {
|
|
|
20
17
|
*/
|
|
21
18
|
clickable?: boolean;
|
|
22
19
|
/**
|
|
23
|
-
* If true
|
|
24
|
-
* a different background color.
|
|
20
|
+
* If `true`, the row is highlighted as selected with a different background color.
|
|
25
21
|
*/
|
|
26
22
|
selected?: boolean;
|
|
27
23
|
/**
|
|
28
|
-
*
|
|
29
|
-
* 0
|
|
24
|
+
* The nesting level of an item. Applies an indent for columns with
|
|
25
|
+
* `Column.indent` set to `true`. `0`, negative values, and an unset value
|
|
26
|
+
* mean no indent.
|
|
30
27
|
*/
|
|
31
28
|
level?: number;
|
|
29
|
+
/**
|
|
30
|
+
* When set to `true`, does not control item virtualization.
|
|
31
|
+
* Useful when you include `DefaultItemRenderer` as a part of a custom row renderer,
|
|
32
|
+
* and track the visibility yourself.
|
|
33
|
+
*/
|
|
34
|
+
noItemVirtualization?: boolean;
|
|
32
35
|
}
|
|
33
36
|
/**
|
|
34
|
-
*
|
|
37
|
+
* Standard component for rendering a table row.
|
|
38
|
+
*
|
|
39
|
+
* Renders an item using the table's column definitions and lets you
|
|
40
|
+
* configure item-scoped behavior such as selection, keyboard navigation,
|
|
41
|
+
* event handlers, `className`, and `ref`.
|
|
42
|
+
*
|
|
43
|
+
* Note that row-level click and keyboard handlers are not discoverable
|
|
44
|
+
* by assistive technologies. Make sure that any functionality relying on
|
|
45
|
+
* them (such as selection or expand/collapse) is also available through
|
|
46
|
+
* accessible controls, such as checkboxes or buttons with accessible
|
|
47
|
+
* labels.
|
|
35
48
|
*/
|
|
36
|
-
export declare function DefaultItemRenderer<T>({ index, keyboardFocusable, clickable, selected, level, ref: userRef, className, ...restProps }: DefaultItemRendererProps & ComponentPropsWithRef<'tr'>): import("react").JSX.Element | null;
|
|
49
|
+
export declare function DefaultItemRenderer<T>({ index, keyboardFocusable, clickable, selected, level, noItemVirtualization, ref: userRef, className, ...restProps }: DefaultItemRendererProps & ComponentPropsWithRef<'tr'>): import("react").JSX.Element | null;
|
|
@@ -1,40 +1,31 @@
|
|
|
1
1
|
import { c } from 'react/compiler-runtime';
|
|
2
2
|
import { useRef, use } from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { TablePropsContext, ColumnAnimationContext } from './table-const.js';
|
|
5
|
+
import { useComposedRef } from '../global/compose-refs.js';
|
|
6
|
+
import { useItemVirtualization } from './item-virtualization.js';
|
|
7
7
|
import { TableRow, TableCell } from './table-primitives.js';
|
|
8
8
|
import { s as styles } from '../_helpers/table.js';
|
|
9
9
|
import { jsx } from 'react/jsx-runtime';
|
|
10
|
-
import '
|
|
11
|
-
import '
|
|
12
|
-
import '
|
|
13
|
-
import '
|
|
14
|
-
import '../icon/icon.js';
|
|
15
|
-
import 'util-deprecate';
|
|
16
|
-
import '../icon/icon.constants.js';
|
|
17
|
-
import '../_helpers/icon-svg.js';
|
|
18
|
-
import '../global/memoize.js';
|
|
19
|
-
import './table-row-focus.js';
|
|
10
|
+
import 'memoize-one';
|
|
11
|
+
import '../global/intersection-observer-context.js';
|
|
12
|
+
import '../internal/virtual-items.js';
|
|
13
|
+
import '../global/schedule-with-cleanup.js';
|
|
20
14
|
|
|
21
|
-
const INDENT_SIZE = 24;
|
|
22
|
-
/**
|
|
23
|
-
* @see TableProps.renderItem
|
|
24
|
-
*/
|
|
25
15
|
function DefaultItemRenderer(t0) {
|
|
26
|
-
const $ = c(
|
|
27
|
-
if ($[0] !== "
|
|
28
|
-
for (let $i = 0; $i <
|
|
16
|
+
const $ = c(39);
|
|
17
|
+
if ($[0] !== "814543263ebfe37ed20c6e2945771deb8a681b9bdb7c32cb1fc590d5f0122c82") {
|
|
18
|
+
for (let $i = 0; $i < 39; $i += 1) {
|
|
29
19
|
$[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
30
20
|
}
|
|
31
|
-
$[0] = "
|
|
21
|
+
$[0] = "814543263ebfe37ed20c6e2945771deb8a681b9bdb7c32cb1fc590d5f0122c82";
|
|
32
22
|
}
|
|
33
23
|
let className;
|
|
34
24
|
let clickable;
|
|
35
25
|
let index;
|
|
36
26
|
let keyboardFocusable;
|
|
37
27
|
let level;
|
|
28
|
+
let noItemVirtualization;
|
|
38
29
|
let restProps;
|
|
39
30
|
let selected;
|
|
40
31
|
let userRef;
|
|
@@ -45,6 +36,7 @@ function DefaultItemRenderer(t0) {
|
|
|
45
36
|
clickable,
|
|
46
37
|
selected,
|
|
47
38
|
level,
|
|
39
|
+
noItemVirtualization,
|
|
48
40
|
ref: userRef,
|
|
49
41
|
className,
|
|
50
42
|
...restProps
|
|
@@ -55,123 +47,137 @@ function DefaultItemRenderer(t0) {
|
|
|
55
47
|
$[4] = index;
|
|
56
48
|
$[5] = keyboardFocusable;
|
|
57
49
|
$[6] = level;
|
|
58
|
-
$[7] =
|
|
59
|
-
$[8] =
|
|
60
|
-
$[9] =
|
|
50
|
+
$[7] = noItemVirtualization;
|
|
51
|
+
$[8] = restProps;
|
|
52
|
+
$[9] = selected;
|
|
53
|
+
$[10] = userRef;
|
|
61
54
|
} else {
|
|
62
55
|
className = $[2];
|
|
63
56
|
clickable = $[3];
|
|
64
57
|
index = $[4];
|
|
65
58
|
keyboardFocusable = $[5];
|
|
66
59
|
level = $[6];
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
60
|
+
noItemVirtualization = $[7];
|
|
61
|
+
restProps = $[8];
|
|
62
|
+
selected = $[9];
|
|
63
|
+
userRef = $[10];
|
|
70
64
|
}
|
|
71
65
|
const localRef = useRef(null);
|
|
72
|
-
const
|
|
66
|
+
const composedRef = useComposedRef(userRef, localRef);
|
|
73
67
|
let t1;
|
|
74
|
-
if ($[
|
|
75
|
-
t1 =
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
68
|
+
if ($[11] !== noItemVirtualization) {
|
|
69
|
+
t1 = (t2, _i, t3) => {
|
|
70
|
+
const [isIntersecting] = t2;
|
|
71
|
+
const [element] = t3;
|
|
72
|
+
return isIntersecting === false && !noItemVirtualization && element?.isConnected && !element.contains(document.activeElement) && !element.previousElementSibling?.contains(document.activeElement) && !element.nextElementSibling?.contains(document.activeElement) ? element.getBoundingClientRect().height : undefined;
|
|
79
73
|
};
|
|
80
|
-
$[
|
|
81
|
-
$[
|
|
74
|
+
$[11] = noItemVirtualization;
|
|
75
|
+
$[12] = t1;
|
|
82
76
|
} else {
|
|
83
|
-
t1 = $[
|
|
77
|
+
t1 = $[12];
|
|
84
78
|
}
|
|
85
|
-
|
|
79
|
+
const t2 = t1;
|
|
80
|
+
let t3;
|
|
81
|
+
if ($[13] !== index || $[14] !== t2) {
|
|
82
|
+
t3 = {
|
|
83
|
+
index,
|
|
84
|
+
refs: localRef,
|
|
85
|
+
onIntersectionChange: t2
|
|
86
|
+
};
|
|
87
|
+
$[13] = index;
|
|
88
|
+
$[14] = t2;
|
|
89
|
+
$[15] = t3;
|
|
90
|
+
} else {
|
|
91
|
+
t3 = $[15];
|
|
92
|
+
}
|
|
93
|
+
useItemVirtualization(t3);
|
|
86
94
|
const tableProps = use(TablePropsContext);
|
|
87
95
|
if (!tableProps) {
|
|
88
96
|
return null;
|
|
89
97
|
}
|
|
98
|
+
const animatedColumn = use(ColumnAnimationContext);
|
|
90
99
|
const {
|
|
91
100
|
data,
|
|
92
101
|
columns
|
|
93
102
|
} = tableProps;
|
|
94
103
|
const item = data[index];
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const t4 = selected && styles.selectedRow;
|
|
105
|
-
let t5;
|
|
106
|
-
if ($[14] !== className || $[15] !== t3 || $[16] !== t4) {
|
|
107
|
-
t5 = classNames(className, t3, t4);
|
|
108
|
-
$[14] = className;
|
|
109
|
-
$[15] = t3;
|
|
110
|
-
$[16] = t4;
|
|
111
|
-
$[17] = t5;
|
|
104
|
+
const t4 = clickable && styles.clickableRow;
|
|
105
|
+
const t5 = selected && styles.selectedRow;
|
|
106
|
+
let t6;
|
|
107
|
+
if ($[16] !== className || $[17] !== t4 || $[18] !== t5) {
|
|
108
|
+
t6 = classNames(className, t4, t5);
|
|
109
|
+
$[16] = className;
|
|
110
|
+
$[17] = t4;
|
|
111
|
+
$[18] = t5;
|
|
112
|
+
$[19] = t6;
|
|
112
113
|
} else {
|
|
113
|
-
|
|
114
|
+
t6 = $[19];
|
|
114
115
|
}
|
|
115
|
-
let
|
|
116
|
-
if ($[
|
|
117
|
-
let
|
|
118
|
-
if ($[
|
|
119
|
-
|
|
116
|
+
let t7;
|
|
117
|
+
if ($[20] !== animatedColumn || $[21] !== columns || $[22] !== data || $[23] !== index || $[24] !== item || $[25] !== level) {
|
|
118
|
+
let t8;
|
|
119
|
+
if ($[27] !== animatedColumn || $[28] !== data || $[29] !== index || $[30] !== item || $[31] !== level) {
|
|
120
|
+
t8 = (column, columnIndex) => {
|
|
120
121
|
var _column$renderCell;
|
|
122
|
+
const {
|
|
123
|
+
key,
|
|
124
|
+
tdClassName,
|
|
125
|
+
indent
|
|
126
|
+
} = column;
|
|
121
127
|
return /*#__PURE__*/jsx(TableCell, {
|
|
122
|
-
className:
|
|
123
|
-
style:
|
|
124
|
-
paddingInlineStart: `${level *
|
|
128
|
+
className: classNames(columnIndex === animatedColumn?.columnIndex && animatedColumn.cellClassName, typeof tdClassName === "function" ? tdClassName(item, index, data) : tdClassName),
|
|
129
|
+
style: indent && level != null && level > 0 ? {
|
|
130
|
+
paddingInlineStart: `${level * 24}px`
|
|
125
131
|
} : undefined,
|
|
126
|
-
children: (_column$renderCell = column.renderCell?.(item, index, data)) !== null && _column$renderCell !== void 0 ? _column$renderCell : getDefaultCellValue(item, columnIndex)
|
|
127
|
-
},
|
|
132
|
+
children: (_column$renderCell = column.renderCell?.(item, index, data)) !== null && _column$renderCell !== void 0 ? _column$renderCell : getDefaultCellValue(item, columnIndex, key)
|
|
133
|
+
}, key);
|
|
128
134
|
};
|
|
129
|
-
$[
|
|
130
|
-
$[
|
|
131
|
-
$[
|
|
132
|
-
$[
|
|
133
|
-
$[
|
|
135
|
+
$[27] = animatedColumn;
|
|
136
|
+
$[28] = data;
|
|
137
|
+
$[29] = index;
|
|
138
|
+
$[30] = item;
|
|
139
|
+
$[31] = level;
|
|
140
|
+
$[32] = t8;
|
|
134
141
|
} else {
|
|
135
|
-
|
|
142
|
+
t8 = $[32];
|
|
136
143
|
}
|
|
137
|
-
|
|
138
|
-
$[
|
|
139
|
-
$[
|
|
140
|
-
$[
|
|
141
|
-
$[
|
|
142
|
-
$[
|
|
143
|
-
$[
|
|
144
|
+
t7 = columns.map(t8);
|
|
145
|
+
$[20] = animatedColumn;
|
|
146
|
+
$[21] = columns;
|
|
147
|
+
$[22] = data;
|
|
148
|
+
$[23] = index;
|
|
149
|
+
$[24] = item;
|
|
150
|
+
$[25] = level;
|
|
151
|
+
$[26] = t7;
|
|
144
152
|
} else {
|
|
145
|
-
|
|
153
|
+
t7 = $[26];
|
|
146
154
|
}
|
|
147
|
-
let
|
|
148
|
-
if ($[
|
|
149
|
-
|
|
150
|
-
ref:
|
|
155
|
+
let t8;
|
|
156
|
+
if ($[33] !== composedRef || $[34] !== keyboardFocusable || $[35] !== restProps || $[36] !== t6 || $[37] !== t7) {
|
|
157
|
+
t8 = /*#__PURE__*/jsx(TableRow, {
|
|
158
|
+
ref: composedRef,
|
|
151
159
|
keyboardFocusable: keyboardFocusable,
|
|
152
|
-
className:
|
|
160
|
+
className: t6,
|
|
153
161
|
...restProps,
|
|
154
|
-
children:
|
|
162
|
+
children: t7
|
|
155
163
|
});
|
|
156
|
-
$[
|
|
157
|
-
$[
|
|
158
|
-
$[
|
|
159
|
-
$[
|
|
160
|
-
$[
|
|
161
|
-
$[
|
|
164
|
+
$[33] = composedRef;
|
|
165
|
+
$[34] = keyboardFocusable;
|
|
166
|
+
$[35] = restProps;
|
|
167
|
+
$[36] = t6;
|
|
168
|
+
$[37] = t7;
|
|
169
|
+
$[38] = t8;
|
|
162
170
|
} else {
|
|
163
|
-
|
|
171
|
+
t8 = $[38];
|
|
164
172
|
}
|
|
165
|
-
return
|
|
173
|
+
return t8;
|
|
166
174
|
}
|
|
167
|
-
function getDefaultCellValue(item, columnIndex) {
|
|
175
|
+
function getDefaultCellValue(item, columnIndex, columnKey) {
|
|
168
176
|
if (Array.isArray(item)) {
|
|
169
|
-
|
|
170
|
-
return String((_item$columnIndex = item[columnIndex]) !== null && _item$columnIndex !== void 0 ? _item$columnIndex : '');
|
|
177
|
+
return String(item[columnIndex]);
|
|
171
178
|
}
|
|
172
179
|
if (item !== null && typeof item === 'object') {
|
|
173
|
-
|
|
174
|
-
return String((_Object$values$column = Object.values(item)[columnIndex]) !== null && _Object$values$column !== void 0 ? _Object$values$column : '');
|
|
180
|
+
return String(item[String(columnKey)]);
|
|
175
181
|
}
|
|
176
182
|
if (columnIndex === 0) {
|
|
177
183
|
return String(item);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import type { Column } from '../table-props';
|
|
3
|
+
import type { ColumnAnimation } from '../table-const';
|
|
4
|
+
export interface ReorderSpec {
|
|
5
|
+
fromIndex: number;
|
|
6
|
+
insertionIndex: number;
|
|
7
|
+
}
|
|
8
|
+
export type ExpectColumnReorder = (reorderSpec: ReorderSpec) => void;
|
|
9
|
+
export declare function useColumnAnimation<T>({ disabled, tableRef, columns, }: {
|
|
10
|
+
disabled: boolean | undefined;
|
|
11
|
+
tableRef: RefObject<HTMLTableElement | null>;
|
|
12
|
+
columns: readonly Column<T>[];
|
|
13
|
+
}): {
|
|
14
|
+
columnAnimation: ColumnAnimation | null;
|
|
15
|
+
expectColumnReorder: ExpectColumnReorder;
|
|
16
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
export type VirtualItem = MaterializedItem | Spacer;
|
|
3
|
+
interface MaterializedItem {
|
|
4
|
+
type: 'materialized';
|
|
5
|
+
index: number;
|
|
6
|
+
}
|
|
7
|
+
interface Spacer {
|
|
8
|
+
type: 'spacer';
|
|
9
|
+
from: number;
|
|
10
|
+
to: number;
|
|
11
|
+
height: number;
|
|
12
|
+
key: string;
|
|
13
|
+
}
|
|
14
|
+
type CollapseItemIntoSpacerCallback = (index: number, height: number) => void;
|
|
15
|
+
export declare const CollapseItemIntoSpacerContext: import("react").Context<CollapseItemIntoSpacerCallback>;
|
|
16
|
+
export declare function useVirtualItems<T>({ enabled, data, data: { length }, scrollerRef, tableRef, estimateHeight, lookaheadPx, retentionMarginPx, minScrollAndResizeDeltaPx, }: {
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
data: readonly T[];
|
|
19
|
+
scrollerRef: RefObject<HTMLElement | null> | undefined;
|
|
20
|
+
tableRef: RefObject<HTMLTableElement | null>;
|
|
21
|
+
estimateHeight: (item: T, index: number, items: readonly T[]) => number;
|
|
22
|
+
lookaheadPx: number;
|
|
23
|
+
retentionMarginPx: number;
|
|
24
|
+
minScrollAndResizeDeltaPx: number;
|
|
25
|
+
}): {
|
|
26
|
+
virtualItems: VirtualItem[];
|
|
27
|
+
intersectionObserverHandle: import("../../global/intersection-observer-context").IntersectionObserverHandle;
|
|
28
|
+
collapseItemIntoSpacer: CollapseItemIntoSpacerCallback;
|
|
29
|
+
};
|
|
30
|
+
export declare function SpacerRow({ spacer: { from, to, height }, colSpan }: {
|
|
31
|
+
spacer: Spacer;
|
|
32
|
+
colSpan: number;
|
|
33
|
+
}): import("react").JSX.Element;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Use in an item renderer to control item virtualization.
|
|
4
|
+
*/
|
|
5
|
+
export declare function useItemVirtualization({ index, refs, onIntersectionChange, }: {
|
|
6
|
+
/**
|
|
7
|
+
* Index of the item.
|
|
8
|
+
*/
|
|
9
|
+
index: number;
|
|
10
|
+
/**
|
|
11
|
+
* One or more elements representing this item.
|
|
12
|
+
*
|
|
13
|
+
* When multiple elements are provided, the virtualization callback receives
|
|
14
|
+
* the intersection state of all of them.
|
|
15
|
+
*
|
|
16
|
+
* If you pass multiple refs, memoize the array (for example with `useMemo()`)
|
|
17
|
+
* to avoid restarting observation on every render.
|
|
18
|
+
*/
|
|
19
|
+
refs: RefObject<HTMLElement | null> | RefObject<HTMLElement | null>[];
|
|
20
|
+
/**
|
|
21
|
+
* Invoked when the `isIntersecting` state of the observed elements changes.
|
|
22
|
+
* Consider wrapping a callback to `useCallback()` to avoid restarting observation on every render.
|
|
23
|
+
*
|
|
24
|
+
* @param intersectionStates - Current intersection state of every observed element.
|
|
25
|
+
* Entries are initially `undefined` until the corresponding element
|
|
26
|
+
* has been reported by `IntersectionObserver`.
|
|
27
|
+
* @param changedIndex - Index of the element whose intersection state changed.
|
|
28
|
+
* @param elements - The observed elements. Note that some elements may
|
|
29
|
+
* already be disconnected from the DOM when this callback is invoked.
|
|
30
|
+
* Use additional checks like `element.isConnected`.
|
|
31
|
+
* @returns Return the height of an item to collapse the item into spacer,
|
|
32
|
+
* or `undefined` to keep the item rendered.
|
|
33
|
+
*/
|
|
34
|
+
onIntersectionChange: (intersectionStates: (boolean | undefined)[], changedIndex: number, elements: (Element | null)[]) => number | undefined;
|
|
35
|
+
}): void;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { c } from 'react/compiler-runtime';
|
|
2
|
+
import { use, useEffect } from 'react';
|
|
3
|
+
import { IntersectionObserverContext } from '../global/intersection-observer-context.js';
|
|
4
|
+
import { CollapseItemIntoSpacerContext } from '../internal/virtual-items.js';
|
|
5
|
+
import '../global/schedule-with-cleanup.js';
|
|
6
|
+
import '../_helpers/table.js';
|
|
7
|
+
import 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Use in an item renderer to control item virtualization.
|
|
11
|
+
*/
|
|
12
|
+
function useItemVirtualization(t0) {
|
|
13
|
+
const $ = c(8);
|
|
14
|
+
if ($[0] !== "15177a0e107705dc6d84a0fc97d3302da4c04a0058a1b771c145ee537ccae2cf") {
|
|
15
|
+
for (let $i = 0; $i < 8; $i += 1) {
|
|
16
|
+
$[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
17
|
+
}
|
|
18
|
+
$[0] = "15177a0e107705dc6d84a0fc97d3302da4c04a0058a1b771c145ee537ccae2cf";
|
|
19
|
+
}
|
|
20
|
+
const {
|
|
21
|
+
index,
|
|
22
|
+
refs,
|
|
23
|
+
onIntersectionChange
|
|
24
|
+
} = t0;
|
|
25
|
+
const handle = use(IntersectionObserverContext);
|
|
26
|
+
const collapseItemIntoSpacer = use(CollapseItemIntoSpacerContext);
|
|
27
|
+
let t1;
|
|
28
|
+
let t2;
|
|
29
|
+
if ($[1] !== collapseItemIntoSpacer || $[2] !== handle || $[3] !== index || $[4] !== onIntersectionChange || $[5] !== refs) {
|
|
30
|
+
t1 = () => {
|
|
31
|
+
const intersectionStates = Array.isArray(refs) ? refs.map(_temp) : [undefined];
|
|
32
|
+
const elements = Array.isArray(refs) ? refs.map(_temp2) : [refs.current];
|
|
33
|
+
const cleanups = [];
|
|
34
|
+
elements.forEach((element, elementIndex) => {
|
|
35
|
+
if (!element) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const cleanup = handle.observe(element, isIntersecting => {
|
|
39
|
+
intersectionStates[elementIndex] = isIntersecting;
|
|
40
|
+
const height = onIntersectionChange(intersectionStates, elementIndex, elements);
|
|
41
|
+
if (height != null) {
|
|
42
|
+
collapseItemIntoSpacer(index, height);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
cleanups.push(cleanup);
|
|
46
|
+
});
|
|
47
|
+
return () => cleanups.forEach(_temp3);
|
|
48
|
+
};
|
|
49
|
+
t2 = [collapseItemIntoSpacer, handle, index, onIntersectionChange, refs];
|
|
50
|
+
$[1] = collapseItemIntoSpacer;
|
|
51
|
+
$[2] = handle;
|
|
52
|
+
$[3] = index;
|
|
53
|
+
$[4] = onIntersectionChange;
|
|
54
|
+
$[5] = refs;
|
|
55
|
+
$[6] = t1;
|
|
56
|
+
$[7] = t2;
|
|
57
|
+
} else {
|
|
58
|
+
t1 = $[6];
|
|
59
|
+
t2 = $[7];
|
|
60
|
+
}
|
|
61
|
+
useEffect(t1, t2);
|
|
62
|
+
}
|
|
63
|
+
function _temp3(cleanup_0) {
|
|
64
|
+
return cleanup_0();
|
|
65
|
+
}
|
|
66
|
+
function _temp2(r) {
|
|
67
|
+
return r.current;
|
|
68
|
+
}
|
|
69
|
+
function _temp() {}
|
|
70
|
+
|
|
71
|
+
export { useItemVirtualization };
|
|
@@ -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,11 +1,20 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Use anywhere inside the table to get access to the props passed to it.
|
|
5
|
+
* Cast to `Context<TableProps<T>>` in usage place.
|
|
6
|
+
*/
|
|
3
7
|
const TablePropsContext = /*#__PURE__*/createContext(null);
|
|
4
|
-
|
|
5
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Provides information about the currently animated column.
|
|
10
|
+
*
|
|
11
|
+
* Use in a custom cell renderer to animate reordered columns
|
|
12
|
+
* consistently with the default table renderer.
|
|
13
|
+
*/
|
|
14
|
+
const ColumnAnimationContext = /*#__PURE__*/createContext(null);
|
|
15
|
+
/**
|
|
16
|
+
* When a row only contains unformatted single-line text, it will be exactly of this height.
|
|
17
|
+
*/
|
|
6
18
|
const defaultRowHeight = 37;
|
|
7
|
-
const defaultLookaheadPx = 400;
|
|
8
|
-
const defaultRetentionMarginPx = 450;
|
|
9
|
-
const defaultMinScrollAndResizeDeltaPx = 50;
|
|
10
19
|
|
|
11
|
-
export {
|
|
20
|
+
export { ColumnAnimationContext, TablePropsContext, defaultRowHeight };
|
|
@@ -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;
|