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
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nmrium",
3
3
  "description": "React component to display and process nuclear magnetic resonance (NMR) spectra.",
4
- "version": "0.24.0",
4
+ "version": "0.26.0",
5
5
  "license": "MIT",
6
6
  "main": "lib-cjs/component/NMRium.js",
7
7
  "module": "lib/component/NMRium.js",
@@ -38,25 +38,25 @@
38
38
  "url": "git+https://github.com/cheminfo/nmrium.git"
39
39
  },
40
40
  "volta": {
41
- "node": "16.14.0"
41
+ "node": "16.14.2"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "react": ">=16.0.0",
45
45
  "react-dom": ">=16.0.0"
46
46
  },
47
47
  "dependencies": {
48
- "@emotion/react": "^11.8.2",
49
- "analysis-ui-components": "^0.10.3",
48
+ "@emotion/react": "^11.9.0",
49
+ "analysis-ui-components": "^0.11.1",
50
50
  "cheminfo-font": "^1.8.1",
51
51
  "cheminfo-types": "^1.1.0",
52
- "d3": "^7.3.0",
52
+ "d3": "^7.4.4",
53
53
  "eventemitter3": "^4.0.7",
54
54
  "file-saver": "^2.0.5",
55
55
  "formik": "^2.2.9",
56
56
  "immer": "^9.0.12",
57
- "jszip": "^3.7.1",
57
+ "jszip": "^3.9.1",
58
58
  "lodash": "^4.17.21",
59
- "mf-parser": "^1.4.5",
59
+ "mf-parser": "^1.4.6",
60
60
  "ml-airpls": "^1.0.0",
61
61
  "ml-array-max": "^1.2.4",
62
62
  "ml-array-mean": "^1.1.6",
@@ -65,30 +65,29 @@
65
65
  "ml-baseline-correction-regression": "^1.0.0",
66
66
  "ml-conrec": "^3.2.1",
67
67
  "ml-gsd": "^10.2.0",
68
- "ml-spectra-processing": "^11.1.0",
68
+ "ml-spectra-processing": "^11.4.0",
69
69
  "ml-stat": "^1.3.3",
70
70
  "multiplet-analysis": "^2.0.0",
71
71
  "nmr-correlation": "^2.2.5",
72
72
  "nmr-parser": "^1.7.3",
73
- "nmr-processing": "^7.4.1",
73
+ "nmr-processing": "^7.4.3",
74
74
  "nmredata": "^0.6.1",
75
75
  "numeral": "^2.0.6",
76
76
  "openchemlib": "^7.4.3",
77
- "openchemlib-utils": "^1.10.0",
78
- "re-resizable": "^6.9.5",
77
+ "openchemlib-utils": "^1.11.0",
78
+ "re-resizable": "^6.9.6",
79
79
  "react-color": "2.17.2",
80
80
  "react-d3-utils": "^0.5.0",
81
- "react-draggable": "^4.4.4",
82
- "react-dropzone": "^12.0.4",
81
+ "react-dropzone": "^12.0.5",
83
82
  "react-error-boundary": "^3.1.4",
84
83
  "react-icons": "^4.3.1",
85
84
  "react-inspector": "^5.1.1",
86
85
  "react-mf": "^2.0.1",
87
86
  "react-ocl": "^4.3.5",
88
- "react-ocl-nmr": "^1.1.0",
89
- "react-plot": "^0.16.0",
90
- "react-rnd": "^10.3.5",
91
- "react-slider": "^1.3.1",
87
+ "react-ocl-nmr": "^1.1.1",
88
+ "react-plot": "^0.17.1",
89
+ "react-rnd": "^10.3.7",
90
+ "react-slider": "^2.0.0",
92
91
  "react-table": "^7.7.0",
93
92
  "react-transition-group": "^4.4.2",
94
93
  "react-use": "^17.3.2",
@@ -96,25 +95,25 @@
96
95
  "yup": "^0.32.11"
97
96
  },
98
97
  "devDependencies": {
99
- "@babel/plugin-transform-modules-commonjs": "^7.17.7",
98
+ "@babel/plugin-transform-modules-commonjs": "^7.17.9",
100
99
  "@babel/preset-react": "^7.16.7",
101
100
  "@babel/preset-typescript": "^7.16.7",
102
- "@playwright/test": "^1.20.1",
101
+ "@playwright/test": "^1.21.1",
103
102
  "@simbathesailor/use-what-changed": "^2.0.0",
104
103
  "@types/d3": "^7.1.0",
105
104
  "@types/jest": "^27.4.1",
106
- "@types/node": "^17.0.23",
105
+ "@types/node": "^17.0.25",
107
106
  "@types/react": "^17.0.43",
108
107
  "@types/react-dom": "^17.0.14",
109
108
  "@types/react-router-dom": "^5.3.3",
110
- "@vitejs/plugin-react": "^1.2.0",
109
+ "@vitejs/plugin-react": "^1.3.1",
111
110
  "@zakodium/eslint-config": "^5.1.1",
112
111
  "cross-env": "^7.0.3",
113
- "eslint": "^8.11.0",
112
+ "eslint": "^8.13.0",
114
113
  "jest": "^27.5.1",
115
114
  "modern-normalize": "^1.1.0",
116
- "prettier": "^2.6.1",
117
- "rc-menu": "^9.5.1",
115
+ "prettier": "^2.6.2",
116
+ "rc-menu": "^9.5.5",
118
117
  "react": "^17.0.2",
119
118
  "react-dom": "^17.0.2",
120
119
  "react-router-dom": "^5.3.0",
@@ -122,6 +121,6 @@
122
121
  "rollup-plugin-analyzer": "^4.0.0",
123
122
  "serve": "^13.0.2",
124
123
  "typescript": "~4.6.3",
125
- "vite": "^2.8.6"
124
+ "vite": "^2.9.5"
126
125
  }
127
- }
126
+ }
@@ -1,12 +0,0 @@
1
- interface ResizedDrop {
2
- from?: number;
3
- to?: number;
4
- }
5
- interface ResizableProps {
6
- from: number;
7
- to: number;
8
- onDrag?: (element: ResizedDrop) => void;
9
- onDrop: (element: ResizedDrop) => void;
10
- }
11
- declare function Resizable({ from, to, onDrag, onDrop }: ResizableProps): import("@emotion/react/jsx-runtime").JSX.Element;
12
- export default Resizable;
@@ -1,105 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
- /** @jsxImportSource @emotion/react */
3
- import { Fragment, useCallback, useRef, useState } from 'react';
4
- import Draggable from 'react-draggable';
5
- import { useChartData } from '../context/ChartContext';
6
- import { useScaleChecked } from '../context/ScaleContext';
7
- function Resizable({ from, to, onDrag = () => null, onDrop }) {
8
- const { height, margin, mode } = useChartData();
9
- const [rightDragVisibility, setRightDragVisibility] = useState(false);
10
- const [leftDragVisibility, setLeftDragVisibility] = useState(false);
11
- const [enable, setEnable] = useState(true);
12
- const draggableRightRef = useRef(null);
13
- const draggableLeftRef = useRef(null);
14
- const { scaleX } = useScaleChecked();
15
- const handleRightStart = useCallback((e) => {
16
- e.preventDefault();
17
- e.stopPropagation();
18
- setRightDragVisibility(true);
19
- }, []);
20
- const handleRightDrag = useCallback((e) => {
21
- onDrag({ from: scaleX().invert(e.layerX) });
22
- }, [onDrag, scaleX]);
23
- const handleRightStop = useCallback((e) => {
24
- e.preventDefault();
25
- e.stopPropagation();
26
- setRightDragVisibility(false);
27
- const _range = mode === 'RTL'
28
- ? [scaleX().invert(e.layerX), to]
29
- : [to, scaleX().invert(e.layerX)];
30
- let resized;
31
- if (_range[1] > _range[0]) {
32
- resized = {
33
- from: _range[0],
34
- to: _range[1],
35
- };
36
- }
37
- else {
38
- resized = {
39
- from,
40
- to,
41
- };
42
- }
43
- onDrop(resized);
44
- }, [from, mode, onDrop, scaleX, to]);
45
- const handleLeftStart = useCallback((e) => {
46
- e.preventDefault();
47
- e.stopPropagation();
48
- setLeftDragVisibility(true);
49
- }, []);
50
- const handleLeftDrag = useCallback((e) => {
51
- onDrag({ to: scaleX().invert(e.layerX) });
52
- }, [onDrag, scaleX]);
53
- const handleLeftStop = useCallback((e) => {
54
- e.preventDefault();
55
- e.stopPropagation();
56
- setLeftDragVisibility(false);
57
- const _range = mode === 'RTL'
58
- ? [from, scaleX().invert(e.layerX)]
59
- : [scaleX().invert(e.layerX), from];
60
- let resized;
61
- if (_range[1] > _range[0]) {
62
- resized = {
63
- from: _range[0],
64
- to: _range[1],
65
- };
66
- }
67
- else {
68
- resized = {
69
- from,
70
- to,
71
- };
72
- }
73
- onDrop(resized);
74
- }, [from, mode, onDrop, scaleX, to]);
75
- const mouseDownCaptureHandler = useCallback(({ shiftKey }) => {
76
- if (shiftKey) {
77
- setEnable(false);
78
- }
79
- }, []);
80
- const mouseUpCaptureHandler = useCallback(() => {
81
- setEnable(true);
82
- }, []);
83
- const mouseOverHandler = useCallback(({ target, shiftKey }) => {
84
- if (shiftKey) {
85
- target.style.cursor = 'crosshair';
86
- }
87
- else {
88
- target.style.cursor = 'ew-resize';
89
- }
90
- }, []);
91
- return (_jsxs(Fragment, { children: [_jsx(Draggable, { axis: "x", defaultPosition: {
92
- x: scaleX()(from),
93
- y: 0,
94
- }, position: {
95
- x: scaleX()(from),
96
- y: 0,
97
- }, scale: 1, handle: ".handle", onStart: handleRightStart, onDrag: handleRightDrag, onStop: handleRightStop, nodeRef: draggableRightRef, children: _jsx("rect", { ref: draggableRightRef, className: enable ? 'handle' : '', width: rightDragVisibility ? 1 : 6, fill: "red", height: height + margin.top, style: { fillOpacity: rightDragVisibility ? 1 : 0 }, onMouseDownCapture: mouseDownCaptureHandler, onMouseUpCapture: mouseUpCaptureHandler, onMouseEnter: mouseOverHandler }) }), _jsx(Draggable, { axis: "x", defaultPosition: {
98
- x: scaleX()(to),
99
- y: 0,
100
- }, position: {
101
- x: scaleX()(to),
102
- y: 0,
103
- }, handle: ".handle", scale: 1, onStart: handleLeftStart, onDrag: handleLeftDrag, onStop: handleLeftStop, nodeRef: draggableLeftRef, children: _jsx("rect", { ref: draggableLeftRef, className: enable ? 'handle' : '', width: leftDragVisibility ? 1 : 6, fill: "red", height: height + margin.top, style: { fillOpacity: leftDragVisibility ? 1 : 0 }, onMouseDownCapture: mouseDownCaptureHandler, onMouseUpCapture: mouseUpCaptureHandler, onMouseEnter: mouseOverHandler }) })] }));
104
- }
105
- export default Resizable;
@@ -1,110 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
7
- /** @jsxImportSource @emotion/react */
8
- const react_1 = require("react");
9
- const react_draggable_1 = __importDefault(require("react-draggable"));
10
- const ChartContext_1 = require("../context/ChartContext");
11
- const ScaleContext_1 = require("../context/ScaleContext");
12
- function Resizable({ from, to, onDrag = () => null, onDrop }) {
13
- const { height, margin, mode } = (0, ChartContext_1.useChartData)();
14
- const [rightDragVisibility, setRightDragVisibility] = (0, react_1.useState)(false);
15
- const [leftDragVisibility, setLeftDragVisibility] = (0, react_1.useState)(false);
16
- const [enable, setEnable] = (0, react_1.useState)(true);
17
- const draggableRightRef = (0, react_1.useRef)(null);
18
- const draggableLeftRef = (0, react_1.useRef)(null);
19
- const { scaleX } = (0, ScaleContext_1.useScaleChecked)();
20
- const handleRightStart = (0, react_1.useCallback)((e) => {
21
- e.preventDefault();
22
- e.stopPropagation();
23
- setRightDragVisibility(true);
24
- }, []);
25
- const handleRightDrag = (0, react_1.useCallback)((e) => {
26
- onDrag({ from: scaleX().invert(e.layerX) });
27
- }, [onDrag, scaleX]);
28
- const handleRightStop = (0, react_1.useCallback)((e) => {
29
- e.preventDefault();
30
- e.stopPropagation();
31
- setRightDragVisibility(false);
32
- const _range = mode === 'RTL'
33
- ? [scaleX().invert(e.layerX), to]
34
- : [to, scaleX().invert(e.layerX)];
35
- let resized;
36
- if (_range[1] > _range[0]) {
37
- resized = {
38
- from: _range[0],
39
- to: _range[1],
40
- };
41
- }
42
- else {
43
- resized = {
44
- from,
45
- to,
46
- };
47
- }
48
- onDrop(resized);
49
- }, [from, mode, onDrop, scaleX, to]);
50
- const handleLeftStart = (0, react_1.useCallback)((e) => {
51
- e.preventDefault();
52
- e.stopPropagation();
53
- setLeftDragVisibility(true);
54
- }, []);
55
- const handleLeftDrag = (0, react_1.useCallback)((e) => {
56
- onDrag({ to: scaleX().invert(e.layerX) });
57
- }, [onDrag, scaleX]);
58
- const handleLeftStop = (0, react_1.useCallback)((e) => {
59
- e.preventDefault();
60
- e.stopPropagation();
61
- setLeftDragVisibility(false);
62
- const _range = mode === 'RTL'
63
- ? [from, scaleX().invert(e.layerX)]
64
- : [scaleX().invert(e.layerX), from];
65
- let resized;
66
- if (_range[1] > _range[0]) {
67
- resized = {
68
- from: _range[0],
69
- to: _range[1],
70
- };
71
- }
72
- else {
73
- resized = {
74
- from,
75
- to,
76
- };
77
- }
78
- onDrop(resized);
79
- }, [from, mode, onDrop, scaleX, to]);
80
- const mouseDownCaptureHandler = (0, react_1.useCallback)(({ shiftKey }) => {
81
- if (shiftKey) {
82
- setEnable(false);
83
- }
84
- }, []);
85
- const mouseUpCaptureHandler = (0, react_1.useCallback)(() => {
86
- setEnable(true);
87
- }, []);
88
- const mouseOverHandler = (0, react_1.useCallback)(({ target, shiftKey }) => {
89
- if (shiftKey) {
90
- target.style.cursor = 'crosshair';
91
- }
92
- else {
93
- target.style.cursor = 'ew-resize';
94
- }
95
- }, []);
96
- return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_draggable_1.default, { axis: "x", defaultPosition: {
97
- x: scaleX()(from),
98
- y: 0,
99
- }, position: {
100
- x: scaleX()(from),
101
- y: 0,
102
- }, scale: 1, handle: ".handle", onStart: handleRightStart, onDrag: handleRightDrag, onStop: handleRightStop, nodeRef: draggableRightRef, children: (0, jsx_runtime_1.jsx)("rect", { ref: draggableRightRef, className: enable ? 'handle' : '', width: rightDragVisibility ? 1 : 6, fill: "red", height: height + margin.top, style: { fillOpacity: rightDragVisibility ? 1 : 0 }, onMouseDownCapture: mouseDownCaptureHandler, onMouseUpCapture: mouseUpCaptureHandler, onMouseEnter: mouseOverHandler }) }), (0, jsx_runtime_1.jsx)(react_draggable_1.default, { axis: "x", defaultPosition: {
103
- x: scaleX()(to),
104
- y: 0,
105
- }, position: {
106
- x: scaleX()(to),
107
- y: 0,
108
- }, handle: ".handle", scale: 1, onStart: handleLeftStart, onDrag: handleLeftDrag, onStop: handleLeftStop, nodeRef: draggableLeftRef, children: (0, jsx_runtime_1.jsx)("rect", { ref: draggableLeftRef, className: enable ? 'handle' : '', width: leftDragVisibility ? 1 : 6, fill: "red", height: height + margin.top, style: { fillOpacity: leftDragVisibility ? 1 : 0 }, onMouseDownCapture: mouseDownCaptureHandler, onMouseUpCapture: mouseUpCaptureHandler, onMouseEnter: mouseOverHandler }) })] }));
109
- }
110
- exports.default = Resizable;