@jetbrains/ring-ui-built 7.0.124 → 8.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (262) hide show
  1. package/components/_helpers/anchor.js +1 -1
  2. package/components/_helpers/avatar-info.js +3 -5
  3. package/components/_helpers/caption.js +1 -1
  4. package/components/_helpers/icon-svg.js +37 -52
  5. package/components/_helpers/legacy-table.js +3 -0
  6. package/components/_helpers/tab-link.js +1 -1
  7. package/components/_helpers/table.js +2 -2
  8. package/components/_helpers/theme.js +49 -37
  9. package/components/alert/alert-actions.js +1 -1
  10. package/components/alert/alert-heading.js +1 -1
  11. package/components/alert/alert.js +2 -2
  12. package/components/alert-service/alert-service.js +2 -2
  13. package/components/auth/auth-core.js +2 -2
  14. package/components/auth/auth.js +2 -2
  15. package/components/auth/down-notification.js +2 -2
  16. package/components/auth/iframe-flow.js +1 -1
  17. package/components/auth/storage.js +2 -2
  18. package/components/auth-dialog/auth-dialog.js +2 -2
  19. package/components/auth-dialog-service/auth-dialog-service.js +2 -2
  20. package/components/avatar/avatar-info.js +1 -1
  21. package/components/avatar/avatar-size.d.ts +0 -4
  22. package/components/avatar/avatar-size.js +0 -4
  23. package/components/avatar/avatar.js +1 -8
  24. package/components/avatar/fallback-avatar.js +3 -48
  25. package/components/avatar-stack/avatar-stack.js +5 -5
  26. package/components/banner/banner.js +2 -2
  27. package/components/button/button.d.ts +0 -4
  28. package/components/button/button.js +4 -10
  29. package/components/button-group/button-group.js +1 -1
  30. package/components/button-toolbar/button-toolbar.js +1 -1
  31. package/components/checkbox/checkbox.d.ts +1 -1
  32. package/components/checkbox/checkbox.js +1 -2
  33. package/components/clipboard/clipboard.js +2 -2
  34. package/components/collapse/collapse-content.js +35 -43
  35. package/components/collapse/collapse-context.d.ts +1 -0
  36. package/components/collapse/collapse-context.js +1 -0
  37. package/components/collapse/collapse-control.js +5 -5
  38. package/components/collapse/collapse.js +34 -25
  39. package/components/collapsible-group/collapsible-group.d.ts +5 -1
  40. package/components/collapsible-group/collapsible-group.js +80 -98
  41. package/components/components/util-stories.js +63 -1
  42. package/components/confirm/confirm.js +2 -2
  43. package/components/confirm-service/confirm-service.js +4 -4
  44. package/components/contenteditable/contenteditable.js +4 -5
  45. package/components/control-help/control-help.js +1 -1
  46. package/components/control-label/control-label.js +1 -1
  47. package/components/data-list/data-list.d.ts +4 -4
  48. package/components/data-list/data-list.js +5 -5
  49. package/components/data-list/data-list.mock.d.ts +1 -1
  50. package/components/data-list/data-list.mock.js +2 -2
  51. package/components/data-list/item.d.ts +1 -1
  52. package/components/data-list/item.js +3 -3
  53. package/components/data-list/selection.d.ts +1 -1
  54. package/components/data-list/selection.js +2 -2
  55. package/components/data-list/title.js +1 -2
  56. package/components/date-picker/date-input.js +2 -2
  57. package/components/date-picker/date-picker.js +2 -3
  58. package/components/date-picker/date-popup.js +4 -5
  59. package/components/date-picker/month-names.js +1 -1
  60. package/components/date-picker/month-slider.js +1 -1
  61. package/components/date-picker/month.d.ts +0 -2
  62. package/components/date-picker/month.js +17 -18
  63. package/components/date-picker/months.js +43 -36
  64. package/components/date-picker/use-scroll-behavior.js +45 -45
  65. package/components/date-picker/weekdays.js +1 -1
  66. package/components/date-picker/years.js +61 -55
  67. package/components/dialog/dialog.d.ts +2 -2
  68. package/components/dialog/dialog.js +5 -5
  69. package/components/dropdown/anchor.js +3 -3
  70. package/components/dropdown/dropdown.js +3 -3
  71. package/components/dropdown-menu/dropdown-menu.d.ts +4 -4
  72. package/components/dropdown-menu/dropdown-menu.js +63 -58
  73. package/components/editable-heading/editable-heading.d.ts +1 -2
  74. package/components/editable-heading/editable-heading.js +14 -13
  75. package/components/error-bubble/error-bubble.js +1 -1
  76. package/components/error-message/error-message.js +1 -2
  77. package/components/footer/footer.js +1 -1
  78. package/components/global/compose-refs.d.ts +2 -1
  79. package/components/global/compose-refs.js +44 -8
  80. package/components/global/configuration.d.ts +0 -5
  81. package/components/global/configuration.js +2 -10
  82. package/components/global/controls-height.js +1 -1
  83. package/components/global/create-stateful-context.js +11 -11
  84. package/components/global/focus-sensor-hoc.js +1 -0
  85. package/components/global/focus-with-temporary-tabindex.d.ts +11 -0
  86. package/components/global/focus-with-temporary-tabindex.js +23 -0
  87. package/components/global/intersection-observer-context.d.ts +46 -0
  88. package/components/global/intersection-observer-context.js +138 -0
  89. package/components/global/is-within-interactive-element.d.ts +6 -0
  90. package/components/global/is-within-interactive-element.js +11 -0
  91. package/components/global/is-within-navigable-element.d.ts +6 -0
  92. package/components/global/is-within-navigable-element.js +11 -0
  93. package/components/global/parse-css-duration.d.ts +5 -0
  94. package/components/global/parse-css-duration.js +14 -0
  95. package/components/global/rerender-hoc.d.ts +4 -2
  96. package/components/global/rerender-hoc.js +11 -24
  97. package/components/global/schedule-with-cleanup.d.ts +12 -0
  98. package/components/global/schedule-with-cleanup.js +36 -0
  99. package/components/{table/selection.d.ts → global/table-selection.d.ts} +15 -15
  100. package/components/{table/selection.js → global/table-selection.js} +5 -5
  101. package/components/global/theme.d.ts +4 -3
  102. package/components/global/theme.js +1 -1
  103. package/components/global/variables.interface.d.ts +0 -4
  104. package/components/header/header-icon.js +3 -3
  105. package/components/header/header.js +3 -3
  106. package/components/header/links.js +1 -1
  107. package/components/header/logo.js +1 -2
  108. package/components/header/profile.js +5 -5
  109. package/components/header/services.js +3 -3
  110. package/components/header/smart-profile.js +3 -3
  111. package/components/header/smart-services.js +3 -3
  112. package/components/heading/heading.js +1 -1
  113. package/components/i18n/i18n-context.js +4 -4
  114. package/components/icon/icon-svg.js +1 -2
  115. package/components/icon/icon.d.ts +0 -1
  116. package/components/icon/icon.js +2 -6
  117. package/components/icon/index.js +1 -2
  118. package/components/input/input.d.ts +1 -1
  119. package/components/input/input.js +3 -3
  120. package/components/internal/reorder-animation-context.js +159 -0
  121. package/components/internal/reorder-handle.js +750 -0
  122. package/components/internal/reorder-layout-context.js +141 -0
  123. package/components/internal/table-header.js +685 -0
  124. package/components/internal/virtualization.js +368 -0
  125. package/components/island/adaptive-island-hoc.js +3 -3
  126. package/components/island/content.d.ts +7 -2
  127. package/components/island/content.js +27 -18
  128. package/components/island/header.js +1 -1
  129. package/components/island/island.js +1 -1
  130. package/components/{table → legacy-table}/cell.js +1 -1
  131. package/components/{table → legacy-table}/header-cell.js +2 -3
  132. package/components/{table → legacy-table}/header.js +2 -3
  133. package/components/{table → legacy-table}/multitable.d.ts +1 -1
  134. package/components/{table → legacy-table}/row-with-focus-sensor.js +3 -3
  135. package/components/{table → legacy-table}/row.d.ts +1 -1
  136. package/components/{table → legacy-table}/row.js +5 -5
  137. package/components/legacy-table/selection-adapter.d.ts +6 -0
  138. package/components/{table → legacy-table}/selection-shortcuts-hoc.d.ts +5 -5
  139. package/components/{table → legacy-table}/simple-table.d.ts +2 -2
  140. package/components/{table → legacy-table}/simple-table.js +5 -5
  141. package/components/{table → legacy-table}/smart-table.d.ts +5 -5
  142. package/components/{table → legacy-table}/smart-table.js +6 -6
  143. package/components/legacy-table/table.d.ts +109 -0
  144. package/components/legacy-table/table.js +369 -0
  145. package/components/list/consts.d.ts +0 -1
  146. package/components/list/consts.js +0 -1
  147. package/components/list/list-item.js +3 -5
  148. package/components/list/list-users-groups-source.js +1 -2
  149. package/components/list/list.d.ts +0 -4
  150. package/components/list/list.js +1 -2
  151. package/components/login-dialog/login-dialog.js +3 -3
  152. package/components/login-dialog/service.js +2 -2
  153. package/components/message/message.js +1 -1
  154. package/components/pager/pager.js +3 -3
  155. package/components/popup/popup.js +1 -1
  156. package/components/popup/popup.target.d.ts +3 -2
  157. package/components/popup/popup.target.js +32 -28
  158. package/components/popup-menu/popup-menu.js +1 -1
  159. package/components/query-assist/query-assist-suggestions.js +1 -2
  160. package/components/query-assist/query-assist.d.ts +3 -1
  161. package/components/query-assist/query-assist.js +2 -2
  162. package/components/radio/radio-item.d.ts +3 -3
  163. package/components/radio/radio-item.js +33 -19
  164. package/components/radio/radio.d.ts +2 -2
  165. package/components/radio/radio.js +2 -2
  166. package/components/scrollable-section/scrollable-section.js +1 -1
  167. package/components/select/chevron-button.js +3 -3
  168. package/components/select/select-filter.js +3 -3
  169. package/components/select/select-popup.d.ts +3 -2
  170. package/components/select/select-popup.js +9 -4
  171. package/components/select/select.d.ts +6 -2
  172. package/components/select/select.js +5 -4
  173. package/components/selection-toolbar/selection-toolbar.d.ts +11 -0
  174. package/components/selection-toolbar/selection-toolbar.js +200 -0
  175. package/components/slider/slider.js +100 -97
  176. package/components/storage/storage-local.js +2 -2
  177. package/components/storage/storage.js +2 -2
  178. package/components/style.css +1 -1
  179. package/components/tab-trap/tab-trap.d.ts +3 -3
  180. package/components/tab-trap/tab-trap.js +83 -80
  181. package/components/table/default-item-renderer.d.ts +55 -0
  182. package/components/table/default-item-renderer.js +240 -0
  183. package/components/table/internal/reorder-animation-context.d.ts +21 -0
  184. package/components/table/internal/reorder-handle.d.ts +9 -0
  185. package/components/table/internal/reorder-layout-context.d.ts +16 -0
  186. package/components/table/internal/table-header.d.ts +1 -0
  187. package/components/table/internal/virtualization.d.ts +41 -0
  188. package/components/table/item-virtualization.d.ts +37 -0
  189. package/components/table/item-virtualization.js +73 -0
  190. package/components/table/reorder-animation.d.ts +37 -0
  191. package/components/table/reorder-animation.js +18 -0
  192. package/components/table/reorder-item-layout.d.ts +32 -0
  193. package/components/table/reorder-item-layout.js +57 -0
  194. package/components/table/table-const.d.ts +10 -0
  195. package/components/table/table-const.js +13 -0
  196. package/components/table/table-primitives.d.ts +64 -0
  197. package/components/table/table-primitives.js +180 -0
  198. package/components/table/table-props.d.ts +304 -0
  199. package/components/table/table-props.js +1 -0
  200. package/components/table/table.d.ts +231 -107
  201. package/components/table/table.js +351 -346
  202. package/components/tabs/collapsible-more.js +1 -1
  203. package/components/tabs/collapsible-tab.js +1 -1
  204. package/components/tabs/collapsible-tabs.js +1 -1
  205. package/components/tabs/dumb-tabs.js +1 -1
  206. package/components/tabs/smart-tabs.js +1 -1
  207. package/components/tabs/tab-link.js +1 -1
  208. package/components/tabs/tabs.js +1 -1
  209. package/components/tag/tag.js +1 -1
  210. package/components/tags-input/tags-input.d.ts +3 -1
  211. package/components/tags-input/tags-input.js +4 -4
  212. package/components/tags-list/tags-list.js +2 -2
  213. package/components/toggle/toggle.js +1 -1
  214. package/components/tooltip/tooltip.d.ts +2 -1
  215. package/components/tooltip/tooltip.js +5 -3
  216. package/components/upload/upload.d.ts +4 -3
  217. package/components/upload/upload.js +7 -30
  218. package/components/user-agreement/service.js +3 -3
  219. package/components/user-agreement/user-agreement.js +2 -2
  220. package/components/user-card/card.js +4 -4
  221. package/components/user-card/smart-user-card-tooltip.js +3 -3
  222. package/components/user-card/tooltip.js +3 -3
  223. package/components/user-card/user-card.js +5 -5
  224. package/components/util-stories.d.ts +26 -0
  225. package/package.json +8 -9
  226. package/components/__mocks__/old-browsers-message.js +0 -3
  227. package/components/_helpers/grid.js +0 -3
  228. package/components/_helpers/sidebar.js +0 -110
  229. package/components/content-layout/content-layout.d.ts +0 -20
  230. package/components/content-layout/content-layout.js +0 -50
  231. package/components/content-layout/sidebar.d.ts +0 -26
  232. package/components/content-layout/sidebar.js +0 -5
  233. package/components/date-picker/use-intersection-observer.d.ts +0 -6
  234. package/components/date-picker/use-intersection-observer.js +0 -93
  235. package/components/expand/collapsible-group.d.ts +0 -8
  236. package/components/expand/collapsible-group.js +0 -52
  237. package/components/global/composeRefs.d.ts +0 -6
  238. package/components/global/composeRefs.js +0 -9
  239. package/components/global/use-event-callback.d.ts +0 -4
  240. package/components/global/use-event-callback.js +0 -49
  241. package/components/grid/col.d.ts +0 -16
  242. package/components/grid/col.js +0 -63
  243. package/components/grid/grid.d.ts +0 -13
  244. package/components/grid/grid.js +0 -27
  245. package/components/grid/row.d.ts +0 -21
  246. package/components/grid/row.js +0 -72
  247. package/components/old-browsers-message/old-browsers-message-stop.d.ts +0 -1
  248. package/components/old-browsers-message/old-browsers-message-stop.js +0 -5
  249. package/components/old-browsers-message/old-browsers-message.d.ts +0 -5
  250. package/components/old-browsers-message/old-browsers-message.js +0 -89
  251. package/components/old-browsers-message/white-list.d.ts +0 -2
  252. package/components/old-browsers-message/white-list.js +0 -30
  253. package/components/table/selection-adapter.d.ts +0 -6
  254. /package/components/{table → legacy-table}/cell.d.ts +0 -0
  255. /package/components/{table → legacy-table}/disable-hover-hoc.d.ts +0 -0
  256. /package/components/{table → legacy-table}/disable-hover-hoc.js +0 -0
  257. /package/components/{table → legacy-table}/header-cell.d.ts +0 -0
  258. /package/components/{table → legacy-table}/header.d.ts +0 -0
  259. /package/components/{table → legacy-table}/multitable.js +0 -0
  260. /package/components/{table → legacy-table}/row-with-focus-sensor.d.ts +0 -0
  261. /package/components/{table → legacy-table}/selection-adapter.js +0 -0
  262. /package/components/{table → legacy-table}/selection-shortcuts-hoc.js +0 -0
@@ -0,0 +1,750 @@
1
+ import { c } from 'react/compiler-runtime';
2
+ import { useRef, use, useEffectEvent, useEffect } from 'react';
3
+ import classNames from 'classnames';
4
+ import dragIcon from '@jetbrains/icons/drag-12px';
5
+ import { TablePropsContext } from '../table/table-const.js';
6
+ import Icon from '../icon/icon.js';
7
+ import { useComposedRef } from '../global/compose-refs.js';
8
+ import { parseCssDuration } from '../global/parse-css-duration.js';
9
+ import { ReorderAnimationContext } from './reorder-animation-context.js';
10
+ import { ReorderLayoutContext } from './reorder-layout-context.js';
11
+ import { s as styles } from '../_helpers/table.js';
12
+ import { jsx } from 'react/jsx-runtime';
13
+ import 'util-deprecate';
14
+ import '../icon/icon.constants.js';
15
+ import '../_helpers/icon-svg.js';
16
+ import '../global/memoize.js';
17
+ import 'memoize-one';
18
+ import '../global/schedule-with-cleanup.js';
19
+
20
+ const columnDragFrameAdjustmentPx = -1;
21
+ const itemDragFrameAdjustmentPx = -2;
22
+ const scrollAreaPx = 100;
23
+ const scrollStepPx = 100;
24
+ const scrollIntervalMs = 200;
25
+ function ReorderHandle(t0) {
26
+ var _columns$index$name;
27
+ const $ = c(117);
28
+ if ($[0] !== "4544842fd05f0c29d1fc5074a4df3120dd2baf71388dcaaf57c84e7cd83c8c63") {
29
+ for (let $i = 0; $i < 117; $i += 1) {
30
+ $[$i] = Symbol.for("react.memo_cache_sentinel");
31
+ }
32
+ $[0] = "4544842fd05f0c29d1fc5074a4df3120dd2baf71388dcaaf57c84e7cd83c8c63";
33
+ }
34
+ let className;
35
+ let direction;
36
+ let index;
37
+ let noDragFrame;
38
+ let noHandleTranslate;
39
+ let onKeyDown;
40
+ let onLostPointerCapture;
41
+ let onPointerCancel;
42
+ let onPointerDown;
43
+ let onPointerMove;
44
+ let onPointerUp;
45
+ let onUserDrag;
46
+ let restProps;
47
+ let userRef;
48
+ if ($[1] !== t0) {
49
+ ({
50
+ direction,
51
+ index,
52
+ noDragFrame,
53
+ noHandleTranslate,
54
+ onUserDrag,
55
+ ref: userRef,
56
+ className,
57
+ onKeyDown,
58
+ onPointerDown,
59
+ onPointerMove,
60
+ onPointerUp,
61
+ onPointerCancel,
62
+ onLostPointerCapture,
63
+ ...restProps
64
+ } = t0);
65
+ $[1] = t0;
66
+ $[2] = className;
67
+ $[3] = direction;
68
+ $[4] = index;
69
+ $[5] = noDragFrame;
70
+ $[6] = noHandleTranslate;
71
+ $[7] = onKeyDown;
72
+ $[8] = onLostPointerCapture;
73
+ $[9] = onPointerCancel;
74
+ $[10] = onPointerDown;
75
+ $[11] = onPointerMove;
76
+ $[12] = onPointerUp;
77
+ $[13] = onUserDrag;
78
+ $[14] = restProps;
79
+ $[15] = userRef;
80
+ } else {
81
+ className = $[2];
82
+ direction = $[3];
83
+ index = $[4];
84
+ noDragFrame = $[5];
85
+ noHandleTranslate = $[6];
86
+ onKeyDown = $[7];
87
+ onLostPointerCapture = $[8];
88
+ onPointerCancel = $[9];
89
+ onPointerDown = $[10];
90
+ onPointerMove = $[11];
91
+ onPointerUp = $[12];
92
+ onUserDrag = $[13];
93
+ restProps = $[14];
94
+ userRef = $[15];
95
+ }
96
+ const localRef = useRef(null);
97
+ const composedRef = useComposedRef(localRef, userRef);
98
+ const isColumn = direction === "columns";
99
+ const tableProps = use(TablePropsContext);
100
+ const data = tableProps?.data;
101
+ const columns = tableProps?.columns;
102
+ const canReorderItem = tableProps?.canReorderItem;
103
+ const onItemReorder = tableProps?.onItemReorder;
104
+ const onColumnReorder = tableProps?.onColumnReorder;
105
+ let t1;
106
+ if ($[16] !== canReorderItem || $[17] !== columns || $[18] !== data || $[19] !== index || $[20] !== isColumn) {
107
+ t1 = function canReorder(insertionIndex) {
108
+ const columnBeingReordered = columns?.[index];
109
+ if (isColumn && columnBeingReordered) {
110
+ const canReorderColumn = columnBeingReordered.canReorder;
111
+ if (canReorderColumn === true) {
112
+ return true;
113
+ }
114
+ if (typeof canReorderColumn === "function") {
115
+ return canReorderColumn(columnBeingReordered, index, insertionIndex, columns);
116
+ }
117
+ return false;
118
+ }
119
+ if (!isColumn && data) {
120
+ return canReorderItem ? canReorderItem(data[index], index, insertionIndex, data) : true;
121
+ }
122
+ return false;
123
+ };
124
+ $[16] = canReorderItem;
125
+ $[17] = columns;
126
+ $[18] = data;
127
+ $[19] = index;
128
+ $[20] = isColumn;
129
+ $[21] = t1;
130
+ } else {
131
+ t1 = $[21];
132
+ }
133
+ const canReorder = t1;
134
+ const {
135
+ expectReorder
136
+ } = use(ReorderAnimationContext);
137
+ let t2;
138
+ if ($[22] !== columns || $[23] !== data || $[24] !== direction || $[25] !== expectReorder || $[26] !== index || $[27] !== isColumn || $[28] !== onColumnReorder || $[29] !== onItemReorder) {
139
+ t2 = function onReorder(insertionIndex_0) {
140
+ if (isColumn && columns) {
141
+ expectReorder({
142
+ direction,
143
+ fromIndex: index,
144
+ insertionIndex: insertionIndex_0
145
+ });
146
+ onColumnReorder?.(columns[index], index, insertionIndex_0, columns);
147
+ } else {
148
+ if (!isColumn && data) {
149
+ expectReorder({
150
+ direction,
151
+ fromIndex: index,
152
+ insertionIndex: insertionIndex_0
153
+ });
154
+ onItemReorder?.(data[index], index, insertionIndex_0, data);
155
+ }
156
+ }
157
+ };
158
+ $[22] = columns;
159
+ $[23] = data;
160
+ $[24] = direction;
161
+ $[25] = expectReorder;
162
+ $[26] = index;
163
+ $[27] = isColumn;
164
+ $[28] = onColumnReorder;
165
+ $[29] = onItemReorder;
166
+ $[30] = t2;
167
+ } else {
168
+ t2 = $[30];
169
+ }
170
+ const onReorder = t2;
171
+ const activeDragRef = useRef(null);
172
+ let t3;
173
+ if ($[31] === Symbol.for("react.memo_cache_sentinel")) {
174
+ t3 = function getDragFrame() {
175
+ return document.body.querySelector(`.${styles.dragFrame}`);
176
+ };
177
+ $[31] = t3;
178
+ } else {
179
+ t3 = $[31];
180
+ }
181
+ const getDragFrame = t3;
182
+ let t4;
183
+ if ($[32] === Symbol.for("react.memo_cache_sentinel")) {
184
+ t4 = function getInsertionIndicator() {
185
+ return document.body.querySelector(`.${styles.insertionIndicator}`);
186
+ };
187
+ $[32] = t4;
188
+ } else {
189
+ t4 = $[32];
190
+ }
191
+ const getInsertionIndicator = t4;
192
+ const {
193
+ getItemBounds,
194
+ getClosestInsertionPoint
195
+ } = use(ReorderLayoutContext);
196
+ let t5;
197
+ if ($[33] !== isColumn || $[34] !== noDragFrame) {
198
+ t5 = function renderDragFrame(clientX, clientY) {
199
+ const drag = activeDragRef.current;
200
+ if (noDragFrame || !drag) {
201
+ return;
202
+ }
203
+ const {
204
+ startX,
205
+ startY,
206
+ initialItemStart,
207
+ initialItemEnd,
208
+ indicatorStart,
209
+ indicatorSize
210
+ } = drag;
211
+ let dragFrame = getDragFrame();
212
+ if (!dragFrame) {
213
+ dragFrame = document.createElement("div");
214
+ dragFrame.className = styles.dragFrame;
215
+ const frameStart = `calc(max(0px, ${indicatorStart - 2}px))`;
216
+ const frameAcrossSize = `${initialItemEnd - initialItemStart}px`;
217
+ const frameAlongSize = indicatorSize;
218
+ dragFrame.style[isColumn ? "top" : "left"] = frameStart;
219
+ dragFrame.style[isColumn ? "width" : "height"] = frameAcrossSize;
220
+ dragFrame.style[isColumn ? "height" : "width"] = frameAlongSize;
221
+ document.body.appendChild(dragFrame);
222
+ }
223
+ if (isColumn) {
224
+ dragFrame.style.left = `${initialItemStart + clientX - startX + columnDragFrameAdjustmentPx}px`;
225
+ } else {
226
+ dragFrame.style.top = `${initialItemStart + clientY - startY + itemDragFrameAdjustmentPx}px`;
227
+ }
228
+ };
229
+ $[33] = isColumn;
230
+ $[34] = noDragFrame;
231
+ $[35] = t5;
232
+ } else {
233
+ t5 = $[35];
234
+ }
235
+ const renderDragFrame = t5;
236
+ let t6;
237
+ if ($[36] !== getItemBounds || $[37] !== index || $[38] !== isColumn || $[39] !== noHandleTranslate) {
238
+ t6 = function translateButton(clientX_0, clientY_0) {
239
+ var _getItemBounds;
240
+ const btn = localRef.current;
241
+ const drag_0 = activeDragRef.current;
242
+ if (noHandleTranslate || !btn || !drag_0) {
243
+ return;
244
+ }
245
+ const {
246
+ startX: startX_0,
247
+ startY: startY_0,
248
+ initialItemStart: initialItemStart_0
249
+ } = drag_0;
250
+ const offsetByPointerMove = isColumn ? clientX_0 - startX_0 : clientY_0 - startY_0;
251
+ const {
252
+ start: itemStart
253
+ } = (_getItemBounds = getItemBounds(index)) !== null && _getItemBounds !== void 0 ? _getItemBounds : {
254
+ start: 0};
255
+ const offsetByItemMove = itemStart - initialItemStart_0;
256
+ const offset = offsetByPointerMove - offsetByItemMove;
257
+ btn.style.transform = isColumn ? `translateX(${offset}px)` : `translateY(${offset}px)`;
258
+ };
259
+ $[36] = getItemBounds;
260
+ $[37] = index;
261
+ $[38] = isColumn;
262
+ $[39] = noHandleTranslate;
263
+ $[40] = t6;
264
+ } else {
265
+ t6 = $[40];
266
+ }
267
+ const translateButton = t6;
268
+ let t7;
269
+ if ($[41] !== canReorder || $[42] !== getClosestInsertionPoint || $[43] !== isColumn) {
270
+ t7 = function getClosestInsertionPointLocal(clientX_1, clientY_1) {
271
+ const clientOffset = isColumn ? clientX_1 : clientY_1;
272
+ return getClosestInsertionPoint(clientOffset, canReorder);
273
+ };
274
+ $[41] = canReorder;
275
+ $[42] = getClosestInsertionPoint;
276
+ $[43] = isColumn;
277
+ $[44] = t7;
278
+ } else {
279
+ t7 = $[44];
280
+ }
281
+ const getClosestInsertionPointLocal = t7;
282
+ let t8;
283
+ if ($[45] !== getItemBounds || $[46] !== isColumn) {
284
+ t8 = function renderInsertionIndicator(t9) {
285
+ const {
286
+ itemIndex,
287
+ after
288
+ } = t9;
289
+ const drag_1 = activeDragRef.current;
290
+ if (!drag_1) {
291
+ return;
292
+ }
293
+ const {
294
+ indicatorStart: indicatorStart_0,
295
+ indicatorSize: indicatorSize_0
296
+ } = drag_1;
297
+ const itemBounds = getItemBounds(itemIndex);
298
+ if (!itemBounds) {
299
+ return;
300
+ }
301
+ const {
302
+ start: itemStart_0,
303
+ end: itemEnd
304
+ } = itemBounds;
305
+ let indicator = getInsertionIndicator();
306
+ if (!indicator) {
307
+ indicator = document.createElement("div");
308
+ indicator.className = styles.insertionIndicator;
309
+ indicator.style[isColumn ? "top" : "left"] = `${indicatorStart_0}px`;
310
+ indicator.style[isColumn ? "height" : "width"] = indicatorSize_0;
311
+ indicator.style[isColumn ? "width" : "height"] = "2px";
312
+ document.body.appendChild(indicator);
313
+ }
314
+ const itemOffset = `${(after ? itemEnd : itemStart_0) - 1}px`;
315
+ indicator.style[isColumn ? "left" : "top"] = itemOffset;
316
+ };
317
+ $[45] = getItemBounds;
318
+ $[46] = isColumn;
319
+ $[47] = t8;
320
+ } else {
321
+ t8 = $[47];
322
+ }
323
+ const renderInsertionIndicator = t8;
324
+ let t9;
325
+ if ($[48] !== onUserDrag) {
326
+ t9 = function cleanupDrag() {
327
+ if (activeDragRef.current) {
328
+ activeDragRef.current.cleanup();
329
+ activeDragRef.current = null;
330
+ }
331
+ const btn_0 = localRef.current;
332
+ if (btn_0) {
333
+ btn_0.style.removeProperty("transform");
334
+ btn_0.style.removeProperty("transition");
335
+ }
336
+ getDragFrame()?.remove();
337
+ getInsertionIndicator()?.remove();
338
+ onUserDrag?.(undefined);
339
+ };
340
+ $[48] = onUserDrag;
341
+ $[49] = t9;
342
+ } else {
343
+ t9 = $[49];
344
+ }
345
+ const cleanupDrag = t9;
346
+ let t10;
347
+ if ($[50] !== cleanupDrag || $[51] !== isColumn || $[52] !== onUserDrag) {
348
+ t10 = function animateNoChangeThenCleanup() {
349
+ const drag_2 = activeDragRef.current;
350
+ if (drag_2?.state !== "is-dragging") {
351
+ return;
352
+ }
353
+ drag_2.state = "ended-with-no-change";
354
+ drag_2.cleanup();
355
+ drag_2.cleanup = _temp;
356
+ const dragFrame_0 = getDragFrame();
357
+ if (dragFrame_0) {
358
+ const {
359
+ initialItemStart: initialItemStart_1
360
+ } = drag_2;
361
+ if (isColumn) {
362
+ dragFrame_0.style.left = `${initialItemStart_1 + columnDragFrameAdjustmentPx}px`;
363
+ } else {
364
+ dragFrame_0.style.top = `${initialItemStart_1 + itemDragFrameAdjustmentPx}px`;
365
+ }
366
+ dragFrame_0.style.transition = "left var(--ring-ease), top var(--ring-ease), opacity var(--ring-ease)";
367
+ dragFrame_0.style.opacity = "0";
368
+ }
369
+ const indicator_0 = getInsertionIndicator();
370
+ if (indicator_0) {
371
+ indicator_0.style.opacity = "0";
372
+ indicator_0.style.transition = "opacity var(--ring-ease)";
373
+ }
374
+ const btn_1 = localRef.current;
375
+ if (btn_1) {
376
+ btn_1.style.transform = isColumn ? "translateX(0)" : "translateY(0)";
377
+ btn_1.style.transition = "transform var(--ring-ease)";
378
+ }
379
+ onUserDrag?.("cancelled");
380
+ const ringEaseMs = parseCssDuration(window.getComputedStyle(document.documentElement).getPropertyValue("--ring-ease"));
381
+ setTimeout(cleanupDrag, ringEaseMs);
382
+ };
383
+ $[50] = cleanupDrag;
384
+ $[51] = isColumn;
385
+ $[52] = onUserDrag;
386
+ $[53] = t10;
387
+ } else {
388
+ t10 = $[53];
389
+ }
390
+ const animateNoChangeThenCleanup = t10;
391
+ let t11;
392
+ if ($[54] !== animateNoChangeThenCleanup || $[55] !== getItemBounds || $[56] !== index || $[57] !== isColumn || $[58] !== onPointerDown || $[59] !== onUserDrag || $[60] !== renderDragFrame) {
393
+ t11 = function handlePointerDown(e) {
394
+ var _getItemBounds2;
395
+ onPointerDown?.(e);
396
+ if (e.defaultPrevented) {
397
+ return;
398
+ }
399
+ const {
400
+ clientX: clientX_2,
401
+ clientY: clientY_2,
402
+ pointerId,
403
+ currentTarget
404
+ } = e;
405
+ const {
406
+ start: initialItemStart_2,
407
+ end: initialItemEnd_0
408
+ } = (_getItemBounds2 = getItemBounds(index)) !== null && _getItemBounds2 !== void 0 ? _getItemBounds2 : {
409
+ start: 0,
410
+ end: 0
411
+ };
412
+ let indicatorStart_1;
413
+ let indicatorSize_1;
414
+ if (isColumn) {
415
+ const thead = currentTarget.closest("thead");
416
+ const table = thead?.closest("table");
417
+ if (!thead || !table) {
418
+ return;
419
+ }
420
+ const {
421
+ top: headerTop
422
+ } = thead.getBoundingClientRect();
423
+ indicatorStart_1 = headerTop;
424
+ const {
425
+ bottom: tableBottom
426
+ } = table.getBoundingClientRect();
427
+ const visibleTableHeight = tableBottom - headerTop;
428
+ const viewportBottomRelativeToHeaderTop = window.innerHeight - headerTop;
429
+ indicatorSize_1 = `min(${visibleTableHeight}px, calc(${viewportBottomRelativeToHeaderTop}px - .5rem))`;
430
+ } else {
431
+ const tr = currentTarget.closest("tr");
432
+ const tbody = tr?.closest("tbody");
433
+ if (!tr || !tbody) {
434
+ return;
435
+ }
436
+ const {
437
+ left: itemLeft,
438
+ right: itemRight
439
+ } = tr.getBoundingClientRect();
440
+ indicatorStart_1 = itemLeft;
441
+ const visibleItemWidth = itemRight - itemLeft;
442
+ const viewportRightRelativeToTableLeft = window.innerWidth - itemLeft;
443
+ indicatorSize_1 = `min(${visibleItemWidth}px, calc(${viewportRightRelativeToTableLeft}px - .5rem))`;
444
+ }
445
+ const keydownListener = function keydownListener(keyEvent) {
446
+ if (keyEvent.key === "Escape") {
447
+ animateNoChangeThenCleanup();
448
+ keyEvent.stopPropagation();
449
+ keyEvent.preventDefault();
450
+ }
451
+ };
452
+ currentTarget.setPointerCapture(pointerId);
453
+ document.addEventListener("keydown", keydownListener);
454
+ currentTarget.style.cursor = "grabbing";
455
+ activeDragRef.current = {
456
+ state: "is-dragging",
457
+ startX: clientX_2,
458
+ startY: clientY_2,
459
+ initialItemStart: initialItemStart_2,
460
+ initialItemEnd: initialItemEnd_0,
461
+ indicatorStart: indicatorStart_1,
462
+ indicatorSize: indicatorSize_1,
463
+ cleanup: () => {
464
+ currentTarget.releasePointerCapture(pointerId);
465
+ document.removeEventListener("keydown", keydownListener);
466
+ currentTarget.style.removeProperty("cursor");
467
+ }
468
+ };
469
+ renderDragFrame(clientX_2, clientY_2);
470
+ onUserDrag?.("pointerdown");
471
+ e.preventDefault();
472
+ };
473
+ $[54] = animateNoChangeThenCleanup;
474
+ $[55] = getItemBounds;
475
+ $[56] = index;
476
+ $[57] = isColumn;
477
+ $[58] = onPointerDown;
478
+ $[59] = onUserDrag;
479
+ $[60] = renderDragFrame;
480
+ $[61] = t11;
481
+ } else {
482
+ t11 = $[61];
483
+ }
484
+ const handlePointerDown = t11;
485
+ const scrollerRef = tableProps?.scrollerRef;
486
+ const lastScrolledRef = useRef(0);
487
+ let t12;
488
+ if ($[62] !== scrollerRef?.current) {
489
+ t12 = function scrollThrottled(scrollDirection) {
490
+ const now = performance.now();
491
+ if (now > lastScrolledRef.current + scrollIntervalMs) {
492
+ var _scrollerRef$current;
493
+ lastScrolledRef.current = now;
494
+ const top = scrollDirection === "up" ? -scrollStepPx : scrollStepPx;
495
+ const scroller = (_scrollerRef$current = scrollerRef?.current) !== null && _scrollerRef$current !== void 0 ? _scrollerRef$current : window;
496
+ scroller?.scrollBy({
497
+ top,
498
+ behavior: "smooth"
499
+ });
500
+ }
501
+ };
502
+ $[62] = scrollerRef?.current;
503
+ $[63] = t12;
504
+ } else {
505
+ t12 = $[63];
506
+ }
507
+ const scrollThrottled = t12;
508
+ let t13;
509
+ if ($[64] !== getClosestInsertionPointLocal || $[65] !== isColumn || $[66] !== onPointerMove || $[67] !== onUserDrag || $[68] !== renderDragFrame || $[69] !== renderInsertionIndicator || $[70] !== scrollThrottled || $[71] !== scrollerRef?.current || $[72] !== translateButton) {
510
+ t13 = function handlePointerMove(e_0) {
511
+ onPointerMove?.(e_0);
512
+ if (e_0.defaultPrevented) {
513
+ return;
514
+ }
515
+ const drag_3 = activeDragRef.current;
516
+ if (drag_3?.state !== "is-dragging") {
517
+ return;
518
+ }
519
+ const {
520
+ clientX: clientX_3,
521
+ clientY: clientY_3
522
+ } = e_0;
523
+ renderDragFrame(clientX_3, clientY_3);
524
+ translateButton(clientX_3, clientY_3);
525
+ const insertionPoint = getClosestInsertionPointLocal(clientX_3, clientY_3);
526
+ if (insertionPoint) {
527
+ renderInsertionIndicator(insertionPoint);
528
+ }
529
+ onUserDrag?.(isColumn ? clientX_3 - drag_3.startX : clientY_3 - drag_3.startY);
530
+ if (!isColumn) {
531
+ var _scrollerRect$top;
532
+ const scrollerRect = scrollerRef?.current?.getBoundingClientRect();
533
+ const scrollerTop = (_scrollerRect$top = scrollerRect?.top) !== null && _scrollerRect$top !== void 0 ? _scrollerRect$top : 0;
534
+ const scrollerBottom = scrollerRect ? Math.min(scrollerRect.bottom, window.innerHeight) : window.innerHeight;
535
+ if (clientY_3 < scrollerTop + scrollAreaPx) {
536
+ scrollThrottled("up");
537
+ } else {
538
+ if (clientY_3 > scrollerBottom - scrollAreaPx) {
539
+ scrollThrottled("down");
540
+ }
541
+ }
542
+ }
543
+ };
544
+ $[64] = getClosestInsertionPointLocal;
545
+ $[65] = isColumn;
546
+ $[66] = onPointerMove;
547
+ $[67] = onUserDrag;
548
+ $[68] = renderDragFrame;
549
+ $[69] = renderInsertionIndicator;
550
+ $[70] = scrollThrottled;
551
+ $[71] = scrollerRef?.current;
552
+ $[72] = translateButton;
553
+ $[73] = t13;
554
+ } else {
555
+ t13 = $[73];
556
+ }
557
+ const handlePointerMove = t13;
558
+ let t14;
559
+ if ($[74] !== animateNoChangeThenCleanup || $[75] !== cleanupDrag || $[76] !== getClosestInsertionPointLocal || $[77] !== index || $[78] !== onPointerUp || $[79] !== onReorder) {
560
+ t14 = function handlePointerUp(e_1) {
561
+ onPointerUp?.(e_1);
562
+ if (e_1.defaultPrevented) {
563
+ return;
564
+ }
565
+ if (activeDragRef.current?.state !== "is-dragging") {
566
+ return;
567
+ }
568
+ const {
569
+ clientX: clientX_4,
570
+ clientY: clientY_4
571
+ } = e_1;
572
+ const insertionPoint_0 = getClosestInsertionPointLocal(clientX_4, clientY_4);
573
+ const insertionIndex_1 = insertionPoint_0 && insertionPoint_0.itemIndex + (insertionPoint_0.after ? 1 : 0);
574
+ if (insertionIndex_1 == null || insertionIndex_1 === index || insertionIndex_1 === index + 1) {
575
+ animateNoChangeThenCleanup();
576
+ return;
577
+ }
578
+ cleanupDrag();
579
+ onReorder(insertionIndex_1);
580
+ };
581
+ $[74] = animateNoChangeThenCleanup;
582
+ $[75] = cleanupDrag;
583
+ $[76] = getClosestInsertionPointLocal;
584
+ $[77] = index;
585
+ $[78] = onPointerUp;
586
+ $[79] = onReorder;
587
+ $[80] = t14;
588
+ } else {
589
+ t14 = $[80];
590
+ }
591
+ const handlePointerUp = t14;
592
+ let t15;
593
+ if ($[81] !== canReorder || $[82] !== columns || $[83] !== data || $[84] !== index || $[85] !== isColumn || $[86] !== onKeyDown || $[87] !== onReorder) {
594
+ t15 = function handleKeyDown(e_2) {
595
+ onKeyDown?.(e_2);
596
+ if (e_2.defaultPrevented) {
597
+ return;
598
+ }
599
+ const left = isColumn && e_2.key === "ArrowLeft";
600
+ const right = isColumn && e_2.key === "ArrowRight";
601
+ const up = !isColumn && e_2.key === "ArrowUp";
602
+ const down = !isColumn && e_2.key === "ArrowDown";
603
+ if (!left && !right && !up && !down || !columns || !data) {
604
+ return;
605
+ }
606
+ const backward = left || up;
607
+ const initialInsertionIndex = backward ? index - 1 : index + 2;
608
+ const maxInsertionIndex = isColumn ? columns.length : data.length;
609
+ const step = backward ? -1 : 1;
610
+ for (let i = initialInsertionIndex; 0 <= i && i <= maxInsertionIndex; i = i + step, i) {
611
+ if (canReorder(i)) {
612
+ onReorder(i);
613
+ e_2.preventDefault();
614
+ return;
615
+ }
616
+ }
617
+ };
618
+ $[81] = canReorder;
619
+ $[82] = columns;
620
+ $[83] = data;
621
+ $[84] = index;
622
+ $[85] = isColumn;
623
+ $[86] = onKeyDown;
624
+ $[87] = onReorder;
625
+ $[88] = t15;
626
+ } else {
627
+ t15 = $[88];
628
+ }
629
+ const handleKeyDown = t15;
630
+ let t16;
631
+ if ($[89] !== animateNoChangeThenCleanup || $[90] !== onPointerCancel) {
632
+ t16 = function handlePointerCancel(e_3) {
633
+ onPointerCancel?.(e_3);
634
+ if (!e_3.defaultPrevented) {
635
+ animateNoChangeThenCleanup();
636
+ }
637
+ };
638
+ $[89] = animateNoChangeThenCleanup;
639
+ $[90] = onPointerCancel;
640
+ $[91] = t16;
641
+ } else {
642
+ t16 = $[91];
643
+ }
644
+ const handlePointerCancel = t16;
645
+ let t17;
646
+ if ($[92] !== animateNoChangeThenCleanup || $[93] !== onLostPointerCapture) {
647
+ t17 = function handleLostPointerCapture(e_4) {
648
+ onLostPointerCapture?.(e_4);
649
+ if (!e_4.defaultPrevented) {
650
+ animateNoChangeThenCleanup();
651
+ }
652
+ };
653
+ $[92] = animateNoChangeThenCleanup;
654
+ $[93] = onLostPointerCapture;
655
+ $[94] = t17;
656
+ } else {
657
+ t17 = $[94];
658
+ }
659
+ const handleLostPointerCapture = t17;
660
+ let t18;
661
+ if ($[95] !== cleanupDrag) {
662
+ t18 = () => {
663
+ if (activeDragRef.current) {
664
+ cleanupDrag();
665
+ }
666
+ };
667
+ $[95] = cleanupDrag;
668
+ $[96] = t18;
669
+ } else {
670
+ t18 = $[96];
671
+ }
672
+ const cleanupComponent = useEffectEvent(t18);
673
+ let t19;
674
+ if ($[97] !== cleanupComponent) {
675
+ t19 = () => cleanupComponent;
676
+ $[97] = cleanupComponent;
677
+ $[98] = t19;
678
+ } else {
679
+ t19 = $[98];
680
+ }
681
+ let t20;
682
+ if ($[99] === Symbol.for("react.memo_cache_sentinel")) {
683
+ t20 = [];
684
+ $[99] = t20;
685
+ } else {
686
+ t20 = $[99];
687
+ }
688
+ useEffect(t19, t20);
689
+ const hint = isColumn ? `Reorder column ${(_columns$index$name = columns?.[index]?.name) !== null && _columns$index$name !== void 0 ? _columns$index$name : String(columns?.[index]?.key)}.` : `Reorder item ${index + 1}.`;
690
+ const description = isColumn ? "Use Left and Right arrow keys to move the column." : "Use Up and Down arrow keys to move the item.";
691
+ const shortcuts = isColumn ? "ArrowLeft ArrowRight" : "ArrowUp ArrowDown";
692
+ const t21 = isColumn ? styles.columnReorderHandle : styles.itemReorderHandle;
693
+ let t22;
694
+ if ($[100] !== className || $[101] !== t21) {
695
+ t22 = classNames(styles.tableButton, t21, className);
696
+ $[100] = className;
697
+ $[101] = t21;
698
+ $[102] = t22;
699
+ } else {
700
+ t22 = $[102];
701
+ }
702
+ let t23;
703
+ if ($[103] === Symbol.for("react.memo_cache_sentinel")) {
704
+ t23 = /*#__PURE__*/jsx(Icon, {
705
+ glyph: dragIcon,
706
+ "aria-hidden": "true"
707
+ });
708
+ $[103] = t23;
709
+ } else {
710
+ t23 = $[103];
711
+ }
712
+ let t24;
713
+ if ($[104] !== composedRef || $[105] !== description || $[106] !== handleKeyDown || $[107] !== handleLostPointerCapture || $[108] !== handlePointerCancel || $[109] !== handlePointerDown || $[110] !== handlePointerMove || $[111] !== handlePointerUp || $[112] !== hint || $[113] !== restProps || $[114] !== shortcuts || $[115] !== t22) {
714
+ t24 = /*#__PURE__*/jsx("button", {
715
+ ref: composedRef,
716
+ type: "button",
717
+ className: t22,
718
+ "aria-label": hint,
719
+ "aria-description": description,
720
+ "aria-keyshortcuts": shortcuts,
721
+ onKeyDown: handleKeyDown,
722
+ onPointerDown: handlePointerDown,
723
+ onPointerMove: handlePointerMove,
724
+ onPointerUp: handlePointerUp,
725
+ onPointerCancel: handlePointerCancel,
726
+ onLostPointerCapture: handleLostPointerCapture,
727
+ ...restProps,
728
+ children: t23
729
+ });
730
+ $[104] = composedRef;
731
+ $[105] = description;
732
+ $[106] = handleKeyDown;
733
+ $[107] = handleLostPointerCapture;
734
+ $[108] = handlePointerCancel;
735
+ $[109] = handlePointerDown;
736
+ $[110] = handlePointerMove;
737
+ $[111] = handlePointerUp;
738
+ $[112] = hint;
739
+ $[113] = restProps;
740
+ $[114] = shortcuts;
741
+ $[115] = t22;
742
+ $[116] = t24;
743
+ } else {
744
+ t24 = $[116];
745
+ }
746
+ return t24;
747
+ }
748
+ function _temp() {}
749
+
750
+ export { ReorderHandle };