nmrium 0.56.0 → 0.57.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 (167) hide show
  1. package/lib/component/1d/ExclusionZoneAnnotation.d.ts +0 -1
  2. package/lib/component/1d/database/DatabaseSpectrum.js +14 -19
  3. package/lib/component/1d/jCouplingGraph/JGraphContext.d.ts +0 -1
  4. package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.d.ts +0 -1
  5. package/lib/component/1d/peaks/PeakEditionManager.js +16 -10
  6. package/lib/component/1d/utilities/getDecimalsCount.js +1 -1
  7. package/lib/component/1d/utilities/intersectionResolver.js +1 -1
  8. package/lib/component/1d-2d/FieldEdition.d.ts +3 -1
  9. package/lib/component/1d-2d/FieldEdition.js +26 -10
  10. package/lib/component/2d/1d-tracer/Left1DChart.d.ts +0 -1
  11. package/lib/component/2d/1d-tracer/Top1DChart.d.ts +0 -1
  12. package/lib/component/2d/XAxis.d.ts +0 -1
  13. package/lib/component/2d/YAxis.d.ts +0 -1
  14. package/lib/component/2d/ft/Contours.js +7 -7
  15. package/lib/component/assignment/AssignmentsContext.d.ts +0 -1
  16. package/lib/component/context/ChartContext.d.ts +0 -1
  17. package/lib/component/context/DispatchContext.d.ts +0 -1
  18. package/lib/component/context/GlobalContext.d.ts +0 -1
  19. package/lib/component/context/KeyModifierContext.js +1 -1
  20. package/lib/component/context/LoaderContext.d.ts +0 -1
  21. package/lib/component/context/PreferencesContext.d.ts +0 -1
  22. package/lib/component/context/ScaleContext.d.ts +0 -1
  23. package/lib/component/elements/ActionButtons.d.ts +1 -0
  24. package/lib/component/elements/ActionButtons.js +4 -4
  25. package/lib/component/elements/ColorInput.d.ts +0 -1
  26. package/lib/component/elements/ColorPickerDropdownController.d.ts +2 -0
  27. package/lib/component/elements/ColorPickerDropdownController.js +8 -0
  28. package/lib/component/elements/ColumnWrapper.d.ts +0 -1
  29. package/lib/component/elements/ContextMenu.d.ts +0 -1
  30. package/lib/component/elements/Input.d.ts +1 -0
  31. package/lib/component/elements/Input.js +2 -1
  32. package/lib/component/elements/Input2.d.ts +13 -0
  33. package/lib/component/elements/Input2.js +118 -0
  34. package/lib/component/elements/Input2Controller.d.ts +12 -0
  35. package/lib/component/elements/Input2Controller.js +22 -0
  36. package/lib/component/elements/MoleculeSelection.js +1 -1
  37. package/lib/component/elements/NumberInput.js +1 -1
  38. package/lib/component/elements/NumberInput2.d.ts +12 -0
  39. package/lib/component/elements/NumberInput2.js +65 -0
  40. package/lib/component/elements/NumberInput2Controller.d.ts +8 -0
  41. package/lib/component/elements/NumberInput2Controller.js +15 -0
  42. package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +3 -3
  43. package/lib/component/elements/ReactTable/Style.d.ts +3 -1
  44. package/lib/component/elements/ReactTable/Style.js +11 -1
  45. package/lib/component/elements/ReactTable/utility/ReactTableContext.d.ts +0 -1
  46. package/lib/component/elements/Select2.d.ts +26 -0
  47. package/lib/component/elements/Select2.js +25 -0
  48. package/lib/component/elements/Select2Controller.d.ts +7 -0
  49. package/lib/component/elements/Select2Controller.js +12 -0
  50. package/lib/component/elements/draggable/useDraggable.d.ts +0 -1
  51. package/lib/component/elements/dropDownButton/DropDownButton.d.ts +2 -4
  52. package/lib/component/elements/dropDownButton/DropDownButton.js +11 -37
  53. package/lib/component/elements/dropDownButton/DropDownList.js +3 -32
  54. package/lib/component/elements/formik/FormikColorPicker.d.ts +0 -1
  55. package/lib/component/elements/formik/FormikColumnFormatField.d.ts +0 -1
  56. package/lib/component/elements/formik/FormikInput.d.ts +0 -1
  57. package/lib/component/elements/formik/FormikInput2.d.ts +11 -0
  58. package/lib/component/elements/formik/FormikInput2.js +26 -0
  59. package/lib/component/elements/formik/FormikOnChange.d.ts +0 -1
  60. package/lib/component/elements/popup/Modal/Context.d.ts +0 -1
  61. package/lib/component/elements/popup/Modal/ModalContent.d.ts +0 -1
  62. package/lib/component/elements/resizer/SVGResizer.d.ts +0 -1
  63. package/lib/component/elements/useFormValidateField.d.ts +1 -0
  64. package/lib/component/elements/useFormValidateField.js +9 -0
  65. package/lib/component/header/ApodizationOptionsPanel.js +26 -11
  66. package/lib/component/header/AutoPeakPickingOptionPanel.d.ts +1 -4
  67. package/lib/component/header/AutoPeakPickingOptionPanel.js +16 -16
  68. package/lib/component/header/BaseLineCorrectionPanel.js +49 -27
  69. package/lib/component/header/Header.js +1 -1
  70. package/lib/component/header/PhaseCorrectionPanel.js +12 -24
  71. package/lib/component/header/RangesPickingOptionPanel.js +12 -12
  72. package/lib/component/header/ZeroFillingOptionsPanel.js +18 -7
  73. package/lib/component/header/Zones2DOptionPanel.js +19 -18
  74. package/lib/component/hooks/useWorkspaceAction.d.ts +1 -1
  75. package/lib/component/modal/editRange/forms/components/SignalTab.d.ts +0 -1
  76. package/lib/component/modal/editRange/forms/components/SignalsContent.d.ts +0 -1
  77. package/lib/component/modal/setting/GeneralSettings.d.ts +5 -1
  78. package/lib/component/modal/setting/GeneralSettings.js +107 -111
  79. package/lib/component/modal/setting/WorkspaceItem.js +4 -9
  80. package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.d.ts +1 -1
  81. package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.js +95 -59
  82. package/lib/component/modal/setting/settings-tabs/DisplayTabContent.js +33 -25
  83. package/lib/component/modal/setting/settings-tabs/GeneralTabContent.js +15 -4
  84. package/lib/component/modal/setting/settings-tabs/ImportationFiltersTabContent.js +56 -39
  85. package/lib/component/modal/setting/settings-tabs/InfoBlockTabContent.js +36 -36
  86. package/lib/component/modal/setting/settings-tabs/NucleiTabContent.js +44 -36
  87. package/lib/component/modal/setting/settings-tabs/OnLoadProcessingTabContent.js +16 -11
  88. package/lib/component/modal/setting/settings-tabs/SpectraColorsTabContent.js +47 -40
  89. package/lib/component/modal/setting/settings-tabs/ToolsTabContent.js +50 -40
  90. package/lib/component/modal/setting/settingsValidation.js +8 -34
  91. package/lib/component/panels/AutomaticAssignment/AutomaticAssignmentTable.d.ts +0 -1
  92. package/lib/component/panels/IntegralsPanel/IntegralTable.d.ts +0 -1
  93. package/lib/component/panels/IntegralsPanel/IntegralsPreferences.d.ts +0 -1
  94. package/lib/component/panels/Panels.js +31 -8
  95. package/lib/component/panels/PeaksPanel/PeaksPreferences.d.ts +0 -1
  96. package/lib/component/panels/PeaksPanel/PeaksTable.d.ts +0 -1
  97. package/lib/component/panels/RangesPanel/RangesPreferences.d.ts +0 -1
  98. package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.d.ts +0 -1
  99. package/lib/component/panels/SpectraPanel/SpectraPreferences.d.ts +0 -1
  100. package/lib/component/panels/SpectraPanel/SpectraPreferences.js +32 -24
  101. package/lib/component/panels/SpectraPanel/SpectraTable.js +17 -2
  102. package/lib/component/panels/SpectraPanel/SpectrumListPanel.d.ts +0 -1
  103. package/lib/component/panels/SpectraPanel/base/ColorIndicator.d.ts +0 -1
  104. package/lib/component/panels/SpectraPanel/base/SpectraColumnsManager.d.ts +3 -3
  105. package/lib/component/panels/SpectraPanel/base/SpectraColumnsManager.js +25 -16
  106. package/lib/component/panels/SpectraPanel/base/setting/Spectrum1DHistogram.d.ts +0 -1
  107. package/lib/component/panels/SpectraPanel/base/setting/Spectrum1DSetting.js +15 -5
  108. package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DHistogram.d.ts +0 -1
  109. package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DSetting.js +44 -6
  110. package/lib/component/panels/SpectraPanel/base/setting/SpectrumSetting.d.ts +0 -1
  111. package/lib/component/panels/SummaryPanel/Overview.d.ts +0 -1
  112. package/lib/component/panels/SummaryPanel/SummaryPanel.d.ts +0 -1
  113. package/lib/component/panels/SummaryPanel/utilities/Utilities.d.ts +1 -1
  114. package/lib/component/panels/ZonesPanel/ZonesPreferences.d.ts +0 -1
  115. package/lib/component/panels/databasePanel/DatabasePanel.js +17 -3
  116. package/lib/component/panels/databasePanel/DatabasePreferences.d.ts +0 -1
  117. package/lib/component/panels/databasePanel/DatabaseTable.d.ts +11 -4
  118. package/lib/component/panels/databasePanel/DatabaseTable.js +20 -5
  119. package/lib/component/panels/informationPanel/InformationEditionModal.d.ts +6 -0
  120. package/lib/component/panels/informationPanel/InformationEditionModal.js +105 -0
  121. package/lib/component/panels/informationPanel/InformationPanel.d.ts +1 -0
  122. package/lib/component/panels/{InformationPanel.js → informationPanel/InformationPanel.js} +2 -2
  123. package/lib/component/panels/multipleAnalysisPanel/preferences/MultipleAnalysisCodeEditor.d.ts +0 -1
  124. package/lib/component/panels/multipleAnalysisPanel/preferences/index.d.ts +0 -1
  125. package/lib/component/panels/predictionPanel/PredictionOptionsPanel.d.ts +0 -1
  126. package/lib/component/panels/predictionPanel/PredictionOptionsPanel.js +1 -1
  127. package/lib/component/panels/predictionPanel/PredictionPreferences.d.ts +0 -1
  128. package/lib/component/panels/spectrumSimulation/SpectrumSimulationPreferences.d.ts +0 -1
  129. package/lib/component/reducer/Reducer.d.ts +1 -1
  130. package/lib/component/reducer/Reducer.js +2 -0
  131. package/lib/component/reducer/actions/DatabaseActions.js +22 -5
  132. package/lib/component/reducer/actions/SpectraActions.d.ts +8 -2
  133. package/lib/component/reducer/actions/SpectraActions.js +58 -21
  134. package/lib/component/reducer/actions/ToolsActions.js +3 -4
  135. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.d.ts +7 -7
  136. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +2 -0
  137. package/lib/component/reducer/preferences/preferencesReducer.d.ts +1 -1
  138. package/lib/component/utility/checkUniqueByKey.d.ts +2 -0
  139. package/lib/component/utility/checkUniqueByKey.js +40 -0
  140. package/lib/component/utility/colorToHexWithAlpha.d.ts +9 -0
  141. package/lib/component/utility/colorToHexWithAlpha.js +4 -0
  142. package/lib/component/workspaces/exercise.js +2 -0
  143. package/lib/component/workspaces/process1D.js +0 -1
  144. package/lib/component/workspaces/workspaceDefaultProperties.js +1 -0
  145. package/lib/data/PredictionManager.js +3 -5
  146. package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +13 -13
  147. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +9 -9
  148. package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +13 -13
  149. package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +13 -13
  150. package/lib/data/data1d/database.d.ts +1 -0
  151. package/lib/data/data1d/database.js +4 -2
  152. package/lib/data/data2d/Spectrum2D/contours.d.ts +8 -22
  153. package/lib/data/data2d/Spectrum2D/contours.js +88 -67
  154. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +4 -2
  155. package/lib/data/data2d/Spectrum2D/zones/detectZonesManual.d.ts +20 -20
  156. package/lib/data/data2d/Spectrum2D/zones/initiateZones.d.ts +20 -20
  157. package/lib/data/getDefaultMatrixFilters.d.ts +1 -1
  158. package/lib/data/initiateFilters.d.ts +1 -1
  159. package/lib/data/matrixGeneration.js +1 -2
  160. package/lib/data/types/common/Keys.d.ts +3 -0
  161. package/lib/data/types/common/Keys.js +1 -0
  162. package/lib/data/utilities/generateNumbersPowerOfX.d.ts +2 -2
  163. package/lib/versionInfo.js +1 -1
  164. package/package.json +32 -31
  165. package/lib/component/elements/formik/FormikSlider.d.ts +0 -6
  166. package/lib/component/elements/formik/FormikSlider.js +0 -15
  167. package/lib/component/panels/InformationPanel.d.ts +0 -1
@@ -1,17 +1,18 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
3
  import { Dialog, DialogBody, DialogFooter, Classes, Tabs, Tab, } from '@blueprintjs/core';
4
4
  import { css } from '@emotion/react';
5
- import { Formik } from 'formik';
6
- import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
5
+ import styled from '@emotion/styled';
6
+ import { yupResolver } from '@hookform/resolvers/yup';
7
+ import { useCallback, useEffect, useMemo, useRef } from 'react';
8
+ import { FormProvider, useForm, useFormContext, useWatch, } from 'react-hook-form';
7
9
  import { FaBolt, FaPaste, FaRegCopy, FaWrench } from 'react-icons/fa';
8
- import { Toolbar, useOnOff } from 'react-science/ui';
10
+ import { Button, Toolbar, useOnOff } from 'react-science/ui';
9
11
  import { ClipboardFallbackModal } from '../../../utils/clipboard/clipboardComponents';
10
12
  import { useClipboard } from '../../../utils/clipboard/clipboardHooks';
11
13
  import { usePreferences, useWorkspacesList, } from '../../context/PreferencesContext';
12
14
  import { useToaster } from '../../context/ToasterContext';
13
15
  import ActionButtons from '../../elements/ActionButtons';
14
- import Button from '../../elements/Button';
15
16
  import Label from '../../elements/Label';
16
17
  import DropDownButton from '../../elements/dropDownButton/DropDownButton';
17
18
  import { useSaveSettings } from '../../hooks/useSaveSettings';
@@ -29,36 +30,13 @@ import OnLoadProcessingTabContent from './settings-tabs/OnLoadProcessingTabConte
29
30
  import SpectraColorsTabContent from './settings-tabs/SpectraColorsTabContent';
30
31
  import ToolsTabContent from './settings-tabs/ToolsTabContent';
31
32
  import { validation } from './settingsValidation';
32
- const styles = css `
33
- .section-header {
34
- font-size: 13px;
35
- color: #2ca8ff;
36
- margin-bottom: 10px;
37
- border-bottom: 0.55px solid #f9f9f9;
38
- padding: 6px 2px;
39
- }
40
-
41
- .label {
42
- font-size: 12px;
43
- font-weight: bold;
44
- margin-right: 10px;
45
- }
46
-
47
- .input {
48
- font-size: 14px;
49
- padding: 3px;
50
- }
51
-
52
- .checkbox-label {
53
- min-width: 300px;
54
- display: inline-block;
55
- }
56
-
57
- .help-checkbox-element {
58
- .checkbox-label {
59
- width: 260px;
60
- }
61
- }
33
+ export const Section = styled.div `
34
+ display: flex;
35
+ font-size: 13px;
36
+ color: #2ca8ff;
37
+ margin-bottom: 10px;
38
+ border-bottom: 0.55px solid #f9f9f9;
39
+ padding: 6px 2px;
62
40
  `;
63
41
  function isRestButtonDisable(currentWorkspaceSetting, workspaceName, customWorkspaces) {
64
42
  if (!PredefinedWorkspaces[workspaceName] &&
@@ -70,79 +48,51 @@ function isRestButtonDisable(currentWorkspaceSetting, workspaceName, customWorks
70
48
  JSON.stringify(getPreferencesByWorkspace(workspaceName, customWorkspaces)));
71
49
  }
72
50
  }
73
- function GeneralSettingsModal({ height }) {
51
+ function GeneralSettingsModal(props) {
52
+ const { ...otherProps } = props;
74
53
  const [isOpenDialog, openDialog, closeDialog] = useOnOff(false);
75
- const { dispatch, current: currentWorkspace, originalWorkspaces, ...preferences } = usePreferences();
76
- const { addNewWorkspace, removeWorkspace, setActiveWorkspace } = useWorkspaceAction();
77
54
  const { saveSettings, SaveSettingsModal } = useSaveSettings();
78
- const toaster = useToaster();
79
- const refForm = useRef(null);
80
- const workspaces = useWorkspacesList();
55
+ return (_jsxs(_Fragment, { children: [_jsx(Toolbar.Item, { id: "general-settings", onClick: openDialog, tooltip: "General settings", icon: _jsx(FaWrench, {}) }), _jsx(SaveSettingsModal, {}), isOpenDialog && (_jsx(InnerGeneralSettingsModal, { ...otherProps, onCloseDialog: closeDialog, onSave: saveSettings }))] }));
56
+ }
57
+ function InnerGeneralSettingsModal(props) {
58
+ const { height, onCloseDialog, onSave } = props;
59
+ const { dispatch, current: currentWorkspace, originalWorkspaces, workspaces, ...preferences } = usePreferences();
60
+ const { addNewWorkspace, removeWorkspace, setActiveWorkspace } = useWorkspaceAction();
61
+ const baseWorkspaces = useWorkspacesList();
81
62
  const workspaceName = preferences.workspace.current;
82
- const [isRestDisabled, setRestDisabled] = useState(isRestButtonDisable(currentWorkspace, workspaceName, originalWorkspaces));
83
63
  const pastRef = useRef(null);
64
+ const methods = useForm({
65
+ defaultValues: currentWorkspace,
66
+ resolver: yupResolver(validation),
67
+ });
68
+ const { reset, getValues } = methods;
84
69
  const workspacesList = useMemo(() => {
85
- return workspaces.concat([
70
+ return baseWorkspaces.concat([
86
71
  {
87
72
  key: 'new',
88
73
  label: 'Custom workspace',
89
74
  },
90
75
  ]);
91
- }, [workspaces]);
92
- const handleReset = () => {
93
- const workSpaceDisplayPreferences = getPreferencesByWorkspace(workspaceName, originalWorkspaces);
94
- void refForm.current?.setValues(workSpaceDisplayPreferences);
95
- };
96
- function submitHandler(values) {
97
- saveSettings(values);
98
- closeDialog?.();
99
- }
76
+ }, [baseWorkspaces]);
100
77
  function addWorkSpaceHandler(name) {
101
- addNewWorkspace(name, refForm.current?.values);
102
- }
103
- async function applyPreferencesHandler() {
104
- const errors = await refForm.current?.validateForm();
105
- if (Object.keys(errors || {}).length > 0) {
106
- refForm.current?.handleSubmit();
107
- }
108
- else {
109
- dispatch({
110
- type: 'APPLY_General_PREFERENCES',
111
- payload: {
112
- data: refForm.current?.values,
113
- },
114
- });
115
- closeDialog?.();
116
- }
78
+ addNewWorkspace(name, getValues());
117
79
  }
118
80
  function deleteWorkSpaceHandler(key) {
119
81
  removeWorkspace(key);
120
82
  }
121
83
  function ChangeWorkspaceHandler(option) {
122
84
  setActiveWorkspace(option.key);
85
+ reset(workspaces[option.key]);
123
86
  }
124
87
  function renderItem(item) {
125
88
  return (_jsx(WorkspaceItem, { item: item, onSave: addWorkSpaceHandler, onDelete: deleteWorkSpaceHandler }));
126
89
  }
127
- function handleDisabledRestButton(values) {
128
- setRestDisabled(isRestButtonDisable(values, workspaceName, originalWorkspaces));
129
- }
130
- const { readText, rawWriteWithType, shouldFallback, cleanShouldFallback, text, } = useClipboard();
131
- function handleCopyWorkspace() {
132
- const data = { [workspaceName]: refForm.current?.values };
133
- void rawWriteWithType(JSON.stringify(data)).then(() => {
134
- toaster.show({
135
- message: 'Workspace copied to clipboard',
136
- intent: 'success',
137
- });
138
- });
139
- }
140
90
  const setWorkspaceSetting = useCallback((inputWorkspace) => {
141
91
  const parseWorkspaceName = Object.keys(inputWorkspace)[0];
142
92
  if (preferences.workspace.current === parseWorkspaceName) {
143
- void refForm.current?.setValues(inputWorkspace[parseWorkspaceName]);
93
+ reset(inputWorkspace[parseWorkspaceName]);
144
94
  }
145
- else if (preferences.workspaces[parseWorkspaceName]) {
95
+ else if (workspaces[parseWorkspaceName]) {
146
96
  pastRef.current = inputWorkspace;
147
97
  dispatch({
148
98
  type: 'SET_WORKSPACE',
@@ -152,19 +102,52 @@ function GeneralSettingsModal({ height }) {
152
102
  },
153
103
  });
154
104
  }
155
- }, [dispatch, preferences.workspace, preferences.workspaces]);
105
+ }, [dispatch, preferences.workspace, workspaces, reset]);
156
106
  useEffect(() => {
157
107
  if (pastRef.current) {
158
108
  setWorkspaceSetting(pastRef.current);
159
109
  pastRef.current = null;
160
110
  }
161
111
  }, [setWorkspaceSetting]);
112
+ return (_jsx(FormProvider, { ...methods, children: _jsxs(Dialog, { isOpen: true, onClose: onCloseDialog, style: { maxWidth: 1000, width: '50vw', minWidth: 800 }, title: "General settings", icon: "cog", children: [_jsx("div", { children: _jsxs("div", { className: Classes.DIALOG_HEADER, style: {
113
+ cursor: 'default',
114
+ paddingTop: '10px',
115
+ boxShadow: 'none',
116
+ backgroundColor: '#f8f8f8',
117
+ }, children: [_jsx(Label, { title: "Workspace", children: _jsx(DropDownButton, { data: workspacesList, renderItem: renderItem, selectedKey: preferences.workspace.current, onSelect: ChangeWorkspaceHandler }) }), _jsx(WorkSpaceActionsButtons, { onPast: (workspaceSettings) => setWorkspaceSetting(workspaceSettings) })] }) }), _jsx(DialogBody, { css: css `
118
+ padding: 0;
119
+ background-color: white;
120
+ `, children: _jsx("div", { style: { height }, children: _jsxs(Tabs, { vertical: true, css: css `
121
+ height: 100%;
122
+
123
+ div[role='tablist'] {
124
+ gap: 0;
125
+ }
126
+
127
+ div[role='tabpanel'] {
128
+ width: 100%;
129
+ padding: 0.8rem;
130
+ overflow: auto;
131
+ max-height: 100%;
132
+ }
133
+ `, children: [_jsx(Tab, { title: "General", id: "general", panel: _jsx(GeneralTabContent, {}) }), _jsx(Tab, { title: "Nuclei", id: "nuclei", panel: _jsx(NucleiTabContent, {}) }), _jsx(Tab, { title: "Panels", id: "display", panel: _jsx(DisplayTabContent, {}) }), _jsx(Tab, { title: "Tools", id: "tools", panel: _jsx(ToolsTabContent, {}) }), _jsx(Tab, { title: "Databases", id: "databases", panel: _jsx(DatabasesTabContent, { currentWorkspace: workspaceName, originalWorkspaces: originalWorkspaces }) }), _jsx(Tab, { title: "Import filters", id: "importation-filters", panel: _jsx(ImportationFiltersTabContent, {}) }), _jsx(Tab, { title: "Title block", id: "title-block", panel: _jsx(InfoBlockTabContent, {}) }), _jsx(Tab, { title: "Auto processing", id: "on-load-processing", panel: _jsx(OnLoadProcessingTabContent, {}) }), _jsx(Tab, { title: "Spectra colors", id: "spectra-colors", panel: _jsx(SpectraColorsTabContent, {}) })] }) }) }), _jsx(DialogFooter, { children: _jsx(DialogActionButtons, { onCloseDialog: onCloseDialog, onSave: onSave }) })] }) }));
134
+ }
135
+ function WorkSpaceActionsButtons(props) {
136
+ const { readText, rawWriteWithType, shouldFallback, cleanShouldFallback, text, } = useClipboard();
137
+ const toaster = useToaster();
138
+ const { reset } = useFormContext();
139
+ const values = useWatch();
140
+ const { originalWorkspaces, workspace: { current: workspaceName }, } = usePreferences();
141
+ function handleReset() {
142
+ const workSpaceDisplayPreferences = getPreferencesByWorkspace(workspaceName, originalWorkspaces);
143
+ reset(workSpaceDisplayPreferences);
144
+ }
162
145
  function handlePastWorkspace(text) {
163
146
  if (!text)
164
147
  return;
165
148
  try {
166
149
  const parseWorkspaces = JSON.parse(text);
167
- setWorkspaceSetting(parseWorkspaces);
150
+ props.onPast(parseWorkspaces);
168
151
  }
169
152
  catch {
170
153
  toaster.show({ message: 'object parse error', intent: 'danger' });
@@ -174,31 +157,44 @@ function GeneralSettingsModal({ height }) {
174
157
  function handlePastWorkspaceAction() {
175
158
  void readText().then(handlePastWorkspace);
176
159
  }
177
- return (_jsxs(_Fragment, { children: [_jsx(Toolbar.Item, { id: "general-settings", onClick: openDialog, tooltip: "General settings", icon: _jsx(FaWrench, {}) }), _jsxs(Dialog, { isOpen: isOpenDialog, onClose: closeDialog, style: { maxWidth: 1000, width: '50vw', minWidth: 800 }, title: "General settings", icon: "cog", children: [_jsx("div", { children: _jsxs("div", { className: Classes.DIALOG_HEADER, style: {
178
- cursor: 'default',
179
- paddingTop: '10px',
180
- boxShadow: 'none',
181
- backgroundColor: '#f8f8f8',
182
- }, children: [_jsx(Label, { title: "Workspace", children: _jsx(DropDownButton, { data: workspacesList, renderItem: renderItem, selectedKey: preferences.workspace.current, onSelect: ChangeWorkspaceHandler }) }), _jsx(Button.Action, { size: "xSmall", onClick: handleReset, toolTip: "Reset workspace preferences", tooltipOrientation: "horizontal", style: {
183
- marginLeft: '10px',
184
- }, disabled: isRestDisabled, children: _jsx(FaBolt, {}) }), _jsx(Button.Done, { size: "xSmall", fill: "outline", onClick: handleCopyWorkspace, toolTip: "Copy workspace preferences", tooltipOrientation: "horizontal", style: {
185
- marginLeft: '10px',
186
- }, children: _jsx(FaRegCopy, {}) }), _jsx(Button.Action, { size: "xSmall", fill: "outline", onClick: handlePastWorkspaceAction, toolTip: "Past workspace preferences", tooltipOrientation: "horizontal", style: {
187
- marginLeft: '10px',
188
- }, children: _jsx(FaPaste, {}) })] }) }), _jsx(DialogBody, { css: css `
189
- padding: 0;
190
- background-color: white;
191
- `, children: _jsx("div", { css: styles, style: { height }, children: _jsx(Formik, { enableReinitialize: true, innerRef: refForm, initialValues: currentWorkspace, validationSchema: validation, onSubmit: submitHandler, validate: handleDisabledRestButton, children: _jsxs(Tabs, { vertical: true, css: css `
192
- height: 100%;
193
-
194
- div[role='tabpanel'] {
195
- width: 100%;
196
- padding: 0.8rem;
197
- overflow: auto;
198
- max-height: 100%;
199
- }
200
- `, fill: true, children: [_jsx(Tab, { title: "General", id: "general", panel: _jsx(GeneralTabContent, {}) }), _jsx(Tab, { title: "Nuclei", id: "nuclei", panel: _jsx(NucleiTabContent, {}) }), _jsx(Tab, { title: "Panels", id: "display", panel: _jsx(DisplayTabContent, {}) }), _jsx(Tab, { title: "Tools", id: "tools", panel: _jsx(ToolsTabContent, {}) }), _jsx(Tab, { title: "Databases", id: "databases", panel: _jsx(DatabasesTabContent, { currentWorkspace: workspaceName, originalWorkspaces: originalWorkspaces }) }), _jsx(Tab, { title: "Import filters", id: "importation-filters", panel: _jsx(ImportationFiltersTabContent, {}) }), _jsx(Tab, { title: "Title block", id: "title-block", panel: _jsx(InfoBlockTabContent, {}) }), _jsx(Tab, { title: "Auto processing", id: "on-load-processing", panel: _jsx(OnLoadProcessingTabContent, {}) }), _jsx(Tab, { title: "Spectra colors", id: "spectra-colors", panel: _jsx(SpectraColorsTabContent, {}) })] }) }) }) }), _jsx(DialogFooter, { children: _jsxs("div", { style: { display: 'flex', justifyContent: 'flex-end' }, children: [_jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: () => refForm.current?.submitForm(), doneLabel: "Apply and Save", onCancel: () => {
201
- closeDialog?.();
202
- } }), _jsx(Button.Secondary, { style: { margin: '0 10px' }, onClick: applyPreferencesHandler, children: "Apply" })] }) })] }), _jsx(SaveSettingsModal, {}), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, onReadText: handlePastWorkspace, text: text, label: "Workspace" })] }));
160
+ function handleCopyWorkspace() {
161
+ const data = { [workspaceName]: values };
162
+ void rawWriteWithType(JSON.stringify(data)).then(() => {
163
+ toaster.show({
164
+ message: 'Workspace copied to clipboard',
165
+ intent: 'success',
166
+ });
167
+ });
168
+ }
169
+ return (_jsxs("div", { style: {
170
+ display: 'flex',
171
+ justifyContent: 'flex-start',
172
+ padding: '0 3px',
173
+ }, children: [_jsx(Button, { outlined: true, intent: "primary", onClick: handleReset, tooltipProps: { content: 'Reset workspace preferences', compact: true }, disabled: isRestButtonDisable(values, workspaceName, originalWorkspaces), children: _jsx(FaBolt, { className: Classes.ICON }) }), _jsx(Button, { outlined: true, onClick: handleCopyWorkspace, tooltipProps: { content: 'Copy workspace preferences', compact: true }, css: css({ margin: '0 5px' }), children: _jsx(FaRegCopy, { className: Classes.ICON }) }), _jsx(Button, { outlined: true, intent: "success", onClick: handlePastWorkspaceAction, tooltipProps: { content: 'Past workspace preferences', compact: true }, children: _jsx(FaPaste, { className: Classes.ICON }) }), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, onReadText: handlePastWorkspace, text: text, label: "Workspace" })] }));
174
+ }
175
+ function DialogActionButtons(props) {
176
+ const { onSave, onCloseDialog } = props;
177
+ const { handleSubmit, formState: { isValid }, } = useFormContext();
178
+ const { dispatch } = usePreferences();
179
+ const values = useWatch();
180
+ function submitHandler(values) {
181
+ onSave(values);
182
+ onCloseDialog?.();
183
+ }
184
+ function applyPreferencesHandler() {
185
+ if (!isValid) {
186
+ return handleSubmit(submitHandler)();
187
+ }
188
+ dispatch({
189
+ type: 'APPLY_General_PREFERENCES',
190
+ payload: {
191
+ data: values,
192
+ },
193
+ });
194
+ props.onCloseDialog?.();
195
+ }
196
+ return (_jsxs("div", { style: { display: 'flex', justifyContent: 'flex-end' }, children: [_jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: () => handleSubmit(submitHandler)(), doneLabel: "Apply and Save", onCancel: () => {
197
+ props.onCloseDialog?.();
198
+ } }), _jsx(Button, { intent: "primary", css: css({ margin: '0 10px' }), onClick: applyPreferencesHandler, children: "Apply" })] }));
203
199
  }
204
200
  export default GeneralSettingsModal;
@@ -1,7 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
- import { FaTimes } from 'react-icons/fa';
4
- import Button from '../../elements/Button';
3
+ import { Button } from 'react-science/ui';
5
4
  const styles = {
6
5
  container: {
7
6
  display: 'flex',
@@ -11,12 +10,8 @@ const styles = {
11
10
  workspaceName: {
12
11
  flex: '1',
13
12
  textAlign: 'left',
14
- fontSize: '11px',
15
- padding: '5px',
16
- },
17
- workspaceVersion: {
18
- fontSize: '9px',
19
- padding: '5px',
13
+ fontSize: '12px',
14
+ padding: '0.5rem',
20
15
  },
21
16
  readOnly: {
22
17
  fontSize: '9px',
@@ -54,7 +49,7 @@ function WorkspaceItem({ item, onSave, onDelete }) {
54
49
  function onTextChange(e) {
55
50
  setName(e.target.value);
56
51
  }
57
- return (_jsx("div", { children: item.key === 'new' ? (_jsxs("div", { style: styles.newContainer, children: [_jsx("input", { style: styles.input, value: name, placeholder: "Custom workspace", onClick: (e) => e.stopPropagation(), onChange: onTextChange }), _jsx(Button.Done, { onClick: addHandler, disabled: !name, style: { fontSize: '11px' }, children: "Save" })] })) : (_jsxs("div", { style: styles.container, children: [_jsx(WorkSpaceIndicator, { source: item.source }), _jsx("span", { style: styles.workspaceName, children: item.label }), item.source !== 'user' && (_jsx("span", { style: styles.readOnly, children: "Read Only" })), item.source === 'user' && onDelete && (_jsx(Button.Danger, { onClick: deleteHandler, size: "xSmall", fill: "clear", children: _jsx(FaTimes, {}) }))] })) }));
52
+ return (_jsx("div", { children: item.key === 'new' ? (_jsxs("div", { style: styles.newContainer, children: [_jsx("input", { style: styles.input, value: name, placeholder: "Custom workspace", onClick: (e) => e.stopPropagation(), onChange: onTextChange }), _jsx(Button, { intent: "success", onClick: addHandler, disabled: !name, style: { fontSize: '11px' }, children: "Save" })] })) : (_jsxs("div", { style: styles.container, children: [_jsx(WorkSpaceIndicator, { source: item.source }), _jsx("span", { style: styles.workspaceName, children: item.label }), item.source !== 'user' && (_jsx("span", { style: styles.readOnly, children: "Read Only" })), item.source === 'user' && onDelete && (_jsx(Button, { minimal: true, intent: "danger", onClick: deleteHandler, small: true, icon: "cross" }))] })) }));
58
53
  }
59
54
  const style = {
60
55
  width: '20px',
@@ -4,5 +4,5 @@ interface DatabasesTabContentProps {
4
4
  currentWorkspace: NMRiumWorkspace;
5
5
  originalWorkspaces: CustomWorkspaces;
6
6
  }
7
- declare function DatabasesTabContent({ currentWorkspace, originalWorkspaces, }: DatabasesTabContentProps): import("react/jsx-runtime").JSX.Element;
7
+ declare function DatabasesTabContent({ currentWorkspace, originalWorkspaces, }: DatabasesTabContentProps): import("@emotion/react/jsx-runtime").JSX.Element;
8
8
  export default DatabasesTabContent;
@@ -1,77 +1,113 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ /** @jsxImportSource @emotion/react */
3
+ import { Checkbox, Classes, Radio } from '@blueprintjs/core';
4
+ import { css } from '@emotion/react';
2
5
  import { v4 } from '@lukeed/uuid';
3
- import { Field, useFormikContext } from 'formik';
4
- import { FaLink, FaPlus, FaTimes } from 'react-icons/fa';
5
- import Button from '../../../elements/Button';
6
+ import { useCallback, useMemo } from 'react';
7
+ import { Controller, useFormContext, useWatch } from 'react-hook-form';
8
+ import { FaPlus, FaRegTrashAlt, FaLink } from 'react-icons/fa';
9
+ import { Button } from 'react-science/ui';
6
10
  import { GroupPane } from '../../../elements/GroupPane';
7
- import FormikCheckBox from '../../../elements/formik/FormikCheckBox';
8
- import FormikInput from '../../../elements/formik/FormikInput';
11
+ import { Input2Controller } from '../../../elements/Input2Controller';
12
+ import ReactTable from '../../../elements/ReactTable/ReactTable';
9
13
  import { getPreferencesByWorkspace } from '../../../reducer/preferences/utilities/getPreferencesByWorkspace';
10
14
  import { isGoogleDocument } from '../../../utility/isGoogleDocument';
11
- const style = {
12
- table: {
13
- width: '100%',
14
- },
15
- th: {
16
- fontSize: '12px',
17
- },
18
- input: {
19
- width: '100%',
20
- },
21
- labelCol: {
22
- width: '30%',
23
- },
24
- serialCol: {
25
- width: '5%',
26
- },
27
- checkbox: {
28
- display: 'block',
29
- margin: '0 auto',
30
- width: 'fit-content',
31
- },
32
- };
15
+ import { Section } from '../GeneralSettings';
16
+ function getKeyPath(index, key) {
17
+ return `databases.data.${index}.${key}`;
18
+ }
33
19
  function DatabasesTabContent({ currentWorkspace, originalWorkspaces, }) {
34
- const { values, setFieldValue } = useFormikContext();
35
- const databases = values.databases;
36
- function deleteHandler(index) {
37
- const _database = databases.data.slice();
38
- _database.splice(index, 1);
39
- void setFieldValue('databases.data', _database);
40
- }
41
- function addHandler() {
42
- const newDatabase = {
20
+ const { setValue, register, control } = useFormContext();
21
+ const databases = useWatch({
22
+ name: 'databases.data',
23
+ }) || [];
24
+ const addHandler = useCallback((data, index = 0) => {
25
+ let databases = [];
26
+ const emptyField = {
43
27
  key: v4(),
44
28
  label: '',
45
29
  url: '',
46
30
  enabled: true,
47
31
  };
48
- void setFieldValue('databases.data', [...databases.data, newDatabase]);
49
- }
32
+ if (data && Array.isArray(data)) {
33
+ databases = [...data.slice(0, index), emptyField, ...data.slice(index)];
34
+ }
35
+ else {
36
+ databases.push(emptyField);
37
+ }
38
+ setValue('databases.data', databases);
39
+ }, [setValue]);
40
+ const deleteHandler = useCallback((data, index) => {
41
+ const databases = data.filter((_, columnIndex) => columnIndex !== index);
42
+ setValue('databases.data', databases);
43
+ }, [setValue]);
44
+ const COLUMNS = useMemo(() => [
45
+ {
46
+ Header: '#',
47
+ style: { width: '25px', textAlign: 'center' },
48
+ accessor: (_, index) => index + 1,
49
+ },
50
+ {
51
+ Header: 'Label',
52
+ style: { minWidth: '150px' },
53
+ Cell: ({ row }) => {
54
+ const name = getKeyPath(row.index, 'label');
55
+ return (_jsx(Input2Controller, { control: control, name: name, noShadowBox: true, style: { backgroundColor: 'transparent' } }));
56
+ },
57
+ },
58
+ {
59
+ Header: 'URL',
60
+ style: { width: '100%' },
61
+ Cell: ({ row }) => {
62
+ const name = getKeyPath(row.index, 'url');
63
+ return (_jsx(Input2Controller, { control: control, name: name, noShadowBox: true, style: { backgroundColor: 'transparent' } }));
64
+ },
65
+ },
66
+ {
67
+ Header: 'Enabled',
68
+ style: { width: '30px', textAlign: 'center' },
69
+ Cell: ({ row }) => (_jsx(Checkbox, { style: { margin: 0 }, ...register(getKeyPath(row.index, 'enabled')) })),
70
+ },
71
+ {
72
+ Header: 'Auto Load',
73
+ style: { width: '30px', textAlign: 'center' },
74
+ Cell: ({ row }) => (_jsx(Controller, { control: control, name: "databases.defaultDatabase", render: ({ field }) => {
75
+ const { onChange, value } = field;
76
+ return (_jsx(Radio, { value: row.original.key, style: { margin: 0 }, checked: value === row.original.key, onChange: onChange }));
77
+ } })),
78
+ },
79
+ {
80
+ Header: '',
81
+ style: { maxWidth: '100px', width: '85px' },
82
+ id: 'op-buttons',
83
+ Cell: ({ data, row }) => {
84
+ const { index, original: record } = row;
85
+ return (_jsxs("div", { style: {
86
+ display: 'flex',
87
+ justifyContent: 'flex-start',
88
+ padding: '0 3px',
89
+ }, children: [_jsx(Button, { small: true, outlined: true, intent: "danger", tooltipProps: { content: '', disabled: true }, onClick: () => deleteHandler(data, index), children: _jsx(FaRegTrashAlt, { className: Classes.ICON }) }), _jsx(Button, { small: true, intent: "success", outlined: true, tooltipProps: { content: '', disabled: true }, onClick: () => addHandler(data, index + 1), css: css `
90
+ margin: 0 3px;
91
+ `, children: _jsx(FaPlus, { className: Classes.ICON }) }), isGoogleDocument(record.url) && (_jsx(Button, { small: true, outlined: true, intent: "primary", onClick: () => window.open(record.url, '_blank'), tooltipProps: { content: 'Open document', compact: true }, children: _jsx(FaLink, { className: Classes.ICON }) }))] }));
92
+ },
93
+ },
94
+ ], [addHandler, control, deleteHandler, register]);
50
95
  function resetHandler() {
51
96
  const workSpaceDisplayPreferences = getPreferencesByWorkspace(currentWorkspace, originalWorkspaces);
52
97
  const database = workSpaceDisplayPreferences.databases.data;
53
- void setFieldValue('databases.data', database);
98
+ setValue('databases.data', database);
54
99
  }
55
- return (_jsx("fieldset", { onClick: (e) => {
56
- if (e.target.checked) {
57
- e.target.checked = false;
58
- void setFieldValue('databases.defaultDatabase', '');
59
- }
60
- }, children: _jsx(GroupPane, { text: "Databases", renderHeader: (text) => {
61
- return (_jsx(DataBaseHeader, { text: text, onReset: resetHandler, onAdd: addHandler }));
62
- }, children: _jsxs("table", { style: style.table, children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { style: style.th, children: "#" }), _jsx("th", { style: style.th, children: "Label " }), _jsx("th", { style: style.th, children: "URL" }), _jsx("th", { style: style.th, children: "Enabled" }), _jsx("th", { style: style.th, children: "Auto Load" }), _jsx("th", {})] }) }), _jsx("tbody", { children: databases?.data.map((item, index) => {
63
- const num = index + 1;
64
- return (
65
- // eslint-disable-next-line react/no-array-index-key
66
- _jsxs("tr", { style: { height: '33px' }, children: [_jsxs("td", { style: style.serialCol, children: [_jsx("span", { children: num }), ' '] }), _jsx("td", { style: style.labelCol, children: _jsx(FormikInput, { style: { input: style.input }, name: `databases.data.${index}.label`, checkErrorAfterInputTouched: false }) }), _jsx("td", { children: _jsx(FormikInput, { style: { input: style.input }, name: `databases.data.${index}.url`, checkErrorAfterInputTouched: false }) }), _jsx("td", { children: _jsx(FormikCheckBox, { style: {
67
- container: style.checkbox,
68
- }, className: "checkbox-element", name: `databases.data.${index}.enabled` }) }), _jsx("td", { children: _jsx(Field, { style: style.checkbox, type: "radio", name: "databases.defaultDatabase", value: item.key }) }), _jsx("td", { children: _jsxs("div", { style: {
69
- display: 'flex',
70
- height: '100%',
71
- }, children: [_jsx(Button.Danger, { style: { fontSize: '14px' }, fill: "clear", onClick: () => deleteHandler(index), children: _jsx(FaTimes, {}) }), databases.length === index + 1 && (_jsx(Button.Done, { fill: "clear", style: { fontSize: '14px' }, onClick: addHandler, children: _jsx(FaPlus, {}) })), isGoogleDocument(item.url) && (_jsx(Button.Action, { style: { fontSize: '13px' }, fill: "clear", onClick: () => window.open(item.url, '_blank'), children: _jsx(FaLink, {}) }))] }) })] }, `${index}`));
72
- }) })] }) }) }));
100
+ return (_jsx(GroupPane, { text: "Databases", renderHeader: (text) => {
101
+ return (_jsx(DataBaseHeader, { text: text, onReset: resetHandler, onAdd: () => addHandler(databases) }));
102
+ }, children: _jsx(ReactTable, { style: {
103
+ 'thead tr th': { zIndex: 1 },
104
+ td: { padding: 0 },
105
+ }, rowStyle: {
106
+ hover: { backgroundColor: '#f7f7f7' },
107
+ active: { backgroundColor: '#f5f5f5' },
108
+ }, data: databases, columns: COLUMNS, emptyDataRowText: "No Fields" }) }));
73
109
  }
74
110
  function DataBaseHeader({ onReset, onAdd, text }) {
75
- return (_jsxs("div", { className: "section-header", style: { display: 'flex' }, children: [_jsx("p", { style: { flex: 1 }, children: text }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx(Button.Danger, { fill: "clear", size: "xSmall", onClick: onReset, style: { margin: '0 5px' }, children: "Reset Databases" }), _jsx(Button.Done, { fill: "outline", size: "xSmall", onClick: onAdd, children: "Add Database" })] })] }));
111
+ return (_jsxs(Section, { children: [_jsx("p", { style: { flex: 1 }, children: text }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx(Button, { small: true, minimal: true, intent: "danger", tooltipProps: { content: '', disabled: true }, onClick: onReset, children: "Reset Databases" }), _jsx(Button, { small: true, outlined: true, intent: "success", tooltipProps: { content: '', disabled: true }, onClick: onAdd, children: "Add Database" })] })] }));
76
112
  }
77
113
  export default DatabasesTabContent;
@@ -1,5 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { CheckBoxCell } from '../../../elements/CheckBoxCell';
2
+ import { Checkbox } from '@blueprintjs/core';
3
+ import { useMemo } from 'react';
4
+ import { useFormContext } from 'react-hook-form';
3
5
  import ReactTable from '../../../elements/ReactTable/ReactTable';
4
6
  const LIST = [
5
7
  {
@@ -63,30 +65,36 @@ const LIST = [
63
65
  name: 'panels.simulationPanel',
64
66
  },
65
67
  ];
66
- const COLUMNS = [
67
- {
68
- index: 1,
69
- Header: '#',
70
- accessor: (_, index) => index + 1,
71
- },
72
- {
73
- index: 1,
74
- Header: 'Feature',
75
- accessor: 'label',
76
- style: { width: '60%' },
77
- },
78
- {
79
- index: 2,
80
- Header: 'Active',
81
- Cell: ({ row }) => (_jsx(CheckBoxCell, { name: `display.${row.original.name}.display`, defaultValue: false })),
82
- },
83
- {
84
- index: 3,
85
- Header: 'Open on load',
86
- Cell: ({ row }) => (_jsx(CheckBoxCell, { name: `display.${row.original.name}.open`, defaultValue: false })),
87
- },
88
- ];
89
68
  function DisplayTabContent() {
90
- return (_jsx("div", { style: { width: '100%', overflow: 'hidden' }, children: _jsx(ReactTable, { columns: COLUMNS, data: LIST }) }));
69
+ const { register } = useFormContext();
70
+ const COLUMNS = useMemo(() => [
71
+ {
72
+ index: 1,
73
+ Header: '#',
74
+ accessor: (_, index) => index + 1,
75
+ },
76
+ {
77
+ index: 1,
78
+ Header: 'Feature',
79
+ accessor: 'label',
80
+ style: { width: '60%' },
81
+ },
82
+ {
83
+ index: 2,
84
+ Header: 'Active',
85
+ style: { textAlign: 'center' },
86
+ Cell: ({ row }) => (_jsx(Checkbox, { style: { margin: 0 }, ...register(`display.${row.original.name}.display`), defaultChecked: false })),
87
+ },
88
+ {
89
+ index: 3,
90
+ Header: 'Open on load',
91
+ style: { textAlign: 'center' },
92
+ Cell: ({ row }) => (_jsx(Checkbox, { style: { margin: 0 }, ...register(`display.${row.original.name}.open`) })),
93
+ },
94
+ ], [register]);
95
+ return (_jsx("div", { style: { width: '100%', overflow: 'hidden' }, children: _jsx(ReactTable, { columns: COLUMNS, data: LIST, rowStyle: {
96
+ hover: { backgroundColor: '#f7f7f7' },
97
+ active: { backgroundColor: '#f5f5f5' },
98
+ } }) }));
91
99
  }
92
100
  export default DisplayTabContent;
@@ -1,10 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Checkbox } from '@blueprintjs/core';
3
+ import { Controller, useFormContext } from 'react-hook-form';
2
4
  import { LOGGER_LEVELS } from '../../../context/LoggerContext';
3
5
  import { GroupPane } from '../../../elements/GroupPane';
4
6
  import Label from '../../../elements/Label';
5
- import FormikCheckBox from '../../../elements/formik/FormikCheckBox';
6
- import FormikInput from '../../../elements/formik/FormikInput';
7
- import FormikSelect from '../../../elements/formik/FormikSelect';
7
+ import { NumberInput2Controller } from '../../../elements/NumberInput2Controller';
8
+ import { Select2 } from '../../../elements/Select2';
8
9
  const labelStyle = {
9
10
  label: { flex: 6 },
10
11
  wrapper: { flex: 6 },
@@ -33,6 +34,16 @@ const LOGS_LEVELS = Object.keys(LOGGER_LEVELS).map((level) => ({
33
34
  value: level,
34
35
  }));
35
36
  function GeneralTabContent() {
36
- return (_jsxs(_Fragment, { children: [_jsxs(GroupPane, { text: "General", children: [_jsx(Label, { title: "Opacity of dimmed spectra [0 - 1]", style: labelStyle, children: _jsx(FormikInput, { name: "general.dimmedSpectraOpacity", checkValue: (value) => Number(value) >= 0 && Number(value) <= 1, type: "number", step: 0.1, min: 0, max: 1, style: { inputWrapper: { width: 60 } } }) }), _jsx(Label, { title: "Invert actions", style: labelStyle, children: _jsx(FormikCheckBox, { name: "general.invert", style: { container: { justifyContent: 'flex-start' } } }) })] }), _jsx(GroupPane, { text: "Experimental features", children: _jsx(Label, { title: "Enable experimental features", style: labelStyle, children: _jsx(FormikCheckBox, { name: "display.general.experimentalFeatures.display", style: { container: { justifyContent: 'flex-start' } } }) }) }), _jsx(GroupPane, { text: "Rendering", children: _jsx(Label, { title: "Spectra rendering", style: labelStyle, children: _jsx(FormikSelect, { items: SHAPE_RENDERING, name: "general.spectraRendering", style: { width: '150px' } }) }) }), _jsxs(GroupPane, { text: "Logging settings", children: [_jsx(Label, { title: "Level", style: labelStyle, children: _jsx(FormikSelect, { items: LOGS_LEVELS, name: "general.loggingLevel", style: { width: '100px' } }) }), _jsx(Label, { title: "Popup logging level", style: labelStyle, children: _jsx(FormikSelect, { items: LOGS_LEVELS, name: "general.popupLoggingLevel", style: { width: '100px' } }) })] })] }));
37
+ const { register, control } = useFormContext();
38
+ return (_jsxs(_Fragment, { children: [_jsxs(GroupPane, { text: "General", children: [_jsx(Label, { title: "Opacity of dimmed spectra [0 - 1]", style: labelStyle, children: _jsx(NumberInput2Controller, { control: control, name: "general.dimmedSpectraOpacity", min: 0, max: 1, stepSize: 0.1, style: { width: 60 } }) }), _jsx(Label, { title: "Invert actions", style: labelStyle, children: _jsx(Checkbox, { style: { margin: 0 }, ...register(`general.invert`) }) })] }), _jsx(GroupPane, { text: "Experimental features", children: _jsx(Label, { title: "Enable experimental features", style: labelStyle, children: _jsx(Checkbox, { style: { margin: 0 }, ...register(`display.general.experimentalFeatures.display`) }) }) }), _jsx(GroupPane, { text: "Rendering", children: _jsx(Label, { title: "Spectra rendering", style: labelStyle, children: _jsx(Controller, { control: control, name: "general.spectraRendering", render: ({ field }) => {
39
+ const { value, onChange } = field;
40
+ return (_jsx(Select2, { items: SHAPE_RENDERING, itemTextKey: "label", itemValueKey: "value", selectedItemValue: value, onItemSelect: (item) => onChange(item.value) }));
41
+ } }) }) }), _jsxs(GroupPane, { text: "Logging settings", children: [_jsx(Label, { title: "Level", style: labelStyle, children: _jsx(Controller, { control: control, name: "general.loggingLevel", render: ({ field }) => {
42
+ const { value, onChange } = field;
43
+ return (_jsx(Select2, { items: LOGS_LEVELS, itemTextKey: "label", itemValueKey: "value", selectedItemValue: value, onItemSelect: (item) => onChange(item.value) }));
44
+ } }) }), _jsx(Label, { title: "Popup logging level", style: labelStyle, children: _jsx(Controller, { control: control, name: "general.popupLoggingLevel", render: ({ field }) => {
45
+ const { value, onChange } = field;
46
+ return (_jsx(Select2, { items: LOGS_LEVELS, itemTextKey: "label", itemValueKey: "value", selectedItemValue: value, onItemSelect: (item) => onChange(item.value) }));
47
+ } }) })] })] }));
37
48
  }
38
49
  export default GeneralTabContent;