@jetbrains/ring-ui 8.0.0-beta.1 → 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/alert/alert-actions.d.ts +4 -0
- package/components/alert/alert-actions.js +5 -0
- package/components/alert/alert-heading.d.ts +4 -0
- package/components/alert/alert-heading.js +6 -0
- package/components/alert/alert.css +63 -22
- package/components/alert/alert.d.ts +14 -1
- package/components/alert/alert.js +34 -19
- package/components/alert/container.css +1 -2
- package/components/alert-service/alert-service.d.ts +2 -1
- package/components/alert-service/alert-service.js +8 -4
- package/components/auth/auth-core.d.ts +5 -9
- package/components/auth/auth-core.js +56 -15
- 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/banner/banner.css +3 -3
- 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 +5 -5
- package/components/checkbox/checkbox.d.ts +1 -1
- package/components/collapse/collapse-content.d.ts +7 -0
- package/components/collapse/collapse-content.js +44 -11
- package/components/collapse/collapse-context.d.ts +2 -0
- package/components/collapse/collapse-context.js +2 -0
- package/components/collapse/collapse-control.js +2 -2
- package/components/collapse/collapse.css +8 -2
- package/components/collapse/collapse.d.ts +9 -0
- package/components/collapse/collapse.js +12 -3
- package/components/{expand → collapsible-group}/collapsible-group.css +7 -1
- package/components/collapsible-group/collapsible-group.d.ts +33 -0
- package/components/{expand → collapsible-group}/collapsible-group.js +13 -21
- package/components/confirm-service/confirm-service.js +2 -2
- package/components/data-list/data-list.d.ts +1 -1
- 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/consts.d.ts +1 -0
- package/components/date-picker/date-input.js +6 -2
- package/components/date-picker/months.js +2 -2
- package/components/date-picker/use-scroll-behavior.js +5 -6
- package/components/date-picker/years.js +2 -2
- 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 +18 -19
- package/components/global/compose-refs.d.ts +2 -1
- package/components/global/compose-refs.js +24 -8
- 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 +31 -11
- package/components/global/intersection-observer-context.js +47 -28
- 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/{legacy-table/selection.d.ts → global/table-selection.d.ts} +14 -14
- package/components/{legacy-table/selection.js → global/table-selection.js} +2 -2
- package/components/global/theme.d.ts +4 -3
- package/components/global/theme.js +8 -8
- package/components/global/variables.css +18 -28
- package/components/global/variables.interface.d.ts +0 -4
- package/components/global/variables_dark.css +18 -25
- package/components/header/header.css +3 -3
- package/components/http/http.d.ts +2 -2
- package/components/http/http.js +2 -2
- package/components/i18n/i18n-context.js +1 -1
- package/components/i18n/i18n.d.ts +1 -0
- package/components/i18n/messages.json +1 -0
- 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/legacy-table/cell.js +1 -1
- package/components/legacy-table/header-cell.js +1 -1
- package/components/legacy-table/header.js +1 -1
- package/components/legacy-table/multitable.d.ts +1 -1
- package/components/legacy-table/row.d.ts +1 -1
- package/components/legacy-table/row.js +1 -1
- package/components/legacy-table/selection-adapter.d.ts +3 -3
- package/components/legacy-table/selection-shortcuts-hoc.d.ts +5 -5
- package/components/legacy-table/simple-table.d.ts +2 -2
- package/components/legacy-table/simple-table.js +3 -3
- package/components/legacy-table/smart-table.d.ts +5 -5
- package/components/legacy-table/smart-table.js +3 -3
- package/components/legacy-table/table.js +1 -1
- 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.d.ts +2 -0
- package/components/popup/popup.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 +41 -11
- package/components/table/default-item-renderer.js +60 -47
- 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/{table-virtualize.js → internal/virtualization.js} +82 -46
- 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 +8 -6
- package/components/table/table-const.js +7 -5
- 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 +179 -67
- package/components/table/table.d.ts +231 -224
- package/components/table/table.js +327 -2
- package/components/tag/tag.css +3 -3
- 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/user-card/smart-user-card-tooltip.d.ts +1 -1
- package/components/util-stories.d.ts +26 -0
- package/components/util-stories.js +61 -0
- package/package.json +44 -47
- 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.d.ts +0 -16
- package/components/global/composeRefs.d.ts +0 -6
- package/components/global/composeRefs.js +0 -7
- package/components/global/use-event-callback.d.ts +0 -1
- package/components/global/use-event-callback.js +0 -15
- 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/table-base.d.ts +0 -24
- package/components/table/table-base.js +0 -79
- package/components/table/table-component.d.ts +0 -53
- package/components/table/table-component.js +0 -101
- package/components/table/table-virtualize.d.ts +0 -32
- /package/components/legacy-table/{table.css → legacy-table.css} +0 -0
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Component, type HTMLAttributes } from 'react';
|
|
2
|
-
export interface GridProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
-
'data-test'?: string | null | undefined;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* @name Grid
|
|
7
|
-
* @deprecated Will be removed in Ring UI 8.0. Use flexbox or another layout library instead.
|
|
8
|
-
*/
|
|
9
|
-
export declare class Grid extends Component<GridProps> {
|
|
10
|
-
render(): import("react").JSX.Element;
|
|
11
|
-
}
|
|
12
|
-
export { default as Row } from './row';
|
|
13
|
-
export { default as Col } from './col';
|
package/components/grid/grid.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Component } from 'react';
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import dataTests from '../global/data-tests';
|
|
4
|
-
import styles from './grid.css';
|
|
5
|
-
/**
|
|
6
|
-
* @name Grid
|
|
7
|
-
* @deprecated Will be removed in Ring UI 8.0. Use flexbox or another layout library instead.
|
|
8
|
-
*/
|
|
9
|
-
export class Grid extends Component {
|
|
10
|
-
render() {
|
|
11
|
-
const { children, className, 'data-test': dataTest, ...restProps } = this.props;
|
|
12
|
-
const classes = classNames(styles['container-fluid'], className);
|
|
13
|
-
return (<div data-test={dataTests('ring-grid', dataTest)} {...restProps} className={classes}>
|
|
14
|
-
{children}
|
|
15
|
-
</div>);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export { default as Row } from './row';
|
|
19
|
-
export { default as Col } from './col';
|
package/components/grid/row.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Component, type HTMLAttributes } from 'react';
|
|
2
|
-
type ModifierType = 'xs' | 'sm' | 'md' | 'lg';
|
|
3
|
-
export interface RowProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
-
'data-test'?: string | null | undefined;
|
|
5
|
-
reverse?: boolean | null | undefined;
|
|
6
|
-
start?: ModifierType | null | undefined;
|
|
7
|
-
center?: ModifierType | null | undefined;
|
|
8
|
-
end?: ModifierType | null | undefined;
|
|
9
|
-
top?: ModifierType | null | undefined;
|
|
10
|
-
middle?: ModifierType | null | undefined;
|
|
11
|
-
baseline?: ModifierType | null | undefined;
|
|
12
|
-
bottom?: ModifierType | null | undefined;
|
|
13
|
-
around?: ModifierType | null | undefined;
|
|
14
|
-
between?: ModifierType | null | undefined;
|
|
15
|
-
first?: ModifierType | null | undefined;
|
|
16
|
-
last?: ModifierType | null | undefined;
|
|
17
|
-
}
|
|
18
|
-
export default class Row extends Component<RowProps> {
|
|
19
|
-
render(): import("react").JSX.Element;
|
|
20
|
-
}
|
|
21
|
-
export {};
|
package/components/grid/row.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Component } from 'react';
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import dataTests from '../global/data-tests';
|
|
4
|
-
import styles from './grid.css';
|
|
5
|
-
const modifierKeys = [
|
|
6
|
-
'start',
|
|
7
|
-
'center',
|
|
8
|
-
'end', // text-align, justify-content
|
|
9
|
-
'around',
|
|
10
|
-
'between', // justify-content
|
|
11
|
-
'top',
|
|
12
|
-
'middle',
|
|
13
|
-
'baseline',
|
|
14
|
-
'bottom', // align-items
|
|
15
|
-
'first',
|
|
16
|
-
'last', // order
|
|
17
|
-
];
|
|
18
|
-
/**
|
|
19
|
-
* Converts xs="middle" to class "middle-xs"
|
|
20
|
-
* @param {Object} props incoming props
|
|
21
|
-
* @mockReturnValue {Array} result modifier classes
|
|
22
|
-
*/
|
|
23
|
-
function getModifierClassNames(props) {
|
|
24
|
-
return modifierKeys.reduce((result, key) => {
|
|
25
|
-
if (props[key]) {
|
|
26
|
-
return result.concat(styles[`${key}-${props[key]}`]);
|
|
27
|
-
}
|
|
28
|
-
return result;
|
|
29
|
-
}, []);
|
|
30
|
-
}
|
|
31
|
-
export default class Row extends Component {
|
|
32
|
-
render() {
|
|
33
|
-
const { children, className, 'data-test': dataTest, reverse, start, center, end, top, middle, baseline, bottom, around, between, first, last, ...restProps } = this.props;
|
|
34
|
-
const classes = classNames(className, styles.row, getModifierClassNames({ start, center, end, top, middle, baseline, bottom, around, between, first, last }), {
|
|
35
|
-
[styles.reverse]: reverse,
|
|
36
|
-
});
|
|
37
|
-
return (<div {...restProps} className={classes} data-test={dataTests('ring-grid-row', dataTest)}>
|
|
38
|
-
{children}
|
|
39
|
-
</div>);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function stop() {}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { stop as default } from './old-browsers-message';
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
@import '../global/variables.css';
|
|
2
|
-
|
|
3
|
-
:global(.ring-old-browsers-message) {
|
|
4
|
-
display: block;
|
|
5
|
-
|
|
6
|
-
margin-top: 15%;
|
|
7
|
-
|
|
8
|
-
text-align: center;
|
|
9
|
-
|
|
10
|
-
color: var(--ring-text-color);
|
|
11
|
-
|
|
12
|
-
font-family: system-ui, Ubuntu, 'Helvetica Neue', Arial, sans-serif;
|
|
13
|
-
font-size: var(--ring-font-size-larger);
|
|
14
|
-
line-height: calc(2.5 * var(--ring-unit));
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
:global(.ring-old-browsers-message_hidden) {
|
|
18
|
-
display: none;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
:global(.ring-old-browsers-message__smile) {
|
|
22
|
-
cursor: pointer;
|
|
23
|
-
user-select: none;
|
|
24
|
-
|
|
25
|
-
font-size: calc(3 * var(--ring-unit));
|
|
26
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { isBrowserInWhiteList } from './white-list';
|
|
2
|
-
/**
|
|
3
|
-
* @name Old Browsers Message
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
The list of versions which are definitely supported. "Browser is unsupported"
|
|
7
|
-
won't be displayed for those and higher versions even when a JS error occurs
|
|
8
|
-
on application start.
|
|
9
|
-
*/
|
|
10
|
-
let smileChanges = 0;
|
|
11
|
-
const MAX_SMILE_CHANGES = 50;
|
|
12
|
-
let previousWindowErrorHandler;
|
|
13
|
-
function changeSmileClickListener(event) {
|
|
14
|
-
const eyes = ['O', 'o', '-', '>', '<'];
|
|
15
|
-
const target = (event.target || event.srcElement);
|
|
16
|
-
smileChanges++;
|
|
17
|
-
function rand(min, max) {
|
|
18
|
-
return Math.round(Math.random() * (max - min)) + min;
|
|
19
|
-
}
|
|
20
|
-
function getRandomEye() {
|
|
21
|
-
return eyes[rand(0, eyes.length - 1)];
|
|
22
|
-
}
|
|
23
|
-
function getRandomSmile() {
|
|
24
|
-
if (smileChanges >= MAX_SMILE_CHANGES) {
|
|
25
|
-
return '\\\\ (x_x) //';
|
|
26
|
-
}
|
|
27
|
-
return `{{ (${getRandomEye()}_${getRandomEye()}) }}`;
|
|
28
|
-
}
|
|
29
|
-
target.innerHTML = getRandomSmile();
|
|
30
|
-
}
|
|
31
|
-
function attachSmileClickListener(smileNode) {
|
|
32
|
-
if (smileNode.addEventListener) {
|
|
33
|
-
smileNode.addEventListener('click', changeSmileClickListener);
|
|
34
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
35
|
-
}
|
|
36
|
-
else if (smileNode.attachEvent) {
|
|
37
|
-
smileNode.attachEvent('onclick', changeSmileClickListener);
|
|
38
|
-
/* eslint-enable */
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Listens to unhandled errors and displays passed node
|
|
43
|
-
*/
|
|
44
|
-
function startOldBrowsersDetector(onOldBrowserDetected) {
|
|
45
|
-
previousWindowErrorHandler = window.onerror;
|
|
46
|
-
window.onerror = function oldBrowsersMessageShower(errorMsg, url, lineNumber) {
|
|
47
|
-
if (onOldBrowserDetected) {
|
|
48
|
-
onOldBrowserDetected();
|
|
49
|
-
}
|
|
50
|
-
if (previousWindowErrorHandler) {
|
|
51
|
-
return previousWindowErrorHandler(errorMsg, url, lineNumber);
|
|
52
|
-
}
|
|
53
|
-
return false;
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* @deprecated Will be removed in Ring UI 8.0.
|
|
58
|
-
*/
|
|
59
|
-
function stopOldBrowserDetector() {
|
|
60
|
-
window.onerror = previousWindowErrorHandler;
|
|
61
|
-
}
|
|
62
|
-
//Start javascript error detection
|
|
63
|
-
startOldBrowsersDetector(() => {
|
|
64
|
-
const oldBrowsersMessageContainer = document.getElementById('ring-old-browsers-message');
|
|
65
|
-
const browserMessage = document.getElementById('ring-old-browsers-message__browser-message');
|
|
66
|
-
const errorMessage = document.getElementById('ring-old-browsers-message__error-message');
|
|
67
|
-
const smileNode = document.getElementById('ring-old-browsers-message__smile');
|
|
68
|
-
if (browserMessage && errorMessage) {
|
|
69
|
-
if (isBrowserInWhiteList()) {
|
|
70
|
-
browserMessage.style.display = 'none';
|
|
71
|
-
errorMessage.style.display = 'block';
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
browserMessage.style.display = 'block';
|
|
75
|
-
errorMessage.style.display = 'none';
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
if (oldBrowsersMessageContainer) {
|
|
79
|
-
oldBrowsersMessageContainer.hidden = false;
|
|
80
|
-
oldBrowsersMessageContainer.style.display = 'block';
|
|
81
|
-
}
|
|
82
|
-
if (smileNode) {
|
|
83
|
-
attachSmileClickListener(smileNode);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
export { stopOldBrowserDetector as stop };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import sniffer from '../global/sniffer';
|
|
2
|
-
const MAJOR_VERSION_INDEX = 0;
|
|
3
|
-
/**
|
|
4
|
-
* SUPPORTED_BROWSERS are defined by Babel plugin, see babel config
|
|
5
|
-
*/
|
|
6
|
-
if (!SUPPORTED_BROWSERS) {
|
|
7
|
-
// eslint-disable-next-line no-console
|
|
8
|
-
console.warn('Ring UI: no SUPPORTED_BROWSERS passed. Please check babel config.');
|
|
9
|
-
}
|
|
10
|
-
const SUPPORTED = SUPPORTED_BROWSERS || [];
|
|
11
|
-
const WHITE_LISTED_BROWSERS = ['chrome', 'firefox', 'safari', 'edge'];
|
|
12
|
-
export const WHITE_LIST = SUPPORTED.reduce((acc, item) => {
|
|
13
|
-
const [, browserName, version] = item.match(/(\S+)\s(\S+)/) ?? [];
|
|
14
|
-
if (!WHITE_LISTED_BROWSERS.includes(browserName)) {
|
|
15
|
-
return acc;
|
|
16
|
-
}
|
|
17
|
-
return {
|
|
18
|
-
...acc,
|
|
19
|
-
[browserName]: parseInt(version, 10),
|
|
20
|
-
};
|
|
21
|
-
}, {});
|
|
22
|
-
export function isBrowserInWhiteList() {
|
|
23
|
-
return sniffer.browser.version[MAJOR_VERSION_INDEX] >= WHITE_LIST[sniffer.browser.name];
|
|
24
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { type ComponentPropsWithoutRef } from 'react';
|
|
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>(props: ComponentPropsWithoutRef<'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>(props: ComponentPropsWithoutRef<'button'>): import("react").JSX.Element | null;
|
|
13
|
-
/**
|
|
14
|
-
* A helper `<tr>` component for a custom {@link TableProps.renderItem} implementations.
|
|
15
|
-
* Applies the standard row classnames.
|
|
16
|
-
*/
|
|
17
|
-
export declare function TableRow(props: {
|
|
18
|
-
ref?: React.Ref<HTMLTableRowElement>;
|
|
19
|
-
} & ComponentPropsWithoutRef<'tr'>): import("react").JSX.Element;
|
|
20
|
-
/**
|
|
21
|
-
* A helper `<td>` component for a custom {@link TableProps.renderItem} implementations.
|
|
22
|
-
* Applies the standard cell classnames, but not data-dependent `tdClassName`.
|
|
23
|
-
*/
|
|
24
|
-
export declare function TableCell(props: ComponentPropsWithoutRef<'td'>): import("react").JSX.Element;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { useContext } from 'react';
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import unsortedIcon from '@jetbrains/icons/unsorted-12px';
|
|
4
|
-
import arrowDownIcon from '@jetbrains/icons/arrow-12px-down';
|
|
5
|
-
import arrowUpIcon from '@jetbrains/icons/arrow-12px-up';
|
|
6
|
-
import trashIcon from '@jetbrains/icons/trash-12px';
|
|
7
|
-
import Icon from '../icon/icon';
|
|
8
|
-
import { ColumnIndexContext, TablePropsContext } from './table-const';
|
|
9
|
-
import styles from './table.css';
|
|
10
|
-
/**
|
|
11
|
-
* Include it in a column header to make the column sortable.
|
|
12
|
-
* Handle clicks with {@link TableProps.onSort}.
|
|
13
|
-
*/
|
|
14
|
-
export function SortButton(props) {
|
|
15
|
-
const tableProps = useContext(TablePropsContext);
|
|
16
|
-
const columnIndex = useContext(ColumnIndexContext);
|
|
17
|
-
const column = tableProps?.columns[columnIndex];
|
|
18
|
-
if (!tableProps || !column) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
const sortOrder = column.sortOrder ?? 'none';
|
|
22
|
-
// eslint-disable-next-line no-nested-ternary, prettier/prettier
|
|
23
|
-
const glyph = sortOrder === 'none' ? unsortedIcon
|
|
24
|
-
: sortOrder === 'ascending' ? arrowUpIcon
|
|
25
|
-
: arrowDownIcon;
|
|
26
|
-
const { className, children, onClick, ...restProps } = props;
|
|
27
|
-
function handleClick(e) {
|
|
28
|
-
onClick?.(e);
|
|
29
|
-
if (!e.defaultPrevented) {
|
|
30
|
-
const sequence = ['none', 'ascending', 'descending'];
|
|
31
|
-
const nextOrder = sequence[(sequence.indexOf(sortOrder) + 1) % sequence.length];
|
|
32
|
-
tableProps.onSort?.(columnIndex, nextOrder);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return (<button type='button' className={classNames(styles.headerButton, className)} onClick={handleClick} {...restProps}>
|
|
36
|
-
{children} <Icon glyph={glyph} aria-hidden/>
|
|
37
|
-
</button>);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Include it in a column header to make the column deletable.
|
|
41
|
-
* Beware that `column.name ?? String(column.key)` is used in the aria-label.
|
|
42
|
-
* Handle clicks with {@link TableProps.onColumnDelete}.
|
|
43
|
-
*/
|
|
44
|
-
export function DeleteColumnButton(props) {
|
|
45
|
-
const tableProps = useContext(TablePropsContext);
|
|
46
|
-
const columnIndex = useContext(ColumnIndexContext);
|
|
47
|
-
const column = tableProps?.columns[columnIndex];
|
|
48
|
-
if (!tableProps || !column) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
const { className, onClick, ...restProps } = props;
|
|
52
|
-
function handleClick(e) {
|
|
53
|
-
onClick?.(e);
|
|
54
|
-
if (!e.defaultPrevented) {
|
|
55
|
-
tableProps.onColumnDelete?.(columnIndex);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return (<button type='button' className={classNames(styles.headerButton, styles.deleteColumnButton, className)} onClick={handleClick} aria-label={`Delete column ${column.name ?? String(column.key)}`} {...restProps}>
|
|
59
|
-
<Icon glyph={trashIcon}/>
|
|
60
|
-
</button>);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* A helper `<tr>` component for a custom {@link TableProps.renderItem} implementations.
|
|
64
|
-
* Applies the standard row classnames.
|
|
65
|
-
*/
|
|
66
|
-
export function TableRow(props) {
|
|
67
|
-
const { ref, className, ...restProps } = props;
|
|
68
|
-
const classes = classNames(styles.row, className);
|
|
69
|
-
return <tr ref={ref} className={classes} {...restProps}/>;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* A helper `<td>` component for a custom {@link TableProps.renderItem} implementations.
|
|
73
|
-
* Applies the standard cell classnames, but not data-dependent `tdClassName`.
|
|
74
|
-
*/
|
|
75
|
-
export function TableCell(props) {
|
|
76
|
-
const { className, ...restProps } = props;
|
|
77
|
-
const classes = classNames(styles.cell, className);
|
|
78
|
-
return <td className={classes} {...restProps}/>;
|
|
79
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { type ComponentPropsWithoutRef } from 'react';
|
|
2
|
-
import type { TableProps } from './table';
|
|
3
|
-
/**
|
|
4
|
-
* The new Table component. Use it instead of tables in the `legacy-table` folder.
|
|
5
|
-
*
|
|
6
|
-
* Minimal usage requires the following props:
|
|
7
|
-
* - `data`
|
|
8
|
-
* - `getKey`
|
|
9
|
-
* - `columns`
|
|
10
|
-
* - `key`
|
|
11
|
-
* - `renderCell` (not required, but usually needed)
|
|
12
|
-
*
|
|
13
|
-
* ## Selection
|
|
14
|
-
*
|
|
15
|
-
* Following three props support the selection:
|
|
16
|
-
*
|
|
17
|
-
* - `selection`
|
|
18
|
-
* - `isItemClickable`
|
|
19
|
-
* - `DefaultItemRenderer.onClick`
|
|
20
|
-
*
|
|
21
|
-
* Only `selection` is required: you can display and modify selection your way, e.g., via
|
|
22
|
-
* checkboxes in cells.
|
|
23
|
-
*
|
|
24
|
-
* ## Sorting
|
|
25
|
-
* You need the following to support sorting:
|
|
26
|
-
*
|
|
27
|
-
* - Include `<SortButton />` in a column header
|
|
28
|
-
* - Set initial `Column.sortOrder` to `none`, `ascending`.
|
|
29
|
-
* Do not leave `undefined` for the accessibility reasons.
|
|
30
|
-
* - Handle `TableProps.onSort` callback in the client code. It is expected
|
|
31
|
-
* to update `columns`, by setting the new `sortOrder` value for
|
|
32
|
-
* the corresponding column, and updating the data accordingly.
|
|
33
|
-
*
|
|
34
|
-
* ## Deleting columns
|
|
35
|
-
* You need the following to support deleting columns:
|
|
36
|
-
*
|
|
37
|
-
* - Make sure the `column` has a proper `name` or `key` prop, which will be
|
|
38
|
-
* automatically included in the aria-label of `<DeleteColumnButton />`.
|
|
39
|
-
* - Include `<DeleteColumnButton />` in a column header
|
|
40
|
-
* - Handle `TableProps.onColumnDelete` callback in the client code. It is expected
|
|
41
|
-
* to update `columns` by removing the corresponding column.
|
|
42
|
-
*
|
|
43
|
-
* ## Row virtualization
|
|
44
|
-
*
|
|
45
|
-
* To render only rows near the viewport and replace others with spacers, use:
|
|
46
|
-
*
|
|
47
|
-
* - `virtualizeRows`
|
|
48
|
-
* - `scrollerRef` — required when the scrollable container is not the whole document
|
|
49
|
-
* - `estimateHeight` — recommended when rows are expected to be taller than
|
|
50
|
-
* the default height (e.g. multiline or custom content)
|
|
51
|
-
* - Fine-tuning props: `lookaheadPx`, `retentionMarginPx`, `minScrollAndResizeDeltaPx`
|
|
52
|
-
*/
|
|
53
|
-
export default function Table<T>(props: TableProps<T> & ComponentPropsWithoutRef<'table'>): import("react").JSX.Element;
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { useRef } from 'react';
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import { IntersectionObserverContext } from '../global/intersection-observer-context';
|
|
4
|
-
import { SpacerRow, useTableVirtualize } from './table-virtualize';
|
|
5
|
-
import { DefaultItemRenderer } from './default-item-renderer';
|
|
6
|
-
import { CollapseItemIntoSpacerContext, ColumnIndexContext, defaultLookaheadPx, defaultMinScrollAndResizeDeltaPx, defaultRetentionMarginPx, defaultRowHeight, TablePropsContext, } from './table-const';
|
|
7
|
-
import styles from './table.css';
|
|
8
|
-
/**
|
|
9
|
-
* The new Table component. Use it instead of tables in the `legacy-table` folder.
|
|
10
|
-
*
|
|
11
|
-
* Minimal usage requires the following props:
|
|
12
|
-
* - `data`
|
|
13
|
-
* - `getKey`
|
|
14
|
-
* - `columns`
|
|
15
|
-
* - `key`
|
|
16
|
-
* - `renderCell` (not required, but usually needed)
|
|
17
|
-
*
|
|
18
|
-
* ## Selection
|
|
19
|
-
*
|
|
20
|
-
* Following three props support the selection:
|
|
21
|
-
*
|
|
22
|
-
* - `selection`
|
|
23
|
-
* - `isItemClickable`
|
|
24
|
-
* - `DefaultItemRenderer.onClick`
|
|
25
|
-
*
|
|
26
|
-
* Only `selection` is required: you can display and modify selection your way, e.g., via
|
|
27
|
-
* checkboxes in cells.
|
|
28
|
-
*
|
|
29
|
-
* ## Sorting
|
|
30
|
-
* You need the following to support sorting:
|
|
31
|
-
*
|
|
32
|
-
* - Include `<SortButton />` in a column header
|
|
33
|
-
* - Set initial `Column.sortOrder` to `none`, `ascending`.
|
|
34
|
-
* Do not leave `undefined` for the accessibility reasons.
|
|
35
|
-
* - Handle `TableProps.onSort` callback in the client code. It is expected
|
|
36
|
-
* to update `columns`, by setting the new `sortOrder` value for
|
|
37
|
-
* the corresponding column, and updating the data accordingly.
|
|
38
|
-
*
|
|
39
|
-
* ## Deleting columns
|
|
40
|
-
* You need the following to support deleting columns:
|
|
41
|
-
*
|
|
42
|
-
* - Make sure the `column` has a proper `name` or `key` prop, which will be
|
|
43
|
-
* automatically included in the aria-label of `<DeleteColumnButton />`.
|
|
44
|
-
* - Include `<DeleteColumnButton />` in a column header
|
|
45
|
-
* - Handle `TableProps.onColumnDelete` callback in the client code. It is expected
|
|
46
|
-
* to update `columns` by removing the corresponding column.
|
|
47
|
-
*
|
|
48
|
-
* ## Row virtualization
|
|
49
|
-
*
|
|
50
|
-
* To render only rows near the viewport and replace others with spacers, use:
|
|
51
|
-
*
|
|
52
|
-
* - `virtualizeRows`
|
|
53
|
-
* - `scrollerRef` — required when the scrollable container is not the whole document
|
|
54
|
-
* - `estimateHeight` — recommended when rows are expected to be taller than
|
|
55
|
-
* the default height (e.g. multiline or custom content)
|
|
56
|
-
* - Fine-tuning props: `lookaheadPx`, `retentionMarginPx`, `minScrollAndResizeDeltaPx`
|
|
57
|
-
*/
|
|
58
|
-
export default function Table(props) {
|
|
59
|
-
const { data, columns, getKey, selection, isItemKeyboardFocusable, onItemFocus, onItemMove, onSort, onColumnDelete, onColumnMove, renderItem, virtualizeRows = false, scrollerRef, estimateHeight = () => defaultRowHeight, lookaheadPx = defaultLookaheadPx, retentionMarginPx = defaultRetentionMarginPx, minScrollAndResizeDeltaPx = defaultMinScrollAndResizeDeltaPx, columnEditButton, ref: userRef, className, theadClassName, theadTrClassName, tbodyClassName, ...restProps } = props;
|
|
60
|
-
const selfRef = useRef(null);
|
|
61
|
-
const tableRef = userRef ?? selfRef;
|
|
62
|
-
const { virtualItems, intersectionObserverHandle, collapseItemIntoSpacer } = useTableVirtualize({
|
|
63
|
-
enabled: virtualizeRows,
|
|
64
|
-
length: data.length,
|
|
65
|
-
scrollerRef,
|
|
66
|
-
tableRef,
|
|
67
|
-
estimateHeight,
|
|
68
|
-
lookaheadPx,
|
|
69
|
-
retentionMarginPx,
|
|
70
|
-
minScrollAndResizeDeltaPx,
|
|
71
|
-
});
|
|
72
|
-
return (<TablePropsContext.Provider value={props}>
|
|
73
|
-
<IntersectionObserverContext.Provider value={intersectionObserverHandle}>
|
|
74
|
-
<table className={classNames(styles.table, className)} ref={tableRef} {...restProps}>
|
|
75
|
-
<thead className={theadClassName}>
|
|
76
|
-
<tr className={classNames(styles.headerRow, theadTrClassName)}>
|
|
77
|
-
{columns.map((column, columnIndex) => (<th key={column.key} className={classNames(styles.headerCell, column.thClassName)} aria-sort={column.sortOrder}>
|
|
78
|
-
<ColumnIndexContext.Provider value={columnIndex}>
|
|
79
|
-
{column.renderHeader?.() ?? column.name ?? String(column.key)}
|
|
80
|
-
</ColumnIndexContext.Provider>
|
|
81
|
-
</th>))}
|
|
82
|
-
</tr>
|
|
83
|
-
</thead>
|
|
84
|
-
|
|
85
|
-
<tbody className={tbodyClassName}>
|
|
86
|
-
{virtualItems.map(virtualItem => {
|
|
87
|
-
if (virtualItem.type === 'spacer') {
|
|
88
|
-
return <SpacerRow key={virtualItem.key} spacer={virtualItem} colSpan={columns.length}/>;
|
|
89
|
-
}
|
|
90
|
-
const index = virtualItem.index;
|
|
91
|
-
const item = data[index];
|
|
92
|
-
const key = props.getKey(item, index);
|
|
93
|
-
return (<CollapseItemIntoSpacerContext.Provider value={height => collapseItemIntoSpacer(index, height)} key={key}>
|
|
94
|
-
{renderItem ? renderItem(item, index, data) : <DefaultItemRenderer index={index}/>}
|
|
95
|
-
</CollapseItemIntoSpacerContext.Provider>);
|
|
96
|
-
})}
|
|
97
|
-
</tbody>
|
|
98
|
-
</table>
|
|
99
|
-
</IntersectionObserverContext.Provider>
|
|
100
|
-
</TablePropsContext.Provider>);
|
|
101
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
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({ enabled, length, scrollerRef, tableRef, estimateHeight, lookaheadPx, retentionMarginPx, minScrollAndResizeDeltaPx, }: {
|
|
15
|
-
enabled: boolean;
|
|
16
|
-
length: number;
|
|
17
|
-
scrollerRef: RefObject<HTMLElement | null> | undefined;
|
|
18
|
-
tableRef: RefObject<HTMLTableElement | null>;
|
|
19
|
-
estimateHeight: (index: number) => 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 {};
|
|
File without changes
|