react-science 0.24.2 → 0.25.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.
- package/README.md +1 -1
- package/lib/app/hooks/file-loading.js +1 -1
- package/lib/app/panels/SignalProcessingPanel.js +1 -1
- package/lib/app-data/kinds/ir/irAutoPeakPickingEnhancer.js +4 -4
- package/lib/app-data/kinds/ir/irMeasurementEnhancer.js +1 -1
- package/lib/app-data/loaders/cdfLoader.js +4 -5
- package/lib/app-data/loaders/jcampLoader.js +1 -1
- package/lib/app-data/loaders/loadMeasurements.js +1 -1
- package/lib/app-data/loaders/wdfLoader.js +1 -1
- package/lib/app-data/state/data/data.helpers.js +3 -3
- package/lib/components/accordion/AccordionContext.js +1 -1
- package/lib/components/color-picker/gradient-select/GradientSelect.js +2 -0
- package/lib/components/color-picker/react-color/common/EditableInput.js +1 -1
- package/lib/components/dropdown-menu/DropdownMenu.js +2 -0
- package/lib/components/dropdown-menu/MenuItems.js +5 -1
- package/lib/components/hooks/useOnOff.js +1 -1
- package/lib/components/modal/ConfirmModal.js +6 -4
- package/lib/components/modal/Modal.js +6 -4
- package/lib/components/modal/useDialog.js +13 -3
- package/lib/components/root-layout/css-reset/customPreflight.js +15 -3
- package/lib/components/root-layout/css-reset/preflight.js +14 -3
- package/lib/components/split-pane/SplitPane.js +2 -1
- package/lib/components/table/Table.js +2 -2
- package/lib/components/value-renderers/Boolean.js +1 -1
- package/lib-esm/app/hooks/file-loading.js +1 -1
- package/lib-esm/app/hooks/file-loading.js.map +1 -1
- package/lib-esm/app/kinds/ir/IrPeaksPanel.js.map +1 -1
- package/lib-esm/app/panels/SignalProcessingPanel.js +1 -1
- package/lib-esm/app/panels/SignalProcessingPanel.js.map +1 -1
- package/lib-esm/app-data/enhancers/enhance.d.ts +1 -1
- package/lib-esm/app-data/enhancers/enhance.d.ts.map +1 -1
- package/lib-esm/app-data/kinds/ir/irAutoPeakPickingEnhancer.js +4 -4
- package/lib-esm/app-data/kinds/ir/irAutoPeakPickingEnhancer.js.map +1 -1
- package/lib-esm/app-data/kinds/ir/irMeasurementEnhancer.js +1 -1
- package/lib-esm/app-data/kinds/ir/irMeasurementEnhancer.js.map +1 -1
- package/lib-esm/app-data/loaders/cdfLoader.d.ts.map +1 -1
- package/lib-esm/app-data/loaders/cdfLoader.js +4 -5
- package/lib-esm/app-data/loaders/cdfLoader.js.map +1 -1
- package/lib-esm/app-data/loaders/jcampLoader.js +1 -1
- package/lib-esm/app-data/loaders/jcampLoader.js.map +1 -1
- package/lib-esm/app-data/loaders/loadMeasurements.js +1 -1
- package/lib-esm/app-data/loaders/loadMeasurements.js.map +1 -1
- package/lib-esm/app-data/loaders/wdfLoader.js +1 -1
- package/lib-esm/app-data/loaders/wdfLoader.js.map +1 -1
- package/lib-esm/app-data/state/data/data.helpers.d.ts +2 -2
- package/lib-esm/app-data/state/data/data.helpers.d.ts.map +1 -1
- package/lib-esm/app-data/state/data/data.helpers.js +3 -3
- package/lib-esm/app-data/state/data/data.helpers.js.map +1 -1
- package/lib-esm/app-data/state/view/AppView.d.ts +1 -1
- package/lib-esm/app-data/state/view/AppView.d.ts.map +1 -1
- package/lib-esm/components/accordion/Accordion.js.map +1 -1
- package/lib-esm/components/accordion/AccordionContext.d.ts +1 -1
- package/lib-esm/components/accordion/AccordionContext.d.ts.map +1 -1
- package/lib-esm/components/accordion/AccordionContext.js +1 -1
- package/lib-esm/components/accordion/AccordionContext.js.map +1 -1
- package/lib-esm/components/color-picker/gradient-select/GradientSelect.d.ts.map +1 -1
- package/lib-esm/components/color-picker/gradient-select/GradientSelect.js +2 -0
- package/lib-esm/components/color-picker/gradient-select/GradientSelect.js.map +1 -1
- package/lib-esm/components/color-picker/react-color/common/EditableInput.js +1 -1
- package/lib-esm/components/color-picker/react-color/common/EditableInput.js.map +1 -1
- package/lib-esm/components/color-picker/react-color/helpers/color.d.ts +13 -13
- package/lib-esm/components/color-picker/react-color/sketch/SketchPresetColors.d.ts +2 -2
- package/lib-esm/components/color-picker/react-color/sketch/SketchPresetColors.d.ts.map +1 -1
- package/lib-esm/components/dropdown-menu/DropdownMenu.d.ts.map +1 -1
- package/lib-esm/components/dropdown-menu/DropdownMenu.js +2 -0
- package/lib-esm/components/dropdown-menu/DropdownMenu.js.map +1 -1
- package/lib-esm/components/dropdown-menu/MenuItems.d.ts.map +1 -1
- package/lib-esm/components/dropdown-menu/MenuItems.js +5 -1
- package/lib-esm/components/dropdown-menu/MenuItems.js.map +1 -1
- package/lib-esm/components/dropdown-menu/useContextMenuPlacement.d.ts +1 -1
- package/lib-esm/components/dropdown-menu/useContextMenuPlacement.d.ts.map +1 -1
- package/lib-esm/components/dropdown-menu/useContextMenuPlacement.js.map +1 -1
- package/lib-esm/components/forms/Select.d.ts +1 -1
- package/lib-esm/components/forms/Select.d.ts.map +1 -1
- package/lib-esm/components/hooks/useModifiedPopper.js.map +1 -1
- package/lib-esm/components/hooks/useOnOff.d.ts.map +1 -1
- package/lib-esm/components/hooks/useOnOff.js +1 -1
- package/lib-esm/components/hooks/useOnOff.js.map +1 -1
- package/lib-esm/components/layout-manager/LayoutManager.d.ts +2 -4
- package/lib-esm/components/layout-manager/LayoutManager.d.ts.map +1 -1
- package/lib-esm/components/layout-manager/LayoutManager.js.map +1 -1
- package/lib-esm/components/modal/ConfirmModal.d.ts.map +1 -1
- package/lib-esm/components/modal/ConfirmModal.js +6 -4
- package/lib-esm/components/modal/ConfirmModal.js.map +1 -1
- package/lib-esm/components/modal/Modal.d.ts +1 -1
- package/lib-esm/components/modal/Modal.d.ts.map +1 -1
- package/lib-esm/components/modal/Modal.js +6 -4
- package/lib-esm/components/modal/Modal.js.map +1 -1
- package/lib-esm/components/modal/useDialog.d.ts +11 -5
- package/lib-esm/components/modal/useDialog.d.ts.map +1 -1
- package/lib-esm/components/modal/useDialog.js +14 -4
- package/lib-esm/components/modal/useDialog.js.map +1 -1
- package/lib-esm/components/root-layout/css-reset/customPreflight.d.ts.map +1 -1
- package/lib-esm/components/root-layout/css-reset/customPreflight.js +15 -3
- package/lib-esm/components/root-layout/css-reset/customPreflight.js.map +1 -1
- package/lib-esm/components/root-layout/css-reset/preflight.d.ts +1 -1
- package/lib-esm/components/root-layout/css-reset/preflight.d.ts.map +1 -1
- package/lib-esm/components/root-layout/css-reset/preflight.js +14 -3
- package/lib-esm/components/root-layout/css-reset/preflight.js.map +1 -1
- package/lib-esm/components/split-pane/SplitPane.d.ts.map +1 -1
- package/lib-esm/components/split-pane/SplitPane.js +2 -1
- package/lib-esm/components/split-pane/SplitPane.js.map +1 -1
- package/lib-esm/components/table/Table.js +2 -2
- package/lib-esm/components/table/Table.js.map +1 -1
- package/lib-esm/components/value-renderers/Boolean.d.ts.map +1 -1
- package/lib-esm/components/value-renderers/Boolean.js +1 -1
- package/lib-esm/components/value-renderers/Boolean.js.map +1 -1
- package/package.json +44 -44
- package/src/app/hooks/file-loading.ts +1 -1
- package/src/app/kinds/ir/IrPeaksPanel.tsx +1 -1
- package/src/app/panels/SignalProcessingPanel.tsx +1 -1
- package/src/app-data/enhancers/enhance.ts +3 -3
- package/src/app-data/kinds/ir/irAutoPeakPickingEnhancer.ts +6 -6
- package/src/app-data/kinds/ir/irMeasurementEnhancer.ts +1 -1
- package/src/app-data/loaders/cdfLoader.ts +4 -5
- package/src/app-data/loaders/jcampLoader.ts +1 -1
- package/src/app-data/loaders/loadMeasurements.ts +1 -1
- package/src/app-data/loaders/wdfLoader.ts +3 -3
- package/src/app-data/state/data/data.helpers.ts +5 -5
- package/src/app-data/state/view/AppView.ts +1 -1
- package/src/components/accordion/Accordion.tsx +1 -1
- package/src/components/accordion/AccordionContext.tsx +3 -3
- package/src/components/color-picker/gradient-select/GradientSelect.tsx +2 -0
- package/src/components/color-picker/react-color/common/EditableInput.jsx +1 -1
- package/src/components/color-picker/react-color/sketch/SketchPresetColors.tsx +1 -1
- package/src/components/dropdown-menu/DropdownMenu.tsx +2 -0
- package/src/components/dropdown-menu/MenuItems.tsx +5 -1
- package/src/components/dropdown-menu/useContextMenuPlacement.ts +1 -1
- package/src/components/forms/Select.tsx +1 -1
- package/src/components/hooks/useModifiedPopper.ts +1 -1
- package/src/components/hooks/useOnOff.ts +1 -2
- package/src/components/layout-manager/LayoutManager.tsx +2 -4
- package/src/components/modal/ConfirmModal.tsx +38 -31
- package/src/components/modal/Modal.tsx +19 -15
- package/src/components/modal/useDialog.ts +36 -10
- package/src/components/root-layout/css-reset/customPreflight.ts +15 -3
- package/src/components/root-layout/css-reset/preflight.css +15 -3
- package/src/components/root-layout/css-reset/preflight.ts +14 -3
- package/src/components/split-pane/SplitPane.tsx +2 -1
- package/src/components/table/Table.tsx +2 -2
- package/src/components/value-renderers/Boolean.tsx +3 -1
|
@@ -36,20 +36,20 @@ export function irAutoPeakPickingEnhancer(
|
|
|
36
36
|
|
|
37
37
|
const datum = measurement.data[0];
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
const x = datum.variables[xVariable]?.data;
|
|
40
|
+
const y = datum.variables[yVariable]?.data;
|
|
41
41
|
if (!x || !y) return [];
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
const { from, to } = options;
|
|
44
44
|
|
|
45
45
|
let peaks: Array<{ x: number; y: number; width: number; index: number }> =
|
|
46
46
|
gsd({ x, y }, options);
|
|
47
47
|
|
|
48
48
|
if (from !== undefined) {
|
|
49
|
-
peaks = peaks.filter((peak) => peak.x >=
|
|
49
|
+
peaks = peaks.filter((peak) => peak.x >= from);
|
|
50
50
|
}
|
|
51
51
|
if (to !== undefined) {
|
|
52
|
-
peaks = peaks.filter((peak) => peak.x <=
|
|
52
|
+
peaks = peaks.filter((peak) => peak.x <= to);
|
|
53
53
|
}
|
|
54
54
|
if (minPeakWidth) {
|
|
55
55
|
peaks = peaks.filter((peak) => peak.width >= minPeakWidth);
|
|
@@ -82,7 +82,7 @@ function getPeakKind(
|
|
|
82
82
|
minTransmittance: number,
|
|
83
83
|
maxTransmittance: number,
|
|
84
84
|
): IrPeakKind {
|
|
85
|
-
|
|
85
|
+
const position =
|
|
86
86
|
(maxTransmittance - transmittance) / (maxTransmittance - minTransmittance);
|
|
87
87
|
if (position < 0.33) {
|
|
88
88
|
return 'w';
|
|
@@ -9,7 +9,7 @@ import type { MeasurementBase } from '../../index';
|
|
|
9
9
|
export function irMeasurementEnhancer(measurement: MeasurementBase) {
|
|
10
10
|
for (const datum of measurement.data) {
|
|
11
11
|
const variables = datum.variables;
|
|
12
|
-
|
|
12
|
+
const yVariable = variables.y;
|
|
13
13
|
let absorbance = true;
|
|
14
14
|
if (yVariable.label.toLowerCase().includes('trans')) {
|
|
15
15
|
absorbance = false;
|
|
@@ -28,8 +28,7 @@ export async function cdfLoader(
|
|
|
28
28
|
kind = 'gclcms';
|
|
29
29
|
} else if (
|
|
30
30
|
reader.dataVariableExists('ordinate_values') &&
|
|
31
|
-
reader.getAttribute('detector_name')
|
|
32
|
-
reader.getAttribute('detector_name').match(/dad|tic/i)
|
|
31
|
+
reader.getAttribute('detector_name')?.match(/dad|tic/i)
|
|
33
32
|
) {
|
|
34
33
|
kind = 'gclc';
|
|
35
34
|
} else {
|
|
@@ -102,7 +101,7 @@ function chromatogramWithMassSpectra(
|
|
|
102
101
|
allIntensities.push(intensities);
|
|
103
102
|
allMasses.push(masses);
|
|
104
103
|
}
|
|
105
|
-
|
|
104
|
+
const data: MeasurementBase['data'] = [];
|
|
106
105
|
for (let i = 0; i < times.length; i++) {
|
|
107
106
|
data.push({
|
|
108
107
|
info: {
|
|
@@ -130,7 +129,7 @@ function chromatogramWithMassSpectra(
|
|
|
130
129
|
|
|
131
130
|
function chromatogram(reader: NetCDFReader): MeasurementBase['data'] {
|
|
132
131
|
// Taken from: https://github.com/cheminfo/netcdf-gcms
|
|
133
|
-
|
|
132
|
+
const data: MeasurementBase['data'] = [];
|
|
134
133
|
const intensities: number[] = reader.getDataVariable('ordinate_values');
|
|
135
134
|
const numberPoints = intensities.length;
|
|
136
135
|
const detector: string = reader.getAttribute('detector_name');
|
|
@@ -163,7 +162,7 @@ function chromatogram(reader: NetCDFReader): MeasurementBase['data'] {
|
|
|
163
162
|
samplingInterval = (runtimeLength - delayTime) / numberPoints;
|
|
164
163
|
}
|
|
165
164
|
|
|
166
|
-
|
|
165
|
+
const times: number[] = [];
|
|
167
166
|
let time = delayTime;
|
|
168
167
|
for (let i = 0; i < numberPoints; i++) {
|
|
169
168
|
times.push(time);
|
|
@@ -92,7 +92,7 @@ function normalizeSpectra(spectra: any) {
|
|
|
92
92
|
data: spectrum.data.y || spectrum.data.Y,
|
|
93
93
|
};
|
|
94
94
|
} else {
|
|
95
|
-
for (
|
|
95
|
+
for (const key in variables) {
|
|
96
96
|
const variable = variables[key];
|
|
97
97
|
if (variable.label) continue;
|
|
98
98
|
variable.label = variable.name || variable.symbol || key;
|
|
@@ -20,7 +20,7 @@ export async function loadMeasurements(
|
|
|
20
20
|
options: LoadOptions = {},
|
|
21
21
|
) {
|
|
22
22
|
const measurements: Partial<Measurements> = {};
|
|
23
|
-
|
|
23
|
+
const logs: ParserLog[] = [];
|
|
24
24
|
const { loaders = [], enhancers = {}, logger = true } = options;
|
|
25
25
|
for (const loader of loaders) {
|
|
26
26
|
const loaderData = await loader(fileCollection, logger ? logs : undefined);
|
|
@@ -60,7 +60,7 @@ function normalizeSpectra(blocks: Wdf['blocks']) {
|
|
|
60
60
|
|
|
61
61
|
for (let i = 0; i < yVariables.length; i++) {
|
|
62
62
|
const yVariable = yVariables[i];
|
|
63
|
-
|
|
63
|
+
const origin = origins[i] || {};
|
|
64
64
|
|
|
65
65
|
results.push({
|
|
66
66
|
variables: { x: getXVariable(blocks), y: yVariable },
|
|
@@ -111,12 +111,12 @@ function getYVariables(blocks: Wdf['blocks']) {
|
|
|
111
111
|
return yVariables;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
interface Origin {
|
|
115
115
|
xPositionUnits: string;
|
|
116
116
|
yPositionUnits: string;
|
|
117
117
|
xPosition: number | bigint;
|
|
118
118
|
yPosition: number | bigint;
|
|
119
|
-
}
|
|
119
|
+
}
|
|
120
120
|
function getOrigins(blocks: Wdf['blocks']) {
|
|
121
121
|
const originBlock = blocks.find(
|
|
122
122
|
(block) => block.blockType === 'WDF_BLOCKID_ORIGIN',
|
|
@@ -93,7 +93,7 @@ export interface MeasurementKindAndId {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
export function getMeasurementKindAndId(data: AppData, measurementId: string) {
|
|
96
|
-
for (
|
|
96
|
+
for (const kind of measurementKinds) {
|
|
97
97
|
const measurement = getMeasurement(data.measurements, kind, measurementId);
|
|
98
98
|
if (measurement) return { kind, id: measurementId };
|
|
99
99
|
}
|
|
@@ -124,16 +124,16 @@ export function* iterateMeasurementEntries(
|
|
|
124
124
|
for (const [measurementKind, measurementData] of Object.entries(
|
|
125
125
|
measurements,
|
|
126
126
|
)) {
|
|
127
|
-
for (
|
|
127
|
+
for (const measurement of measurementData.entries) {
|
|
128
128
|
yield { kind: measurementKind as MeasurementKind, measurement };
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
export
|
|
133
|
+
export interface MeasurementAndView<Kind extends MeasurementKind> {
|
|
134
134
|
measurement: Measurements[Kind]['entries'][number];
|
|
135
135
|
view: AppView['measurements'][string];
|
|
136
|
-
}
|
|
136
|
+
}
|
|
137
137
|
|
|
138
138
|
export function* iterateKindMeasurementsAndView<Kind extends MeasurementKind>(
|
|
139
139
|
state: AppState,
|
|
@@ -141,7 +141,7 @@ export function* iterateKindMeasurementsAndView<Kind extends MeasurementKind>(
|
|
|
141
141
|
): IterableIterator<MeasurementAndView<Kind>> {
|
|
142
142
|
const measurements = state.data.measurements[kind];
|
|
143
143
|
const view = state.view.measurements;
|
|
144
|
-
for (
|
|
144
|
+
for (const measurement of measurements.entries) {
|
|
145
145
|
yield { measurement, view: view[measurement.id] };
|
|
146
146
|
}
|
|
147
147
|
}
|
|
@@ -3,7 +3,7 @@ import type { MeasurementKind } from '../index';
|
|
|
3
3
|
|
|
4
4
|
export interface AppView {
|
|
5
5
|
selectedKind?: MeasurementKind;
|
|
6
|
-
selectedMeasurements: Partial<Record<MeasurementKind,
|
|
6
|
+
selectedMeasurements: Partial<Record<MeasurementKind, string[]>>;
|
|
7
7
|
measurements: Record<string, MeasurementAppView>;
|
|
8
8
|
plot: Partial<Record<MeasurementKind, PlotView>>;
|
|
9
9
|
}
|
|
@@ -66,7 +66,7 @@ Accordion.Item = function AccordionItem(props: AccordionItemProps) {
|
|
|
66
66
|
const { item, utils } = useAccordionContext(props.title, props.defaultOpened);
|
|
67
67
|
|
|
68
68
|
const onClickHandle = useCallback(
|
|
69
|
-
(event: ReactMouseEvent<HTMLButtonElement
|
|
69
|
+
(event: ReactMouseEvent<HTMLButtonElement>) => {
|
|
70
70
|
if (event.shiftKey) {
|
|
71
71
|
utils.clear();
|
|
72
72
|
} else {
|
|
@@ -19,7 +19,7 @@ type ActionType<Action, Payload = void> = Payload extends void
|
|
|
19
19
|
: { type: Action; payload: Payload };
|
|
20
20
|
|
|
21
21
|
export interface AccordionState {
|
|
22
|
-
items:
|
|
22
|
+
items: AccordionItemState[];
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
type AccordionActions =
|
|
@@ -131,7 +131,7 @@ export function useAccordionContext(title: string, defaultOpened?: boolean) {
|
|
|
131
131
|
return () => utils.remove(title);
|
|
132
132
|
}, [defaultOpened, title, utils]);
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
const item = getItem(title, state.items);
|
|
135
135
|
|
|
136
136
|
return useMemo(
|
|
137
137
|
() => ({
|
|
@@ -189,7 +189,7 @@ export function AccordionProvider(props: { children: ReactNode }) {
|
|
|
189
189
|
);
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
function getItem(title: string, items:
|
|
192
|
+
function getItem(title: string, items: AccordionItemState[]) {
|
|
193
193
|
const item = items.find((element) => element.title === title);
|
|
194
194
|
return item;
|
|
195
195
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error
|
|
3
|
+
// @ts-ignore This import fails when compiling to CJS.
|
|
2
4
|
import { Listbox } from '@headlessui/react';
|
|
3
5
|
import * as scaleChromatic from 'd3-scale-chromatic';
|
|
4
6
|
import { Fragment } from 'react';
|
|
@@ -6,7 +6,7 @@ const UP_KEY_CODE = 38;
|
|
|
6
6
|
const DOWN_KEY_CODE = 40;
|
|
7
7
|
const VALID_KEY_CODES = new Set([UP_KEY_CODE, DOWN_KEY_CODE]);
|
|
8
8
|
const isValidKeyCode = (keyCode) => VALID_KEY_CODES.has(keyCode);
|
|
9
|
-
const getNumberValue = (value) => Number(String(value).
|
|
9
|
+
const getNumberValue = (value) => Number(String(value).replaceAll('%', ''));
|
|
10
10
|
|
|
11
11
|
let idCounter = 1;
|
|
12
12
|
|
|
@@ -3,7 +3,7 @@ import { CSSProperties, MouseEvent, useCallback } from 'react';
|
|
|
3
3
|
import { Swatch } from '../common';
|
|
4
4
|
|
|
5
5
|
interface SketchPresetColorsProps {
|
|
6
|
-
colors:
|
|
6
|
+
colors: Array<string | { color: string; title: string }>;
|
|
7
7
|
onClick: (data: { hex: any; source: string }, event: any) => void;
|
|
8
8
|
onSwatchHover: any;
|
|
9
9
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error
|
|
2
|
+
// @ts-ignore This import fails when compiling to CJS.
|
|
1
3
|
import { Menu } from '@headlessui/react';
|
|
2
4
|
import type { Placement } from '@popperjs/core';
|
|
3
5
|
import { ReactNode, useRef, ElementType, ComponentProps } from 'react';
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error
|
|
3
|
+
// @ts-ignore This import fails when compiling to CJS.
|
|
2
4
|
import { Menu } from '@headlessui/react';
|
|
3
5
|
import type { ReactNode } from 'react';
|
|
4
6
|
|
|
@@ -57,7 +59,9 @@ const ItemsDiv = styled.div<{
|
|
|
57
59
|
align-items: center;
|
|
58
60
|
border-radius: 6px;
|
|
59
61
|
background-color: white;
|
|
60
|
-
box-shadow:
|
|
62
|
+
box-shadow:
|
|
63
|
+
rgba(0, 0, 0, 0.3) 0px 19px 38px,
|
|
64
|
+
rgba(0, 0, 0, 0.22) 0px 5px 12px;
|
|
61
65
|
padding-top: 5px;
|
|
62
66
|
padding-bottom: 5px;
|
|
63
67
|
--cell-padding: 16px;
|
|
@@ -15,7 +15,7 @@ export function useContextMenuPlacement(placement: Placement) {
|
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
const handleContextMenu = useCallback(
|
|
18
|
-
(event: React.MouseEvent<HTMLDivElement
|
|
18
|
+
(event: React.MouseEvent<HTMLDivElement>) => {
|
|
19
19
|
const { clientX, clientY, pageX, pageY } = event;
|
|
20
20
|
event.preventDefault();
|
|
21
21
|
|
|
@@ -21,7 +21,7 @@ export interface SelectProps {
|
|
|
21
21
|
placeholder?: string;
|
|
22
22
|
value: string | undefined;
|
|
23
23
|
onSelect?: (value: string | undefined) => void;
|
|
24
|
-
options:
|
|
24
|
+
options: Array<Option[] | Category[]>;
|
|
25
25
|
disabled?: boolean;
|
|
26
26
|
style?: CSSProperties;
|
|
27
27
|
}
|
|
@@ -48,7 +48,7 @@ export function useModifiedPopper<
|
|
|
48
48
|
const [referenceElement, setReferenceElement] = useState<R | null>(null);
|
|
49
49
|
const [popperElement, setPopperElement] = useState<P | null>(null);
|
|
50
50
|
|
|
51
|
-
const modifiers: Modifier<'sameWidth' | 'offset'
|
|
51
|
+
const modifiers: Array<Modifier<'sameWidth' | 'offset'>> = [];
|
|
52
52
|
|
|
53
53
|
if (sameWidth) {
|
|
54
54
|
modifiers.push(sameWidthModifier);
|
|
@@ -4,9 +4,8 @@ export function useOnOff(
|
|
|
4
4
|
initialValue = false,
|
|
5
5
|
): [isOn: boolean, setOn: () => void, setOff: () => void, toggle: () => void] {
|
|
6
6
|
const [isOn, setOnOff] = useState(initialValue);
|
|
7
|
-
|
|
8
7
|
const setOn = useCallback(() => setOnOff(true), []);
|
|
9
8
|
const setOff = useCallback(() => setOnOff(false), []);
|
|
10
|
-
const toggle = useCallback(() => setOnOff(!isOn), [
|
|
9
|
+
const toggle = useCallback(() => setOnOff((isOn) => !isOn), []);
|
|
11
10
|
return [isOn, setOn, setOff, toggle];
|
|
12
11
|
}
|
|
@@ -18,9 +18,7 @@ const layoutComponents: ComponentsMap = {
|
|
|
18
18
|
DropZone,
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
[componentName: string]: ComponentType<any>;
|
|
23
|
-
}
|
|
21
|
+
type ComponentsMap = Record<string, ComponentType<any>>;
|
|
24
22
|
|
|
25
23
|
interface LayoutManagerProps {
|
|
26
24
|
layout: Layout;
|
|
@@ -33,7 +31,7 @@ export interface Layout {
|
|
|
33
31
|
}
|
|
34
32
|
interface LayoutComponent {
|
|
35
33
|
id: string;
|
|
36
|
-
component: keyof typeof layoutComponents | FunctionComponent
|
|
34
|
+
component: keyof typeof layoutComponents | FunctionComponent;
|
|
37
35
|
children?: LayoutComponent[];
|
|
38
36
|
}
|
|
39
37
|
|
|
@@ -41,7 +41,9 @@ const ConfirmModalContents = styled.div<{
|
|
|
41
41
|
border-width: 1px;
|
|
42
42
|
border-color: transparent;
|
|
43
43
|
border-radius: 0.5rem;
|
|
44
|
-
box-shadow:
|
|
44
|
+
box-shadow:
|
|
45
|
+
0 0 0 0,
|
|
46
|
+
0 0px 16px rgba(0, 0, 0, 0.3);
|
|
45
47
|
border-top: 10px solid ${({ headerColor }) => headerColor};
|
|
46
48
|
`;
|
|
47
49
|
|
|
@@ -77,7 +79,7 @@ export function ConfirmModal(props: ConfirmModalProps) {
|
|
|
77
79
|
} = props;
|
|
78
80
|
|
|
79
81
|
const dialogRef = useRef<HTMLDialogElement>(null);
|
|
80
|
-
const dialogProps = useDialog({
|
|
82
|
+
const { dialogProps, isModalShown } = useDialog({
|
|
81
83
|
dialogRef,
|
|
82
84
|
isOpen,
|
|
83
85
|
requestCloseOnEsc,
|
|
@@ -102,36 +104,41 @@ export function ConfirmModal(props: ConfirmModalProps) {
|
|
|
102
104
|
return (
|
|
103
105
|
<Portal>
|
|
104
106
|
<ConfirmModalDialog {...dialogProps} ref={dialogRef}>
|
|
105
|
-
|
|
106
|
-
<
|
|
107
|
-
<
|
|
108
|
-
{
|
|
109
|
-
|
|
107
|
+
{isModalShown && (
|
|
108
|
+
<RootLayoutProvider innerRef={portalDomNode}>
|
|
109
|
+
<ConfirmModalContents
|
|
110
|
+
headerColor={headerColor}
|
|
111
|
+
style={{ maxWidth }}
|
|
112
|
+
>
|
|
113
|
+
<ConfirmModalChildrenRoot headerColor={headerColor}>
|
|
114
|
+
{children}
|
|
115
|
+
</ConfirmModalChildrenRoot>
|
|
110
116
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
117
|
+
<ConfirmModalFooter>
|
|
118
|
+
<Button
|
|
119
|
+
onClick={onConfirm}
|
|
120
|
+
backgroundColor={{
|
|
121
|
+
basic: 'hsla(243deg, 75%, 58%, 1)',
|
|
122
|
+
hover: 'hsla(245deg, 58%, 50%, 1)',
|
|
123
|
+
}}
|
|
124
|
+
color={{ basic: 'white' }}
|
|
125
|
+
>
|
|
126
|
+
{saveText}
|
|
127
|
+
</Button>
|
|
128
|
+
<Button
|
|
129
|
+
onClick={onCancel}
|
|
130
|
+
backgroundColor={{
|
|
131
|
+
basic: 'hsla(0deg, 72%, 50%, 1)',
|
|
132
|
+
hover: 'hsla(0deg, 73%, 42%, 1)',
|
|
133
|
+
}}
|
|
134
|
+
color={{ basic: 'white' }}
|
|
135
|
+
>
|
|
136
|
+
{cancelText}
|
|
137
|
+
</Button>
|
|
138
|
+
</ConfirmModalFooter>
|
|
139
|
+
</ConfirmModalContents>
|
|
140
|
+
</RootLayoutProvider>
|
|
141
|
+
)}
|
|
135
142
|
</ConfirmModalDialog>
|
|
136
143
|
</Portal>
|
|
137
144
|
);
|
|
@@ -9,7 +9,7 @@ import ModalCloseButton from './ModalCloseButton';
|
|
|
9
9
|
import { useDialog } from './useDialog';
|
|
10
10
|
|
|
11
11
|
export interface ModalProps {
|
|
12
|
-
children: ReactElement |
|
|
12
|
+
children: ReactElement | ReactElement[];
|
|
13
13
|
isOpen: boolean;
|
|
14
14
|
requestCloseOnEsc?: boolean;
|
|
15
15
|
hasCloseButton?: boolean;
|
|
@@ -36,7 +36,9 @@ const DialogContents = styled.div`
|
|
|
36
36
|
border-width: 1px;
|
|
37
37
|
border-color: transparent;
|
|
38
38
|
border-radius: 0.5rem;
|
|
39
|
-
box-shadow:
|
|
39
|
+
box-shadow:
|
|
40
|
+
0 0 0 0,
|
|
41
|
+
0 0px 16px rgba(0, 0, 0, 0.3);
|
|
40
42
|
`;
|
|
41
43
|
|
|
42
44
|
const ModalHeaderStyled = styled.div`
|
|
@@ -74,7 +76,7 @@ export function Modal(props: ModalProps) {
|
|
|
74
76
|
} = props;
|
|
75
77
|
|
|
76
78
|
const dialogRef = useRef<HTMLDialogElement>(null);
|
|
77
|
-
const dialogProps = useDialog({
|
|
79
|
+
const { dialogProps, isModalShown } = useDialog({
|
|
78
80
|
dialogRef,
|
|
79
81
|
isOpen,
|
|
80
82
|
requestCloseOnEsc,
|
|
@@ -99,18 +101,20 @@ export function Modal(props: ModalProps) {
|
|
|
99
101
|
return (
|
|
100
102
|
<Portal>
|
|
101
103
|
<DialogRoot {...dialogProps} ref={dialogRef}>
|
|
102
|
-
|
|
103
|
-
<
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
104
|
+
{isModalShown && (
|
|
105
|
+
<RootLayoutProvider innerRef={portalDomNode}>
|
|
106
|
+
<DialogContents
|
|
107
|
+
style={{
|
|
108
|
+
maxWidth,
|
|
109
|
+
height: height || 'max-content',
|
|
110
|
+
width: width || '100%',
|
|
111
|
+
}}
|
|
112
|
+
>
|
|
113
|
+
{children}
|
|
114
|
+
{hasCloseButton && <ModalCloseButton onClick={onRequestClose} />}
|
|
115
|
+
</DialogContents>
|
|
116
|
+
</RootLayoutProvider>
|
|
117
|
+
)}
|
|
114
118
|
</DialogRoot>
|
|
115
119
|
</Portal>
|
|
116
120
|
);
|
|
@@ -4,31 +4,49 @@ import {
|
|
|
4
4
|
RefObject,
|
|
5
5
|
useCallback,
|
|
6
6
|
useEffect,
|
|
7
|
+
useMemo,
|
|
7
8
|
} from 'react';
|
|
8
9
|
import { useKbsDisableGlobal } from 'react-kbs';
|
|
9
10
|
|
|
11
|
+
import { useOnOff } from '../index';
|
|
12
|
+
|
|
13
|
+
interface UseDialogOptions {
|
|
14
|
+
dialogRef: RefObject<HTMLDialogElement>;
|
|
15
|
+
isOpen: boolean;
|
|
16
|
+
requestCloseOnEsc: boolean;
|
|
17
|
+
requestCloseOnBackdrop: boolean;
|
|
18
|
+
onRequestClose?: () => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface UseDialogReturn {
|
|
22
|
+
dialogProps: {
|
|
23
|
+
onClick: MouseEventHandler<HTMLDialogElement>;
|
|
24
|
+
onCancel: ReactEventHandler<HTMLDialogElement>;
|
|
25
|
+
};
|
|
26
|
+
isModalShown: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
10
29
|
export function useDialog({
|
|
11
30
|
dialogRef,
|
|
12
31
|
isOpen,
|
|
13
32
|
requestCloseOnEsc,
|
|
14
33
|
requestCloseOnBackdrop,
|
|
15
34
|
onRequestClose,
|
|
16
|
-
}: {
|
|
17
|
-
dialogRef: RefObject<HTMLDialogElement>;
|
|
18
|
-
isOpen: boolean;
|
|
19
|
-
requestCloseOnEsc: boolean;
|
|
20
|
-
requestCloseOnBackdrop: boolean;
|
|
21
|
-
onRequestClose?: () => void;
|
|
22
|
-
}) {
|
|
35
|
+
}: UseDialogOptions): UseDialogReturn {
|
|
23
36
|
useKbsDisableGlobal(isOpen);
|
|
37
|
+
const [isModalShown, showModal, hideModal] = useOnOff(false);
|
|
24
38
|
|
|
25
39
|
useEffect(() => {
|
|
26
40
|
const dialog = dialogRef.current;
|
|
27
41
|
if (dialog && isOpen) {
|
|
42
|
+
showModal();
|
|
28
43
|
dialog.showModal();
|
|
29
|
-
return () =>
|
|
44
|
+
return () => {
|
|
45
|
+
hideModal();
|
|
46
|
+
dialog.close();
|
|
47
|
+
};
|
|
30
48
|
}
|
|
31
|
-
}, [dialogRef, isOpen]);
|
|
49
|
+
}, [dialogRef, isOpen, showModal, hideModal]);
|
|
32
50
|
|
|
33
51
|
const onCancel = useCallback<ReactEventHandler<HTMLDialogElement>>(
|
|
34
52
|
(event) => {
|
|
@@ -65,5 +83,13 @@ export function useDialog({
|
|
|
65
83
|
[dialogRef, requestCloseOnBackdrop, onRequestClose],
|
|
66
84
|
);
|
|
67
85
|
|
|
68
|
-
|
|
86
|
+
const dialogProps = useMemo<UseDialogReturn['dialogProps']>(
|
|
87
|
+
() => ({ onClick, onCancel }),
|
|
88
|
+
[onClick, onCancel],
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
dialogProps,
|
|
93
|
+
isModalShown,
|
|
94
|
+
};
|
|
69
95
|
}
|
|
@@ -6,9 +6,21 @@ export const CustomDivPreflight = styled.div`
|
|
|
6
6
|
line-height: 1.5;
|
|
7
7
|
-webkit-text-size-adjust: 100%;
|
|
8
8
|
tab-size: 4;
|
|
9
|
-
font-family:
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
font-family:
|
|
10
|
+
ui-sans-serif,
|
|
11
|
+
system-ui,
|
|
12
|
+
-apple-system,
|
|
13
|
+
BlinkMacSystemFont,
|
|
14
|
+
'Segoe UI',
|
|
15
|
+
Roboto,
|
|
16
|
+
'Helvetica Neue',
|
|
17
|
+
Arial,
|
|
18
|
+
'Noto Sans',
|
|
19
|
+
sans-serif,
|
|
20
|
+
'Apple Color Emoji',
|
|
21
|
+
'Segoe UI Emoji',
|
|
22
|
+
'Segoe UI Symbol',
|
|
23
|
+
'Noto Color Emoji';
|
|
12
24
|
|
|
13
25
|
width: 100%;
|
|
14
26
|
height: 100%;
|
|
@@ -62,9 +62,21 @@ html {
|
|
|
62
62
|
-webkit-text-size-adjust: 100%; /* 2 */
|
|
63
63
|
-moz-tab-size: 4; /* 3 */
|
|
64
64
|
tab-size: 4; /* 3 */
|
|
65
|
-
font-family:
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
font-family:
|
|
66
|
+
ui-sans-serif,
|
|
67
|
+
system-ui,
|
|
68
|
+
-apple-system,
|
|
69
|
+
BlinkMacSystemFont,
|
|
70
|
+
'Segoe UI',
|
|
71
|
+
Roboto,
|
|
72
|
+
'Helvetica Neue',
|
|
73
|
+
Arial,
|
|
74
|
+
'Noto Sans',
|
|
75
|
+
sans-serif,
|
|
76
|
+
'Apple Color Emoji',
|
|
77
|
+
'Segoe UI Emoji',
|
|
78
|
+
'Segoe UI Symbol',
|
|
79
|
+
'Noto Color Emoji'; /* 4 */
|
|
68
80
|
}
|
|
69
81
|
|
|
70
82
|
/*
|
|
@@ -67,9 +67,20 @@ SOFTWARE.
|
|
|
67
67
|
-webkit-text-size-adjust: 100%; /* 2 */
|
|
68
68
|
-moz-tab-size: 4; /* 3 */
|
|
69
69
|
tab-size: 4; /* 3 */
|
|
70
|
-
font-family:
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
font-family:
|
|
71
|
+
ui-sans-serif,
|
|
72
|
+
system-ui,
|
|
73
|
+
-apple-system,
|
|
74
|
+
BlinkMacSystemFont,
|
|
75
|
+
'Segoe UI',
|
|
76
|
+
Roboto,
|
|
77
|
+
'Helvetica Neue',
|
|
78
|
+
Arial,
|
|
79
|
+
'Noto Sans',
|
|
80
|
+
sans-serif,
|
|
81
|
+
'Apple Color Emoji',
|
|
82
|
+
'Segoe UI Emoji',
|
|
83
|
+
'Segoe UI Symbol',
|
|
73
84
|
'Noto Color Emoji'; /* 4 */
|
|
74
85
|
}
|
|
75
86
|
|
|
@@ -175,6 +175,7 @@ export function SplitPane(props: SplitPaneProps) {
|
|
|
175
175
|
display: 'flex',
|
|
176
176
|
height: '100%',
|
|
177
177
|
width: '100%',
|
|
178
|
+
[direction === 'horizontal' ? 'minWidth' : 'minHeight']: 0,
|
|
178
179
|
flexDirection: direction === 'horizontal' ? 'row' : 'column',
|
|
179
180
|
}}
|
|
180
181
|
>
|
|
@@ -232,7 +233,7 @@ function SplitSide(props: SplitSideProps) {
|
|
|
232
233
|
function parseSize(size: string): [number, SplitPaneType] {
|
|
233
234
|
const value = Number.parseFloat(size);
|
|
234
235
|
// remove numbers and dots from the string
|
|
235
|
-
const type = size.
|
|
236
|
+
const type = size.replaceAll(/[\d .]/g, '') as SplitPaneType;
|
|
236
237
|
|
|
237
238
|
return [value, type];
|
|
238
239
|
}
|