@jetbrains/ring-ui 8.0.0-beta.2 → 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.
Files changed (121) hide show
  1. package/babel.config.js +1 -1
  2. package/components/auth-dialog-service/auth-dialog-service.js +2 -2
  3. package/components/checkbox/checkbox.d.ts +1 -1
  4. package/components/collapse/collapse-content.js +2 -2
  5. package/components/collapse/collapse-control.js +2 -2
  6. package/components/collapse/collapse.js +2 -2
  7. package/components/collapsible-group/collapsible-group.css +138 -0
  8. package/components/collapsible-group/collapsible-group.d.ts +20 -0
  9. package/components/collapsible-group/collapsible-group.js +73 -0
  10. package/components/confirm-service/confirm-service.js +2 -2
  11. package/components/data-list/data-list.d.ts +1 -1
  12. package/components/data-list/data-list.mock.d.ts +1 -1
  13. package/components/data-list/item.d.ts +1 -1
  14. package/components/data-list/selection.d.ts +1 -1
  15. package/components/data-list/selection.js +1 -1
  16. package/components/date-picker/months.js +2 -2
  17. package/components/date-picker/use-scroll-behavior.js +5 -6
  18. package/components/date-picker/years.js +2 -2
  19. package/components/dialog/dialog.d.ts +2 -2
  20. package/components/dialog/dialog.js +2 -2
  21. package/components/dropdown-menu/dropdown-menu.d.ts +4 -4
  22. package/components/dropdown-menu/dropdown-menu.js +4 -4
  23. package/components/editable-heading/editable-heading.d.ts +1 -2
  24. package/components/editable-heading/editable-heading.js +18 -19
  25. package/components/expand/collapsible-group.css +23 -89
  26. package/components/expand/collapsible-group.d.ts +8 -16
  27. package/components/expand/collapsible-group.js +13 -72
  28. package/components/global/compose-refs.d.ts +2 -1
  29. package/components/global/compose-refs.js +24 -8
  30. package/components/global/create-stateful-context.js +5 -5
  31. package/components/global/focus-with-temporary-tabindex.d.ts +11 -0
  32. package/components/global/focus-with-temporary-tabindex.js +21 -0
  33. package/components/global/intersection-observer-context.d.ts +31 -11
  34. package/components/global/intersection-observer-context.js +47 -28
  35. package/components/global/is-within-interactive-element.d.ts +6 -0
  36. package/components/global/is-within-interactive-element.js +26 -0
  37. package/components/global/is-within-navigable-element.d.ts +6 -0
  38. package/components/global/is-within-navigable-element.js +27 -0
  39. package/components/global/parse-css-duration.d.ts +5 -0
  40. package/components/global/parse-css-duration.js +13 -0
  41. package/components/global/rerender-hoc.d.ts +4 -2
  42. package/components/global/rerender-hoc.js +4 -4
  43. package/components/global/schedule-with-cleanup.d.ts +12 -0
  44. package/components/global/schedule-with-cleanup.js +34 -0
  45. package/components/{legacy-table/selection.d.ts → global/table-selection.d.ts} +14 -14
  46. package/components/{legacy-table/selection.js → global/table-selection.js} +2 -2
  47. package/components/global/theme.d.ts +4 -3
  48. package/components/global/theme.js +8 -8
  49. package/components/i18n/i18n-context.js +1 -1
  50. package/components/input/input.d.ts +1 -1
  51. package/components/island/adaptive-island-hoc.js +4 -4
  52. package/components/island/content.d.ts +7 -2
  53. package/components/island/content.js +5 -5
  54. package/components/legacy-table/cell.js +1 -1
  55. package/components/legacy-table/header-cell.js +1 -1
  56. package/components/legacy-table/header.js +1 -1
  57. package/components/legacy-table/multitable.d.ts +1 -1
  58. package/components/legacy-table/row.d.ts +1 -1
  59. package/components/legacy-table/row.js +1 -1
  60. package/components/legacy-table/selection-adapter.d.ts +3 -3
  61. package/components/legacy-table/selection-shortcuts-hoc.d.ts +5 -5
  62. package/components/legacy-table/simple-table.d.ts +2 -2
  63. package/components/legacy-table/simple-table.js +3 -3
  64. package/components/legacy-table/smart-table.d.ts +5 -5
  65. package/components/legacy-table/smart-table.js +3 -3
  66. package/components/legacy-table/table.js +1 -1
  67. package/components/login-dialog/service.js +2 -2
  68. package/components/popup/popup.d.ts +2 -0
  69. package/components/popup/popup.js +2 -2
  70. package/components/popup/popup.target.d.ts +3 -2
  71. package/components/popup/popup.target.js +4 -6
  72. package/components/query-assist/query-assist.d.ts +3 -1
  73. package/components/query-assist/query-assist.js +2 -2
  74. package/components/radio/radio-item.d.ts +3 -3
  75. package/components/radio/radio-item.js +3 -4
  76. package/components/radio/radio.d.ts +2 -2
  77. package/components/radio/radio.js +1 -1
  78. package/components/select/select-popup.d.ts +1 -1
  79. package/components/select/select.d.ts +4 -2
  80. package/components/slider/slider.js +4 -5
  81. package/components/tab-trap/tab-trap.d.ts +3 -3
  82. package/components/tab-trap/tab-trap.js +3 -5
  83. package/components/table/default-item-renderer.d.ts +35 -11
  84. package/components/table/default-item-renderer.js +47 -47
  85. package/components/table/internal/column-animation.d.ts +16 -0
  86. package/components/table/internal/column-animation.js +45 -0
  87. package/components/table/internal/table-header.d.ts +4 -0
  88. package/components/table/internal/table-header.js +357 -0
  89. package/components/table/internal/virtual-items.d.ts +34 -0
  90. package/components/table/{table-virtualize.js → internal/virtual-items.js} +78 -44
  91. package/components/table/item-virtualization.d.ts +35 -0
  92. package/components/table/item-virtualization.js +28 -0
  93. package/components/table/table-const.d.ts +40 -6
  94. package/components/table/table-const.js +14 -5
  95. package/components/table/table-primitives.d.ts +21 -0
  96. package/components/table/table-primitives.js +25 -0
  97. package/components/table/table-props.d.ts +280 -0
  98. package/components/table/table-props.js +1 -0
  99. package/components/table/table.css +171 -66
  100. package/components/table/table.d.ts +205 -224
  101. package/components/table/table.js +298 -2
  102. package/components/tags-input/tags-input.d.ts +3 -1
  103. package/components/tooltip/tooltip.js +2 -2
  104. package/components/upload/upload.d.ts +4 -3
  105. package/components/upload/upload.js +3 -7
  106. package/components/user-agreement/service.js +2 -2
  107. package/components/util-stories.d.ts +26 -0
  108. package/components/util-stories.js +61 -0
  109. package/package.json +41 -41
  110. package/components/date-picker/use-intersection-observer.d.ts +0 -6
  111. package/components/date-picker/use-intersection-observer.js +0 -48
  112. package/components/global/composeRefs.d.ts +0 -6
  113. package/components/global/composeRefs.js +0 -7
  114. package/components/global/use-event-callback.d.ts +0 -1
  115. package/components/global/use-event-callback.js +0 -15
  116. package/components/table/table-base.d.ts +0 -24
  117. package/components/table/table-base.js +0 -79
  118. package/components/table/table-component.d.ts +0 -53
  119. package/components/table/table-component.js +0 -101
  120. package/components/table/table-virtualize.d.ts +0 -32
  121. /package/components/legacy-table/{table.css → legacy-table.css} +0 -0
@@ -1,48 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- export function useIntersectionObserver(containerRef, scrollMargin = 0) {
3
- const [handle, setHandle] = useState(null);
4
- useEffect(() => {
5
- const container = containerRef.current;
6
- if (!container)
7
- return;
8
- const elementToSetVisible = new Map();
9
- const observer = new IntersectionObserver(entries => {
10
- for (const entry of entries) {
11
- const setVisible = elementToSetVisible.get(entry.target);
12
- setVisible?.(entry.isIntersecting);
13
- }
14
- }, {
15
- root: container,
16
- ...(scrollMargin
17
- ? {
18
- scrollMargin: `${scrollMargin}px`,
19
- }
20
- : {}),
21
- });
22
- setHandle({
23
- observeVisibility(element, setVisible) {
24
- elementToSetVisible.set(element, setVisible);
25
- observer.observe(element);
26
- return () => {
27
- elementToSetVisible.delete(element);
28
- observer.unobserve(element);
29
- };
30
- },
31
- });
32
- return () => {
33
- observer.disconnect();
34
- setHandle(null);
35
- };
36
- }, [containerRef, scrollMargin]);
37
- return handle;
38
- }
39
- export function useVisibility(handle, elementRef) {
40
- const [isVisible, setIsVisible] = useState(false);
41
- useEffect(() => {
42
- const element = elementRef.current;
43
- if (!element || !handle)
44
- return;
45
- return handle.observeVisibility(element, setIsVisible);
46
- }, [handle, elementRef, setIsVisible]);
47
- return isVisible;
48
- }
@@ -1,6 +0,0 @@
1
- import { createComposedRef as _createComposedRef } from './compose-refs';
2
- /**
3
- * @deprecated Use createComposedRef from './compose-refs' instead
4
- */
5
- declare const createComposedRef: typeof _createComposedRef;
6
- export { createComposedRef };
@@ -1,7 +0,0 @@
1
- /* eslint-disable unicorn/filename-case */
2
- import { createComposedRef as _createComposedRef } from './compose-refs';
3
- /**
4
- * @deprecated Use createComposedRef from './compose-refs' instead
5
- */
6
- const createComposedRef = _createComposedRef;
7
- export { createComposedRef };
@@ -1 +0,0 @@
1
- export default function useEventCallback<I extends unknown[], O>(fn: (...args: I) => O): (...args: I) => O;
@@ -1,15 +0,0 @@
1
- import { useCallback, useLayoutEffect, useRef } from 'react';
2
- // TODO deprecate in favor of useEffectEvent after dropping support for React < 19.2
3
- export default function useEventCallback(fn) {
4
- const ref = useRef(null);
5
- useLayoutEffect(() => {
6
- ref.current = fn;
7
- });
8
- return useCallback((...args) => {
9
- const { current } = ref;
10
- if (current === null || current === undefined) {
11
- throw new Error('callback created in useEventCallback can only be called from event handlers');
12
- }
13
- return current(...args);
14
- }, []);
15
- }
@@ -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 {};