@jetbrains/ring-ui 8.0.0-beta.4 → 8.0.0-beta.5

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 (51) hide show
  1. package/components/alert/alert-actions.d.ts +4 -0
  2. package/components/alert/alert-actions.js +5 -0
  3. package/components/alert/alert-heading.d.ts +4 -0
  4. package/components/alert/alert-heading.js +6 -0
  5. package/components/alert/alert.css +63 -22
  6. package/components/alert/alert.d.ts +14 -1
  7. package/components/alert/alert.js +34 -19
  8. package/components/alert/container.css +1 -2
  9. package/components/alert-service/alert-service.d.ts +2 -1
  10. package/components/alert-service/alert-service.js +8 -4
  11. package/components/auth/auth-core.d.ts +5 -9
  12. package/components/auth/auth-core.js +56 -15
  13. package/components/button-group/button-group.css +5 -5
  14. package/components/date-picker/consts.d.ts +1 -0
  15. package/components/date-picker/date-input.js +6 -2
  16. package/components/header/header.css +3 -3
  17. package/components/http/http.d.ts +2 -2
  18. package/components/http/http.js +2 -2
  19. package/components/i18n/i18n.d.ts +1 -0
  20. package/components/i18n/messages.json +1 -0
  21. package/components/table/default-item-renderer.d.ts +7 -1
  22. package/components/table/default-item-renderer.js +18 -5
  23. package/components/table/internal/reorder-animation-context.d.ts +21 -0
  24. package/components/table/internal/reorder-animation-context.js +60 -0
  25. package/components/table/internal/reorder-handle.d.ts +9 -0
  26. package/components/table/internal/reorder-handle.js +334 -0
  27. package/components/table/internal/reorder-layout-context.d.ts +16 -0
  28. package/components/table/internal/reorder-layout-context.js +69 -0
  29. package/components/table/internal/table-header.d.ts +1 -4
  30. package/components/table/internal/table-header.js +32 -246
  31. package/components/table/internal/{virtual-items.d.ts → virtualization.d.ts} +10 -3
  32. package/components/table/internal/{virtual-items.js → virtualization.js} +8 -6
  33. package/components/table/item-virtualization.d.ts +5 -3
  34. package/components/table/item-virtualization.js +4 -6
  35. package/components/table/reorder-animation.d.ts +37 -0
  36. package/components/table/reorder-animation.js +11 -0
  37. package/components/table/reorder-item-layout.d.ts +32 -0
  38. package/components/table/reorder-item-layout.js +23 -0
  39. package/components/table/table-const.d.ts +0 -32
  40. package/components/table/table-const.js +0 -7
  41. package/components/table/table-primitives.d.ts +43 -0
  42. package/components/table/table-primitives.js +9 -0
  43. package/components/table/table-props.d.ts +29 -5
  44. package/components/table/table.css +17 -10
  45. package/components/table/table.d.ts +31 -5
  46. package/components/table/table.js +64 -35
  47. package/components/user-card/smart-user-card-tooltip.d.ts +1 -1
  48. package/components/util-stories.d.ts +2 -2
  49. package/package.json +12 -12
  50. package/components/table/internal/column-animation.d.ts +0 -16
  51. package/components/table/internal/column-animation.js +0 -45
@@ -19,3 +19,46 @@ export declare function TableRow(props: TableRowProps & ComponentPropsWithRef<'t
19
19
  * Applies the standard cell class names, but not data-dependent `tdClassName`.
20
20
  */
21
21
  export declare function TableCell(props: ComponentPropsWithRef<'td'>): import("react").JSX.Element;
22
+ /**
23
+ * - `'pointerdown'` means the user has pressed the mouse button or touched the handle.
24
+ * - `number` means the distance in pixels the user has dragged the handle along
25
+ * the Y axis.
26
+ * - `'cancelled'` means the reorder was aborted — e.g. the user pressed Escape,
27
+ * released the pointer outside the browser, or dropped the item at its original
28
+ * position. Use this phase to play a cancellation animation in your custom renderer.
29
+ * This state lasts 600 ms (matching the built-in cancel animation), after which
30
+ * `undefined` is sent.
31
+ * - `undefined` means the drag interaction is fully over. Sent after a successful
32
+ * reorder as well as after the `'cancelled'` phase, so you can always do cleanup
33
+ * here without managing your own timer.
34
+ */
35
+ export type DragState = 'pointerdown' | number | 'cancelled' | undefined;
36
+ export interface ItemReorderHandleProps {
37
+ /**
38
+ * The index of the item in the table data array.
39
+ */
40
+ index: number;
41
+ /**
42
+ * When `true`, the drag frame, indicating the currently dragged item,
43
+ * will not be rendered.
44
+ */
45
+ noDragFrame?: boolean;
46
+ /**
47
+ * When `true`, the drag handle stays fixed in place instead of following
48
+ * the pointer during drag.
49
+ */
50
+ noHandleTranslate?: boolean;
51
+ /**
52
+ * Callback that is called when the user drags the handle.
53
+ * Use it for custom drag indication.
54
+ * The `TableProps.onItemReorder` will be called after this callback.
55
+ * @param state The current drag state.
56
+ */
57
+ onUserDrag?: (state: DragState) => void;
58
+ }
59
+ /**
60
+ * A drag handle that allows the user to reorder the row. Place it anywhere
61
+ * inside a row renderer.
62
+ * Use {@link TableProps.canReorderItem} and {@link TableProps.onItemReorder}.
63
+ */
64
+ export declare function ItemReorderHandle({ index, ...restProps }: ItemReorderHandleProps & ComponentPropsWithRef<'button'>): import("react").JSX.Element;
@@ -1,4 +1,5 @@
1
1
  import classNames from 'classnames';
2
+ import { ReorderHandle } from './internal/reorder-handle';
2
3
  import styles from './table.css';
3
4
  /**
4
5
  * @internal
@@ -23,3 +24,11 @@ export function TableCell(props) {
23
24
  const classes = classNames(styles.cell, className);
24
25
  return <td className={classes} {...restProps}/>;
25
26
  }
27
+ /**
28
+ * A drag handle that allows the user to reorder the row. Place it anywhere
29
+ * inside a row renderer.
30
+ * Use {@link TableProps.canReorderItem} and {@link TableProps.onItemReorder}.
31
+ */
32
+ export function ItemReorderHandle({ index, ...restProps }) {
33
+ return <ReorderHandle direction='items' index={index} {...restProps}/>;
34
+ }
@@ -34,7 +34,7 @@ export interface TableProps<T> {
34
34
  * Called when the user clicks on a column delete button in the header.
35
35
  * The client is expected to update the `columns` prop with the column removed.
36
36
  */
37
- onColumnDelete?: (columnIndex: number, columns: readonly Column<T>[]) => void;
37
+ onColumnDelete?: (column: Column<T>, columnIndex: number, columns: readonly Column<T>[]) => void;
38
38
  /**
39
39
  * Called when the user reorders columns by dragging a column.
40
40
  * The `insertionIndex` parameter represents an insertion position in the original,
@@ -43,20 +43,44 @@ export interface TableProps<T> {
43
43
  * One possible implementation is:
44
44
  *
45
45
  * ```ts
46
- * const [moved] = columns.splice(fromIndex, 1);
47
- * columns.splice(fromIndex < insertionIndex ? insertionIndex - 1 : insertionIndex, 0, moved);
46
+ * columns.splice(fromIndex, 1);
47
+ * columns.splice(fromIndex < insertionIndex ? insertionIndex - 1 : insertionIndex, 0, columnBeingReordered);
48
48
  * ```
49
49
  *
50
50
  * The callback is not called when the reorder operation would not change the
51
51
  * column order, i.e. when
52
52
  * `insertionIndex === fromIndex || insertionIndex === fromIndex + 1`.
53
53
  */
54
- onColumnReorder?: (fromIndex: number, insertionIndex: number, columns: readonly Column<T>[]) => void;
54
+ onColumnReorder?: (columnBeingReordered: Column<T>, fromIndex: number, insertionIndex: number, columns: readonly Column<T>[]) => void;
55
55
  /**
56
56
  * By default, when a column is reordered, the moved column is highlighted
57
57
  * with a temporary background color. Set `true` to disable this animation.
58
58
  */
59
59
  noColumnReorderAnimation?: boolean;
60
+ /**
61
+ * If defined, determines whether an item may be reordered to a specific insertion position.
62
+ * If not defined, any item may be reordered to any position.
63
+ */
64
+ canReorderItem?: (itemBeingReordered: T, fromIndex: number, insertionIndex: number, items: readonly T[]) => boolean;
65
+ /**
66
+ * Called when the user reorders items by dragging a handle.
67
+ * The `insertionIndex` parameter represents an insertion position in the original,
68
+ * unchanged `data` array before the item is removed. See {@link TableProps.onColumnReorder}
69
+ * for an example implementation.
70
+ *
71
+ * To make reorder possible, render `ItemReorderHandle` (from `table-primitives`)
72
+ * anywhere in a row.
73
+ *
74
+ * The callback is not called when the reorder operation would not change the
75
+ * item order, i.e. when
76
+ * `insertionIndex === fromIndex || insertionIndex === fromIndex + 1`.
77
+ */
78
+ onItemReorder?: (itemBeingReordered: T, fromIndex: number, insertionIndex: number, items: readonly T[]) => void;
79
+ /**
80
+ * By default, when an item is reordered, the moved item is highlighted
81
+ * with a temporary background color. Set `true` to disable this animation.
82
+ */
83
+ noItemReorderAnimation?: boolean;
60
84
  /**
61
85
  * Customizes how an item is rendered.
62
86
  *
@@ -266,7 +290,7 @@ export interface Column<T> {
266
290
  * Make sure {@link Column.name} or {@link Column.key} is meaningful,
267
291
  * as it will be included in the `aria-label` of the reorder button.
268
292
  */
269
- canReorder?: boolean | ((insertionIndex: number, columns: readonly Column<T>[]) => boolean);
293
+ canReorder?: boolean | ((columnBeingReordered: Column<T>, fromIndex: number, insertionIndex: number, columns: readonly Column<T>[]) => boolean);
270
294
  /**
271
295
  * The class name to apply to the `th` element inside `table > thead`.
272
296
  */
@@ -1,7 +1,7 @@
1
1
  @import '../global/variables.css';
2
2
 
3
3
  .table {
4
- --animated-column-fade-out-duration: 600ms;
4
+ --reorder-animation-fade-out-duration: 600ms;
5
5
 
6
6
  width: 100%;
7
7
 
@@ -40,7 +40,7 @@
40
40
  &:hover {
41
41
  --header-cell-shadow-color: var(--ring-line-color);
42
42
 
43
- &:not(.animatedColumnInitial, .animatedColumnFadeOut) {
43
+ &:not(.reorderAnimationInitial, .reorderAnimationFadeOut) {
44
44
  background-color: var(--ring-grey-container-light-color);
45
45
  }
46
46
  }
@@ -67,7 +67,7 @@
67
67
  }
68
68
  }
69
69
 
70
- .headerButton {
70
+ .tableButton {
71
71
  margin: unset;
72
72
  padding: unset;
73
73
 
@@ -134,6 +134,15 @@
134
134
  touch-action: none;
135
135
  }
136
136
 
137
+ .itemReorderHandle {
138
+ cursor: grab;
139
+
140
+ color: var(--ring-secondary-color);
141
+
142
+ border-radius: var(--ring-border-radius);
143
+ touch-action: none;
144
+ }
145
+
137
146
  .theadColumnEditing .columnReorderHandle,
138
147
  .headerCell:hover .columnReorderHandle,
139
148
  .columnReorderHandle:focus-visible {
@@ -167,7 +176,7 @@
167
176
  }
168
177
  }
169
178
 
170
- .columnDragFrame {
179
+ .dragFrame {
171
180
  position: fixed;
172
181
 
173
182
  z-index: var(--ring-overlay-z-index);
@@ -180,24 +189,22 @@
180
189
  background-color: rgba(var(--ring-border-accent-components), 0.06);
181
190
  }
182
191
 
183
- .columnInsertionIndicator {
192
+ .insertionIndicator {
184
193
  position: fixed;
185
194
 
186
195
  z-index: var(--ring-overlay-z-index);
187
196
 
188
- width: 2px;
189
-
190
197
  background-color: var(--ring-main-color);
191
198
  }
192
199
 
193
- .animatedColumnInitial {
200
+ .reorderAnimationInitial {
194
201
  transition: none;
195
202
 
196
203
  background-color: rgba(var(--ring-border-accent-components), 0.12);
197
204
  }
198
205
 
199
- .animatedColumnFadeOut {
200
- transition: background-color var(--animated-column-fade-out-duration) ease-out;
206
+ .reorderAnimationFadeOut {
207
+ transition: background-color var(--reorder-animation-fade-out-duration) ease-out;
201
208
 
202
209
  background-color: transparent;
203
210
  }
@@ -89,7 +89,7 @@ import type { TableProps } from './table-props';
89
89
  * Note that for accessibility reasons, you should have a cell with a checkbox
90
90
  * to display and toggle item selection.
91
91
  *
92
- * ## Rows focus
92
+ * ## Row focus
93
93
  *
94
94
  * The table implements the ["roving tabindex"](https://developer.mozilla.org/en-US/docs/Web/Accessibility/Guides/Keyboard-navigable_JavaScript_widgets#technique_1_roving_tabindex)
95
95
  * technique to focus rows with the up/down arrow keys.
@@ -157,6 +157,23 @@ import type { TableProps } from './table-props';
157
157
  * expected to update `columns` by moving the corresponding column to the
158
158
  * new position.
159
159
  *
160
+ * ## Item reorder
161
+ *
162
+ * To allow the user to reorder rows by dragging:
163
+ *
164
+ * - Place `ItemReorderHandle` (from `table/table-primitives`) anywhere inside
165
+ * a cell. It renders a drag icon button the user can grab to reorder the row.
166
+ * - Handle `TableProps.onItemReorder`. It is expected to update `data` by
167
+ * moving the item to the new position.
168
+ * - Optionally, set `TableProps.canReorderItem` to restrict which positions
169
+ * an item may be dropped into.
170
+ *
171
+ * By default, dragging shows a drag frame (a border around the dragged row)
172
+ * and an insertion indicator (a line between rows showing where the item will
173
+ * land). To implement fully custom drag visuals, set `noDragFrame` and
174
+ * `noHandleTranslate` on `ItemReorderHandle` and use its `onUserDrag` callback
175
+ * to track the drag lifecycle.
176
+ *
160
177
  * ## Row virtualization
161
178
  *
162
179
  * To render only rows near the viewport while replacing off-screen rows with
@@ -198,10 +215,19 @@ import type { TableProps } from './table-props';
198
215
  * set the `noItemVirtualization` prop to `true`, otherwise it will also try
199
216
  * to control the virtualization, possibly reporting incorrect item height.
200
217
  *
201
- * ### Column reorder animation
218
+ * ### Item reorder
219
+ *
220
+ * If `TableProps.onItemReorder` is set and your item spans multiple rows, call
221
+ * `useReorderItemLayout()` (from `table/reorder-item-layout`) to register the
222
+ * item's boundaries so the insertion indicator and insertion point calculation
223
+ * are correct. If `DefaultItemRenderer` is included inside your custom renderer,
224
+ * set its `noReorderLayout` prop to `true` to prevent double registration.
225
+ *
226
+ * ### Reorder animation
202
227
  *
203
- * Default-rendered rows highlight the column that was just reordered. To apply
204
- * the same animation to your custom-rendered rows, use `ColumnAnimationContext`
205
- * (from `table/table-const`) to get information about the currently animated column.
228
+ * After a column or item is reordered, the table briefly highlights the moved
229
+ * element. To apply the same animation in your custom-rendered rows, use
230
+ * `useReorderAnimation()` (from `table/reorder-animation`) to get information
231
+ * about the currently animated column or item.
206
232
  */
207
233
  export default function Table<T>(props: TableProps<T> & ComponentPropsWithRef<'table'>): React.JSX.Element;
@@ -1,15 +1,15 @@
1
- import React, { Fragment, useCallback, useRef } from 'react';
1
+ import React, { Fragment, useRef } from 'react';
2
2
  import classNames from 'classnames';
3
- import { IntersectionObserverContext } from '../global/intersection-observer-context';
4
- import { CollapseItemIntoSpacerContext, SpacerRow, useVirtualItems } from './internal/virtual-items';
3
+ import { SpacerRow, useVirtualItems, VirtualizationContext } from './internal/virtualization';
5
4
  import { DefaultItemRenderer } from './default-item-renderer';
6
- import { ColumnAnimationContext, defaultRowHeight, TablePropsContext } from './table-const';
5
+ import { defaultRowHeight, TablePropsContext } from './table-const';
7
6
  import { focusWithTemporaryTabIndex } from '../global/focus-with-temporary-tabindex';
8
- import { useColumnAnimation } from './internal/column-animation';
7
+ import { ReorderAnimationContext, useReorderAnimationContextValue } from './internal/reorder-animation-context';
9
8
  import { useComposedRef } from '../global/compose-refs';
10
9
  import { TableHeader } from './internal/table-header';
11
10
  import { keyboardFocusableAttrName } from './table-primitives';
12
11
  import { isWithinNavigableElement } from '../global/is-within-navigable-element';
12
+ import { ReorderLayoutContext, useReorderLayoutContextValue } from './internal/reorder-layout-context';
13
13
  import styles from './table.css';
14
14
  /**
15
15
  * Table component replacing the tables in the `legacy-table` folder.
@@ -100,7 +100,7 @@ import styles from './table.css';
100
100
  * Note that for accessibility reasons, you should have a cell with a checkbox
101
101
  * to display and toggle item selection.
102
102
  *
103
- * ## Rows focus
103
+ * ## Row focus
104
104
  *
105
105
  * The table implements the ["roving tabindex"](https://developer.mozilla.org/en-US/docs/Web/Accessibility/Guides/Keyboard-navigable_JavaScript_widgets#technique_1_roving_tabindex)
106
106
  * technique to focus rows with the up/down arrow keys.
@@ -168,6 +168,23 @@ import styles from './table.css';
168
168
  * expected to update `columns` by moving the corresponding column to the
169
169
  * new position.
170
170
  *
171
+ * ## Item reorder
172
+ *
173
+ * To allow the user to reorder rows by dragging:
174
+ *
175
+ * - Place `ItemReorderHandle` (from `table/table-primitives`) anywhere inside
176
+ * a cell. It renders a drag icon button the user can grab to reorder the row.
177
+ * - Handle `TableProps.onItemReorder`. It is expected to update `data` by
178
+ * moving the item to the new position.
179
+ * - Optionally, set `TableProps.canReorderItem` to restrict which positions
180
+ * an item may be dropped into.
181
+ *
182
+ * By default, dragging shows a drag frame (a border around the dragged row)
183
+ * and an insertion indicator (a line between rows showing where the item will
184
+ * land). To implement fully custom drag visuals, set `noDragFrame` and
185
+ * `noHandleTranslate` on `ItemReorderHandle` and use its `onUserDrag` callback
186
+ * to track the drag lifecycle.
187
+ *
171
188
  * ## Row virtualization
172
189
  *
173
190
  * To render only rows near the viewport while replacing off-screen rows with
@@ -209,14 +226,23 @@ import styles from './table.css';
209
226
  * set the `noItemVirtualization` prop to `true`, otherwise it will also try
210
227
  * to control the virtualization, possibly reporting incorrect item height.
211
228
  *
212
- * ### Column reorder animation
229
+ * ### Item reorder
213
230
  *
214
- * Default-rendered rows highlight the column that was just reordered. To apply
215
- * the same animation to your custom-rendered rows, use `ColumnAnimationContext`
216
- * (from `table/table-const`) to get information about the currently animated column.
231
+ * If `TableProps.onItemReorder` is set and your item spans multiple rows, call
232
+ * `useReorderItemLayout()` (from `table/reorder-item-layout`) to register the
233
+ * item's boundaries so the insertion indicator and insertion point calculation
234
+ * are correct. If `DefaultItemRenderer` is included inside your custom renderer,
235
+ * set its `noReorderLayout` prop to `true` to prevent double registration.
236
+ *
237
+ * ### Reorder animation
238
+ *
239
+ * After a column or item is reordered, the table briefly highlights the moved
240
+ * element. To apply the same animation in your custom-rendered rows, use
241
+ * `useReorderAnimation()` (from `table/reorder-animation`) to get information
242
+ * about the currently animated column or item.
217
243
  */
218
244
  export default function Table(props) {
219
- const { data, columns, getKey, noHeader, stickyHeader, onSort, onColumnDelete, onColumnReorder, noColumnReorderAnimation, renderItem, virtualizeRows = false, scrollerRef, estimateHeight = () => defaultRowHeight,
245
+ const { data, columns, getKey, noHeader, stickyHeader, onSort, onColumnDelete, onColumnReorder, noColumnReorderAnimation, canReorderItem, onItemReorder, noItemReorderAnimation, renderItem, virtualizeRows = false, scrollerRef, estimateHeight = () => defaultRowHeight,
220
246
  // eslint-disable-next-line no-magic-numbers
221
247
  lookaheadPx = 400,
222
248
  // eslint-disable-next-line no-magic-numbers
@@ -224,22 +250,14 @@ export default function Table(props) {
224
250
  // eslint-disable-next-line no-magic-numbers
225
251
  minScrollAndResizeDeltaPx = 50, columnEditing, onColumnEditingRequest, columnEditButton, theadClassName, theadTrClassName, tbodyClassName, ref: userRef, className, ...restProps } = props;
226
252
  const localRef = useRef(null);
227
- const { virtualItems, intersectionObserverHandle, collapseItemIntoSpacer } = useVirtualItems({
228
- enabled: virtualizeRows,
229
- data,
230
- scrollerRef,
231
- tableRef: localRef,
232
- estimateHeight,
233
- lookaheadPx,
234
- retentionMarginPx,
235
- minScrollAndResizeDeltaPx,
236
- });
237
- const { columnAnimation, expectColumnReorder } = useColumnAnimation({
238
- disabled: noColumnReorderAnimation,
253
+ const reorderAnimationContextValue = useReorderAnimationContextValue({
254
+ noColumnReorderAnimation,
255
+ noItemReorderAnimation,
239
256
  tableRef: localRef,
257
+ data,
240
258
  columns,
241
259
  });
242
- const handleRowNavigation = useCallback((e) => {
260
+ function handleRowNavigation(e) {
243
261
  if (e.defaultPrevented || isWithinNavigableElement(e.target))
244
262
  return;
245
263
  const arrowUp = e.key === 'ArrowUp';
@@ -259,15 +277,26 @@ export default function Table(props) {
259
277
  return;
260
278
  }
261
279
  }
262
- }, []);
280
+ }
281
+ const { virtualItems, virtualizationContextValue } = useVirtualItems({
282
+ enabled: virtualizeRows,
283
+ data,
284
+ scrollerRef,
285
+ tableRef: localRef,
286
+ estimateHeight,
287
+ lookaheadPx,
288
+ retentionMarginPx,
289
+ minScrollAndResizeDeltaPx,
290
+ });
291
+ const itemReorderLayoutContextValue = useReorderLayoutContextValue();
263
292
  return (<TablePropsContext value={props}>
264
- <ColumnAnimationContext value={columnAnimation}>
293
+ <ReorderAnimationContext value={reorderAnimationContextValue}>
265
294
  <table className={classNames(styles.table, className)} ref={useComposedRef(userRef, localRef)} {...restProps}>
266
- <TableHeader expectColumnReorder={expectColumnReorder}/>
267
- <IntersectionObserverContext value={intersectionObserverHandle}>
268
- <CollapseItemIntoSpacerContext value={collapseItemIntoSpacer}>
269
- {/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */}
270
- <tbody className={tbodyClassName} onKeyDown={handleRowNavigation}>
295
+ <TableHeader />
296
+ {/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */}
297
+ <tbody className={tbodyClassName} onKeyDown={handleRowNavigation}>
298
+ <VirtualizationContext value={virtualizationContextValue}>
299
+ <ReorderLayoutContext value={itemReorderLayoutContextValue}>
271
300
  {(virtualizeRows ? virtualItems : data).map((item, index) => {
272
301
  let dataItem;
273
302
  let dataItemIndex;
@@ -289,10 +318,10 @@ export default function Table(props) {
289
318
  {renderItem ? (renderItem(dataItem, dataItemIndex, data)) : (<DefaultItemRenderer index={dataItemIndex}/>)}
290
319
  </Fragment>);
291
320
  })}
292
- </tbody>
293
- </CollapseItemIntoSpacerContext>
294
- </IntersectionObserverContext>
321
+ </ReorderLayoutContext>
322
+ </VirtualizationContext>
323
+ </tbody>
295
324
  </table>
296
- </ColumnAnimationContext>
325
+ </ReorderAnimationContext>
297
326
  </TablePropsContext>);
298
327
  }
@@ -10,6 +10,6 @@ export default class SmartUserCardTooltip extends Component<SmartUserCardTooltip
10
10
  loading: boolean;
11
11
  };
12
12
  loadUser: () => Promise<void>;
13
- renderNoUser: () => "" | import("react").JSX.Element;
13
+ renderNoUser: () => import("react").JSX.Element | "";
14
14
  render(): import("react").JSX.Element;
15
15
  }
@@ -19,9 +19,9 @@ export declare function createRandom(seed: bigint): {
19
19
  /**
20
20
  * Up to random n items (in random order) from the array
21
21
  */
22
- <T>(array: T[], n: number): T[];
22
+ <T>(array: readonly T[], n: number): T[];
23
23
  /**
24
24
  * Random item from the array
25
25
  */
26
- <T>(array: T[]): T;
26
+ <T>(array: readonly T[]): T;
27
27
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetbrains/ring-ui",
3
- "version": "8.0.0-beta.4",
3
+ "version": "8.0.0-beta.5",
4
4
  "description": "JetBrains UI library",
5
5
  "author": {
6
6
  "name": "JetBrains"
@@ -132,7 +132,7 @@
132
132
  "@types/react": "^19.2.17",
133
133
  "@types/react-dom": "^19.2.3",
134
134
  "@types/webpack-env": "^1.18.8",
135
- "@vitejs/plugin-react": "^6.0.2",
135
+ "@vitejs/plugin-react": "^6.0.3",
136
136
  "@vitest/eslint-plugin": "^1.6.20",
137
137
  "acorn": "^8.17.0",
138
138
  "babel-plugin-require-context-hook": "^1.0.0",
@@ -155,10 +155,10 @@
155
155
  "eslint-plugin-react": "^7.37.5",
156
156
  "eslint-plugin-react-hooks": "^7.1.1",
157
157
  "eslint-plugin-storybook": "^10.4.6",
158
- "eslint-plugin-unicorn": "^68.0.0",
158
+ "eslint-plugin-unicorn": "^70.0.0",
159
159
  "events": "^3.3.0",
160
160
  "glob": "^13.0.6",
161
- "globals": "^17.6.0",
161
+ "globals": "^17.7.0",
162
162
  "html-webpack-plugin": "^5.6.7",
163
163
  "http-server": "^14.1.1",
164
164
  "husky": "^9.1.7",
@@ -170,7 +170,7 @@
170
170
  "markdown-it": "^14.2.0",
171
171
  "merge-options": "^3.0.4",
172
172
  "pinst": "^3.0.0",
173
- "prettier": "^3.8.4",
173
+ "prettier": "^3.9.4",
174
174
  "raw-loader": "^4.0.2",
175
175
  "react": "^19.2.7",
176
176
  "react-dom": "^19.2.7",
@@ -180,19 +180,19 @@
180
180
  "rollup-plugin-clear": "^2.0.7",
181
181
  "storage-mock": "^2.1.0",
182
182
  "storybook": "10.4.6",
183
- "stylelint": "^17.13.0",
183
+ "stylelint": "^17.14.0",
184
184
  "stylelint-config-sass-guidelines": "^13.0.0",
185
185
  "svg-inline-loader": "^0.8.2",
186
186
  "teamcity-service-messages": "^0.1.14",
187
187
  "terser-webpack-plugin": "^5.6.1",
188
188
  "typed-css-modules": "^0.9.1",
189
189
  "typescript": "~6.0.3",
190
- "typescript-eslint": "^8.61.1",
191
- "vite": "^8.0.16",
190
+ "typescript-eslint": "^8.62.1",
191
+ "vite": "^8.1.0",
192
192
  "vitest": "^4.1.9",
193
193
  "vitest-teamcity-reporter": "^0.4.1",
194
- "webpack": "^5.107.2",
195
- "webpack-cli": "^7.0.3",
194
+ "webpack": "^5.108.1",
195
+ "webpack-cli": "^7.1.0",
196
196
  "xmlappend": "^1.0.4"
197
197
  },
198
198
  "peerDependencies": {
@@ -227,7 +227,7 @@
227
227
  "babel-loader": "10.1.1",
228
228
  "babel-plugin-react-compiler": "^1.0.0",
229
229
  "babel-plugin-transform-define": "^2.1.4",
230
- "browserslist": "^4.28.2",
230
+ "browserslist": "^4.28.4",
231
231
  "change-case": "^4.1.1",
232
232
  "classnames": "^2.5.1",
233
233
  "combokeys": "^3.0.1",
@@ -238,7 +238,7 @@
238
238
  "element-resize-detector": "^1.2.4",
239
239
  "fastdom": "^1.0.12",
240
240
  "file-loader": "^6.2.0",
241
- "focus-trap": "^8.2.1",
241
+ "focus-trap": "^8.2.2",
242
242
  "highlight.js": "^10.7.2",
243
243
  "just-debounce-it": "^3.2.0",
244
244
  "memoize-one": "^6.0.0",
@@ -1,16 +0,0 @@
1
- import { type RefObject } from 'react';
2
- import type { Column } from '../table-props';
3
- import type { ColumnAnimation } from '../table-const';
4
- export interface ReorderSpec {
5
- fromIndex: number;
6
- insertionIndex: number;
7
- }
8
- export type ExpectColumnReorder = (reorderSpec: ReorderSpec) => void;
9
- export declare function useColumnAnimation<T>({ disabled, tableRef, columns, }: {
10
- disabled: boolean | undefined;
11
- tableRef: RefObject<HTMLTableElement | null>;
12
- columns: readonly Column<T>[];
13
- }): {
14
- columnAnimation: ColumnAnimation | null;
15
- expectColumnReorder: ExpectColumnReorder;
16
- };
@@ -1,45 +0,0 @@
1
- import { useCallback, useEffect, useRef, useState } from 'react';
2
- import { parseCssDuration } from '../../global/parse-css-duration';
3
- import { requestAnimationFrameWithCleanup, setTimeoutWithCleanup } from '../../global/schedule-with-cleanup';
4
- import styles from '../table.css';
5
- const reorderExpectationTimeout = 1000;
6
- export function useColumnAnimation({ disabled, tableRef, columns, }) {
7
- const [columnAnimation, setColumnAnimation] = useState(null);
8
- const pendingColumnReorder = useRef(null);
9
- const expectColumnReorder = useCallback((reorderSpec) => {
10
- if (disabled)
11
- return;
12
- const timerId = window.setTimeout(() => {
13
- pendingColumnReorder.current = null;
14
- }, reorderExpectationTimeout);
15
- pendingColumnReorder.current = { ...reorderSpec, timerId, columns };
16
- }, [disabled, columns]);
17
- useEffect(() => {
18
- return () => {
19
- if (pendingColumnReorder.current) {
20
- window.clearTimeout(pendingColumnReorder.current.timerId);
21
- pendingColumnReorder.current = null;
22
- }
23
- };
24
- }, []);
25
- useEffect(() => {
26
- const table = tableRef.current;
27
- if (!table || !pendingColumnReorder.current || columns === pendingColumnReorder.current.columns)
28
- return;
29
- const { fromIndex, insertionIndex } = pendingColumnReorder.current;
30
- pendingColumnReorder.current = null;
31
- const columnIndex = fromIndex < insertionIndex ? insertionIndex - 1 : insertionIndex;
32
- return requestAnimationFrameWithCleanup(() => setColumnAnimation(prev => prev == null ? { columnIndex, phase: 'initial', cellClassName: styles.animatedColumnInitial } : prev));
33
- }, [columns, tableRef]);
34
- useEffect(() => {
35
- if (columnAnimation?.phase === 'initial') {
36
- return requestAnimationFrameWithCleanup(() => setColumnAnimation(prev => prev === columnAnimation ? { ...prev, phase: 'fade-out', cellClassName: styles.animatedColumnFadeOut } : prev));
37
- }
38
- if (columnAnimation?.phase === 'fade-out') {
39
- const fadeOutMs = parseCssDuration(window.getComputedStyle(tableRef.current).getPropertyValue('--animated-column-fade-out-duration'));
40
- return setTimeoutWithCleanup(() => setColumnAnimation(prev => (prev === columnAnimation ? null : prev)), fadeOutMs);
41
- }
42
- return undefined;
43
- }, [columnAnimation, tableRef]);
44
- return { columnAnimation, expectColumnReorder };
45
- }