react-science 13.0.2 → 15.0.0

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 (150) hide show
  1. package/lib/components/activity_bar/activity_bar.js +1 -1
  2. package/lib/components/activity_bar/activity_bar.js.map +1 -1
  3. package/lib/components/activity_panel/activity_panel.js +1 -1
  4. package/lib/components/activity_panel/activity_panel.js.map +1 -1
  5. package/lib/components/drop-zone/DropZone.js +1 -1
  6. package/lib/components/drop-zone/DropZone.js.map +1 -1
  7. package/lib/components/forms/radio-button-group/RadioButton.js +4 -4
  8. package/lib/components/forms/radio-button-group/RadioButton.js.map +1 -1
  9. package/lib/components/forms/radio-button-group/RadioButtonGroup.d.ts +2 -2
  10. package/lib/components/forms/radio-button-group/RadioButtonGroup.d.ts.map +1 -1
  11. package/lib/components/forms/radio-button-group/RadioButtonGroup.js +8 -8
  12. package/lib/components/forms/radio-button-group/RadioButtonGroup.js.map +1 -1
  13. package/lib/components/forms/styles.d.ts +0 -1
  14. package/lib/components/forms/styles.d.ts.map +1 -1
  15. package/lib/components/forms/styles.js.map +1 -1
  16. package/lib/components/header/PanelHeader.d.ts.map +1 -1
  17. package/lib/components/header/PanelHeader.js +1 -1
  18. package/lib/components/header/PanelHeader.js.map +1 -1
  19. package/lib/components/index.d.ts +1 -1
  20. package/lib/components/index.js +1 -1
  21. package/lib/components/info-panel/InfoPanel.js +2 -2
  22. package/lib/components/info-panel/InfoPanel.js.map +1 -1
  23. package/lib/components/logger/FifoLoggerDialog.js +1 -1
  24. package/lib/components/logger/FifoLoggerDialog.js.map +1 -1
  25. package/lib/components/split_pane/index.d.ts +3 -0
  26. package/lib/components/split_pane/index.d.ts.map +1 -0
  27. package/lib/components/split_pane/index.js +3 -0
  28. package/lib/components/split_pane/index.js.map +1 -0
  29. package/lib/components/{split-pane/SplitPane.d.ts → split_pane/split_pane.d.ts} +7 -5
  30. package/lib/components/split_pane/split_pane.d.ts.map +1 -0
  31. package/lib/components/{split-pane/SplitPane.js → split_pane/split_pane.js} +25 -32
  32. package/lib/components/split_pane/split_pane.js.map +1 -0
  33. package/lib/components/split_pane/split_pane_helpers.d.ts +9 -0
  34. package/lib/components/split_pane/split_pane_helpers.d.ts.map +1 -0
  35. package/lib/components/split_pane/split_pane_helpers.js +10 -0
  36. package/lib/components/split_pane/split_pane_helpers.js.map +1 -0
  37. package/lib/components/{split-pane/useSplitPaneSize.d.ts → split_pane/use_split_pane_size.d.ts} +5 -3
  38. package/lib/components/split_pane/use_split_pane_size.d.ts.map +1 -0
  39. package/lib/components/split_pane/use_split_pane_size.js +78 -0
  40. package/lib/components/split_pane/use_split_pane_size.js.map +1 -0
  41. package/lib/components/table/index.d.ts +1 -0
  42. package/lib/components/table/index.d.ts.map +1 -1
  43. package/lib/components/table/index.js +1 -0
  44. package/lib/components/table/index.js.map +1 -1
  45. package/lib/components/table/reorder_rows/draggable_row_context.d.ts +9 -0
  46. package/lib/components/table/reorder_rows/draggable_row_context.d.ts.map +1 -0
  47. package/lib/components/table/reorder_rows/draggable_row_context.js +10 -0
  48. package/lib/components/table/reorder_rows/draggable_row_context.js.map +1 -0
  49. package/lib/components/table/reorder_rows/draggable_row_tr.d.ts +18 -0
  50. package/lib/components/table/reorder_rows/draggable_row_tr.d.ts.map +1 -0
  51. package/lib/components/table/reorder_rows/draggable_row_tr.js +107 -0
  52. package/lib/components/table/reorder_rows/draggable_row_tr.js.map +1 -0
  53. package/lib/components/table/reorder_rows/drop_indicator.d.ts +18 -0
  54. package/lib/components/table/reorder_rows/drop_indicator.d.ts.map +1 -0
  55. package/lib/components/table/reorder_rows/drop_indicator.js +19 -0
  56. package/lib/components/table/reorder_rows/drop_indicator.js.map +1 -0
  57. package/lib/components/table/reorder_rows/dropped_item_context.d.ts +3 -0
  58. package/lib/components/table/reorder_rows/dropped_item_context.d.ts.map +1 -0
  59. package/lib/components/table/reorder_rows/dropped_item_context.js +10 -0
  60. package/lib/components/table/reorder_rows/dropped_item_context.js.map +1 -0
  61. package/lib/components/table/reorder_rows/dropped_item_provider.d.ts +5 -0
  62. package/lib/components/table/reorder_rows/dropped_item_provider.d.ts.map +1 -0
  63. package/lib/components/table/reorder_rows/dropped_item_provider.js +8 -0
  64. package/lib/components/table/reorder_rows/dropped_item_provider.js.map +1 -0
  65. package/lib/components/table/reorder_rows/index.d.ts +5 -0
  66. package/lib/components/table/reorder_rows/index.d.ts.map +1 -0
  67. package/lib/components/table/reorder_rows/index.js +5 -0
  68. package/lib/components/table/reorder_rows/index.js.map +1 -0
  69. package/lib/components/table/reorder_rows/item_data.d.ts +26 -0
  70. package/lib/components/table/reorder_rows/item_data.d.ts.map +1 -0
  71. package/lib/components/table/reorder_rows/item_data.js +13 -0
  72. package/lib/components/table/reorder_rows/item_data.js.map +1 -0
  73. package/lib/components/table/reorder_rows/item_order_context.d.ts +15 -0
  74. package/lib/components/table/reorder_rows/item_order_context.d.ts.map +1 -0
  75. package/lib/components/table/reorder_rows/item_order_context.js +10 -0
  76. package/lib/components/table/reorder_rows/item_order_context.js.map +1 -0
  77. package/lib/components/table/reorder_rows/item_order_provider.d.ts +10 -0
  78. package/lib/components/table/reorder_rows/item_order_provider.d.ts.map +1 -0
  79. package/lib/components/table/reorder_rows/item_order_provider.js +34 -0
  80. package/lib/components/table/reorder_rows/item_order_provider.js.map +1 -0
  81. package/lib/components/table/reorder_rows/table_drag_row_handler.d.ts +2 -0
  82. package/lib/components/table/reorder_rows/table_drag_row_handler.d.ts.map +1 -0
  83. package/lib/components/table/reorder_rows/table_drag_row_handler.js +9 -0
  84. package/lib/components/table/reorder_rows/table_drag_row_handler.js.map +1 -0
  85. package/lib/components/table/reorder_rows/use_drop_monitor.d.ts +9 -0
  86. package/lib/components/table/reorder_rows/use_drop_monitor.d.ts.map +1 -0
  87. package/lib/components/table/reorder_rows/use_drop_monitor.js +57 -0
  88. package/lib/components/table/reorder_rows/use_drop_monitor.js.map +1 -0
  89. package/lib/components/table/table_body.d.ts +4 -1
  90. package/lib/components/table/table_body.d.ts.map +1 -1
  91. package/lib/components/table/table_body.js +20 -6
  92. package/lib/components/table/table_body.js.map +1 -1
  93. package/lib/components/table/table_root.d.ts +37 -1
  94. package/lib/components/table/table_root.d.ts.map +1 -1
  95. package/lib/components/table/table_root.js +41 -7
  96. package/lib/components/table/table_root.js.map +1 -1
  97. package/lib/components/table/table_row_cell.d.ts +2 -1
  98. package/lib/components/table/table_row_cell.d.ts.map +1 -1
  99. package/lib/components/table/table_row_cell.js +2 -2
  100. package/lib/components/table/table_row_cell.js.map +1 -1
  101. package/lib/components/table/table_utils.d.ts +11 -2
  102. package/lib/components/table/table_utils.d.ts.map +1 -1
  103. package/lib/components/table/table_utils.js.map +1 -1
  104. package/lib/components/toolbar/Toolbar.js +2 -2
  105. package/lib/components/toolbar/Toolbar.js.map +1 -1
  106. package/lib/components/toolbar/TooltipHelpContent.js +2 -2
  107. package/package.json +19 -16
  108. package/src/components/activity_bar/activity_bar.tsx +1 -1
  109. package/src/components/activity_panel/activity_panel.tsx +1 -1
  110. package/src/components/drop-zone/DropZone.tsx +1 -1
  111. package/src/components/forms/radio-button-group/RadioButton.tsx +7 -7
  112. package/src/components/forms/radio-button-group/RadioButtonGroup.tsx +15 -11
  113. package/src/components/forms/styles.ts +0 -2
  114. package/src/components/header/PanelHeader.tsx +6 -1
  115. package/src/components/index.ts +1 -1
  116. package/src/components/info-panel/InfoPanel.tsx +2 -2
  117. package/src/components/logger/FifoLoggerDialog.tsx +2 -2
  118. package/src/components/split_pane/index.ts +2 -0
  119. package/src/components/{split-pane/SplitPane.tsx → split_pane/split_pane.tsx} +63 -56
  120. package/src/components/split_pane/split_pane_helpers.ts +19 -0
  121. package/src/components/split_pane/use_split_pane_size.tsx +120 -0
  122. package/src/components/table/index.ts +1 -0
  123. package/src/components/table/reorder_rows/draggable_row_context.ts +23 -0
  124. package/src/components/table/reorder_rows/draggable_row_tr.tsx +166 -0
  125. package/src/components/table/reorder_rows/drop_indicator.tsx +28 -0
  126. package/src/components/table/reorder_rows/dropped_item_context.ts +23 -0
  127. package/src/components/table/reorder_rows/dropped_item_provider.tsx +13 -0
  128. package/src/components/table/reorder_rows/index.ts +4 -0
  129. package/src/components/table/reorder_rows/item_data.ts +33 -0
  130. package/src/components/table/reorder_rows/item_order_context.ts +27 -0
  131. package/src/components/table/reorder_rows/item_order_provider.tsx +61 -0
  132. package/src/components/table/reorder_rows/table_drag_row_handler.tsx +22 -0
  133. package/src/components/table/reorder_rows/use_drop_monitor.ts +74 -0
  134. package/src/components/table/table_body.tsx +58 -9
  135. package/src/components/table/table_root.tsx +167 -35
  136. package/src/components/table/table_row_cell.tsx +5 -3
  137. package/src/components/table/table_utils.ts +16 -2
  138. package/src/components/toolbar/Toolbar.tsx +2 -2
  139. package/src/components/toolbar/TooltipHelpContent.tsx +2 -2
  140. package/lib/components/split-pane/SplitPane.d.ts.map +0 -1
  141. package/lib/components/split-pane/SplitPane.js.map +0 -1
  142. package/lib/components/split-pane/index.d.ts +0 -2
  143. package/lib/components/split-pane/index.d.ts.map +0 -1
  144. package/lib/components/split-pane/index.js +0 -2
  145. package/lib/components/split-pane/index.js.map +0 -1
  146. package/lib/components/split-pane/useSplitPaneSize.d.ts.map +0 -1
  147. package/lib/components/split-pane/useSplitPaneSize.js +0 -60
  148. package/lib/components/split-pane/useSplitPaneSize.js.map +0 -1
  149. package/src/components/split-pane/index.ts +0 -1
  150. package/src/components/split-pane/useSplitPaneSize.tsx +0 -99
@@ -0,0 +1,78 @@
1
+ import { useCallback, useEffect, useRef, useState } from 'react';
2
+ import { serializeSize } from './split_pane_helpers.js';
3
+ export function useSplitPaneSize(options) {
4
+ const { controlledSide, direction, splitterRef, sizeType, onSizeChange, onResize, } = options;
5
+ const [isResizing, setIsResizing] = useState(false);
6
+ const onPointerDown = useCallback(() => {
7
+ setIsResizing(true);
8
+ }, []);
9
+ const onResizeRef = useRef(onResize);
10
+ const onSizeChangeRef = useRef(onSizeChange);
11
+ useEffect(() => {
12
+ onResizeRef.current = onResize;
13
+ onSizeChangeRef.current = onSizeChange;
14
+ }, [onResize, onSizeChange]);
15
+ useEffect(() => {
16
+ if (isResizing) {
17
+ let lastSize = null;
18
+ function moveCallback(event) {
19
+ if (!splitterRef.current)
20
+ return;
21
+ const { clientX, clientY } = event;
22
+ const parentDiv = splitterRef.current.parentElement;
23
+ const bounds = parentDiv.getBoundingClientRect();
24
+ const parentDimension = direction === 'horizontal'
25
+ ? parentDiv.clientWidth
26
+ : parentDiv.clientHeight;
27
+ const client = direction === 'horizontal'
28
+ ? clientX - bounds.left
29
+ : clientY - bounds.top;
30
+ const centralizingValue = direction === 'horizontal'
31
+ ? splitterRef.current.clientWidth / 2
32
+ : splitterRef.current.clientHeight / 2;
33
+ const value = controlledSide === 'start' ? client : parentDimension - client;
34
+ if (sizeType === 'px') {
35
+ const newSize = getValueFromSplitter(value - centralizingValue, {
36
+ min: 0,
37
+ max: parentDimension,
38
+ });
39
+ lastSize = { value: newSize, type: sizeType };
40
+ onSizeChangeRef.current?.(lastSize);
41
+ }
42
+ else if (sizeType === '%') {
43
+ const valueDiff = (value / parentDimension) * 100;
44
+ const newSize = getValueFromSplitter(valueDiff, {
45
+ min: 0,
46
+ max: 100,
47
+ });
48
+ lastSize = { value: newSize, type: sizeType };
49
+ onSizeChangeRef.current?.(lastSize);
50
+ }
51
+ }
52
+ function upCallback() {
53
+ setIsResizing(false);
54
+ if (lastSize) {
55
+ onResizeRef.current?.(serializeSize(lastSize));
56
+ }
57
+ }
58
+ window.addEventListener('pointermove', moveCallback);
59
+ window.addEventListener('pointerup', upCallback);
60
+ return () => {
61
+ window.removeEventListener('pointermove', moveCallback);
62
+ window.removeEventListener('pointerup', upCallback);
63
+ };
64
+ }
65
+ }, [isResizing, controlledSide, direction, sizeType, splitterRef]);
66
+ return {
67
+ onPointerDown,
68
+ isResizing,
69
+ };
70
+ }
71
+ function getValueFromSplitter(value, options) {
72
+ const newValue = Math.round((value + Number.EPSILON) * 100) / 100;
73
+ return getMinMax(newValue, options);
74
+ }
75
+ function getMinMax(value, options) {
76
+ return Math.min(Math.max(value, options.min), options.max);
77
+ }
78
+ //# sourceMappingURL=use_split_pane_size.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_split_pane_size.js","sourceRoot":"","sources":["../../../src/components/split_pane/use_split_pane_size.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAQjE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAWxD,MAAM,UAAU,gBAAgB,CAAC,OAAgC;IAC/D,MAAM,EACJ,cAAc,EACd,SAAS,EACT,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,QAAQ,GACT,GAAG,OAAO,CAAC;IAEZ,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpD,MAAM,aAAa,GAAG,WAAW,CAAC,GAAG,EAAE;QACrC,aAAa,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IACrC,MAAM,eAAe,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;IAE7C,SAAS,CAAC,GAAG,EAAE;QACb,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAC;QAC/B,eAAe,CAAC,OAAO,GAAG,YAAY,CAAC;IACzC,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;IAE7B,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,UAAU,EAAE,CAAC;YACf,IAAI,QAAQ,GAA+B,IAAI,CAAC;YAChD,SAAS,YAAY,CAAC,KAAmB;gBACvC,IAAI,CAAC,WAAW,CAAC,OAAO;oBAAE,OAAO;gBACjC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,KAAK,CAA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C,CAAC;AAC7D,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from './table_root.js';
2
2
  export * from './table_utils.js';
3
+ export * from './reorder_rows/index.js';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/table/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/table/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from './table_root.js';
2
2
  export * from './table_utils.js';
3
+ export * from './reorder_rows/index.js';
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/table/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/table/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { RefObject } from 'react';
2
+ import type { DraggableItemState } from './item_data.js';
3
+ export interface DraggableRowContext {
4
+ state: DraggableItemState;
5
+ dragHandleRef: RefObject<HTMLButtonElement>;
6
+ }
7
+ export declare const draggableRowContext: import("react").Context<DraggableRowContext | null>;
8
+ export declare function useTableDraggableRowContext(): DraggableRowContext;
9
+ //# sourceMappingURL=draggable_row_context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draggable_row_context.d.ts","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/draggable_row_context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,kBAAkB,CAAC;IAC1B,aAAa,EAAE,SAAS,CAAC,iBAAiB,CAAC,CAAC;CAC7C;AAED,eAAO,MAAM,mBAAmB,qDAE/B,CAAC;AAEF,wBAAgB,2BAA2B,wBAQ1C"}
@@ -0,0 +1,10 @@
1
+ import { createContext, useContext } from 'react';
2
+ export const draggableRowContext = createContext(null);
3
+ export function useTableDraggableRowContext() {
4
+ const context = useContext(draggableRowContext);
5
+ if (!context) {
6
+ throw new Error('useDraggableItemContext must be used within an ItemContextProvider');
7
+ }
8
+ return context;
9
+ }
10
+ //# sourceMappingURL=draggable_row_context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draggable_row_context.js","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/draggable_row_context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AASlD,MAAM,CAAC,MAAM,mBAAmB,GAAG,aAAa,CAC9C,IAAI,CACL,CAAC;AAEF,MAAM,UAAU,2BAA2B;IACzC,MAAM,OAAO,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAC;IAChD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,oEAAoE,CACrE,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { Row, RowData } from '@tanstack/react-table';
2
+ import type { TableRowPreviewRenderer, TableRowTrProps } from '../table_utils.js';
3
+ export interface TableDraggableRowTrProps<TData extends RowData> {
4
+ /**
5
+ * Props to be spread on the `tr` element.
6
+ */
7
+ trProps: TableRowTrProps;
8
+ /**
9
+ * Row data.
10
+ */
11
+ row: Row<TData>;
12
+ /**
13
+ * Preview of the row being dragged.
14
+ */
15
+ renderRowPreview: TableRowPreviewRenderer<TData>;
16
+ }
17
+ export declare function TableDraggableRowTr<TData extends RowData>(props: TableDraggableRowTrProps<TData>): import("react/jsx-runtime").JSX.Element;
18
+ //# sourceMappingURL=draggable_row_tr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draggable_row_tr.d.ts","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/draggable_row_tr.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAK1D,OAAO,KAAK,EACV,uBAAuB,EACvB,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAS3B,MAAM,WAAW,wBAAwB,CAAC,KAAK,SAAS,OAAO;IAC7D;;OAEG;IACH,OAAO,EAAE,eAAe,CAAC;IACzB;;OAEG;IACH,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;IAChB;;OAEG;IACH,gBAAgB,EAAE,uBAAuB,CAAC,KAAK,CAAC,CAAC;CAClD;AAED,wBAAgB,mBAAmB,CAAC,KAAK,SAAS,OAAO,EACvD,KAAK,EAAE,wBAAwB,CAAC,KAAK,CAAC,2CA0GvC"}
@@ -0,0 +1,107 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
3
+ import { draggable, dropTargetForElements, } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
4
+ import { pointerOutsideOfPreview } from '@atlaskit/pragmatic-drag-and-drop/element/pointer-outside-of-preview';
5
+ import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
6
+ import { attachClosestEdge, extractClosestEdge, } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
7
+ import { Colors } from '@blueprintjs/core';
8
+ import { useEffect, useMemo, useRef, useState } from 'react';
9
+ import { createPortal } from 'react-dom';
10
+ import { assert } from '../../utils/index.js';
11
+ import { draggableRowContext } from './draggable_row_context.js';
12
+ import { useDroppedItemContext } from './dropped_item_context.js';
13
+ import { getItemData, isItemData } from './item_data.js';
14
+ import { useItemOrder } from './item_order_context.js';
15
+ export function TableDraggableRowTr(props) {
16
+ const { trProps, row, renderRowPreview } = props;
17
+ const { instanceId } = useItemOrder();
18
+ const innerRef = useRef(null);
19
+ const [state, setState] = useState(idleState);
20
+ const [droppedItemId, setDroppedItemId] = useDroppedItemContext();
21
+ const dragHandleRef = useRef(null);
22
+ useEffect(() => {
23
+ const trElement = innerRef.current;
24
+ assert(trElement, 'tr ref is null');
25
+ assert(dragHandleRef.current, 'dragHandleRef is null');
26
+ function canDrop({ source }) {
27
+ return (isItemData(source.data) &&
28
+ source.data.instanceId === instanceId &&
29
+ source.data.id !== row.id);
30
+ }
31
+ const data = getItemData(row, instanceId);
32
+ return combine(draggable({
33
+ element: trElement,
34
+ dragHandle: dragHandleRef.current,
35
+ getInitialData: () => data,
36
+ onGenerateDragPreview({ nativeSetDragImage }) {
37
+ setCustomNativeDragPreview({
38
+ nativeSetDragImage,
39
+ getOffset: pointerOutsideOfPreview({
40
+ x: '8px',
41
+ y: '8px',
42
+ }),
43
+ render({ container }) {
44
+ setState({ type: 'preview', container });
45
+ return () => setState(draggingState);
46
+ },
47
+ });
48
+ },
49
+ onDragStart() {
50
+ setState(draggingState);
51
+ },
52
+ onDrop() {
53
+ setState(idleState);
54
+ },
55
+ }), dropTargetForElements({
56
+ element: trElement,
57
+ canDrop,
58
+ getIsSticky: () => false,
59
+ getData({ input }) {
60
+ return attachClosestEdge(data, {
61
+ element: trElement,
62
+ input,
63
+ allowedEdges: ['top', 'bottom'],
64
+ });
65
+ },
66
+ onDrag({ self }) {
67
+ const closestEdge = extractClosestEdge(self.data);
68
+ setState((current) => {
69
+ if (current.type === 'is-over' &&
70
+ current.closestEdge === closestEdge) {
71
+ return current;
72
+ }
73
+ return { type: 'is-over', closestEdge };
74
+ });
75
+ },
76
+ onDragLeave() {
77
+ setState(idleState);
78
+ },
79
+ onDrop() {
80
+ setState(idleState);
81
+ },
82
+ }));
83
+ }, [row, instanceId]);
84
+ useEffect(() => {
85
+ if (droppedItemId === row.id && innerRef.current) {
86
+ triggerPostFlash(innerRef.current);
87
+ setDroppedItemId(undefined);
88
+ }
89
+ }, [droppedItemId, row.id, setDroppedItemId]);
90
+ const value = useMemo(() => {
91
+ return {
92
+ dragHandleRef,
93
+ state,
94
+ };
95
+ }, [state]);
96
+ return (_jsxs(_Fragment, { children: [_jsx(draggableRowContext.Provider, { value: value, children: _jsx("tr", { ...trProps, ref: innerRef }) }), state.type === 'preview' &&
97
+ createPortal(renderRowPreview(row), state.container)] }));
98
+ }
99
+ const idleState = { type: 'idle' };
100
+ const draggingState = { type: 'dragging' };
101
+ function triggerPostFlash(element) {
102
+ element.animate([{ backgroundColor: Colors.BLUE5, opacity: 0.5 }, { opacity: 0.5 }], {
103
+ duration: 250,
104
+ iterations: 1,
105
+ });
106
+ }
107
+ //# sourceMappingURL=draggable_row_tr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draggable_row_tr.js","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/draggable_row_tr.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2CAA2C,CAAC;AAEpE,OAAO,EACL,SAAS,EACT,qBAAqB,GACtB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,sEAAsE,CAAC;AAC/G,OAAO,EAAE,0BAA0B,EAAE,MAAM,0EAA0E,CAAC;AACtH,OAAO,EACL,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE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M,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,EACnE;QACE,QAAQ,EAAE,GAAG;QACb,UAAU,EAAE,CAAC;KACd,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { Edge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/types';
2
+ export interface TableDropIndicatorProps {
3
+ /**
4
+ * The edge (top or bottom) on which to render the drop indicator
5
+ * with respect to the nearest relatively positioned element.
6
+ */
7
+ edge: Edge;
8
+ }
9
+ /**
10
+ * An absolutely positioned line which indicates where a dragged item will
11
+ * be dropped.
12
+ *
13
+ */
14
+ export declare const TableDropIndicator: import("@emotion/styled").StyledComponent<{
15
+ theme?: import("@emotion/react").Theme;
16
+ as?: React.ElementType;
17
+ } & TableDropIndicatorProps, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
18
+ //# sourceMappingURL=drop_indicator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drop_indicator.d.ts","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/drop_indicator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gDAAgD,CAAC;AAI3E,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,IAAI,EAAE,IAAI,CAAC;CACZ;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB;;SAEvB,MACN,WAAU;mIAOX,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { Colors } from '@blueprintjs/core';
2
+ import styled from '@emotion/styled';
3
+ /**
4
+ * An absolutely positioned line which indicates where a dragged item will
5
+ * be dropped.
6
+ *
7
+ */
8
+ export const TableDropIndicator = styled.div `
9
+ position: absolute;
10
+ z-index: 1;
11
+ background-color: ${Colors.BLUE3};
12
+ height: 2px;
13
+ left: 0;
14
+ right: 0;
15
+ pointer-events: none;
16
+ ${(props) => props.edge === 'top' && 'top: -1px;'}
17
+ ${(props) => props.edge === 'bottom' && 'bottom: -1px;'}
18
+ `;
19
+ //# sourceMappingURL=drop_indicator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drop_indicator.js","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/drop_indicator.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAUrC;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAyB;;;sBAG/C,MAAM,CAAC,KAAK;;;;;IAK9B,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,IAAI,YAAY;IAC/C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,eAAe;CACxD,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const droppedItemContext: import("react").Context<[string | undefined, import("react").Dispatch<import("react").SetStateAction<string | undefined>>] | null>;
2
+ export declare function useDroppedItemContext(): [string | undefined, import("react").Dispatch<import("react").SetStateAction<string | undefined>>];
3
+ //# sourceMappingURL=dropped_item_context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dropped_item_context.d.ts","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/dropped_item_context.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,kBAAkB,oIAE9B,CAAC;AAEF,wBAAgB,qBAAqB,uGAUpC"}
@@ -0,0 +1,10 @@
1
+ import { createContext, useContext } from 'react';
2
+ export const droppedItemContext = createContext(null);
3
+ export function useDroppedItemContext() {
4
+ const context = useContext(droppedItemContext);
5
+ if (!context) {
6
+ throw new Error('useDroppedItemId must be used within a DroppedItemProvider');
7
+ }
8
+ return context;
9
+ }
10
+ //# sourceMappingURL=dropped_item_context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dropped_item_context.js","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/dropped_item_context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAOlD,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAC7C,IAAI,CACL,CAAC;AAEF,MAAM,UAAU,qBAAqB;IACnC,MAAM,OAAO,GAAG,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAE/C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,4DAA4D,CAC7D,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { ReactNode } from 'react';
2
+ export declare function DroppedItemProvider(props: {
3
+ children: ReactNode;
4
+ }): import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=dropped_item_provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dropped_item_provider.d.ts","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/dropped_item_provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,2CAOjE"}
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { droppedItemContext } from './dropped_item_context.js';
4
+ export function DroppedItemProvider(props) {
5
+ const value = useState();
6
+ return (_jsx(droppedItemContext.Provider, { value: value, children: props.children }));
7
+ }
8
+ //# sourceMappingURL=dropped_item_provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dropped_item_provider.js","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/dropped_item_provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,UAAU,mBAAmB,CAAC,KAA8B;IAChE,MAAM,KAAK,GAAG,QAAQ,EAAU,CAAC;IACjC,OAAO,CACL,KAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YACtC,KAAK,CAAC,QAAQ,GACa,CAC/B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './table_drag_row_handler.js';
2
+ export { useTableDraggableRowContext } from './draggable_row_context.js';
3
+ export * from './draggable_row_tr.js';
4
+ export * from './drop_indicator.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './table_drag_row_handler.js';
2
+ export { useTableDraggableRowContext } from './draggable_row_context.js';
3
+ export * from './draggable_row_tr.js';
4
+ export * from './drop_indicator.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { Edge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/types';
2
+ import type { Row } from '@tanstack/react-table';
3
+ declare const itemKey: unique symbol;
4
+ export interface ItemData {
5
+ [itemKey]: true;
6
+ instanceId: symbol;
7
+ id: string;
8
+ index: number;
9
+ [key: string]: unknown;
10
+ [key: symbol]: unknown;
11
+ }
12
+ export declare function getItemData(row: Row<unknown>, instanceId: symbol): ItemData;
13
+ export declare function isItemData(data: Record<string | symbol, unknown>): data is ItemData;
14
+ export type DraggableItemState = {
15
+ type: 'idle';
16
+ } | {
17
+ type: 'preview';
18
+ container: HTMLElement;
19
+ } | {
20
+ type: 'dragging';
21
+ } | {
22
+ type: 'is-over';
23
+ closestEdge: Edge | null;
24
+ };
25
+ export {};
26
+ //# sourceMappingURL=item_data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item_data.d.ts","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/item_data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gDAAgD,CAAC;AAC3E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAEjD,QAAA,MAAM,OAAO,eAA4B,CAAC;AAC1C,MAAM,WAAW,QAAQ;IACvB,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,QAAQ,CAO3E;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,GACrC,IAAI,IAAI,QAAQ,CAElB;AAED,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,WAAW,CAAA;CAAE,GAC3C;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GACpB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,WAAW,EAAE,IAAI,GAAG,IAAI,CAAA;CAAE,CAAC"}
@@ -0,0 +1,13 @@
1
+ const itemKey = Symbol('table-item-data');
2
+ export function getItemData(row, instanceId) {
3
+ return {
4
+ [itemKey]: true,
5
+ id: row.id,
6
+ index: row.index,
7
+ instanceId,
8
+ };
9
+ }
10
+ export function isItemData(data) {
11
+ return data[itemKey] === true;
12
+ }
13
+ //# sourceMappingURL=item_data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item_data.js","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/item_data.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAU1C,MAAM,UAAU,WAAW,CAAC,GAAiB,EAAE,UAAkB;IAC/D,OAAO;QACL,CAAC,OAAO,CAAC,EAAE,IAAI;QACf,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,UAAU;KACX,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,IAAsC;IAEtC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;AAChC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { Edge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/types';
2
+ import type { Row } from '@tanstack/react-table';
3
+ export type ReorderItemCallback = (args: {
4
+ startIndex: number;
5
+ indexOfTarget: number;
6
+ closestEdgeOfTarget: Edge | null;
7
+ }) => void;
8
+ export interface ItemOrderContextValue<T = unknown> {
9
+ items: Array<Row<T>>;
10
+ reorderItem: ReorderItemCallback;
11
+ instanceId: symbol;
12
+ }
13
+ export declare const itemOrderContext: import("react").Context<ItemOrderContextValue<unknown> | null>;
14
+ export declare function useItemOrder(): ItemOrderContextValue<unknown>;
15
+ //# sourceMappingURL=item_order_context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item_order_context.d.ts","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/item_order_context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gDAAgD,CAAC;AAC3E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAGjD,MAAM,MAAM,mBAAmB,GAAG,CAAC,IAAI,EAAE;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,IAAI,GAAG,IAAI,CAAC;CAClC,KAAK,IAAI,CAAC;AAEX,MAAM,WAAW,qBAAqB,CAAC,CAAC,GAAG,OAAO;IAChD,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACrB,WAAW,EAAE,mBAAmB,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,gBAAgB,gEAE5B,CAAC;AAEF,wBAAgB,YAAY,mCAM3B"}
@@ -0,0 +1,10 @@
1
+ import { createContext, useContext } from 'react';
2
+ export const itemOrderContext = createContext(null);
3
+ export function useItemOrder() {
4
+ const context = useContext(itemOrderContext);
5
+ if (!context) {
6
+ throw new Error('useItemOrder must be used within a ListContextProvider');
7
+ }
8
+ return context;
9
+ }
10
+ //# sourceMappingURL=item_order_context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item_order_context.js","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/item_order_context.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAclD,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAC3C,IAAI,CACL,CAAC;AAEF,MAAM,UAAU,YAAY;IAC1B,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC7C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { Row } from '@tanstack/react-table';
2
+ import type { ReactNode } from 'react';
3
+ interface ItemOrderProviderProps<T> {
4
+ items: Array<Row<T>>;
5
+ onOrderChanged: (items: Array<Row<T>>) => void;
6
+ children: ReactNode;
7
+ }
8
+ export declare function ItemOrderProvider<T = unknown>(props: ItemOrderProviderProps<T>): import("react/jsx-runtime").JSX.Element;
9
+ export {};
10
+ //# sourceMappingURL=item_order_provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item_order_provider.d.ts","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/item_order_provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMvC,UAAU,sBAAsB,CAAC,CAAC;IAChC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACrB,cAAc,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAC/C,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,iBAAiB,CAAC,CAAC,GAAG,OAAO,EAC3C,KAAK,EAAE,sBAAsB,CAAC,CAAC,CAAC,2CA4CjC"}
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { reorder } from '@atlaskit/pragmatic-drag-and-drop/reorder';
3
+ import { getReorderDestinationIndex } from '@atlaskit/pragmatic-drag-and-drop-hitbox/util/get-reorder-destination-index';
4
+ import { useCallback, useMemo, useState } from 'react';
5
+ import { itemOrderContext } from './item_order_context.js';
6
+ export function ItemOrderProvider(props) {
7
+ // Isolated instances of this component from one another
8
+ const [instanceId] = useState(() => Symbol('table-instance-id'));
9
+ const { items, onOrderChanged, children } = props;
10
+ const reorderItem = useCallback(({ startIndex, indexOfTarget, closestEdgeOfTarget }) => {
11
+ const finishIndex = getReorderDestinationIndex({
12
+ startIndex,
13
+ closestEdgeOfTarget,
14
+ indexOfTarget,
15
+ axis: 'vertical',
16
+ });
17
+ if (finishIndex === startIndex) {
18
+ // If there is no change, we skip the update
19
+ return;
20
+ }
21
+ onOrderChanged(reorder({
22
+ list: items,
23
+ startIndex,
24
+ finishIndex,
25
+ }));
26
+ }, [items, onOrderChanged]);
27
+ const value = useMemo(() => ({
28
+ reorderItem,
29
+ items: items,
30
+ instanceId,
31
+ }), [reorderItem, items, instanceId]);
32
+ return (_jsx(itemOrderContext.Provider, { value: value, children: children }));
33
+ }
34
+ //# sourceMappingURL=item_order_provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item_order_provider.js","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/item_order_provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2CAA2C,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,6EAA6E,CAAC;AAGzH,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAQ3D,MAAM,UAAU,iBAAiB,CAC/B,KAAgC;IAEhC,wDAAwD;IACxD,MAAM,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC;IACjE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAClD,MAAM,WAAW,GAAG,WAAW,CAC7B,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,mBAAmB,EAAE,EAAE,EAAE;QACrD,MAAM,WAAW,GAAG,0BAA0B,CAAC;YAC7C,UAAU;YACV,mBAAmB;YACnB,aAAa;YACb,IAAI,EAAE,UAAU;SACjB,CAAC,CAAC;QAEH,IAAI,WAAW,KAAK,UAAU,EAAE,CAAC;YAC/B,4CAA4C;YAC5C,OAAO;QACT,CAAC;QAED,cAAc,CACZ,OAAO,CAAC;YACN,IAAI,EAAE,KAAK;YACX,UAAU;YACV,WAAW;SACZ,CAAC,CACH,CAAC;IACJ,CAAC,EACD,CAAC,KAAK,EAAE,cAAc,CAAC,CACxB,CAAC;IAEF,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC;QACL,WAAW;QACX,KAAK,EAAE,KAA4B;QACnC,UAAU;KACX,CAAC,EACF,CAAC,WAAW,EAAE,KAAK,EAAE,UAAU,CAAC,CACjC,CAAC;IAEF,OAAO,CACL,KAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YACpC,QAAQ,GACiB,CAC7B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function TableDragRowHandler(): import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=table_drag_row_handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table_drag_row_handler.d.ts","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/table_drag_row_handler.tsx"],"names":[],"mappings":"AAKA,wBAAgB,mBAAmB,4CAgBlC"}
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button } from '@blueprintjs/core';
3
+ import { useTableDraggableRowContext } from './draggable_row_context.js';
4
+ import { TableDropIndicator } from './drop_indicator.js';
5
+ export function TableDragRowHandler() {
6
+ const { dragHandleRef, state } = useTableDraggableRowContext();
7
+ return (_jsxs(_Fragment, { children: [_jsx(Button, { icon: "drag-handle-horizontal", type: "button", ref: dragHandleRef, variant: "minimal", style: { cursor: 'grab' } }), state?.type === 'is-over' && state.closestEdge && (_jsx(TableDropIndicator, { edge: state.closestEdge }))] }));
8
+ }
9
+ //# sourceMappingURL=table_drag_row_handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table_drag_row_handler.js","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/table_drag_row_handler.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,UAAU,mBAAmB;IACjC,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,2BAA2B,EAAE,CAAC;IAC/D,OAAO,CACL,8BACE,KAAC,MAAM,IACL,IAAI,EAAC,wBAAwB,EAC7B,IAAI,EAAC,QAAQ,EACb,GAAG,EAAE,aAAa,EAClB,OAAO,EAAC,SAAS,EACjB,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GACzB,EACD,KAAK,EAAE,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,WAAW,IAAI,CACjD,KAAC,kBAAkB,IAAC,IAAI,EAAE,KAAK,CAAC,WAAW,GAAI,CAChD,IACA,CACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { RefObject } from 'react';
2
+ /**
3
+ * Monitor drop events.
4
+ * Check if they can be acted on to reorder items.
5
+ * @param scrollElementRef The element to auto-scroll when dragging elements.
6
+ * @param enabled Enable or disable the monitoring.
7
+ */
8
+ export declare function useDropMonitor(scrollElementRef: RefObject<Element>, enabled: boolean): void;
9
+ //# sourceMappingURL=use_drop_monitor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_drop_monitor.d.ts","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/use_drop_monitor.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AASvC;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,gBAAgB,EAAE,SAAS,CAAC,OAAO,CAAC,EACpC,OAAO,EAAE,OAAO,QAmDjB"}