@jetbrains/ring-ui-built 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 (65) hide show
  1. package/components/_helpers/alert.js +3 -0
  2. package/components/_helpers/caption.js +1 -1
  3. package/components/_helpers/header.js +1 -1
  4. package/components/_helpers/table.js +1 -1
  5. package/components/alert/alert-actions.d.ts +4 -0
  6. package/components/alert/alert-actions.js +51 -0
  7. package/components/alert/alert-heading.d.ts +4 -0
  8. package/components/alert/alert-heading.js +62 -0
  9. package/components/alert/alert.d.ts +14 -1
  10. package/components/alert/alert.js +43 -25
  11. package/components/alert-service/alert-service.d.ts +2 -1
  12. package/components/alert-service/alert-service.js +15 -5
  13. package/components/auth/auth-core.d.ts +5 -9
  14. package/components/auth/auth-core.js +71 -17
  15. package/components/auth/auth.js +7 -1
  16. package/components/auth/down-notification.js +7 -1
  17. package/components/auth/storage.js +7 -1
  18. package/components/clipboard/clipboard.js +7 -1
  19. package/components/date-picker/consts.d.ts +1 -0
  20. package/components/date-picker/date-input.js +3 -2
  21. package/components/header/header.js +7 -1
  22. package/components/header/smart-profile.js +7 -1
  23. package/components/http/http.d.ts +2 -2
  24. package/components/http/http.js +2 -2
  25. package/components/i18n/i18n.d.ts +1 -0
  26. package/components/i18n/i18n.js +2 -0
  27. package/components/internal/reorder-animation-context.js +159 -0
  28. package/components/internal/reorder-handle.js +750 -0
  29. package/components/internal/reorder-layout-context.js +141 -0
  30. package/components/internal/table-header.js +221 -645
  31. package/components/internal/{virtual-items.js → virtualization.js} +29 -14
  32. package/components/old-browsers-message/white-list.js +2 -2
  33. package/components/storage/storage-local.js +7 -1
  34. package/components/storage/storage.js +7 -1
  35. package/components/style.css +1 -1
  36. package/components/table/default-item-renderer.d.ts +7 -1
  37. package/components/table/default-item-renderer.js +119 -67
  38. package/components/table/internal/reorder-animation-context.d.ts +21 -0
  39. package/components/table/internal/reorder-handle.d.ts +9 -0
  40. package/components/table/internal/reorder-layout-context.d.ts +16 -0
  41. package/components/table/internal/table-header.d.ts +1 -4
  42. package/components/table/internal/{virtual-items.d.ts → virtualization.d.ts} +10 -3
  43. package/components/table/item-virtualization.d.ts +5 -3
  44. package/components/table/item-virtualization.js +13 -11
  45. package/components/table/reorder-animation.d.ts +37 -0
  46. package/components/table/reorder-animation.js +18 -0
  47. package/components/table/reorder-item-layout.d.ts +32 -0
  48. package/components/table/reorder-item-layout.js +57 -0
  49. package/components/table/table-const.d.ts +0 -32
  50. package/components/table/table-const.js +1 -8
  51. package/components/table/table-primitives.d.ts +43 -0
  52. package/components/table/table-primitives.js +62 -5
  53. package/components/table/table-props.d.ts +29 -5
  54. package/components/table/table.d.ts +31 -5
  55. package/components/table/table.js +177 -170
  56. package/components/user-agreement/service.js +7 -1
  57. package/components/user-card/card.js +7 -1
  58. package/components/user-card/smart-user-card-tooltip.d.ts +1 -1
  59. package/components/user-card/smart-user-card-tooltip.js +7 -1
  60. package/components/user-card/tooltip.js +7 -1
  61. package/components/user-card/user-card.js +7 -1
  62. package/components/util-stories.d.ts +2 -2
  63. package/package.json +2 -2
  64. package/components/internal/column-animation.js +0 -133
  65. package/components/table/internal/column-animation.d.ts +0 -16
@@ -5,16 +5,9 @@ import { createContext } from 'react';
5
5
  * Cast to `Context<TableProps<T>>` in usage place.
6
6
  */
7
7
  const TablePropsContext = /*#__PURE__*/createContext(null);
8
- /**
9
- * Provides information about the currently animated column.
10
- *
11
- * Use in a custom cell renderer to animate reordered columns
12
- * consistently with the default table renderer.
13
- */
14
- const ColumnAnimationContext = /*#__PURE__*/createContext(null);
15
8
  /**
16
9
  * When a row only contains unformatted single-line text, it will be exactly of this height.
17
10
  */
18
11
  const defaultRowHeight = 37;
19
12
 
20
- export { ColumnAnimationContext, TablePropsContext, defaultRowHeight };
13
+ export { TablePropsContext, defaultRowHeight };
@@ -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,7 +1,22 @@
1
1
  import { c } from 'react/compiler-runtime';
2
2
  import classNames from 'classnames';
3
+ import { ReorderHandle } from '../internal/reorder-handle.js';
3
4
  import { s as styles } from '../_helpers/table.js';
4
5
  import { jsx } from 'react/jsx-runtime';
6
+ import 'react';
7
+ import '@jetbrains/icons/drag-12px';
8
+ import './table-const.js';
9
+ import '../icon/icon.js';
10
+ import 'util-deprecate';
11
+ import '../icon/icon.constants.js';
12
+ import '../_helpers/icon-svg.js';
13
+ import '../global/memoize.js';
14
+ import '../global/compose-refs.js';
15
+ import 'memoize-one';
16
+ import '../global/parse-css-duration.js';
17
+ import '../internal/reorder-animation-context.js';
18
+ import '../global/schedule-with-cleanup.js';
19
+ import '../internal/reorder-layout-context.js';
5
20
 
6
21
  const keyboardFocusableAttrName = 'data-keyboard-focusable';
7
22
  /**
@@ -10,11 +25,11 @@ const keyboardFocusableAttrName = 'data-keyboard-focusable';
10
25
  */
11
26
  function TableRow(props) {
12
27
  const $ = c(13);
13
- if ($[0] !== "cabc2a5dbbf0c25c3facc4244a2cfb0e9361a7af6c622110f3bd4ba41a3d1955") {
28
+ if ($[0] !== "93324b17cadcfd02a0d3ded987965c5c50fdfc14a72160047cf34b19f7c0c48d") {
14
29
  for (let $i = 0; $i < 13; $i += 1) {
15
30
  $[$i] = Symbol.for("react.memo_cache_sentinel");
16
31
  }
17
- $[0] = "cabc2a5dbbf0c25c3facc4244a2cfb0e9361a7af6c622110f3bd4ba41a3d1955";
32
+ $[0] = "93324b17cadcfd02a0d3ded987965c5c50fdfc14a72160047cf34b19f7c0c48d";
18
33
  }
19
34
  let className;
20
35
  let keyboardFocusable;
@@ -76,11 +91,11 @@ function TableRow(props) {
76
91
  */
77
92
  function TableCell(props) {
78
93
  const $ = c(9);
79
- if ($[0] !== "cabc2a5dbbf0c25c3facc4244a2cfb0e9361a7af6c622110f3bd4ba41a3d1955") {
94
+ if ($[0] !== "93324b17cadcfd02a0d3ded987965c5c50fdfc14a72160047cf34b19f7c0c48d") {
80
95
  for (let $i = 0; $i < 9; $i += 1) {
81
96
  $[$i] = Symbol.for("react.memo_cache_sentinel");
82
97
  }
83
- $[0] = "cabc2a5dbbf0c25c3facc4244a2cfb0e9361a7af6c622110f3bd4ba41a3d1955";
98
+ $[0] = "93324b17cadcfd02a0d3ded987965c5c50fdfc14a72160047cf34b19f7c0c48d";
84
99
  }
85
100
  let className;
86
101
  let restProps;
@@ -119,5 +134,47 @@ function TableCell(props) {
119
134
  }
120
135
  return t1;
121
136
  }
137
+ /**
138
+ * A drag handle that allows the user to reorder the row. Place it anywhere
139
+ * inside a row renderer.
140
+ * Use {@link TableProps.canReorderItem} and {@link TableProps.onItemReorder}.
141
+ */
142
+ function ItemReorderHandle(t0) {
143
+ const $ = c(7);
144
+ if ($[0] !== "93324b17cadcfd02a0d3ded987965c5c50fdfc14a72160047cf34b19f7c0c48d") {
145
+ for (let $i = 0; $i < 7; $i += 1) {
146
+ $[$i] = Symbol.for("react.memo_cache_sentinel");
147
+ }
148
+ $[0] = "93324b17cadcfd02a0d3ded987965c5c50fdfc14a72160047cf34b19f7c0c48d";
149
+ }
150
+ let index;
151
+ let restProps;
152
+ if ($[1] !== t0) {
153
+ ({
154
+ index,
155
+ ...restProps
156
+ } = t0);
157
+ $[1] = t0;
158
+ $[2] = index;
159
+ $[3] = restProps;
160
+ } else {
161
+ index = $[2];
162
+ restProps = $[3];
163
+ }
164
+ let t1;
165
+ if ($[4] !== index || $[5] !== restProps) {
166
+ t1 = /*#__PURE__*/jsx(ReorderHandle, {
167
+ direction: "items",
168
+ index: index,
169
+ ...restProps
170
+ });
171
+ $[4] = index;
172
+ $[5] = restProps;
173
+ $[6] = t1;
174
+ } else {
175
+ t1 = $[6];
176
+ }
177
+ return t1;
178
+ }
122
179
 
123
- export { TableCell, TableRow, keyboardFocusableAttrName };
180
+ export { ItemReorderHandle, TableCell, TableRow, keyboardFocusableAttrName };
@@ -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
  */
@@ -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;