nmrium 0.24.0 → 0.26.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 (220) hide show
  1. package/lib/component/1d/IntegralResizable.js +13 -13
  2. package/lib/component/1d/multiAnalysis/AnalysisRange.js +30 -31
  3. package/lib/component/1d/multiplicityTree/MultiplicityTree.js +5 -5
  4. package/lib/component/1d/ranges/Range.js +24 -33
  5. package/lib/component/2d/zones/Signal.js +8 -8
  6. package/lib/component/2d/zones/Zone.js +3 -3
  7. package/lib/component/EventsTrackers/KeysListenerTracker.js +1 -1
  8. package/lib/component/NMRium.js +22 -29
  9. package/lib/component/assignment/AssignmentsContext.d.ts +35 -0
  10. package/lib/component/assignment/AssignmentsContext.js +83 -0
  11. package/lib/component/assignment/AssignmentsReducer.d.ts +32 -0
  12. package/lib/component/assignment/AssignmentsReducer.js +39 -0
  13. package/lib/component/assignment/actions/initAssignment.d.ts +5 -0
  14. package/lib/component/assignment/actions/initAssignment.js +62 -0
  15. package/lib/component/assignment/actions/removeAssignment.d.ts +16 -0
  16. package/lib/component/assignment/actions/removeAssignment.js +24 -0
  17. package/lib/component/assignment/actions/setActiveAssignment.d.ts +10 -0
  18. package/lib/component/assignment/actions/setActiveAssignment.js +8 -0
  19. package/lib/component/assignment/actions/toggleAssignment.d.ts +7 -0
  20. package/lib/component/assignment/actions/toggleAssignment.js +44 -0
  21. package/lib/component/assignment/index.d.ts +0 -18
  22. package/lib/component/assignment/index.js +12 -266
  23. package/lib/component/assignment/utilities/filterForIDsWithAssignment.d.ts +2 -0
  24. package/lib/component/assignment/utilities/filterForIDsWithAssignment.js +3 -0
  25. package/lib/component/context/GlobalContext.d.ts +12 -3
  26. package/lib/component/context/GlobalContext.js +1 -1
  27. package/lib/component/elements/ActionButtons.d.ts +10 -0
  28. package/lib/component/elements/ActionButtons.js +14 -0
  29. package/lib/component/elements/Button.d.ts +30 -5
  30. package/lib/component/elements/Button.js +151 -4
  31. package/lib/component/elements/ContextMenu.js +6 -6
  32. package/lib/component/elements/ReactTable/Elements/ReactTableRow.d.ts +5 -1
  33. package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +38 -10
  34. package/lib/component/elements/ReactTable/ReactTable.d.ts +3 -1
  35. package/lib/component/elements/ReactTable/ReactTable.js +7 -2
  36. package/lib/component/elements/ReactTable/Style.d.ts +1 -3
  37. package/lib/component/elements/ReactTable/Style.js +1 -7
  38. package/lib/component/elements/ToolTip/ToolTip.js +3 -2
  39. package/lib/component/elements/resizer/DivResizer.d.ts +2 -0
  40. package/lib/component/elements/resizer/DivResizer.js +107 -0
  41. package/lib/component/elements/resizer/Resizer.d.ts +18 -0
  42. package/lib/component/elements/resizer/Resizer.js +12 -0
  43. package/lib/component/elements/resizer/SVGResizer.d.ts +2 -0
  44. package/lib/component/elements/resizer/SVGResizer.js +71 -0
  45. package/lib/component/elements/resizer/useDraggable.d.ts +19 -0
  46. package/lib/component/elements/resizer/useDraggable.js +52 -0
  47. package/lib/component/header/AutoPeakPickingOptionPanel.js +4 -15
  48. package/lib/component/header/BaseLineCorrectionPanel.js +2 -9
  49. package/lib/component/header/ManualPhaseCorrectionPanel.js +2 -9
  50. package/lib/component/header/RangesPickingOptionPanel.js +3 -16
  51. package/lib/component/header/ZeroFillingOptionsPanel.js +2 -9
  52. package/lib/component/header/Zones2DOptionPanel.js +3 -14
  53. package/lib/component/hooks/useExport.js +11 -9
  54. package/lib/component/loader/DropZone.js +1 -0
  55. package/lib/component/modal/AlignSpectraModal.js +2 -1
  56. package/lib/component/modal/ExportAsMatrixModal.js +2 -1
  57. package/lib/component/modal/ImportPublicationStringModal.js +2 -1
  58. package/lib/component/modal/LoadJCAMPModal.js +7 -6
  59. package/lib/component/modal/ModalStyle.js +4 -26
  60. package/lib/component/modal/MoleculeStructureEditorModal.js +2 -1
  61. package/lib/component/modal/MultipleSpectraFiltersModal/index.js +2 -1
  62. package/lib/component/modal/PredictSpectraModal.js +2 -7
  63. package/lib/component/modal/SaveAsModal.d.ts +1 -1
  64. package/lib/component/modal/SaveAsModal.js +2 -1
  65. package/lib/component/modal/setting/FormattingTabContent.js +17 -11
  66. package/lib/component/modal/setting/GeneralSettings.js +3 -1
  67. package/lib/component/modal/setting/settingsValidation.d.ts +8 -0
  68. package/lib/component/modal/setting/settingsValidation.js +40 -0
  69. package/lib/component/panels/AutomaticAssignment/AutomaticAssignment.js +6 -4
  70. package/lib/component/panels/AutomaticAssignment/AutomaticAssignmentTable.d.ts +4 -3
  71. package/lib/component/panels/AutomaticAssignment/AutomaticAssignmentTable.js +13 -6
  72. package/lib/component/panels/AutomaticAssignment/useAutoAssignments.d.ts +10 -0
  73. package/lib/component/panels/AutomaticAssignment/useAutoAssignments.js +60 -0
  74. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +11 -5
  75. package/lib/component/panels/MoleculesPanel/Utilities.d.ts +20 -11
  76. package/lib/component/panels/MoleculesPanel/Utilities.js +50 -68
  77. package/lib/component/panels/MoleculesPanel/useAtomAssignment.d.ts +2 -2
  78. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +55 -60
  79. package/lib/component/panels/RangesPanel/RangesHeader.js +2 -2
  80. package/lib/component/panels/RangesPanel/RangesPanel.js +1 -1
  81. package/lib/component/panels/RangesPanel/RangesTableRow.js +12 -11
  82. package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.d.ts +16 -9
  83. package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.js +2 -2
  84. package/lib/component/panels/RangesPanel/TableColumns/SignalAssignmentsColumn.d.ts +2 -3
  85. package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.js +1 -1
  86. package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +5 -18
  87. package/lib/component/panels/SummaryPanel/SummaryPanel.js +1 -1
  88. package/lib/component/panels/ZonesPanel/TableColumns/ActionsColumn.js +1 -1
  89. package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumn.d.ts +5 -7
  90. package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumn.js +2 -2
  91. package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumns.d.ts +4 -8
  92. package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumns.js +1 -1
  93. package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumn.d.ts +5 -9
  94. package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumn.js +4 -4
  95. package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumns.d.ts +4 -8
  96. package/lib/component/panels/ZonesPanel/ZonesPanel.js +1 -1
  97. package/lib/component/panels/ZonesPanel/ZonesTableRow.d.ts +2 -1
  98. package/lib/component/panels/ZonesPanel/ZonesTableRow.js +20 -20
  99. package/lib/component/panels/header/SpectraAutomaticPickingButton.d.ts +2 -0
  100. package/lib/component/panels/header/SpectraAutomaticPickingButton.js +30 -0
  101. package/lib/component/panels/predictionPanel/PredictionOptions.js +2 -18
  102. package/lib/component/reducer/Reducer.d.ts +2 -0
  103. package/lib/component/reducer/Reducer.js +4 -1
  104. package/lib/component/reducer/actions/AssignmentsActions.d.ts +9 -0
  105. package/lib/component/reducer/actions/AssignmentsActions.js +18 -0
  106. package/lib/component/reducer/actions/LoadActions.d.ts +1 -1
  107. package/lib/component/reducer/actions/LoadActions.js +10 -5
  108. package/lib/component/reducer/preferencesReducer.d.ts +1 -8
  109. package/lib/component/reducer/preferencesReducer.js +16 -16
  110. package/lib/component/reducer/types/Types.d.ts +1 -0
  111. package/lib/component/reducer/types/Types.js +1 -0
  112. package/lib/component/utility/Export.d.ts +3 -3
  113. package/lib/component/utility/Export.js +10 -9
  114. package/lib/component/utility/FormatNumber.js +1 -1
  115. package/lib/component/workspaces/Workspace.d.ts +2 -4
  116. package/lib/component/workspaces/basic.js +8 -9
  117. package/lib/data/SpectraManager.js +23 -15
  118. package/lib/data/data1d/Data1DManager.d.ts +1 -1
  119. package/lib/data/data1d/Data1DManager.js +2 -1
  120. package/lib/data/data1d/Spectrum1D/toJSON.d.ts +2 -0
  121. package/lib/data/data1d/Spectrum1D/toJSON.js +1 -0
  122. package/lib/data/data1d/database.d.ts +1 -2
  123. package/lib/data/data1d/database.js +1 -1
  124. package/lib/data/data1d/filter1d/exclusionZones.d.ts +1 -4
  125. package/lib/data/data2d/Data2DManager.d.ts +1 -1
  126. package/lib/data/data2d/Data2DManager.js +2 -1
  127. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +1 -1
  128. package/lib/data/data2d/Spectrum2D/toJSON.d.ts +2 -0
  129. package/lib/data/data2d/Spectrum2D/toJSON.js +1 -0
  130. package/lib/data/types/common/Source.d.ts +1 -0
  131. package/lib/data/types/data2d/Signal2DAxisData.d.ts +1 -1
  132. package/lib/versionInfo.js +1 -1
  133. package/lib-cjs/component/1d/IntegralResizable.js +12 -12
  134. package/lib-cjs/component/1d/multiAnalysis/AnalysisRange.js +29 -30
  135. package/lib-cjs/component/1d/multiplicityTree/MultiplicityTree.js +6 -6
  136. package/lib-cjs/component/1d/ranges/Range.js +26 -35
  137. package/lib-cjs/component/2d/zones/Signal.js +9 -9
  138. package/lib-cjs/component/2d/zones/Zone.js +4 -4
  139. package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +2 -2
  140. package/lib-cjs/component/NMRium.js +22 -29
  141. package/lib-cjs/component/assignment/AssignmentsContext.js +88 -0
  142. package/lib-cjs/component/assignment/AssignmentsReducer.js +45 -0
  143. package/lib-cjs/component/assignment/actions/initAssignment.js +65 -0
  144. package/lib-cjs/component/assignment/actions/removeAssignment.js +29 -0
  145. package/lib-cjs/component/assignment/actions/setActiveAssignment.js +11 -0
  146. package/lib-cjs/component/assignment/actions/toggleAssignment.js +47 -0
  147. package/lib-cjs/component/assignment/index.js +15 -269
  148. package/lib-cjs/component/assignment/utilities/filterForIDsWithAssignment.js +7 -0
  149. package/lib-cjs/component/context/GlobalContext.js +1 -1
  150. package/lib-cjs/component/elements/ActionButtons.js +20 -0
  151. package/lib-cjs/component/elements/Button.js +150 -4
  152. package/lib-cjs/component/elements/ContextMenu.js +6 -6
  153. package/lib-cjs/component/elements/ReactTable/Elements/ReactTableRow.js +42 -14
  154. package/lib-cjs/component/elements/ReactTable/ReactTable.js +7 -2
  155. package/lib-cjs/component/elements/ReactTable/Style.js +1 -9
  156. package/lib-cjs/component/elements/ToolTip/ToolTip.js +3 -2
  157. package/lib-cjs/component/elements/resizer/DivResizer.js +113 -0
  158. package/lib-cjs/component/elements/resizer/Resizer.js +18 -0
  159. package/lib-cjs/component/elements/resizer/SVGResizer.js +77 -0
  160. package/lib-cjs/component/elements/resizer/useDraggable.js +55 -0
  161. package/lib-cjs/component/header/AutoPeakPickingOptionPanel.js +3 -14
  162. package/lib-cjs/component/header/BaseLineCorrectionPanel.js +2 -9
  163. package/lib-cjs/component/header/ManualPhaseCorrectionPanel.js +2 -9
  164. package/lib-cjs/component/header/RangesPickingOptionPanel.js +2 -15
  165. package/lib-cjs/component/header/ZeroFillingOptionsPanel.js +2 -9
  166. package/lib-cjs/component/header/Zones2DOptionPanel.js +2 -13
  167. package/lib-cjs/component/hooks/useExport.js +11 -9
  168. package/lib-cjs/component/loader/DropZone.js +1 -0
  169. package/lib-cjs/component/modal/AlignSpectraModal.js +2 -1
  170. package/lib-cjs/component/modal/ExportAsMatrixModal.js +2 -1
  171. package/lib-cjs/component/modal/ImportPublicationStringModal.js +2 -1
  172. package/lib-cjs/component/modal/LoadJCAMPModal.js +7 -6
  173. package/lib-cjs/component/modal/ModalStyle.js +4 -26
  174. package/lib-cjs/component/modal/MoleculeStructureEditorModal.js +5 -1
  175. package/lib-cjs/component/modal/MultipleSpectraFiltersModal/index.js +2 -1
  176. package/lib-cjs/component/modal/PredictSpectraModal.js +2 -7
  177. package/lib-cjs/component/modal/SaveAsModal.js +2 -1
  178. package/lib-cjs/component/modal/setting/FormattingTabContent.js +17 -11
  179. package/lib-cjs/component/modal/setting/GeneralSettings.js +3 -1
  180. package/lib-cjs/component/modal/setting/settingsValidation.js +66 -0
  181. package/lib-cjs/component/panels/AutomaticAssignment/AutomaticAssignment.js +6 -4
  182. package/lib-cjs/component/panels/AutomaticAssignment/AutomaticAssignmentTable.js +13 -6
  183. package/lib-cjs/component/panels/AutomaticAssignment/useAutoAssignments.js +67 -0
  184. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +12 -6
  185. package/lib-cjs/component/panels/MoleculesPanel/Utilities.js +50 -68
  186. package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +55 -60
  187. package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +3 -3
  188. package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +2 -2
  189. package/lib-cjs/component/panels/RangesPanel/RangesTableRow.js +15 -14
  190. package/lib-cjs/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.js +2 -2
  191. package/lib-cjs/component/panels/RangesPanel/hooks/useEditRangeModal.js +2 -2
  192. package/lib-cjs/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -16
  193. package/lib-cjs/component/panels/SummaryPanel/SummaryPanel.js +2 -2
  194. package/lib-cjs/component/panels/ZonesPanel/TableColumns/ActionsColumn.js +2 -2
  195. package/lib-cjs/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumn.js +2 -2
  196. package/lib-cjs/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumns.js +1 -1
  197. package/lib-cjs/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumn.js +4 -4
  198. package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +2 -2
  199. package/lib-cjs/component/panels/ZonesPanel/ZonesTableRow.js +21 -21
  200. package/lib-cjs/component/panels/header/SpectraAutomaticPickingButton.js +37 -0
  201. package/lib-cjs/component/panels/predictionPanel/PredictionOptions.js +2 -18
  202. package/lib-cjs/component/reducer/Reducer.js +4 -1
  203. package/lib-cjs/component/reducer/actions/AssignmentsActions.js +21 -0
  204. package/lib-cjs/component/reducer/actions/LoadActions.js +9 -4
  205. package/lib-cjs/component/reducer/preferencesReducer.js +16 -16
  206. package/lib-cjs/component/reducer/types/Types.js +2 -1
  207. package/lib-cjs/component/utility/Export.js +10 -9
  208. package/lib-cjs/component/utility/FormatNumber.js +1 -1
  209. package/lib-cjs/component/workspaces/basic.js +8 -9
  210. package/lib-cjs/data/SpectraManager.js +23 -15
  211. package/lib-cjs/data/data1d/Data1DManager.js +2 -1
  212. package/lib-cjs/data/data1d/Spectrum1D/toJSON.js +1 -0
  213. package/lib-cjs/data/data2d/Data2DManager.js +2 -1
  214. package/lib-cjs/data/data2d/Spectrum2D/initiateDatum2D.js +1 -1
  215. package/lib-cjs/data/data2d/Spectrum2D/toJSON.js +1 -0
  216. package/lib-cjs/versionInfo.js +1 -1
  217. package/package.json +25 -26
  218. package/lib/component/1d/Resizable.d.ts +0 -12
  219. package/lib/component/1d/Resizable.js +0 -105
  220. package/lib-cjs/component/1d/Resizable.js +0 -110
@@ -1,5 +1,152 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Fragment } from 'react';
3
- export default function Button({ onClick, ...props }) {
4
- return (_jsx(Fragment, { children: _jsx("button", { type: "button", onClick: onClick, ...props }) }));
1
+ import { jsxs as _jsxs, jsx as _jsx } from "@emotion/react/jsx-runtime";
2
+ /** @jsxImportSource @emotion/react */
3
+ import { css } from '@emotion/react';
4
+ const colorPalettes = {
5
+ success: {
6
+ base: '#2dd36f',
7
+ shade: '#28ba62',
8
+ tint: '#42d77d',
9
+ },
10
+ danger: {
11
+ base: '#eb445a',
12
+ shade: '#cf3c4f',
13
+ tint: '#ed576b',
14
+ },
15
+ warning: {
16
+ base: '#ffc409',
17
+ shade: '#e0ac08',
18
+ tint: '#ffca22',
19
+ },
20
+ medium: {
21
+ base: '#92949c',
22
+ shade: '#808289',
23
+ tint: '#9d9fa6',
24
+ },
25
+ light: {
26
+ base: '#f4f5f8',
27
+ shade: '#d7d8da',
28
+ tint: '#f5f6f9',
29
+ },
30
+ };
31
+ const sizeConfig = {
32
+ xSmall: {
33
+ fontSize: '0.75rem',
34
+ padding: '0.15rem 0.3rem',
35
+ borderRadius: '0.15rem',
36
+ },
37
+ small: {
38
+ fontSize: '0.8rem',
39
+ padding: '0.25rem 0.5rem',
40
+ borderRadius: '0.2rem',
41
+ },
42
+ medium: {
43
+ fontSize: '1rem',
44
+ padding: '0.375rem 0.75rem',
45
+ borderRadius: '0.25rem',
46
+ },
47
+ large: {
48
+ fontSize: '1.25rem',
49
+ padding: '0.5rem 1rem',
50
+ borderRadius: '0.3rem',
51
+ },
52
+ };
53
+ function getFillStyle(props) {
54
+ const { borderColor, fill, backgroundColor, color } = props;
55
+ switch (fill) {
56
+ case 'solid': {
57
+ return css `
58
+ border-color: transparent;
59
+ background-color: ${backgroundColor.base};
60
+ color: ${color.hover};
61
+ `;
62
+ }
63
+ case 'outline': {
64
+ return css `
65
+ border-style: solid;
66
+ border-color: ${backgroundColor.base};
67
+ background-color: transparent;
68
+ color: ${color.base};
69
+ `;
70
+ }
71
+ case 'clear': {
72
+ return css `
73
+ border-color: transparent;
74
+ background-color: transparent;
75
+ color: ${color.base};
76
+ `;
77
+ }
78
+ default:
79
+ return css `
80
+ background-color: ${backgroundColor.base};
81
+ color: ${color.base};
82
+ border-color: ${borderColor};
83
+ `;
84
+ }
5
85
  }
86
+ const styles = {
87
+ button: (props) => {
88
+ const { size, backgroundColor, color, borderRadius } = props;
89
+ const basic = css `
90
+ display: flex;
91
+ flex-direction: row;
92
+ border-width: 1px;
93
+ align-items: center;
94
+ `;
95
+ const fillStyle = getFillStyle(props);
96
+ const colorStyle = css `
97
+ &:not([disabled]):hover {
98
+ background-color: ${backgroundColor.hover};
99
+ color: ${color.hover};
100
+ }
101
+ &:not([disabled]):active {
102
+ background-color: ${backgroundColor?.active || backgroundColor.hover};
103
+ color: ${color?.active || color.hover};
104
+ }
105
+
106
+ &:disabled {
107
+ opacity: 0.25;
108
+ }
109
+ `;
110
+ return css([
111
+ basic,
112
+ sizeConfig[size],
113
+ fillStyle,
114
+ colorStyle,
115
+ { borderRadius },
116
+ ]);
117
+ },
118
+ };
119
+ const Button = (props) => {
120
+ const { onClick, size = 'small', color = { base: 'black', hover: 'white' }, backgroundColor = { base: 'white', hover: 'black', active: 'black' }, borderColor = 'transparent', fill, borderRadius, style = {}, ...restProps } = props;
121
+ return (_jsx("button", { type: "button", onClick: onClick, css: [
122
+ styles.button({
123
+ size,
124
+ backgroundColor,
125
+ color,
126
+ borderColor,
127
+ fill,
128
+ borderRadius,
129
+ }),
130
+ style,
131
+ ], ...restProps, children: _jsxs("span", { style: { flex: 1 }, children: [" ", props.children] }) }));
132
+ };
133
+ function ThemeButton(props) {
134
+ const { colorTheme, ...buttonProps } = props;
135
+ const { base, shade, tint } = colorPalettes[props.colorTheme];
136
+ const { color = { base: shade, hover: 'white' }, backgroundColor = {
137
+ base: base,
138
+ hover: shade,
139
+ active: tint,
140
+ }, fill = 'solid', ...restProps } = buttonProps;
141
+ return _jsx(Button, { ...{ fill, ...restProps, backgroundColor, color } });
142
+ }
143
+ Button.Done = (props) => {
144
+ return _jsx(ThemeButton, { ...props, colorTheme: "success" });
145
+ };
146
+ Button.Danger = (props) => {
147
+ return _jsx(ThemeButton, { ...props, colorTheme: "danger" });
148
+ };
149
+ Button.Action = (props) => {
150
+ return _jsx(ThemeButton, { ...props, colorTheme: "medium" });
151
+ };
152
+ export default Button;
@@ -47,22 +47,22 @@ function ContextMenu({ context }, ref) {
47
47
  left: 0,
48
48
  top: 0,
49
49
  });
50
- const { rootRef, elementsWraperRef } = useGlobal();
50
+ const { rootRef, elementsWrapperRef } = useGlobal();
51
51
  const [data, setData] = useState();
52
52
  const [isVisible, show] = useState();
53
53
  const [sourceElement, setSourceElement] = useState(null);
54
54
  const root = useRef();
55
55
  useEffect(() => {
56
56
  root.current = document.createElement('div');
57
- if (elementsWraperRef) {
58
- elementsWraperRef.appendChild(root.current);
57
+ if (elementsWrapperRef) {
58
+ elementsWrapperRef.appendChild(root.current);
59
59
  }
60
60
  return () => {
61
- if (root.current && elementsWraperRef) {
62
- elementsWraperRef.removeChild(root.current);
61
+ if (root.current && elementsWrapperRef) {
62
+ elementsWrapperRef.removeChild(root.current);
63
63
  }
64
64
  };
65
- }, [elementsWraperRef]);
65
+ }, [elementsWrapperRef]);
66
66
  const contextMenuHandler = (event) => {
67
67
  event.preventDefault();
68
68
  setSourceElement(event.target.parentElement);
@@ -1,11 +1,15 @@
1
1
  /** @jsxImportSource @emotion/react */
2
2
  /// <reference types="react" />
3
3
  import { HighlightedSource } from '../../../highlight/index';
4
- interface ReactTableRowProps {
4
+ export interface ClickEvent {
5
+ onClick?: (event: Event, data: unknown) => void;
6
+ }
7
+ interface ReactTableRowProps extends ClickEvent {
5
8
  row: any;
6
9
  highlightedSource?: HighlightedSource;
7
10
  onContextMenu: () => void;
8
11
  isVisible: boolean;
12
+ isRowActive: boolean;
9
13
  }
10
14
  declare const _default: import("react").ForwardRefExoticComponent<ReactTableRowProps & import("react").RefAttributes<unknown>>;
11
15
  export default _default;
@@ -1,8 +1,26 @@
1
1
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
- import { useMemo, forwardRef, useEffect } from 'react';
3
+ import { css } from '@emotion/react';
4
+ import { useMemo, forwardRef, useEffect, useCallback } from 'react';
4
5
  import { HighlightedSource, useHighlight } from '../../../highlight/index';
5
- import { HighlightedRowStyle, ConstantlyHighlightedRowStyle } from '../Style';
6
+ function highlightStyle(isActive, row) {
7
+ if (isActive) {
8
+ return { backgroundColor: '#ff6f0057' };
9
+ }
10
+ else if (row.original?.isConstantlyHighlighted === true) {
11
+ return { backgroundColor: '#f5f5dc' };
12
+ }
13
+ return {};
14
+ }
15
+ const rowCss = css `
16
+ &:hover {
17
+ background-color: #ff6f0091 !important;
18
+ }
19
+
20
+ &:active {
21
+ background-color: #ff6f0070 !important;
22
+ }
23
+ `;
6
24
  function getIDs(row) {
7
25
  const id = row.original.id;
8
26
  if (id) {
@@ -16,7 +34,7 @@ function getIDs(row) {
16
34
  return [''];
17
35
  }
18
36
  function ReactTableRow(props, ref) {
19
- const { row, highlightedSource = HighlightedSource.UNKNOWN, onContextMenu, } = props;
37
+ const { row, highlightedSource = HighlightedSource.UNKNOWN, onContextMenu, onClick, isRowActive = false, } = props;
20
38
  const data = useMemo(() => ({
21
39
  type: highlightedSource,
22
40
  extra: row.original,
@@ -28,12 +46,14 @@ function ReactTableRow(props, ref) {
28
46
  };
29
47
  // eslint-disable-next-line react-hooks/exhaustive-deps
30
48
  }, []);
49
+ const clickHandler = useCallback((event) => {
50
+ onClick?.(event, row);
51
+ }, [onClick, row]);
31
52
  return useMemo(() => {
32
- return (_jsx("tr", { ref: ref, onContextMenu: onContextMenu, css: highlight.isActive
33
- ? HighlightedRowStyle
34
- : Object.prototype.hasOwnProperty.call(row.original, 'isConstantlyHighlighted') && row.original.isConstantlyHighlighted === true
35
- ? ConstantlyHighlightedRowStyle
36
- : null, ...row.getRowProps(), ...highlight.onHover, children: row.cells.map((cell) => {
53
+ return (_jsx("tr", { ref: ref, onContextMenu: onContextMenu, css: [
54
+ highlightStyle(highlight.isActive || isRowActive, row),
55
+ onClick && rowCss,
56
+ ], ...row.getRowProps(), ...highlight.onHover, children: row.cells.map((cell) => {
37
57
  const { style, padding } = cell.column;
38
58
  if (cell.isRowSpanned) {
39
59
  return null;
@@ -42,9 +62,17 @@ function ReactTableRow(props, ref) {
42
62
  return (_jsx("td", { rowSpan: cell.rowSpan, ...cell.getCellProps(), onContextMenu: (e) => {
43
63
  e.preventDefault();
44
64
  return false;
45
- }, style: { padding, ...style }, children: cell.render('Cell') }, cell.key));
65
+ }, style: { padding, ...style }, onClick: clickHandler, children: cell.render('Cell') }, cell.key));
46
66
  }
47
67
  }) }, row.getRowProps().key));
48
- }, [highlight.isActive, highlight.onHover, onContextMenu, ref, row]);
68
+ }, [
69
+ clickHandler,
70
+ highlight.isActive,
71
+ highlight.onHover,
72
+ onClick,
73
+ onContextMenu,
74
+ ref,
75
+ row,
76
+ ]);
49
77
  }
50
78
  export default forwardRef(ReactTableRow);
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { HighlightedSource } from '../../highlight';
3
- interface ReactTableProps {
3
+ import { ClickEvent } from './Elements/ReactTableRow';
4
+ interface ReactTableProps extends ClickEvent {
4
5
  data: any;
5
6
  columns: any;
6
7
  highlightedSource?: HighlightedSource;
@@ -11,6 +12,7 @@ interface ReactTableProps {
11
12
  approxItemHeight?: number;
12
13
  groupKey?: string;
13
14
  enableVirtualScroll?: boolean;
15
+ highlightActiveRow?: boolean;
14
16
  }
15
17
  export interface TableVirtualConfig {
16
18
  offsetHeight: number;
@@ -19,9 +19,10 @@ const styles = {
19
19
  },
20
20
  };
21
21
  const ReactTableInner = forwardRef(function ReactTableInner(props, ref) {
22
- const { data, columns, highlightedSource, context = null, onScroll, approxItemHeight = 40, enableVirtualScroll = false, groupKey, } = props;
22
+ const { data, columns, highlightedSource, context = null, onScroll, approxItemHeight = 40, enableVirtualScroll = false, groupKey, onClick, highlightActiveRow = false, } = props;
23
23
  const contextRef = useRef(null);
24
24
  const { index: indexBoundary } = useReactTableContext();
25
+ const [rowIndex, setRowIndex] = useState();
25
26
  const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow, rowSpanHeaders, } = useTable({
26
27
  columns,
27
28
  data,
@@ -35,6 +36,10 @@ const ReactTableInner = forwardRef(function ReactTableInner(props, ref) {
35
36
  const rowsData = enableVirtualScroll
36
37
  ? rows.slice(indexBoundary.start, indexBoundary.end)
37
38
  : rows;
39
+ const clickHandler = useCallback((event, row) => {
40
+ setRowIndex(row.index);
41
+ onClick?.(event, row);
42
+ }, [onClick]);
38
43
  return (_jsxs("div", { ref: ref, className: "table-container", style: {
39
44
  overflowY: 'auto',
40
45
  position: 'relative',
@@ -47,7 +52,7 @@ const ReactTableInner = forwardRef(function ReactTableInner(props, ref) {
47
52
  } })), _jsxs("table", { ...getTableProps(), css: ReactTableStyle, style: styles.table(enableVirtualScroll), children: [_jsx(ReactTableHeader, { headerGroups: headerGroups }), _jsx("tbody", { ...getTableBodyProps(), children: rowsData.map((row, index) => {
48
53
  prepareRow(row);
49
54
  prepareRowSpan(rows, enableVirtualScroll ? index + indexBoundary.start : index, rowSpanHeaders, groupKey);
50
- return (_jsx(ReactTableRow, { row: row, ...row.getRowProps(), onContextMenu: (e) => contextMenuHandler(e, row), highlightedSource: highlightedSource }, row.key));
55
+ return (_jsx(ReactTableRow, { row: row, ...row.getRowProps(), onContextMenu: (e) => contextMenuHandler(e, row), onClick: highlightActiveRow ? clickHandler : onClick, highlightedSource: highlightedSource, isRowActive: rowIndex === index }, row.key));
51
56
  }) })] }), _jsx(ContextMenu, { ref: contextRef, context: context })] }));
52
57
  });
53
58
  function ReactTable(props) {
@@ -1,4 +1,2 @@
1
- declare const HighlightedRowStyle: import("@emotion/utils").SerializedStyles;
2
- declare const ConstantlyHighlightedRowStyle: import("@emotion/utils").SerializedStyles;
3
1
  declare const ReactTableStyle: import("@emotion/utils").SerializedStyles;
4
- export { ReactTableStyle, HighlightedRowStyle, ConstantlyHighlightedRowStyle };
2
+ export { ReactTableStyle };
@@ -1,10 +1,4 @@
1
1
  import { css } from '@emotion/react';
2
- const HighlightedRowStyle = css `
3
- background-color: #ff6f0057;
4
- `;
5
- const ConstantlyHighlightedRowStyle = css `
6
- background-color: #f5f5dc;
7
- `;
8
2
  const ReactTableStyle = css `
9
3
  border-spacing: 0;
10
4
  border: 1px solid #dedede;
@@ -46,4 +40,4 @@ const ReactTableStyle = css `
46
40
  }
47
41
  }
48
42
  `;
49
- export { ReactTableStyle, HighlightedRowStyle, ConstantlyHighlightedRowStyle };
43
+ export { ReactTableStyle };
@@ -23,7 +23,7 @@ function ToolTip({ style = { popup: {}, mainContainer: {} }, className = '', pop
23
23
  const refContent = useRef(null);
24
24
  const [placement, setPlacement] = useState({ x: 0, y: 0 });
25
25
  const [show, showToolTip] = useState(false);
26
- const { elementsWraperRef } = useGlobal();
26
+ const { elementsWrapperRef } = useGlobal();
27
27
  useLayoutEffect(() => {
28
28
  const getPopupPlacement = () => {
29
29
  let x;
@@ -90,11 +90,12 @@ function ToolTip({ style = { popup: {}, mainContainer: {} }, className = '', pop
90
90
  alignItems: 'center',
91
91
  ...style.mainContainer,
92
92
  }, ref: refChild, onMouseOver: mouseOverHandler, onMouseOut: mouseLeaveHandler, children: children }), show &&
93
+ elementsWrapperRef &&
93
94
  createPortal(_jsx("div", { ref: refContent, style: {
94
95
  ...styles.popup,
95
96
  transform: `translate(${placement.x + offset.x}px,${placement.y + offset.y}px)`,
96
97
  zIndex: 999999999,
97
98
  ...style.popup,
98
- }, className: className, children: _jsx("span", { style: { pointerEvents: 'none' }, children: title }) }), elementsWraperRef)] }));
99
+ }, className: className, children: _jsx("span", { style: { pointerEvents: 'none' }, children: title }) }), elementsWrapperRef)] }));
99
100
  }
100
101
  export default memo(ToolTip);
@@ -0,0 +1,2 @@
1
+ import { ResizerProps } from './Resizer';
2
+ export default function DivResizer(props: ResizerProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,107 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ /** @jsxImportSource @emotion/react */
3
+ import { css } from '@emotion/react';
4
+ import { useEffect } from 'react';
5
+ import useDraggable from './useDraggable';
6
+ const anchorStyle = {
7
+ marginLeft: '5px',
8
+ width: '2px',
9
+ height: '100%',
10
+ pointerEvents: 'none',
11
+ position: 'relative',
12
+ };
13
+ const styles = {
14
+ container: (position) => css `
15
+ position: absolute;
16
+ height: 100%;
17
+ width: 10px;
18
+ left: -5px;
19
+ cursor: e-resize;
20
+ transform: translateX(${position}px);
21
+ user-select: none;
22
+ z-index: 99999999;
23
+
24
+ &:hover {
25
+ div {
26
+ background-color: red;
27
+ }
28
+ }
29
+ `,
30
+ content: (anchorSide, left, right) => {
31
+ const width = right.previousPosition - left.previousPosition;
32
+ const baseCss = css `
33
+ position: absolute;
34
+ width: ${width}px;
35
+ overflow: hidden;
36
+ `;
37
+ if (right.position.action === 'move' || left.position.action === 'move') {
38
+ const scale = (right.position.x - left.position.x) / width;
39
+ if (anchorSide === 'RIGHT') {
40
+ return [
41
+ baseCss,
42
+ css `
43
+ transform: translateX(${left.position.x}px) scaleX(${scale});
44
+ transform-origin: left center;
45
+ `,
46
+ ];
47
+ }
48
+ else if (anchorSide === 'LEFT') {
49
+ return css([
50
+ baseCss,
51
+ css `
52
+ transform: translateX(${left.position.x}px) scaleX(${scale});
53
+ transform-origin: left center;
54
+ `,
55
+ ]);
56
+ }
57
+ }
58
+ else {
59
+ return css([
60
+ baseCss,
61
+ css `
62
+ transform: translateX(${left.position.x}px);
63
+ `,
64
+ ]);
65
+ }
66
+ },
67
+ };
68
+ export default function DivResizer(props) {
69
+ const { children, initialPosition = { x1: 10, x2: 40 }, onStart, onMove, onEnd, } = props;
70
+ const right = useDraggable({
71
+ x: initialPosition.x2,
72
+ anchor: 'RIGHT',
73
+ });
74
+ const left = useDraggable({
75
+ x: initialPosition.x1,
76
+ anchor: 'LEFT',
77
+ });
78
+ const anchor = left.isActive
79
+ ? left.anchor
80
+ : right.isActive
81
+ ? right.anchor
82
+ : '';
83
+ useEffect(() => {
84
+ const position = { x1: left.position.x, x2: right.position.x };
85
+ const status = left.isActive
86
+ ? left.position.action
87
+ : right.isActive
88
+ ? right.position.action
89
+ : '';
90
+ switch (status) {
91
+ case 'start':
92
+ onStart?.(position);
93
+ break;
94
+ case 'move':
95
+ onMove?.(position);
96
+ break;
97
+ case 'end':
98
+ onEnd?.(position);
99
+ break;
100
+ default:
101
+ break;
102
+ }
103
+ }, [left, onEnd, onMove, onStart, right]);
104
+ return (_jsxs(_Fragment, { children: [_jsx("div", { "data-no-export": "true", onMouseDown: right.onMouseDown, css: styles.container(right.position.x), children: _jsx("div", { style: anchorStyle }) }), _jsx("div", { css: styles.content(anchor, left, right), children: typeof children === 'function'
105
+ ? children?.(left.position.x, right.position.x)
106
+ : children }), _jsx("div", { "data-no-export": "true", onMouseDown: left.onMouseDown, css: styles.container(left.position.x), children: _jsx("div", { style: anchorStyle }) })] }));
107
+ }
@@ -0,0 +1,18 @@
1
+ import { ReactFragment } from 'react';
2
+ export interface Position {
3
+ x1: number;
4
+ x2: number;
5
+ }
6
+ declare type ChildType = Array<React.ReactElement> | React.ReactElement | ReactFragment | boolean | null;
7
+ export interface ResizerProps {
8
+ children?: ChildType | ((x1: number, x2: number) => ChildType);
9
+ initialPosition?: Position;
10
+ position?: Position;
11
+ onStart?: PositionChangeHandler;
12
+ onMove?: PositionChangeHandler;
13
+ onEnd?: PositionChangeHandler;
14
+ tag?: 'div' | 'svg';
15
+ }
16
+ declare type PositionChangeHandler = (data: Position) => void;
17
+ export default function Resizer(props: ResizerProps): JSX.Element;
18
+ export {};
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import DivResizer from './DivResizer';
3
+ import SVGResizer from './SVGResizer';
4
+ export default function Resizer(props) {
5
+ const { tag = 'div', ...resProps } = props;
6
+ if (tag === 'div') {
7
+ return _jsx(DivResizer, { ...resProps });
8
+ }
9
+ else {
10
+ return _jsx(SVGResizer, { ...resProps });
11
+ }
12
+ }
@@ -0,0 +1,2 @@
1
+ import { ResizerProps } from './Resizer';
2
+ export default function SVGResizer(props: ResizerProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,71 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ /** @jsxImportSource @emotion/react */
3
+ import { css } from '@emotion/react';
4
+ import { useEffect } from 'react';
5
+ import useDraggable from './useDraggable';
6
+ const anchorStyle = {
7
+ width: '2px',
8
+ height: '100%',
9
+ pointerEvents: 'none',
10
+ fill: 'transparent',
11
+ };
12
+ const styles = {
13
+ container: (position) => css `
14
+ transform: translateX(${position}px);
15
+
16
+ &:hover {
17
+ rect:last-child {
18
+ fill: red !important;
19
+ }
20
+ }
21
+ `,
22
+ innerContainer: css `
23
+ position: absolute;
24
+ height: 100%;
25
+ fill: transparent;
26
+ width: 10px;
27
+ cursor: e-resize;
28
+ user-select: none;
29
+ z-index: 99999999;
30
+ `,
31
+ };
32
+ export default function SVGResizer(props) {
33
+ const { children, initialPosition = { x1: 10, x2: 40 }, onStart, onMove, onEnd, } = props;
34
+ const right = useDraggable({
35
+ x: initialPosition.x2,
36
+ anchor: 'RIGHT',
37
+ });
38
+ const left = useDraggable({
39
+ x: initialPosition.x1,
40
+ anchor: 'LEFT',
41
+ });
42
+ useEffect(() => {
43
+ const position = { x1: left.position.x, x2: right.position.x };
44
+ const status = left.isActive
45
+ ? left.position.action
46
+ : right.isActive
47
+ ? right.position.action
48
+ : '';
49
+ switch (status) {
50
+ case 'start':
51
+ onStart?.(position);
52
+ break;
53
+ case 'move':
54
+ onMove?.(position);
55
+ break;
56
+ case 'end':
57
+ onEnd?.(position);
58
+ break;
59
+ default:
60
+ break;
61
+ }
62
+ }, [left, onEnd, onMove, onStart, right]);
63
+ return (_jsxs("g", { style: {
64
+ transform: `translateX(${left.position.x}px)`,
65
+ }, children: [typeof children === 'function'
66
+ ? children(left.position.x, right.position.x)
67
+ : children, _jsx(SVGResizerHandle, { onMouseDown: left.onMouseDown, position: 0 }), _jsx(SVGResizerHandle, { onMouseDown: right.onMouseDown, position: right.position.x - left.position.x })] }));
68
+ }
69
+ function SVGResizerHandle(props) {
70
+ return (_jsxs("g", { onMouseDown: props.onMouseDown, css: styles.container(props.position), "data-no-export": "true", children: [_jsx("rect", { x: "-5px", css: styles.innerContainer }), _jsx("rect", { x: "-2.5px", style: anchorStyle })] }));
71
+ }
@@ -0,0 +1,19 @@
1
+ /// <reference types="react" />
2
+ interface UseDraggable {
3
+ x: number;
4
+ anchor: Anchor;
5
+ }
6
+ export interface Draggable {
7
+ onMouseDown: (event: React.MouseEvent<HTMLDivElement | SVGElement, MouseEvent>) => void;
8
+ position: {
9
+ x: number;
10
+ action: Action;
11
+ };
12
+ previousPosition: number;
13
+ isActive: boolean;
14
+ anchor: Anchor;
15
+ }
16
+ declare type Action = 'start' | 'move' | 'end' | null;
17
+ export declare type Anchor = 'RIGHT' | 'LEFT';
18
+ export default function useDraggable(props: UseDraggable): Draggable;
19
+ export {};
@@ -0,0 +1,52 @@
1
+ import { useCallback, useEffect, useRef, useState } from 'react';
2
+ export default function useDraggable(props) {
3
+ const { x, anchor } = props;
4
+ const isActive = useRef(false);
5
+ const positionRef = useRef({
6
+ relativeX: x,
7
+ x,
8
+ });
9
+ const [position, setPosition] = useState({
10
+ x,
11
+ action: null,
12
+ });
13
+ useEffect(() => {
14
+ positionRef.current = { relativeX: x, x };
15
+ setPosition({ x, action: null });
16
+ }, [x]);
17
+ const onMouseDown = useCallback((e) => {
18
+ setPosition({ x: positionRef.current.x, action: 'start' });
19
+ positionRef.current.relativeX = e.clientX - positionRef.current.relativeX;
20
+ isActive.current = true;
21
+ e.stopPropagation();
22
+ function onMouseUp(e) {
23
+ e.stopPropagation();
24
+ if (isActive.current) {
25
+ const x = e.clientX - positionRef.current.relativeX;
26
+ positionRef.current = { relativeX: x, x };
27
+ setPosition({ x, action: 'end' });
28
+ isActive.current = false;
29
+ }
30
+ window.removeEventListener('mousemove', onMouseMove);
31
+ window.removeEventListener('mouseup', onMouseUp);
32
+ }
33
+ function onMouseMove(e) {
34
+ e.stopPropagation();
35
+ if (isActive.current) {
36
+ setPosition({
37
+ x: e.clientX - positionRef.current.relativeX,
38
+ action: 'move',
39
+ });
40
+ }
41
+ }
42
+ window.addEventListener('mousemove', onMouseMove);
43
+ window.addEventListener('mouseup', onMouseUp);
44
+ }, []);
45
+ return {
46
+ onMouseDown,
47
+ position,
48
+ previousPosition: positionRef.current.x,
49
+ isActive: isActive.current,
50
+ anchor,
51
+ };
52
+ }