@jetbrains/ring-ui-built 8.0.0-beta.3 → 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 (120) 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/heading.js +2 -2
  5. package/components/_helpers/table.js +1 -1
  6. package/components/_helpers/theme.js +1 -1
  7. package/components/alert/alert-actions.d.ts +4 -0
  8. package/components/alert/alert-actions.js +51 -0
  9. package/components/alert/alert-heading.d.ts +4 -0
  10. package/components/alert/alert-heading.js +62 -0
  11. package/components/alert/alert.d.ts +14 -1
  12. package/components/alert/alert.js +44 -26
  13. package/components/alert-service/alert-service.d.ts +2 -1
  14. package/components/alert-service/alert-service.js +15 -5
  15. package/components/auth/auth-core.d.ts +5 -9
  16. package/components/auth/auth-core.js +71 -17
  17. package/components/auth/auth.js +7 -1
  18. package/components/auth/down-notification.js +7 -1
  19. package/components/auth/iframe-flow.js +1 -1
  20. package/components/auth/storage.js +7 -1
  21. package/components/checkbox/checkbox.d.ts +1 -1
  22. package/components/clipboard/clipboard.js +7 -1
  23. package/components/collapsible-group/collapsible-group.d.ts +20 -0
  24. package/components/collapsible-group/collapsible-group.js +382 -0
  25. package/components/components/util-stories.js +63 -1
  26. package/components/data-list/data-list.js +1 -1
  27. package/components/data-list/title.js +1 -1
  28. package/components/date-picker/consts.d.ts +1 -0
  29. package/components/date-picker/date-input.js +3 -2
  30. package/components/date-picker/date-popup.js +3 -3
  31. package/components/dropdown-menu/dropdown-menu.js +6 -6
  32. package/components/editable-heading/editable-heading.js +122 -109
  33. package/components/expand/collapsible-group.d.ts +8 -20
  34. package/components/expand/collapsible-group.js +34 -365
  35. package/components/global/compose-refs.d.ts +2 -1
  36. package/components/global/compose-refs.js +44 -8
  37. package/components/global/focus-sensor-hoc.js +1 -0
  38. package/components/global/focus-with-temporary-tabindex.d.ts +11 -0
  39. package/components/global/focus-with-temporary-tabindex.js +23 -0
  40. package/components/global/intersection-observer-context.d.ts +29 -9
  41. package/components/global/intersection-observer-context.js +50 -52
  42. package/components/global/is-within-interactive-element.d.ts +6 -0
  43. package/components/global/is-within-interactive-element.js +11 -0
  44. package/components/global/is-within-navigable-element.d.ts +6 -0
  45. package/components/global/is-within-navigable-element.js +11 -0
  46. package/components/global/parse-css-duration.d.ts +5 -0
  47. package/components/global/parse-css-duration.js +14 -0
  48. package/components/global/rerender-hoc.js +1 -0
  49. package/components/global/schedule-with-cleanup.d.ts +12 -0
  50. package/components/global/schedule-with-cleanup.js +36 -0
  51. package/components/global/table-selection.js +1 -1
  52. package/components/global/theme.js +1 -1
  53. package/components/header/header.js +8 -2
  54. package/components/header/smart-profile.js +7 -1
  55. package/components/heading/heading.js +3 -3
  56. package/components/http/http.d.ts +2 -2
  57. package/components/http/http.js +2 -2
  58. package/components/i18n/i18n.d.ts +1 -0
  59. package/components/i18n/i18n.js +2 -0
  60. package/components/input/input.d.ts +1 -1
  61. package/components/internal/reorder-animation-context.js +159 -0
  62. package/components/internal/reorder-handle.js +750 -0
  63. package/components/internal/reorder-layout-context.js +141 -0
  64. package/components/internal/table-header.js +685 -0
  65. package/components/{table/table-virtualize.js → internal/virtualization.js} +123 -84
  66. package/components/legacy-table/header-cell.js +2 -2
  67. package/components/legacy-table/row-with-focus-sensor.js +1 -1
  68. package/components/legacy-table/row.d.ts +1 -1
  69. package/components/legacy-table/simple-table.js +1 -1
  70. package/components/legacy-table/smart-table.js +1 -1
  71. package/components/legacy-table/table.js +1 -1
  72. package/components/markdown/markdown.js +2 -2
  73. package/components/message/message.js +1 -1
  74. package/components/old-browsers-message/white-list.js +2 -2
  75. package/components/popup/popup.d.ts +2 -0
  76. package/components/popup/popup.js +5 -1
  77. package/components/select/select-popup.d.ts +1 -1
  78. package/components/select/select.d.ts +1 -1
  79. package/components/storage/storage-local.js +7 -1
  80. package/components/storage/storage.js +7 -1
  81. package/components/style.css +1 -1
  82. package/components/table/default-item-renderer.d.ts +29 -10
  83. package/components/table/default-item-renderer.js +151 -93
  84. package/components/table/internal/reorder-animation-context.d.ts +21 -0
  85. package/components/table/internal/reorder-handle.d.ts +9 -0
  86. package/components/table/internal/reorder-layout-context.d.ts +16 -0
  87. package/components/table/internal/table-header.d.ts +1 -0
  88. package/components/table/internal/virtualization.d.ts +41 -0
  89. package/components/table/item-virtualization.d.ts +37 -0
  90. package/components/table/item-virtualization.js +73 -0
  91. package/components/table/reorder-animation.d.ts +37 -0
  92. package/components/table/reorder-animation.js +18 -0
  93. package/components/table/reorder-item-layout.d.ts +32 -0
  94. package/components/table/reorder-item-layout.js +57 -0
  95. package/components/table/table-const.d.ts +8 -6
  96. package/components/table/table-const.js +8 -6
  97. package/components/table/table-primitives.d.ts +52 -16
  98. package/components/table/table-primitives.js +64 -207
  99. package/components/table/table-props.d.ts +304 -0
  100. package/components/table/table-props.js +1 -0
  101. package/components/table/table.d.ts +231 -209
  102. package/components/table/table.js +365 -17
  103. package/components/tooltip/tooltip.js +1 -1
  104. package/components/user-agreement/service.js +13 -7
  105. package/components/user-card/card.js +7 -1
  106. package/components/user-card/smart-user-card-tooltip.d.ts +1 -1
  107. package/components/user-card/smart-user-card-tooltip.js +7 -1
  108. package/components/user-card/tooltip.js +7 -1
  109. package/components/user-card/user-card.js +7 -1
  110. package/components/util-stories.d.ts +26 -0
  111. package/package.json +3 -3
  112. package/components/date-picker/use-intersection-observer.d.ts +0 -6
  113. package/components/date-picker/use-intersection-observer.js +0 -93
  114. package/components/global/composeRefs.d.ts +0 -6
  115. package/components/global/composeRefs.js +0 -9
  116. package/components/table/table-component.d.ts +0 -80
  117. package/components/table/table-component.js +0 -290
  118. package/components/table/table-row-focus.d.ts +0 -4
  119. package/components/table/table-row-focus.js +0 -41
  120. package/components/table/table-virtualize.d.ts +0 -32
@@ -0,0 +1,304 @@
1
+ import type { AriaAttributes, ReactNode, RefObject } from 'react';
2
+ export interface TableProps<T> {
3
+ /**
4
+ * The data items to render. `null` and `undefined` items are not supported.
5
+ * Referentially identical items are not supported either.
6
+ */
7
+ data: readonly T[];
8
+ /**
9
+ * Column definitions.
10
+ */
11
+ columns: readonly Column<T>[];
12
+ /**
13
+ * Used as a key in the items list.
14
+ */
15
+ getKey: (item: T, index: number, items: readonly T[]) => React.Key;
16
+ /**
17
+ * If `true`, the table header will not be rendered.
18
+ *
19
+ * Note that this may impact accessibility. If necessary, provide additional
20
+ * information via `aria-label` or `aria-description` on the `Table` element.
21
+ */
22
+ noHeader?: boolean;
23
+ /**
24
+ * If true, renders a sticky header.
25
+ */
26
+ stickyHeader?: boolean;
27
+ /**
28
+ * Called when the user clicks the sort button in a column header.
29
+ * The client is expected to update the `columns` prop with the new
30
+ * sort order for the corresponding column, and update the data accordingly.
31
+ */
32
+ onSort?: (columnIndex: number, newOrder: SortOrder, columns: readonly Column<T>[]) => void;
33
+ /**
34
+ * Called when the user clicks on a column delete button in the header.
35
+ * The client is expected to update the `columns` prop with the column removed.
36
+ */
37
+ onColumnDelete?: (column: Column<T>, columnIndex: number, columns: readonly Column<T>[]) => void;
38
+ /**
39
+ * Called when the user reorders columns by dragging a column.
40
+ * The `insertionIndex` parameter represents an insertion position in the original,
41
+ * unchanged `columns` array before the column is removed.
42
+ *
43
+ * One possible implementation is:
44
+ *
45
+ * ```ts
46
+ * columns.splice(fromIndex, 1);
47
+ * columns.splice(fromIndex < insertionIndex ? insertionIndex - 1 : insertionIndex, 0, columnBeingReordered);
48
+ * ```
49
+ *
50
+ * The callback is not called when the reorder operation would not change the
51
+ * column order, i.e. when
52
+ * `insertionIndex === fromIndex || insertionIndex === fromIndex + 1`.
53
+ */
54
+ onColumnReorder?: (columnBeingReordered: Column<T>, fromIndex: number, insertionIndex: number, columns: readonly Column<T>[]) => void;
55
+ /**
56
+ * By default, when a column is reordered, the moved column is highlighted
57
+ * with a temporary background color. Set `true` to disable this animation.
58
+ */
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;
84
+ /**
85
+ * Customizes how an item is rendered.
86
+ *
87
+ * Return `DefaultItemRenderer` to configure row-specific behavior such as
88
+ * `clickable`, `keyboardFocusable`, event handlers, `className`, or `ref`.
89
+ *
90
+ * You can also return custom row(s) instead. See the `Table` documentation
91
+ * for details.
92
+ */
93
+ renderItem?: (item: T, index: number, items: readonly T[]) => ReactNode;
94
+ /**
95
+ * Only renders rows near the viewport.
96
+ *
97
+ * Rows may transition between two states:
98
+ * - materialized: rendered as actual table rows. This happens when
99
+ * the corresponding spacer approaches the viewport, as specified by
100
+ * `lookaheadPx`.
101
+ * - virtualized: replaced with spacer rows of the same height. This happens
102
+ * when the row moves sufficiently far from the viewport, as specified by
103
+ * `retentionMarginPx`.
104
+ *
105
+ * Toggling this prop should normally work as expected, but a seamless
106
+ * transition is not guaranteed: the scroll position may reset to the top.
107
+ * However, if row height estimates are accurate and the data has not
108
+ * changed, the browser may apply scroll anchoring, resulting in a smoother
109
+ * transition, possibly with brief flickering but without scroll jumps.
110
+ */
111
+ virtualizeRows?: boolean;
112
+ /**
113
+ * Used with `virtualizeRows` as the source of scroll events, the target of
114
+ * `ResizeObserver`, and the root of `IntersectionObserver`. Required when
115
+ * the scrollable container is not the whole document.
116
+ *
117
+ * If not set:
118
+ * - the scroll listener is attached to `window`
119
+ * - `ResizeObserver` observes `document.body`
120
+ * - `IntersectionObserver` has no root (i.e. the viewport is used)
121
+ *
122
+ * Note that if this scroller is nested inside another scrollable container,
123
+ * the outer container is not tracked. As a result, items may not materialize
124
+ * until the inner scroller is scrolled.
125
+ *
126
+ * Support for nested scroll containers may be added in the future.
127
+ */
128
+ scrollerRef?: RefObject<HTMLElement | null>;
129
+ /**
130
+ * Used with `virtualizeRows` to estimate the height of items that have not
131
+ * been rendered yet. The function should be fast and side-effect free.
132
+ * Do not measure the DOM here. Once a row is rendered, its actual height
133
+ * will be measured and used instead of this estimate.
134
+ *
135
+ * Note the effects of imprecise estimates:
136
+ * - When the height is underestimated, the table may materialize more rows
137
+ * than specified by `lookaheadPx`. If the resulting rows extend beyond
138
+ * `retentionMarginPx`, they will be virtualized again. If this causes
139
+ * relayout flickering, increase `retentionMarginPx`.
140
+ * - When the height is overestimated, the table may materialize fewer rows
141
+ * than specified by `lookaheadPx`, which may leave a spacer partially
142
+ * visible. To avoid this, increase `lookaheadPx` (and `retentionMarginPx`
143
+ * accordingly, since it should be greater than `lookaheadPx`).
144
+ *
145
+ * Default: 37px = 16px padding + 20px line height + 1px border.
146
+ */
147
+ estimateHeight?: (item: T, index: number, items: readonly T[]) => number;
148
+ /**
149
+ * When using `virtualizeRows`, the number of pixels above and below
150
+ * the viewport to materialize in advance.
151
+ *
152
+ * Increase this value if blank space becomes visible during fast scrolling.
153
+ *
154
+ * Default: 400px.
155
+ */
156
+ lookaheadPx?: number;
157
+ /**
158
+ * Used with `virtualizeRows`. Additional margin around the viewport before
159
+ * materialized rows become eligible for virtualization.
160
+ *
161
+ * Increasing this value reduces row churn when heights are underestimated.
162
+ * In that case, the table may materialize more rows than needed and then
163
+ * immediately virtualize them again. A larger margin keeps such rows
164
+ * rendered for longer, at the cost of rendering more rows overall.
165
+ *
166
+ * This value should be greater than `lookaheadPx`. Increase it if you notice
167
+ * table relayouts during initial render or scrolling.
168
+ *
169
+ * Default: 450px.
170
+ */
171
+ retentionMarginPx?: number;
172
+ /**
173
+ * When using `virtualizeRows`, ignore scroll and resize position changes
174
+ * smaller than this value.
175
+ *
176
+ * Measurement inaccuracies and rounding artifacts may slightly change the
177
+ * table layout during materialization and virtualization. With scroll
178
+ * anchoring enabled (the default browser behavior), the browser may then
179
+ * adjust the scroll position, triggering additional scroll or resize events.
180
+ * Small deltas are ignored to prevent such feedback loops from causing
181
+ * oscillations at virtualization boundaries.
182
+ *
183
+ * Increase if you expect high inaccuracy in height measurements, or if you
184
+ * notice oscillations at virtualization boundaries.
185
+ *
186
+ * Default: 50px.
187
+ */
188
+ minScrollAndResizeDeltaPx?: number;
189
+ /**
190
+ * "Column editing mode" is a mode in which controls that are normally hidden
191
+ * become visible, such as column reorder and delete buttons.
192
+ *
193
+ * When this prop is `undefined`, the component manages the mode internally.
194
+ * Users can toggle it by tapping the table header on mobile or by clicking
195
+ * the column edit button, if enabled. Since tapping the table header is not
196
+ * discoverable by assistive technologies, it's recommended to enable
197
+ * `columnEditButton` when using the internal mode.
198
+ *
199
+ * Alternatively, pass `true` or `false` to control the mode externally.
200
+ */
201
+ columnEditing?: boolean;
202
+ /**
203
+ * Called when the user requests to enter or leave column editing mode.
204
+ *
205
+ * The `source` parameter indicates what triggered the request.
206
+ *
207
+ * When `columnEditing` is not controlled, the component automatically
208
+ * applies the requested change internally.
209
+ *
210
+ * When `columnEditing` is controlled externally and you still want to
211
+ * respond to user requests, use this callback to decide whether to
212
+ * update the mode.
213
+ */
214
+ onColumnEditingRequest?: (editing: boolean, source: 'header' | 'edit-button') => void;
215
+ /**
216
+ * Whether to show a small gear button in the top-right corner that
217
+ * toggles column editing mode.
218
+ *
219
+ * For accessibility, it's recommended to enable this button unless you
220
+ * provide an external control for toggling column editing mode.
221
+ */
222
+ columnEditButton?: boolean;
223
+ /**
224
+ * Applied to the `<thead>` element.
225
+ */
226
+ theadClassName?: string;
227
+ /**
228
+ * Applied to the only `<tr>` element within the `<thead>`.
229
+ */
230
+ theadTrClassName?: string;
231
+ /**
232
+ * Applied to the `<tbody>` element.
233
+ */
234
+ tbodyClassName?: string;
235
+ }
236
+ export type SortOrder = Extract<AriaAttributes['aria-sort'], 'none' | 'ascending' | 'descending'>;
237
+ /**
238
+ * The column specification.
239
+ */
240
+ export interface Column<T> {
241
+ /**
242
+ * Used as a key in the columns list.
243
+ */
244
+ key: React.Key;
245
+ /**
246
+ * Used in `aria-label`s of column controls which do not contain text,
247
+ * such as the delete column button. If not set, the `String(key)` is used.
248
+ */
249
+ name?: string;
250
+ /**
251
+ * Renders the content of the column header, excluding controls such as
252
+ * the sort and delete buttons. If not specified, the default behavior is
253
+ * `name ?? String(key)`.
254
+ */
255
+ renderHeader?: () => ReactNode;
256
+ /**
257
+ * Renders the value of a single cell. If not specified, the default
258
+ * behavior is:
259
+ *
260
+ * - If `item` is an `Array`, renders `String(item[columnIndex])`
261
+ * - If `item` is an `Object`, renders `String(item[String(columnKey)])`
262
+ * - Otherwise:
263
+ * - The first column renders `String(item)`
264
+ * - Other columns render an empty string
265
+ */
266
+ renderCell?: (item: T, index: number, items: readonly T[]) => ReactNode;
267
+ /**
268
+ * If the column gets an indent when `DefaultItemRendererProps.level` returns
269
+ * a positive number.
270
+ */
271
+ indent?: boolean;
272
+ /**
273
+ * If set, displays sort button and includes `aria-sort` in the column header.
274
+ * Handle clicks with {@link TableProps.onSort}.
275
+ */
276
+ sortOrder?: AriaAttributes['aria-sort'];
277
+ /**
278
+ * Whether to display a delete button in the column header.
279
+ * Handle delete requests with {@link TableProps.onColumnDelete}.
280
+ * Make sure {@link Column.name} or {@link Column.key} is meaningful,
281
+ * as it will be included in the `aria-label` of the delete button.
282
+ */
283
+ deletable?: boolean;
284
+ /**
285
+ * Displays a reorder handle in the column header.
286
+ * Handle reorder requests with {@link TableProps.onColumnReorder}.
287
+ * If a function is provided, it determines whether the column may be moved
288
+ * to the specified insertion position.
289
+ *
290
+ * Make sure {@link Column.name} or {@link Column.key} is meaningful,
291
+ * as it will be included in the `aria-label` of the reorder button.
292
+ */
293
+ canReorder?: boolean | ((columnBeingReordered: Column<T>, fromIndex: number, insertionIndex: number, columns: readonly Column<T>[]) => boolean);
294
+ /**
295
+ * The class name to apply to the `th` element inside `table > thead`.
296
+ */
297
+ thClassName?: string;
298
+ /**
299
+ * The class name to apply to the `td` element inside `table > tbody`.
300
+ * If a custom `TableProps.renderItem` is provided, this prop is not used,
301
+ * unless the custom renderer falls back to the `DefaultItemRenderer`.
302
+ */
303
+ tdClassName?: string | ((item: T, index: number, items: readonly T[]) => string | undefined);
304
+ }
@@ -0,0 +1 @@
1
+