@jetbrains/ring-ui-built 7.0.115 → 8.0.0-beta.3
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/anchor.js +1 -1
- package/components/_helpers/avatar-info.js +1 -1
- package/components/_helpers/icon-svg.js +1 -1
- package/components/_helpers/legacy-table.js +3 -0
- package/components/_helpers/tab-link.js +1 -1
- package/components/_helpers/table.js +2 -2
- package/components/_helpers/theme.js +49 -37
- package/components/alert/alert.js +1 -1
- package/components/alert-service/alert-service.js +1 -1
- package/components/auth/auth-core.js +1 -1
- package/components/auth/auth.js +1 -1
- package/components/auth/down-notification.js +1 -1
- package/components/auth/iframe-flow.js +1 -1
- package/components/auth/storage.js +1 -1
- package/components/auth-dialog/auth-dialog.js +1 -1
- package/components/auth-dialog-service/auth-dialog-service.js +2 -2
- package/components/avatar/avatar-info.js +1 -1
- package/components/avatar/avatar.js +1 -1
- package/components/avatar/fallback-avatar.js +1 -1
- package/components/avatar-stack/avatar-stack.js +1 -1
- package/components/banner/banner.js +1 -1
- package/components/button/button.js +1 -1
- package/components/button-group/button-group.js +1 -1
- package/components/checkbox/checkbox.js +1 -1
- package/components/clipboard/clipboard.js +1 -1
- package/components/collapse/collapse-content.js +5 -5
- package/components/collapse/collapse-control.js +5 -5
- package/components/collapse/collapse.js +4 -4
- package/components/confirm/confirm.js +1 -1
- package/components/confirm-service/confirm-service.js +2 -2
- package/components/contenteditable/contenteditable.js +1 -1
- package/components/control-help/control-help.js +1 -1
- package/components/control-label/control-label.js +1 -1
- package/components/data-list/data-list.d.ts +4 -4
- package/components/data-list/data-list.js +3 -3
- package/components/data-list/data-list.mock.d.ts +1 -1
- package/components/data-list/data-list.mock.js +1 -1
- package/components/data-list/item.d.ts +1 -1
- package/components/data-list/item.js +1 -1
- package/components/data-list/selection.d.ts +1 -1
- package/components/data-list/selection.js +2 -2
- package/components/data-list/title.js +1 -1
- package/components/date-picker/date-input.js +1 -1
- package/components/date-picker/date-picker.js +2 -3
- package/components/date-picker/date-popup.js +2 -3
- package/components/date-picker/month-names.js +1 -1
- package/components/date-picker/month-slider.js +1 -1
- package/components/date-picker/month.d.ts +0 -2
- package/components/date-picker/month.js +17 -18
- package/components/date-picker/months.js +43 -35
- package/components/date-picker/use-intersection-observer.js +1 -1
- package/components/date-picker/use-scroll-behavior.js +45 -44
- package/components/date-picker/weekdays.js +1 -1
- package/components/date-picker/years.js +61 -54
- package/components/dialog/dialog.d.ts +2 -2
- package/components/dialog/dialog.js +3 -3
- package/components/dropdown/anchor.js +1 -1
- package/components/dropdown/dropdown.js +1 -1
- package/components/dropdown-menu/dropdown-menu.d.ts +4 -4
- package/components/dropdown-menu/dropdown-menu.js +62 -57
- package/components/editable-heading/editable-heading.d.ts +1 -2
- package/components/editable-heading/editable-heading.js +13 -12
- package/components/error-bubble/error-bubble.js +1 -1
- package/components/error-message/error-message.js +1 -1
- package/components/expand/collapsible-group.d.ts +5 -1
- package/components/expand/collapsible-group.js +15 -14
- package/components/footer/footer.js +1 -1
- package/components/global/create-stateful-context.js +11 -11
- package/components/global/intersection-observer-context.d.ts +26 -0
- package/components/global/intersection-observer-context.js +140 -0
- package/components/global/rerender-hoc.d.ts +4 -2
- package/components/global/rerender-hoc.js +10 -24
- package/components/{table/selection.d.ts → global/table-selection.d.ts} +15 -15
- package/components/{table/selection.js → global/table-selection.js} +4 -4
- package/components/global/theme.d.ts +4 -3
- package/components/global/theme.js +1 -1
- package/components/header/header-icon.js +1 -1
- package/components/header/header.js +1 -1
- package/components/header/links.js +1 -1
- package/components/header/logo.js +1 -1
- package/components/header/profile.js +1 -1
- package/components/header/services.js +1 -1
- package/components/header/smart-profile.js +1 -1
- package/components/header/smart-services.js +1 -1
- package/components/heading/heading.js +1 -1
- package/components/i18n/i18n-context.js +4 -4
- package/components/icon/icon-svg.js +1 -1
- package/components/icon/icon.js +1 -1
- package/components/icon/index.js +1 -1
- package/components/input/input.js +1 -1
- package/components/island/adaptive-island-hoc.js +3 -3
- package/components/island/content.d.ts +7 -2
- package/components/island/content.js +27 -18
- package/components/island/header.js +1 -1
- package/components/island/island.js +1 -1
- package/components/{table → legacy-table}/cell.js +1 -1
- package/components/{table → legacy-table}/header-cell.js +4 -4
- package/components/{table → legacy-table}/header.js +2 -2
- package/components/{table → legacy-table}/multitable.d.ts +1 -1
- package/components/{table → legacy-table}/row-with-focus-sensor.js +2 -2
- package/components/{table → legacy-table}/row.js +4 -4
- 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 +4 -4
- package/components/{table → legacy-table}/smart-table.d.ts +5 -5
- package/components/{table → legacy-table}/smart-table.js +5 -5
- package/components/legacy-table/table.d.ts +109 -0
- package/components/legacy-table/table.js +369 -0
- package/components/list/list-item.js +1 -1
- package/components/list/list-users-groups-source.js +1 -1
- package/components/list/list.js +1 -1
- package/components/login-dialog/login-dialog.js +1 -1
- package/components/login-dialog/service.js +2 -2
- package/components/message/message.js +1 -1
- package/components/old-browsers-message/white-list.js +2 -2
- package/components/pager/pager.js +1 -1
- package/components/popup/popup.js +1 -1
- package/components/popup/popup.target.d.ts +3 -2
- package/components/popup/popup.target.js +32 -28
- package/components/popup-menu/popup-menu.js +1 -1
- package/components/query-assist/query-assist-suggestions.js +1 -1
- 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 +32 -18
- package/components/radio/radio.d.ts +2 -2
- package/components/radio/radio.js +2 -2
- package/components/scrollable-section/scrollable-section.js +1 -1
- package/components/select/chevron-button.js +1 -1
- package/components/select/select-filter.js +1 -1
- package/components/select/select-popup.js +1 -1
- package/components/select/select.d.ts +3 -1
- package/components/select/select.js +1 -1
- package/components/slider/slider.js +100 -96
- package/components/storage/storage-local.js +1 -1
- package/components/storage/storage.js +1 -1
- package/components/style.css +1 -1
- package/components/tab-trap/tab-trap.d.ts +3 -3
- package/components/tab-trap/tab-trap.js +83 -80
- package/components/table/default-item-renderer.d.ts +36 -0
- package/components/table/default-item-renderer.js +182 -0
- package/components/table/table-component.d.ts +80 -0
- package/components/table/table-component.js +290 -0
- package/components/table/table-const.d.ts +8 -0
- package/components/table/table-const.js +11 -0
- package/components/table/table-primitives.d.ts +28 -0
- package/components/table/table-primitives.js +323 -0
- package/components/table/table-row-focus.d.ts +4 -0
- package/components/table/table-row-focus.js +41 -0
- package/components/table/table-virtualize.d.ts +32 -0
- package/components/table/table-virtualize.js +329 -0
- package/components/table/table.d.ts +206 -104
- package/components/table/table.js +19 -362
- package/components/tabs/collapsible-more.js +1 -1
- package/components/tabs/collapsible-tab.js +1 -1
- package/components/tabs/collapsible-tabs.js +1 -1
- package/components/tabs/dumb-tabs.js +1 -1
- package/components/tabs/smart-tabs.js +1 -1
- package/components/tabs/tab-link.js +1 -1
- package/components/tabs/tabs.js +1 -1
- package/components/tag/tag.js +1 -1
- package/components/tags-input/tags-input.d.ts +3 -1
- package/components/tags-input/tags-input.js +1 -1
- package/components/tags-list/tags-list.js +1 -1
- package/components/toggle/toggle.js +1 -1
- package/components/tooltip/tooltip.js +2 -2
- package/components/upload/upload.d.ts +4 -3
- package/components/upload/upload.js +7 -29
- package/components/user-agreement/service.js +2 -2
- package/components/user-agreement/user-agreement.js +1 -1
- package/components/user-card/card.js +1 -1
- package/components/user-card/smart-user-card-tooltip.js +1 -1
- package/components/user-card/tooltip.js +1 -1
- package/components/user-card/user-card.js +1 -1
- package/package.json +6 -6
- package/components/global/use-event-callback.d.ts +0 -1
- package/components/global/use-event-callback.js +0 -44
- 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.d.ts +0 -0
- /package/components/{table → legacy-table}/selection-adapter.js +0 -0
- /package/components/{table → legacy-table}/selection-shortcuts-hoc.js +0 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
export type VirtualItem = RenderedItem | Spacer;
|
|
3
|
+
interface RenderedItem {
|
|
4
|
+
type: 'rendered';
|
|
5
|
+
index: number;
|
|
6
|
+
}
|
|
7
|
+
interface Spacer {
|
|
8
|
+
type: 'spacer';
|
|
9
|
+
from: number;
|
|
10
|
+
to: number;
|
|
11
|
+
height: number;
|
|
12
|
+
key: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function useTableVirtualize<T>({ enabled, data, data: { length }, scrollerRef, tableRef, estimateHeight, lookaheadPx, retentionMarginPx, minScrollAndResizeDeltaPx, }: {
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
data: T[];
|
|
17
|
+
scrollerRef: RefObject<HTMLElement | null> | undefined;
|
|
18
|
+
tableRef: RefObject<HTMLTableElement | null>;
|
|
19
|
+
estimateHeight: (item: T, index: number, items: T[]) => number;
|
|
20
|
+
lookaheadPx: number;
|
|
21
|
+
retentionMarginPx: number;
|
|
22
|
+
minScrollAndResizeDeltaPx: number;
|
|
23
|
+
}): {
|
|
24
|
+
virtualItems: VirtualItem[];
|
|
25
|
+
intersectionObserverHandle: import("../global/intersection-observer-context").IntersectionObserverHandle | null;
|
|
26
|
+
collapseItemIntoSpacer: (index: number, height: number) => void;
|
|
27
|
+
};
|
|
28
|
+
export declare function SpacerRow({ spacer: { from, to, height }, colSpan }: {
|
|
29
|
+
spacer: Spacer;
|
|
30
|
+
colSpan: number;
|
|
31
|
+
}): import("react").JSX.Element;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { c } from 'react/compiler-runtime';
|
|
2
|
+
import { useRef, useState, useEffect } from 'react';
|
|
3
|
+
import { useIntersectionObserverHandle } from '../global/intersection-observer-context.js';
|
|
4
|
+
import { s as styles } from '../_helpers/table.js';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
const virtualizationThrottleDelay = 50;
|
|
8
|
+
function useTableVirtualize(t0) {
|
|
9
|
+
const $ = c(34);
|
|
10
|
+
if ($[0] !== "4b7f7b12eb2c9ae3487ce5d00c7be96dc9b8807a6bbfe2c9b314700f443d7188") {
|
|
11
|
+
for (let $i = 0; $i < 34; $i += 1) {
|
|
12
|
+
$[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
13
|
+
}
|
|
14
|
+
$[0] = "4b7f7b12eb2c9ae3487ce5d00c7be96dc9b8807a6bbfe2c9b314700f443d7188";
|
|
15
|
+
}
|
|
16
|
+
const {
|
|
17
|
+
enabled,
|
|
18
|
+
data,
|
|
19
|
+
data: t1,
|
|
20
|
+
scrollerRef,
|
|
21
|
+
tableRef,
|
|
22
|
+
estimateHeight,
|
|
23
|
+
lookaheadPx,
|
|
24
|
+
retentionMarginPx,
|
|
25
|
+
minScrollAndResizeDeltaPx
|
|
26
|
+
} = t0;
|
|
27
|
+
const {
|
|
28
|
+
length
|
|
29
|
+
} = t1;
|
|
30
|
+
let t2;
|
|
31
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
32
|
+
t2 = [];
|
|
33
|
+
$[1] = t2;
|
|
34
|
+
} else {
|
|
35
|
+
t2 = $[1];
|
|
36
|
+
}
|
|
37
|
+
const itemsMaterialization = useRef(t2);
|
|
38
|
+
let t3;
|
|
39
|
+
if ($[2] !== data || $[3] !== estimateHeight || $[4] !== length) {
|
|
40
|
+
t3 = () => [{
|
|
41
|
+
type: "spacer",
|
|
42
|
+
from: 0,
|
|
43
|
+
to: length,
|
|
44
|
+
height: data.reduce((acc, item, index, items) => acc + estimateHeight(item, index, items), 0),
|
|
45
|
+
key: `${styles.spacerRow}-0`
|
|
46
|
+
}];
|
|
47
|
+
$[2] = data;
|
|
48
|
+
$[3] = estimateHeight;
|
|
49
|
+
$[4] = length;
|
|
50
|
+
$[5] = t3;
|
|
51
|
+
} else {
|
|
52
|
+
t3 = $[5];
|
|
53
|
+
}
|
|
54
|
+
const [virtualItems, setVirtualItems] = useState(t3);
|
|
55
|
+
let t4;
|
|
56
|
+
if ($[6] !== data || $[7] !== estimateHeight || $[8] !== lookaheadPx || $[9] !== scrollerRef || $[10] !== tableRef) {
|
|
57
|
+
t4 = () => {
|
|
58
|
+
var _scrollerRef$current$;
|
|
59
|
+
if (!tableRef.current) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const containerHeight = (_scrollerRef$current$ = scrollerRef?.current?.clientHeight) !== null && _scrollerRef$current$ !== void 0 ? _scrollerRef$current$ : window.innerHeight;
|
|
63
|
+
for (const spacerRow of tableRef.current.querySelectorAll(`.${styles.spacerRow}`)) {
|
|
64
|
+
const rect = spacerRow.getBoundingClientRect();
|
|
65
|
+
const spacerIntersectsLookaheadArea = rect.top < containerHeight + lookaheadPx && rect.bottom > -lookaheadPx;
|
|
66
|
+
if (!spacerIntersectsLookaheadArea) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const visibleOffsetStart = Math.max(0, -rect.top);
|
|
70
|
+
const visibleOffsetEnd = Math.min(rect.height, containerHeight - rect.top);
|
|
71
|
+
const materializeOffsetStart = visibleOffsetStart - lookaheadPx;
|
|
72
|
+
const materializeOffsetEnd = visibleOffsetEnd + lookaheadPx;
|
|
73
|
+
let offsetInSpacer = 0;
|
|
74
|
+
const from = Number(spacerRow.dataset.from);
|
|
75
|
+
const to = Number(spacerRow.dataset.to);
|
|
76
|
+
for (let i = from; i < to; i++) {
|
|
77
|
+
const itemMaterialization = itemsMaterialization.current[i];
|
|
78
|
+
const itemHeight = typeof itemMaterialization === "number" ? itemMaterialization : estimateHeight(data[i], i, data);
|
|
79
|
+
const itemOffsetStart = offsetInSpacer;
|
|
80
|
+
const itemOffsetEnd = offsetInSpacer + itemHeight;
|
|
81
|
+
if (itemOffsetStart < materializeOffsetEnd && itemOffsetEnd > materializeOffsetStart) {
|
|
82
|
+
itemsMaterialization.current[i] = true;
|
|
83
|
+
} else {
|
|
84
|
+
if (itemOffsetStart > materializeOffsetEnd) {
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
offsetInSpacer = offsetInSpacer + itemHeight;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
$[6] = data;
|
|
93
|
+
$[7] = estimateHeight;
|
|
94
|
+
$[8] = lookaheadPx;
|
|
95
|
+
$[9] = scrollerRef;
|
|
96
|
+
$[10] = tableRef;
|
|
97
|
+
$[11] = t4;
|
|
98
|
+
} else {
|
|
99
|
+
t4 = $[11];
|
|
100
|
+
}
|
|
101
|
+
const materializeVisibleSpacerItems = t4;
|
|
102
|
+
let t5;
|
|
103
|
+
if ($[12] !== data || $[13] !== estimateHeight || $[14] !== length) {
|
|
104
|
+
t5 = () => {
|
|
105
|
+
const newVirtualItems = [];
|
|
106
|
+
let spacerCounter = 0;
|
|
107
|
+
for (let i_0 = 0; i_0 < length; i_0++) {
|
|
108
|
+
const itemMaterialization_0 = itemsMaterialization.current[i_0];
|
|
109
|
+
if (itemMaterialization_0 === true) {
|
|
110
|
+
newVirtualItems.push({
|
|
111
|
+
type: "rendered",
|
|
112
|
+
index: i_0
|
|
113
|
+
});
|
|
114
|
+
} else {
|
|
115
|
+
const lastItemOrSpacer = newVirtualItems[newVirtualItems.length - 1];
|
|
116
|
+
const lastSpacer = lastItemOrSpacer?.type === "spacer" ? lastItemOrSpacer : undefined;
|
|
117
|
+
const height = typeof itemMaterialization_0 === "number" ? itemMaterialization_0 : estimateHeight(data[i_0], i_0, data);
|
|
118
|
+
if (lastSpacer) {
|
|
119
|
+
lastSpacer.to = i_0 + 1;
|
|
120
|
+
lastSpacer.height = lastSpacer.height + height;
|
|
121
|
+
} else {
|
|
122
|
+
newVirtualItems.push({
|
|
123
|
+
type: "spacer",
|
|
124
|
+
from: i_0,
|
|
125
|
+
to: i_0 + 1,
|
|
126
|
+
height,
|
|
127
|
+
key: `${styles.spacerRow}-${spacerCounter++}`
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
setVirtualItems(newVirtualItems);
|
|
133
|
+
};
|
|
134
|
+
$[12] = data;
|
|
135
|
+
$[13] = estimateHeight;
|
|
136
|
+
$[14] = length;
|
|
137
|
+
$[15] = t5;
|
|
138
|
+
} else {
|
|
139
|
+
t5 = $[15];
|
|
140
|
+
}
|
|
141
|
+
const recomputeVirtualItems = t5;
|
|
142
|
+
const timerIdRef = useRef(null);
|
|
143
|
+
const callbacksRef = useRef(null);
|
|
144
|
+
let t6;
|
|
145
|
+
if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
|
|
146
|
+
t6 = (...t7) => {
|
|
147
|
+
const callbacks = t7;
|
|
148
|
+
if (timerIdRef.current != null) {
|
|
149
|
+
callbacks.forEach(cb => {
|
|
150
|
+
callbacksRef.current.delete(cb);
|
|
151
|
+
callbacksRef.current.add(cb);
|
|
152
|
+
});
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
callbacksRef.current = new Set(callbacks);
|
|
156
|
+
timerIdRef.current = window.setTimeout(() => {
|
|
157
|
+
callbacksRef.current.forEach(_temp);
|
|
158
|
+
timerIdRef.current = null;
|
|
159
|
+
callbacksRef.current = null;
|
|
160
|
+
}, virtualizationThrottleDelay);
|
|
161
|
+
};
|
|
162
|
+
$[16] = t6;
|
|
163
|
+
} else {
|
|
164
|
+
t6 = $[16];
|
|
165
|
+
}
|
|
166
|
+
const throttle = t6;
|
|
167
|
+
let t7;
|
|
168
|
+
let t8;
|
|
169
|
+
if ($[17] !== enabled || $[18] !== materializeVisibleSpacerItems || $[19] !== minScrollAndResizeDeltaPx || $[20] !== recomputeVirtualItems || $[21] !== scrollerRef) {
|
|
170
|
+
t7 = () => {
|
|
171
|
+
if (!enabled) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const scroller = scrollerRef?.current;
|
|
175
|
+
let lastHandledScrollTop = -Infinity;
|
|
176
|
+
let lastHandledHeight = -Infinity;
|
|
177
|
+
let lastHandledWidth = -Infinity;
|
|
178
|
+
const handleViewportChange = function handleViewportChange() {
|
|
179
|
+
const scrollTop = scroller ? scroller.scrollTop : window.scrollY;
|
|
180
|
+
const height_0 = scroller ? scroller.clientHeight : window.innerHeight;
|
|
181
|
+
const width = scroller ? scroller.clientWidth : window.innerWidth;
|
|
182
|
+
if (Math.abs(scrollTop - lastHandledScrollTop) >= minScrollAndResizeDeltaPx || Math.abs(height_0 - lastHandledHeight) >= minScrollAndResizeDeltaPx || Math.abs(width - lastHandledWidth) >= minScrollAndResizeDeltaPx) {
|
|
183
|
+
lastHandledScrollTop = scrollTop;
|
|
184
|
+
lastHandledHeight = height_0;
|
|
185
|
+
lastHandledWidth = width;
|
|
186
|
+
throttle(materializeVisibleSpacerItems, recomputeVirtualItems);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
const scrollTarget = scroller !== null && scroller !== void 0 ? scroller : window;
|
|
190
|
+
scrollTarget.addEventListener("scroll", handleViewportChange, {
|
|
191
|
+
passive: true
|
|
192
|
+
});
|
|
193
|
+
const resizeObserver = new ResizeObserver(handleViewportChange);
|
|
194
|
+
const resizeTarget = scroller !== null && scroller !== void 0 ? scroller : document.documentElement;
|
|
195
|
+
resizeObserver.observe(resizeTarget);
|
|
196
|
+
handleViewportChange();
|
|
197
|
+
return () => {
|
|
198
|
+
scrollTarget.removeEventListener("scroll", handleViewportChange);
|
|
199
|
+
resizeObserver.unobserve(resizeTarget);
|
|
200
|
+
resizeObserver.disconnect();
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
t8 = [enabled, materializeVisibleSpacerItems, minScrollAndResizeDeltaPx, recomputeVirtualItems, scrollerRef, throttle];
|
|
204
|
+
$[17] = enabled;
|
|
205
|
+
$[18] = materializeVisibleSpacerItems;
|
|
206
|
+
$[19] = minScrollAndResizeDeltaPx;
|
|
207
|
+
$[20] = recomputeVirtualItems;
|
|
208
|
+
$[21] = scrollerRef;
|
|
209
|
+
$[22] = t7;
|
|
210
|
+
$[23] = t8;
|
|
211
|
+
} else {
|
|
212
|
+
t7 = $[22];
|
|
213
|
+
t8 = $[23];
|
|
214
|
+
}
|
|
215
|
+
useEffect(t7, t8);
|
|
216
|
+
const intersectionObserverHandle = useIntersectionObserverHandle(scrollerRef, scrollerRef ? retentionMarginPx : undefined, !scrollerRef ? retentionMarginPx : undefined);
|
|
217
|
+
let t9;
|
|
218
|
+
if ($[24] !== enabled || $[25] !== recomputeVirtualItems) {
|
|
219
|
+
t9 = (index_0, height_1) => {
|
|
220
|
+
if (!enabled) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
itemsMaterialization.current[index_0] = height_1;
|
|
224
|
+
throttle(recomputeVirtualItems);
|
|
225
|
+
};
|
|
226
|
+
$[24] = enabled;
|
|
227
|
+
$[25] = recomputeVirtualItems;
|
|
228
|
+
$[26] = t9;
|
|
229
|
+
} else {
|
|
230
|
+
t9 = $[26];
|
|
231
|
+
}
|
|
232
|
+
const collapseItemIntoSpacer = t9;
|
|
233
|
+
let t10;
|
|
234
|
+
if ($[27] !== enabled || $[28] !== length) {
|
|
235
|
+
t10 = Array.from({
|
|
236
|
+
length: enabled ? 0 : length
|
|
237
|
+
}, _temp2);
|
|
238
|
+
$[27] = enabled;
|
|
239
|
+
$[28] = length;
|
|
240
|
+
$[29] = t10;
|
|
241
|
+
} else {
|
|
242
|
+
t10 = $[29];
|
|
243
|
+
}
|
|
244
|
+
const allVisibleVirtualItems = t10;
|
|
245
|
+
const t11 = enabled ? virtualItems : allVisibleVirtualItems;
|
|
246
|
+
let t12;
|
|
247
|
+
if ($[30] !== collapseItemIntoSpacer || $[31] !== intersectionObserverHandle || $[32] !== t11) {
|
|
248
|
+
t12 = {
|
|
249
|
+
virtualItems: t11,
|
|
250
|
+
intersectionObserverHandle,
|
|
251
|
+
collapseItemIntoSpacer
|
|
252
|
+
};
|
|
253
|
+
$[30] = collapseItemIntoSpacer;
|
|
254
|
+
$[31] = intersectionObserverHandle;
|
|
255
|
+
$[32] = t11;
|
|
256
|
+
$[33] = t12;
|
|
257
|
+
} else {
|
|
258
|
+
t12 = $[33];
|
|
259
|
+
}
|
|
260
|
+
return t12;
|
|
261
|
+
}
|
|
262
|
+
function _temp2(_, index_1) {
|
|
263
|
+
return {
|
|
264
|
+
type: "rendered",
|
|
265
|
+
index: index_1
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
function _temp(cb_0) {
|
|
269
|
+
return cb_0();
|
|
270
|
+
}
|
|
271
|
+
function SpacerRow(t0) {
|
|
272
|
+
const $ = c(10);
|
|
273
|
+
if ($[0] !== "4b7f7b12eb2c9ae3487ce5d00c7be96dc9b8807a6bbfe2c9b314700f443d7188") {
|
|
274
|
+
for (let $i = 0; $i < 10; $i += 1) {
|
|
275
|
+
$[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
276
|
+
}
|
|
277
|
+
$[0] = "4b7f7b12eb2c9ae3487ce5d00c7be96dc9b8807a6bbfe2c9b314700f443d7188";
|
|
278
|
+
}
|
|
279
|
+
const {
|
|
280
|
+
spacer: t1,
|
|
281
|
+
colSpan
|
|
282
|
+
} = t0;
|
|
283
|
+
const {
|
|
284
|
+
from,
|
|
285
|
+
to,
|
|
286
|
+
height
|
|
287
|
+
} = t1;
|
|
288
|
+
let t2;
|
|
289
|
+
if ($[1] !== height) {
|
|
290
|
+
t2 = {
|
|
291
|
+
height
|
|
292
|
+
};
|
|
293
|
+
$[1] = height;
|
|
294
|
+
$[2] = t2;
|
|
295
|
+
} else {
|
|
296
|
+
t2 = $[2];
|
|
297
|
+
}
|
|
298
|
+
let t3;
|
|
299
|
+
if ($[3] !== colSpan || $[4] !== t2) {
|
|
300
|
+
t3 = /*#__PURE__*/jsx("td", {
|
|
301
|
+
className: styles.spacerCell,
|
|
302
|
+
colSpan: colSpan,
|
|
303
|
+
style: t2
|
|
304
|
+
});
|
|
305
|
+
$[3] = colSpan;
|
|
306
|
+
$[4] = t2;
|
|
307
|
+
$[5] = t3;
|
|
308
|
+
} else {
|
|
309
|
+
t3 = $[5];
|
|
310
|
+
}
|
|
311
|
+
let t4;
|
|
312
|
+
if ($[6] !== from || $[7] !== t3 || $[8] !== to) {
|
|
313
|
+
t4 = /*#__PURE__*/jsx("tr", {
|
|
314
|
+
className: styles.spacerRow,
|
|
315
|
+
"data-from": from,
|
|
316
|
+
"data-to": to,
|
|
317
|
+
children: t3
|
|
318
|
+
});
|
|
319
|
+
$[6] = from;
|
|
320
|
+
$[7] = t3;
|
|
321
|
+
$[8] = to;
|
|
322
|
+
$[9] = t4;
|
|
323
|
+
} else {
|
|
324
|
+
t4 = $[9];
|
|
325
|
+
}
|
|
326
|
+
return t4;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export { SpacerRow, useTableVirtualize };
|
|
@@ -1,109 +1,211 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
+
export default Table;
|
|
4
|
+
export interface TableProps<T> {
|
|
5
|
+
/**
|
|
6
|
+
* The data items to render. `null` and `undefined` as an item is not supported.
|
|
7
|
+
* Referentially same items are not supported either.
|
|
8
|
+
*/
|
|
13
9
|
data: T[];
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Columns specification.
|
|
12
|
+
*/
|
|
13
|
+
columns: Column<T>[];
|
|
14
|
+
/**
|
|
15
|
+
* Used to render a row key, e.g. `<tr key={getKey(item, index)}>`.
|
|
16
|
+
*/
|
|
17
|
+
getKey: (item: T, index: number, items: T[]) => React.Key;
|
|
18
|
+
/**
|
|
19
|
+
* If true, the table header will not be rendered.
|
|
20
|
+
*/
|
|
21
|
+
noHeader?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Called when the client moves a row by dragging it.
|
|
24
|
+
*/
|
|
25
|
+
onItemMove?: (item: T, fromIndex: number, toIndex: number, items: T[]) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Called when the client clicks on SortButton in a column header.
|
|
28
|
+
*/
|
|
29
|
+
onSort?: (columnIndex: number, newOrder: SortOrder, columns: Column<T>[]) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Called when the client clicks on a column delete button in the header.
|
|
32
|
+
*/
|
|
33
|
+
onColumnDelete?: (columnIndex: number, columns: Column<T>[]) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Called when the client moves a column.
|
|
36
|
+
*/
|
|
37
|
+
onColumnMove?: (fromIndex: number, toIndex: number, columns: Column<T>[]) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Implement to specify props like `clickable`, handlers like `onClick`,
|
|
40
|
+
* a custom `className`, a `ref` etc., or to provide a custom renderer.
|
|
41
|
+
*
|
|
42
|
+
* ```tsx
|
|
43
|
+
* <Table
|
|
44
|
+
* renderItem={(item, index) => (
|
|
45
|
+
* <DefaultItemRenderer
|
|
46
|
+
* index={index}
|
|
47
|
+
* className='my-row'
|
|
48
|
+
* clickable
|
|
49
|
+
* onClick={() => setSelection(selection.focus(item))}
|
|
50
|
+
* />
|
|
51
|
+
* )}
|
|
52
|
+
* />
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* In your custom implementation, use `TableRow` and `TableCell` base components to apply the
|
|
56
|
+
* standard classnames, but beware that `tdClassName` won't be applied.
|
|
57
|
+
*
|
|
58
|
+
* You can also use `DefaultItemRenderer` in combination with your custom rows.
|
|
59
|
+
*/
|
|
60
|
+
renderItem?: (item: T, index: number, items: T[]) => ReactNode;
|
|
61
|
+
/**
|
|
62
|
+
* Only renders rows near the viewport.
|
|
63
|
+
*
|
|
64
|
+
* Rows may transition between two states:
|
|
65
|
+
* - materialized: rendered as actual table rows. This happens when the corresponding
|
|
66
|
+
* spacer approaches the viewport, as specified by `lookaheadPx`.
|
|
67
|
+
* - virtualized: replaced with spacer rows of the same height. This happens when the row
|
|
68
|
+
* moves sufficiently far from the viewport, as specified by `retentionMarginPx`.
|
|
69
|
+
*/
|
|
70
|
+
virtualizeRows?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Used with `virtualizeRows` as a source of scroll events, as a target for ResizeObserver,
|
|
73
|
+
* and as the root for IntersectionObserver. Required when the scrollable container is not
|
|
74
|
+
* the whole document.
|
|
75
|
+
*
|
|
76
|
+
* If not set:
|
|
77
|
+
* - scroll listener is attached to `window`
|
|
78
|
+
* - ResizeObserver observes `document.body`
|
|
79
|
+
* - IntersectionObserver has no root (i.e. the viewport is used)
|
|
80
|
+
*/
|
|
81
|
+
scrollerRef?: RefObject<HTMLElement | null>;
|
|
82
|
+
/**
|
|
83
|
+
* Used with `virtualizeRows` to estimate the height of items that have not been rendered yet.
|
|
84
|
+
* The function should be fast and side-effect free. Do not measure the DOM here.
|
|
85
|
+
* Once a row is rendered, its actual height will be measured and used instead of this estimate.
|
|
86
|
+
*
|
|
87
|
+
* Note the effects of imprecise estimates:
|
|
88
|
+
* - When the height is underestimated, the table may materialize more rows than specified by `lookaheadPx`.
|
|
89
|
+
* If the resulting rows extend beyond `retentionMarginPx`, they will be virtualized again.
|
|
90
|
+
* If this causes relayout flickering, increase `retentionMarginPx`.
|
|
91
|
+
* - When the height is overestimated, the table may materialize fewer rows than specified by `lookaheadPx`,
|
|
92
|
+
* which may leave a spacer partially visible. To avoid this, increase `lookaheadPx` (and
|
|
93
|
+
* `retentionMarginPx` accordingly, since it should be greater than `lookaheadPx`).
|
|
94
|
+
*
|
|
95
|
+
* Default: 37px = 16px padding + 20px line height + 1px border.
|
|
96
|
+
*/
|
|
97
|
+
estimateHeight?: (item: T, index: number, items: T[]) => number;
|
|
98
|
+
/**
|
|
99
|
+
* When using `virtualizeRows`, the number of pixels above and below the viewport
|
|
100
|
+
* to materialize in advance.
|
|
101
|
+
*
|
|
102
|
+
* Increase this value if blank space becomes visible during fast scrolling.
|
|
103
|
+
*
|
|
104
|
+
* Default: 400px.
|
|
105
|
+
*/
|
|
106
|
+
lookaheadPx?: number;
|
|
107
|
+
/**
|
|
108
|
+
* Used with `virtualizeRows`. Additional margin around the viewport before
|
|
109
|
+
* materialized rows become eligible for virtualization.
|
|
110
|
+
*
|
|
111
|
+
* Increasing this value reduces row churn when heights are underestimated.
|
|
112
|
+
* In that case, the table may materialize more rows than needed and then immediately
|
|
113
|
+
* virtualize them again. A larger margin keeps such rows rendered for longer,
|
|
114
|
+
* at the cost of rendering more rows overall.
|
|
115
|
+
*
|
|
116
|
+
* This value should be greater than `lookaheadPx`.
|
|
117
|
+
* Increase it if you notice table relayouts during initial render or scrolling.
|
|
118
|
+
*
|
|
119
|
+
* Default: 450px.
|
|
120
|
+
*/
|
|
121
|
+
retentionMarginPx?: number;
|
|
122
|
+
/**
|
|
123
|
+
* When using `virtualizeRows`, ignore scroll and resize position changes
|
|
124
|
+
* smaller than this value.
|
|
125
|
+
*
|
|
126
|
+
* Measurement inaccuracies and rounding artifacts may slightly change the
|
|
127
|
+
* table layout during materialization and virtualization. With scroll
|
|
128
|
+
* anchoring enabled (the default browser behavior), the browser may then
|
|
129
|
+
* adjust the scroll position, triggering additional scroll or resize events.
|
|
130
|
+
* Small deltas are ignored to prevent such feedback loops from causing
|
|
131
|
+
* oscillations at virtualization boundaries.
|
|
132
|
+
*
|
|
133
|
+
* Increase if you expect high inaccuracy in height measurements, or if you
|
|
134
|
+
* notice oscillations at virtualization boundaries.
|
|
135
|
+
*
|
|
136
|
+
* Default: 50px.
|
|
137
|
+
*/
|
|
138
|
+
minScrollAndResizeDeltaPx?: number;
|
|
139
|
+
/**
|
|
140
|
+
* Whether to show a small gear button at the top right corner.
|
|
141
|
+
*/
|
|
142
|
+
columnEditButton?: 'everywhere' | 'mobileOnly';
|
|
143
|
+
/**
|
|
144
|
+
* Applied to the `<thead>` element.
|
|
145
|
+
*/
|
|
146
|
+
theadClassName?: string;
|
|
147
|
+
/**
|
|
148
|
+
* Applied to the only `<tr>` element within the `<thead>`.
|
|
149
|
+
*/
|
|
150
|
+
theadTrClassName?: string;
|
|
151
|
+
/**
|
|
152
|
+
* Applied to the `<tbody>` element.
|
|
153
|
+
*/
|
|
154
|
+
tbodyClassName?: string;
|
|
56
155
|
}
|
|
156
|
+
export type SortOrder = 'none' | 'ascending' | 'descending';
|
|
57
157
|
/**
|
|
58
|
-
*
|
|
158
|
+
* The column specification.
|
|
59
159
|
*/
|
|
60
|
-
export
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
160
|
+
export interface Column<T> {
|
|
161
|
+
/**
|
|
162
|
+
* Used to render a row key, e.g. `<thead><tr><td key={getKey(item, index, items)}...</td></tr></thead>`.
|
|
163
|
+
*/
|
|
164
|
+
key: React.Key;
|
|
165
|
+
/**
|
|
166
|
+
* Used in aria-labels of controls which do not contain text,
|
|
167
|
+
* e.g. `DeleteColumnButton`. If not set, the `String(key)` is used.
|
|
168
|
+
*/
|
|
169
|
+
name?: string;
|
|
170
|
+
/**
|
|
171
|
+
* Default: name ?? String(key)
|
|
172
|
+
*/
|
|
173
|
+
renderHeader?: () => ReactNode;
|
|
174
|
+
/**
|
|
175
|
+
* Renders a single cell value for a column.
|
|
176
|
+
* Default:
|
|
177
|
+
* - If item is an Array, renders `String(item[columnIndex])`
|
|
178
|
+
* - If item is an Object, renders `Object.values(item)[columnIndex]`
|
|
179
|
+
* - Otherwise:
|
|
180
|
+
* - The first column renders `String(item)`
|
|
181
|
+
* - Other columns render empty value
|
|
182
|
+
*/
|
|
183
|
+
renderCell?: (item: T, index: number, items: T[]) => ReactNode;
|
|
184
|
+
/**
|
|
185
|
+
* If the column gets an indent when `TableProps.getItemLevel()` returns
|
|
186
|
+
* a positive number.
|
|
187
|
+
*/
|
|
188
|
+
indent?: boolean;
|
|
189
|
+
/**
|
|
190
|
+
* The current sort order displayed by `SortButton` and indicated
|
|
191
|
+
* by `aria-sort` in `th`.
|
|
192
|
+
*
|
|
193
|
+
* - `undefined` or not set means that the column is not sortable,
|
|
194
|
+
* and it shouldn't have a `SortButton`.
|
|
195
|
+
* - `none` means that the column is sortable, but currently not sorted.
|
|
196
|
+
* It should include a `SortButton`.
|
|
197
|
+
* - `ascending` and `descending` mean that the column is sorted
|
|
198
|
+
* in the corresponding order, and it should include a `SortButton`.
|
|
199
|
+
*/
|
|
200
|
+
sortOrder?: SortOrder;
|
|
201
|
+
/**
|
|
202
|
+
* The classname to apply to the `th` element inside `table / thead`.
|
|
203
|
+
*/
|
|
204
|
+
thClassName?: string;
|
|
205
|
+
/**
|
|
206
|
+
* The classname to apply to the `td` element inside `table / tbody`.
|
|
207
|
+
* If a custom `TableProps.renderItem` is provided, this prop is not used,
|
|
208
|
+
* unless the custom renderer falls back to `DefaultItemRenderer`.
|
|
209
|
+
*/
|
|
210
|
+
tdClassName?: (item: T, index: number, items: T[]) => string | undefined;
|
|
109
211
|
}
|