@insync-stageplayer/measurements 0.5.37 → 0.6.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/lib/AsyncSubject.d.ts +23 -23
- package/lib/AsyncSubject.js +64 -64
- package/lib/client/MeasurementDataClient.d.ts +135 -130
- package/lib/client/MeasurementDataClient.d.ts.map +1 -1
- package/lib/client/MeasurementDataClient.js +99 -99
- package/lib/client/MeasurementDataClient.js.map +1 -1
- package/lib/client/OnlineMeasurementDataClient.d.ts +44 -44
- package/lib/client/OnlineMeasurementDataClient.d.ts.map +1 -1
- package/lib/client/OnlineMeasurementDataClient.js +211 -211
- package/lib/client/OnlineMeasurementDataClient.js.map +1 -1
- package/lib/client/debug.d.ts +1 -1
- package/lib/client/debug.js +4 -4
- package/lib/client/index.d.ts +3 -3
- package/lib/client/index.js +3 -3
- package/lib/client/offline/OfflineMeasurementDataClient.d.ts +16 -16
- package/lib/client/offline/OfflineMeasurementDataClient.js +47 -47
- package/lib/client/offline/offline.d.ts +16 -16
- package/lib/client/offline/offline.js +82 -82
- package/lib/client/sbf.d.ts +35 -35
- package/lib/client/sbf.js +88 -88
- package/lib/client/signalviewer/SignalViewerDataClient.d.ts +37 -37
- package/lib/client/signalviewer/SignalViewerDataClient.d.ts.map +1 -1
- package/lib/client/signalviewer/SignalViewerDataClient.js +163 -164
- package/lib/client/signalviewer/SignalViewerDataClient.js.map +1 -1
- package/lib/client/signalviewer/SignalViewerDataClient.worker.d.ts +79 -73
- package/lib/client/signalviewer/SignalViewerDataClient.worker.d.ts.map +1 -1
- package/lib/client/signalviewer/SignalViewerDataClient.worker.js +342 -211
- package/lib/client/signalviewer/SignalViewerDataClient.worker.js.map +1 -1
- package/lib/components/Icon/CloseIcon.d.ts +6 -6
- package/lib/components/Icon/CloseIcon.js +24 -24
- package/lib/components/Icon/Icon.test.d.ts +1 -1
- package/lib/components/Icon/Icon.test.js +11 -11
- package/lib/components/MeasurementsChooser.d.ts +38 -38
- package/lib/components/MeasurementsChooser.d.ts.map +1 -1
- package/lib/components/MeasurementsChooser.js +178 -181
- package/lib/components/MeasurementsChooser.js.map +1 -1
- package/lib/components/MeasurementsModuleProvider.d.ts +34 -34
- package/lib/components/MeasurementsModuleProvider.d.ts.map +1 -1
- package/lib/components/MeasurementsModuleProvider.js +100 -79
- package/lib/components/MeasurementsModuleProvider.js.map +1 -1
- package/lib/components/MeasurementsTable/CheckboxCell.d.ts +35 -35
- package/lib/components/MeasurementsTable/CheckboxCell.js +28 -28
- package/lib/components/MeasurementsTable/ColorCell.d.ts +29 -29
- package/lib/components/MeasurementsTable/ColorCell.d.ts.map +1 -1
- package/lib/components/MeasurementsTable/ColorCell.js +58 -58
- package/lib/components/MeasurementsTable/ColorPicker.d.ts +6 -3
- package/lib/components/MeasurementsTable/ColorPicker.d.ts.map +1 -1
- package/lib/components/MeasurementsTable/ColorPicker.js +10 -10
- package/lib/components/MeasurementsTable/ColumnResizer.d.ts +4 -4
- package/lib/components/MeasurementsTable/ColumnResizer.js +5 -5
- package/lib/components/MeasurementsTable/ColumnSorting.d.ts +13 -13
- package/lib/components/MeasurementsTable/ColumnSorting.d.ts.map +1 -1
- package/lib/components/MeasurementsTable/ColumnSorting.js +10 -10
- package/lib/components/MeasurementsTable/MeasurementsTable.d.ts +72 -72
- package/lib/components/MeasurementsTable/MeasurementsTable.d.ts.map +1 -1
- package/lib/components/MeasurementsTable/MeasurementsTable.js +229 -217
- package/lib/components/MeasurementsTable/MeasurementsTable.js.map +1 -1
- package/lib/components/MeasurementsTable/MeasurementsTable.test.d.ts +1 -1
- package/lib/components/MeasurementsTable/MeasurementsTable.test.js +102 -102
- package/lib/components/MeasurementsTable/MeasurementsTableNoldus.d.ts +72 -72
- package/lib/components/MeasurementsTable/MeasurementsTableNoldus.d.ts.map +1 -1
- package/lib/components/MeasurementsTable/MeasurementsTableNoldus.js +193 -193
- package/lib/components/MeasurementsTable/SelectedContext.d.ts +10 -10
- package/lib/components/MeasurementsTable/SelectedContext.js +10 -10
- package/lib/components/MeasurementsTable/TextColumnFilter.d.ts +8 -8
- package/lib/components/MeasurementsTable/TextColumnFilter.d.ts.map +1 -1
- package/lib/components/MeasurementsTable/TextColumnFilter.js +15 -15
- package/lib/components/MeasurementsTable/filters.d.ts +3 -3
- package/lib/components/MeasurementsTable/filters.js +9 -9
- package/lib/components/MeasurementsTable/index.d.ts +2 -2
- package/lib/components/MeasurementsTable/index.js +2 -2
- package/lib/components/ModalMeasurementChooser.d.ts +19 -19
- package/lib/components/ModalMeasurementChooser.js +35 -35
- package/lib/conversion/UnitConversion.d.ts +13 -0
- package/lib/conversion/UnitConversion.d.ts.map +1 -0
- package/lib/conversion/UnitConversion.js +266 -0
- package/lib/conversion/UnitConversion.js.map +1 -0
- package/lib/hooks/useMarkerData.d.ts +6 -4
- package/lib/hooks/useMarkerData.d.ts.map +1 -1
- package/lib/hooks/useMarkerData.js +93 -63
- package/lib/hooks/useMarkerData.js.map +1 -1
- package/lib/hooks/useMeasurement.d.ts +41 -17
- package/lib/hooks/useMeasurement.d.ts.map +1 -1
- package/lib/hooks/useMeasurement.js +41 -41
- package/lib/hooks/useMeasurements.d.ts +11 -11
- package/lib/hooks/useMeasurements.js +22 -22
- package/lib/hooks/useMeasurementsModule.d.ts +20 -20
- package/lib/hooks/useMeasurementsModule.js +12 -12
- package/lib/hooks/useOverlayMeasurementData.d.ts +1 -1
- package/lib/hooks/useOverlayMeasurementData.js +23 -23
- package/lib/hooks/useTimedMeasurementData.d.ts +26 -26
- package/lib/hooks/useTimedMeasurementData.d.ts.map +1 -1
- package/lib/hooks/useTimedMeasurementData.js +125 -125
- package/lib/hooks/useTimedMeasurementData.js.map +1 -1
- package/lib/hooks/useWindowedMeasurementData.d.ts +25 -25
- package/lib/hooks/useWindowedMeasurementData.d.ts.map +1 -1
- package/lib/hooks/useWindowedMeasurementData.js +120 -120
- package/lib/hooks/useWindowedMeasurementData.js.map +1 -1
- package/lib/index.d.ts +15 -14
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +15 -14
- package/lib/index.js.map +1 -1
- package/lib/redux/measurements.slice.d.ts +75 -122
- package/lib/redux/measurements.slice.d.ts.map +1 -1
- package/lib/redux/measurements.slice.js +90 -89
- package/lib/redux/measurements.slice.js.map +1 -1
- package/lib/redux/reducer.d.ts +3 -10
- package/lib/redux/reducer.d.ts.map +1 -1
- package/lib/redux/reducer.js +2 -2
- package/lib/redux/reducer.js.map +1 -1
- package/lib/types.d.ts +93 -93
- package/lib/types.js +51 -51
- package/package.json +7 -10
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* A component that displays a list of measurements. Provides searching/sorting/selecting capabilities.
|
|
14
|
-
*
|
|
15
|
-
* Also allows a user to change the colors of measurements.
|
|
16
|
-
*/
|
|
17
|
-
import React, { useMemo, useCallback, useState } from "react";
|
|
18
|
-
import { useTable, useFilters, useFlexLayout, useResizeColumns, useSortBy, } from "react-table";
|
|
19
|
-
import { useTheme as useSelectedTheme } from "@insync-stageplayer/ui-components";
|
|
20
|
-
import styled from "styled-components";
|
|
21
|
-
import { SelectedContext } from "./SelectedContext";
|
|
22
|
-
import { CheckboxCell } from "./CheckboxCell";
|
|
23
|
-
import * as filters from "./filters";
|
|
24
|
-
import { TextColumnFilter } from "./TextColumnFilter";
|
|
25
|
-
import { ColumnResizer } from "./ColumnResizer";
|
|
26
|
-
import { useScrollbarWidth } from "react-use/lib/useScrollbarWidth";
|
|
27
|
-
import { ColumnSorting } from "./ColumnSorting";
|
|
28
|
-
import "bootstrap/dist/css/bootstrap.css";
|
|
29
|
-
/**
|
|
30
|
-
* Toggles a value inside an array. If a value is present in the array, it will be removed, if not
|
|
31
|
-
* it will be added.
|
|
32
|
-
* @param arr The array to toggle the value in.
|
|
33
|
-
* @param v The value being toggled.
|
|
34
|
-
* @returns
|
|
35
|
-
*/
|
|
36
|
-
const toggle = (arr, v) => {
|
|
37
|
-
if (arr.indexOf(v) === -1) {
|
|
38
|
-
return [...arr, v];
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
return arr.filter((cv) => cv !== v);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* A component that displays a list of measurements. Provides searching/sorting/selecting capabilities.
|
|
14
|
+
*
|
|
15
|
+
* Also allows a user to change the colors of measurements.
|
|
16
|
+
*/
|
|
17
|
+
import React, { useMemo, useCallback, useState } from "react";
|
|
18
|
+
import { useTable, useFilters, useFlexLayout, useResizeColumns, useSortBy, } from "react-table";
|
|
19
|
+
import { useTheme as useSelectedTheme } from "@insync-stageplayer/ui-components";
|
|
20
|
+
import styled from "styled-components";
|
|
21
|
+
import { SelectedContext } from "./SelectedContext";
|
|
22
|
+
import { CheckboxCell } from "./CheckboxCell";
|
|
23
|
+
import * as filters from "./filters";
|
|
24
|
+
import { TextColumnFilter } from "./TextColumnFilter";
|
|
25
|
+
import { ColumnResizer } from "./ColumnResizer";
|
|
26
|
+
import { useScrollbarWidth } from "react-use/lib/useScrollbarWidth";
|
|
27
|
+
import { ColumnSorting } from "./ColumnSorting";
|
|
28
|
+
import "bootstrap/dist/css/bootstrap.css";
|
|
29
|
+
/**
|
|
30
|
+
* Toggles a value inside an array. If a value is present in the array, it will be removed, if not
|
|
31
|
+
* it will be added.
|
|
32
|
+
* @param arr The array to toggle the value in.
|
|
33
|
+
* @param v The value being toggled.
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
const toggle = (arr, v) => {
|
|
37
|
+
if (arr.indexOf(v) === -1) {
|
|
38
|
+
return [...arr, v];
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return arr.filter((cv) => cv !== v);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
44
|
const Table = styled.div `
|
|
45
45
|
display: flex;
|
|
46
46
|
flex-direction: column;
|
|
47
|
-
`;
|
|
47
|
+
`;
|
|
48
48
|
const TableHead = styled.div `
|
|
49
49
|
border-top: 1px solid ${(props) => props.theme.colors.accent};
|
|
50
|
-
`;
|
|
50
|
+
`;
|
|
51
51
|
const Tr = styled.div `
|
|
52
52
|
line-height: 1.5em;
|
|
53
53
|
&:hover {
|
|
54
54
|
background-color: ${(props) => !props.selected ? props.theme.colors.action.selected : undefined};
|
|
55
55
|
}
|
|
56
|
-
${(props) => props.selected
|
|
57
|
-
? `background-color: ${props.theme.colors.action.selected}`
|
|
56
|
+
${(props) => props.selected
|
|
57
|
+
? `background-color: ${props.theme.colors.action.selected}`
|
|
58
58
|
: undefined};
|
|
59
|
-
`;
|
|
59
|
+
`;
|
|
60
60
|
const TableBody = styled.div `
|
|
61
61
|
max-height: 100%;
|
|
62
|
-
`;
|
|
62
|
+
`;
|
|
63
63
|
const TableBodyContainer = styled.div `
|
|
64
64
|
flex: 1;
|
|
65
65
|
scrollbar-width: thin;
|
|
66
|
-
`;
|
|
66
|
+
`;
|
|
67
67
|
const Cell = styled.div `
|
|
68
68
|
border: 1px solid ${(props) => props.theme.colors.accent};
|
|
69
|
-
`;
|
|
69
|
+
`;
|
|
70
70
|
const Td = styled(Cell) `
|
|
71
71
|
padding: 0 0.5em 0 0.5em;
|
|
72
72
|
display: flex;
|
|
73
73
|
align-items: center;
|
|
74
|
-
`;
|
|
74
|
+
`;
|
|
75
75
|
const Truncated = styled.div `
|
|
76
76
|
display: block;
|
|
77
77
|
white-space: nowrap;
|
|
78
78
|
overflow: hidden;
|
|
79
79
|
text-overflow: ellipsis;
|
|
80
|
-
`;
|
|
80
|
+
`;
|
|
81
81
|
const StyledTextColumnFilter = styled(TextColumnFilter) `
|
|
82
82
|
width: 100%;
|
|
83
|
-
`;
|
|
83
|
+
`;
|
|
84
84
|
const Th = styled(Cell) `
|
|
85
85
|
padding: 0 0.5em 0.5em 0.5em;
|
|
86
86
|
display: flex;
|
|
@@ -89,145 +89,145 @@ const Th = styled(Cell) `
|
|
|
89
89
|
&:last-child {
|
|
90
90
|
border-right: 2px solid ${(props) => props.theme.colors.accent};
|
|
91
91
|
}
|
|
92
|
-
`;
|
|
92
|
+
`;
|
|
93
93
|
const ColumnHeader = styled.div `
|
|
94
94
|
user-select: none;
|
|
95
|
-
`;
|
|
96
|
-
/**
|
|
97
|
-
* Definitions for the filters, please check https://react-table.tanstack.com/docs/api/useFilters#table-options
|
|
98
|
-
*/
|
|
99
|
-
const filterTypes = {
|
|
100
|
-
text: filters.textFilter,
|
|
101
|
-
};
|
|
102
|
-
/**
|
|
103
|
-
* The initial state of the table.
|
|
104
|
-
*/
|
|
105
|
-
const initialState = {
|
|
106
|
-
// Sorting by the measurement name.
|
|
107
|
-
sortBy: [{ id: "stageplayer_name_filter", desc: false }],
|
|
108
|
-
};
|
|
109
|
-
/**
|
|
110
|
-
* Convenience function for quickly creating a non-selectable column definition for react table.
|
|
111
|
-
* @param options
|
|
112
|
-
* @returns
|
|
113
|
-
*/
|
|
114
|
-
const createColumn = (options) => (Object.assign({ Filter: StyledTextColumnFilter, selectable: true }, options));
|
|
115
|
-
const defaultOnChange = () => { };
|
|
116
|
-
/**
|
|
117
|
-
* A component to render a list of measurements in a table. This table provides functionalities like:
|
|
118
|
-
*
|
|
119
|
-
* Please read up here https://react-table.tanstack.com/ for more information as to how this component works internally.
|
|
120
|
-
*
|
|
121
|
-
* - Sorting
|
|
122
|
-
* - Resizable columns
|
|
123
|
-
* - Changing measurement colors
|
|
124
|
-
* - Searching measurements
|
|
125
|
-
* - Selecting measurements
|
|
126
|
-
* @param props
|
|
127
|
-
* @returns
|
|
128
|
-
*/
|
|
129
|
-
export const MeasurementsTableNoldus = (props) => {
|
|
130
|
-
const { selected = [], measurements, onChange = defaultOnChange, onColorChange, onYAxisPosChange, widths, single, formatFrequency, globallyUniqueMeasurementColors, dataViewerId } = props, rest = __rest(props, ["selected", "measurements", "onChange", "onColorChange", "onYAxisPosChange", "widths", "single", "formatFrequency", "globallyUniqueMeasurementColors", "dataViewerId"]);
|
|
131
|
-
const [showColorPicker, setShowColorPicker] = useState();
|
|
132
|
-
let selectedDataScaleValue = 0;
|
|
133
|
-
// This doesn't work correctly, the column separators between the top row and rest don't align nicely.
|
|
134
|
-
const scrollbarWidth = useScrollbarWidth();
|
|
135
|
-
const widthProps = useCallback((index, defaultVal = undefined) => {
|
|
136
|
-
return widths && widths[index] !== -1
|
|
137
|
-
? { width: widths[index], minWidth: widths[index] }
|
|
138
|
-
: defaultVal
|
|
139
|
-
? { width: defaultVal, minWidth: defaultVal }
|
|
140
|
-
: {};
|
|
141
|
-
}, [widths]);
|
|
142
|
-
const columns = useMemo(() => [
|
|
143
|
-
createColumn(Object.assign({ Header: React.createElement("div", { "aria-label": "Active" }), accessor: "id", Cell: (data) => {
|
|
144
|
-
return (React.createElement(CheckboxCell, { id: data.value, rowToDisable: selected.length !== 0 &&
|
|
145
|
-
data.row.original.dataScale !== selectedDataScaleValue }));
|
|
146
|
-
}, disableFilters: true, disableResizing: true, disableSortBy: true, maxWidth: 30 }, widthProps(0, 35))),
|
|
147
|
-
createColumn(Object.assign({ id: "stageplayer_name_filter", Header: "Name", accessor: "name" }, widthProps(1))),
|
|
148
|
-
createColumn(Object.assign({ Header: "Unit", accessor: "unit" }, widthProps(2, 35))),
|
|
149
|
-
createColumn(Object.assign({ Header: "Min", accessor: "min" }, widthProps(3, 50))),
|
|
150
|
-
createColumn(Object.assign({ Header: "Max", accessor: "max" }, widthProps(4, 50))),
|
|
151
|
-
createColumn(Object.assign({ Header: "Sample Rate", id: "sampleRate", accessor: "frequency", Cell: (data) => {
|
|
152
|
-
return formatFrequency ? formatFrequency(data.value) : data.value;
|
|
153
|
-
}, readable: "sample rate", disableFilters: true }, widthProps(5, 100))),
|
|
154
|
-
], [
|
|
155
|
-
onColorChange,
|
|
156
|
-
widthProps,
|
|
157
|
-
showColorPicker,
|
|
158
|
-
formatFrequency,
|
|
159
|
-
globallyUniqueMeasurementColors,
|
|
160
|
-
dataViewerId,
|
|
161
|
-
selected.length,
|
|
162
|
-
selectedDataScaleValue,
|
|
163
|
-
]);
|
|
164
|
-
const selectedTheme = useSelectedTheme();
|
|
165
|
-
const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow } = useTable({
|
|
166
|
-
columns,
|
|
167
|
-
data: measurements,
|
|
168
|
-
filterTypes,
|
|
169
|
-
initialState,
|
|
170
|
-
disableSortRemove: true,
|
|
171
|
-
autoResetSortBy: false,
|
|
172
|
-
autoResetFilters: false,
|
|
173
|
-
}, useFilters, useFlexLayout, useResizeColumns, useSortBy);
|
|
174
|
-
return (
|
|
175
|
-
// apply the table props
|
|
176
|
-
React.createElement(SelectedContext.Provider, { value: { single, selected, yAxisLeftSelected: [], onChange } },
|
|
177
|
-
React.createElement(Table, Object.assign({}, getTableProps(), rest),
|
|
178
|
-
React.createElement(TableHead, { scrollbarWidth: scrollbarWidth }, headerGroups.map((headerGroup) => (React.createElement("div", Object.assign({}, headerGroup.getHeaderGroupProps()), headerGroup.headers.map((column) => (React.createElement(Th, Object.assign({}, column.getHeaderProps()),
|
|
179
|
-
React.createElement(ColumnHeader, Object.assign({}, column.getSortByToggleProps(), { role: "button" }),
|
|
180
|
-
column.render("Header"),
|
|
181
|
-
React.createElement(ColumnSorting, { column: column })),
|
|
182
|
-
column.canFilter && React.createElement("div", null, column.render("Filter")),
|
|
183
|
-
column.getResizerProps ? (React.createElement(ColumnResizer, Object.assign({}, column.getResizerProps(), { resizing: column.isResizing }))) : null))))))),
|
|
184
|
-
React.createElement(TableBodyContainer, null,
|
|
185
|
-
React.createElement(TableBody, Object.assign({}, getTableBodyProps()), rows.map((row, i) => {
|
|
186
|
-
prepareRow(row);
|
|
187
|
-
if (selected.indexOf(row.values.id) !== -1)
|
|
188
|
-
selectedDataScaleValue = row.original.dataScale;
|
|
189
|
-
return (React.createElement(Tr, Object.assign({}, row.getRowProps(), { tabIndex: 0, selected: selected.indexOf(row.values.id) !== -1, onKeyDown: (e) => {
|
|
190
|
-
if (e.key === "Enter" &&
|
|
191
|
-
(selected.length === 0 ||
|
|
192
|
-
row.original.dataScale === selectedDataScaleValue)) {
|
|
193
|
-
onChange && onChange(toggle(selected, row.values.id));
|
|
194
|
-
}
|
|
195
|
-
else if (e.key === "ArrowDown") {
|
|
196
|
-
const target = e.target;
|
|
197
|
-
if (target instanceof HTMLElement &&
|
|
198
|
-
target.nextSibling instanceof HTMLElement) {
|
|
199
|
-
e.preventDefault();
|
|
200
|
-
e.stopPropagation();
|
|
201
|
-
target.nextSibling.focus();
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
else if (e.key === "ArrowUp") {
|
|
205
|
-
const target = e.target;
|
|
206
|
-
if (target instanceof HTMLElement &&
|
|
207
|
-
target.previousSibling instanceof HTMLElement) {
|
|
208
|
-
e.preventDefault();
|
|
209
|
-
e.stopPropagation();
|
|
210
|
-
target.previousSibling.focus();
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
} }), row.cells.map((cell) => {
|
|
214
|
-
const clickHandler = () => {
|
|
215
|
-
if (selected.length === 0 ||
|
|
216
|
-
cell.row.original.dataScale === selectedDataScaleValue) {
|
|
217
|
-
cell.column.selectable && onChange
|
|
218
|
-
? onChange(single
|
|
219
|
-
? [cell.row.original.id]
|
|
220
|
-
: toggle(selected, cell.row.original.id))
|
|
221
|
-
: onYAxisPosChange &&
|
|
222
|
-
onYAxisPosChange(single
|
|
223
|
-
? [cell.row.original.id]
|
|
224
|
-
: toggle(selected, cell.row.original.id));
|
|
225
|
-
selectedDataScaleValue = cell.row.original.dataScale;
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
return (React.createElement(Td, Object.assign({}, cell.getCellProps(), { onClick: clickHandler }),
|
|
229
|
-
React.createElement(Truncated, { title: cell.value }, cell.render("Cell"))));
|
|
230
|
-
})));
|
|
231
|
-
}))))));
|
|
232
|
-
};
|
|
95
|
+
`;
|
|
96
|
+
/**
|
|
97
|
+
* Definitions for the filters, please check https://react-table.tanstack.com/docs/api/useFilters#table-options
|
|
98
|
+
*/
|
|
99
|
+
const filterTypes = {
|
|
100
|
+
text: filters.textFilter,
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* The initial state of the table.
|
|
104
|
+
*/
|
|
105
|
+
const initialState = {
|
|
106
|
+
// Sorting by the measurement name.
|
|
107
|
+
sortBy: [{ id: "stageplayer_name_filter", desc: false }],
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Convenience function for quickly creating a non-selectable column definition for react table.
|
|
111
|
+
* @param options
|
|
112
|
+
* @returns
|
|
113
|
+
*/
|
|
114
|
+
const createColumn = (options) => (Object.assign({ Filter: StyledTextColumnFilter, selectable: true }, options));
|
|
115
|
+
const defaultOnChange = () => { };
|
|
116
|
+
/**
|
|
117
|
+
* A component to render a list of measurements in a table. This table provides functionalities like:
|
|
118
|
+
*
|
|
119
|
+
* Please read up here https://react-table.tanstack.com/ for more information as to how this component works internally.
|
|
120
|
+
*
|
|
121
|
+
* - Sorting
|
|
122
|
+
* - Resizable columns
|
|
123
|
+
* - Changing measurement colors
|
|
124
|
+
* - Searching measurements
|
|
125
|
+
* - Selecting measurements
|
|
126
|
+
* @param props
|
|
127
|
+
* @returns
|
|
128
|
+
*/
|
|
129
|
+
export const MeasurementsTableNoldus = (props) => {
|
|
130
|
+
const { selected = [], measurements, onChange = defaultOnChange, onColorChange, onYAxisPosChange, widths, single, formatFrequency, globallyUniqueMeasurementColors, dataViewerId } = props, rest = __rest(props, ["selected", "measurements", "onChange", "onColorChange", "onYAxisPosChange", "widths", "single", "formatFrequency", "globallyUniqueMeasurementColors", "dataViewerId"]);
|
|
131
|
+
const [showColorPicker, setShowColorPicker] = useState();
|
|
132
|
+
let selectedDataScaleValue = 0;
|
|
133
|
+
// This doesn't work correctly, the column separators between the top row and rest don't align nicely.
|
|
134
|
+
const scrollbarWidth = useScrollbarWidth();
|
|
135
|
+
const widthProps = useCallback((index, defaultVal = undefined) => {
|
|
136
|
+
return widths && widths[index] !== -1
|
|
137
|
+
? { width: widths[index], minWidth: widths[index] }
|
|
138
|
+
: defaultVal
|
|
139
|
+
? { width: defaultVal, minWidth: defaultVal }
|
|
140
|
+
: {};
|
|
141
|
+
}, [widths]);
|
|
142
|
+
const columns = useMemo(() => [
|
|
143
|
+
createColumn(Object.assign({ Header: React.createElement("div", { "aria-label": "Active" }), accessor: "id", Cell: (data) => {
|
|
144
|
+
return (React.createElement(CheckboxCell, { id: data.value, rowToDisable: selected.length !== 0 &&
|
|
145
|
+
data.row.original.dataScale !== selectedDataScaleValue }));
|
|
146
|
+
}, disableFilters: true, disableResizing: true, disableSortBy: true, maxWidth: 30 }, widthProps(0, 35))),
|
|
147
|
+
createColumn(Object.assign({ id: "stageplayer_name_filter", Header: "Name", accessor: "name" }, widthProps(1))),
|
|
148
|
+
createColumn(Object.assign({ Header: "Unit", accessor: "unit" }, widthProps(2, 35))),
|
|
149
|
+
createColumn(Object.assign({ Header: "Min", accessor: "min" }, widthProps(3, 50))),
|
|
150
|
+
createColumn(Object.assign({ Header: "Max", accessor: "max" }, widthProps(4, 50))),
|
|
151
|
+
createColumn(Object.assign({ Header: "Sample Rate", id: "sampleRate", accessor: "frequency", Cell: (data) => {
|
|
152
|
+
return formatFrequency ? formatFrequency(data.value) : data.value;
|
|
153
|
+
}, readable: "sample rate", disableFilters: true }, widthProps(5, 100))),
|
|
154
|
+
], [
|
|
155
|
+
onColorChange,
|
|
156
|
+
widthProps,
|
|
157
|
+
showColorPicker,
|
|
158
|
+
formatFrequency,
|
|
159
|
+
globallyUniqueMeasurementColors,
|
|
160
|
+
dataViewerId,
|
|
161
|
+
selected.length,
|
|
162
|
+
selectedDataScaleValue,
|
|
163
|
+
]);
|
|
164
|
+
const selectedTheme = useSelectedTheme();
|
|
165
|
+
const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow } = useTable({
|
|
166
|
+
columns,
|
|
167
|
+
data: measurements,
|
|
168
|
+
filterTypes,
|
|
169
|
+
initialState,
|
|
170
|
+
disableSortRemove: true,
|
|
171
|
+
autoResetSortBy: false,
|
|
172
|
+
autoResetFilters: false,
|
|
173
|
+
}, useFilters, useFlexLayout, useResizeColumns, useSortBy);
|
|
174
|
+
return (
|
|
175
|
+
// apply the table props
|
|
176
|
+
React.createElement(SelectedContext.Provider, { value: { single, selected, yAxisLeftSelected: [], onChange } },
|
|
177
|
+
React.createElement(Table, Object.assign({}, getTableProps(), rest),
|
|
178
|
+
React.createElement(TableHead, { scrollbarWidth: scrollbarWidth }, headerGroups.map((headerGroup) => (React.createElement("div", Object.assign({}, headerGroup.getHeaderGroupProps()), headerGroup.headers.map((column) => (React.createElement(Th, Object.assign({}, column.getHeaderProps()),
|
|
179
|
+
React.createElement(ColumnHeader, Object.assign({}, column.getSortByToggleProps(), { role: "button" }),
|
|
180
|
+
column.render("Header"),
|
|
181
|
+
React.createElement(ColumnSorting, { column: column })),
|
|
182
|
+
column.canFilter && React.createElement("div", null, column.render("Filter")),
|
|
183
|
+
column.getResizerProps ? (React.createElement(ColumnResizer, Object.assign({}, column.getResizerProps(), { resizing: column.isResizing }))) : null))))))),
|
|
184
|
+
React.createElement(TableBodyContainer, null,
|
|
185
|
+
React.createElement(TableBody, Object.assign({}, getTableBodyProps()), rows.map((row, i) => {
|
|
186
|
+
prepareRow(row);
|
|
187
|
+
if (selected.indexOf(row.values.id) !== -1)
|
|
188
|
+
selectedDataScaleValue = row.original.dataScale;
|
|
189
|
+
return (React.createElement(Tr, Object.assign({}, row.getRowProps(), { tabIndex: 0, selected: selected.indexOf(row.values.id) !== -1, onKeyDown: (e) => {
|
|
190
|
+
if (e.key === "Enter" &&
|
|
191
|
+
(selected.length === 0 ||
|
|
192
|
+
row.original.dataScale === selectedDataScaleValue)) {
|
|
193
|
+
onChange && onChange(toggle(selected, row.values.id));
|
|
194
|
+
}
|
|
195
|
+
else if (e.key === "ArrowDown") {
|
|
196
|
+
const target = e.target;
|
|
197
|
+
if (target instanceof HTMLElement &&
|
|
198
|
+
target.nextSibling instanceof HTMLElement) {
|
|
199
|
+
e.preventDefault();
|
|
200
|
+
e.stopPropagation();
|
|
201
|
+
target.nextSibling.focus();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
else if (e.key === "ArrowUp") {
|
|
205
|
+
const target = e.target;
|
|
206
|
+
if (target instanceof HTMLElement &&
|
|
207
|
+
target.previousSibling instanceof HTMLElement) {
|
|
208
|
+
e.preventDefault();
|
|
209
|
+
e.stopPropagation();
|
|
210
|
+
target.previousSibling.focus();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
} }), row.cells.map((cell) => {
|
|
214
|
+
const clickHandler = () => {
|
|
215
|
+
if (selected.length === 0 ||
|
|
216
|
+
cell.row.original.dataScale === selectedDataScaleValue) {
|
|
217
|
+
cell.column.selectable && onChange
|
|
218
|
+
? onChange(single
|
|
219
|
+
? [cell.row.original.id]
|
|
220
|
+
: toggle(selected, cell.row.original.id))
|
|
221
|
+
: onYAxisPosChange &&
|
|
222
|
+
onYAxisPosChange(single
|
|
223
|
+
? [cell.row.original.id]
|
|
224
|
+
: toggle(selected, cell.row.original.id));
|
|
225
|
+
selectedDataScaleValue = cell.row.original.dataScale;
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
return (React.createElement(Td, Object.assign({}, cell.getCellProps(), { onClick: clickHandler }),
|
|
229
|
+
React.createElement(Truncated, { title: cell.value }, cell.render("Cell"))));
|
|
230
|
+
})));
|
|
231
|
+
}))))));
|
|
232
|
+
};
|
|
233
233
|
//# sourceMappingURL=MeasurementsTableNoldus.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
/**
|
|
3
|
-
* A context for keeping track of selected values. This will keep rerenders in the table to a minimum.
|
|
4
|
-
*/
|
|
5
|
-
export declare const SelectedContext: import("react").Context<{
|
|
6
|
-
single: boolean | undefined;
|
|
7
|
-
selected: string[];
|
|
8
|
-
yAxisLeftSelected: string[];
|
|
9
|
-
onChange: (newSelected: string[]) => void;
|
|
10
|
-
}>;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* A context for keeping track of selected values. This will keep rerenders in the table to a minimum.
|
|
4
|
+
*/
|
|
5
|
+
export declare const SelectedContext: import("react").Context<{
|
|
6
|
+
single: boolean | undefined;
|
|
7
|
+
selected: string[];
|
|
8
|
+
yAxisLeftSelected: string[];
|
|
9
|
+
onChange: (newSelected: string[]) => void;
|
|
10
|
+
}>;
|
|
11
11
|
//# sourceMappingURL=SelectedContext.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createContext } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* A context for keeping track of selected values. This will keep rerenders in the table to a minimum.
|
|
4
|
-
*/
|
|
5
|
-
export const SelectedContext = createContext({
|
|
6
|
-
single: false,
|
|
7
|
-
selected: [],
|
|
8
|
-
yAxisLeftSelected: [],
|
|
9
|
-
onChange: (newSelected) => { },
|
|
10
|
-
});
|
|
1
|
+
import { createContext } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* A context for keeping track of selected values. This will keep rerenders in the table to a minimum.
|
|
4
|
+
*/
|
|
5
|
+
export const SelectedContext = createContext({
|
|
6
|
+
single: false,
|
|
7
|
+
selected: [],
|
|
8
|
+
yAxisLeftSelected: [],
|
|
9
|
+
onChange: (newSelected) => { },
|
|
10
|
+
});
|
|
11
11
|
//# sourceMappingURL=SelectedContext.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { FilterProps } from "react-table";
|
|
3
|
-
interface TextColumnFilterProps<T extends object> extends FilterProps<T> {
|
|
4
|
-
className: string;
|
|
5
|
-
style: React.CSSProperties;
|
|
6
|
-
}
|
|
7
|
-
export declare function TextColumnFilter<T extends object>({ column: { id, filterValue, setFilter, readable }, style, className, }: TextColumnFilterProps<T>): JSX.Element;
|
|
8
|
-
export {};
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FilterProps } from "react-table";
|
|
3
|
+
interface TextColumnFilterProps<T extends object> extends FilterProps<T> {
|
|
4
|
+
className: string;
|
|
5
|
+
style: React.CSSProperties;
|
|
6
|
+
}
|
|
7
|
+
export declare function TextColumnFilter<T extends object>({ column: { id, filterValue, setFilter, readable }, style, className, }: TextColumnFilterProps<T>): React.JSX.Element;
|
|
8
|
+
export {};
|
|
9
9
|
//# sourceMappingURL=TextColumnFilter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextColumnFilter.d.ts","sourceRoot":"","sources":["../../../src/components/MeasurementsTable/TextColumnFilter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,UAAU,qBAAqB,CAAC,CAAC,SAAS,MAAM,CAAE,SAAQ,WAAW,CAAC,CAAC,CAAC;IACtE,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC;CAC5B;AAED,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAAE,EACjD,MAAM,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,EAChD,KAAK,EACL,SAAS,GACV,EAAE,qBAAqB,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"TextColumnFilter.d.ts","sourceRoot":"","sources":["../../../src/components/MeasurementsTable/TextColumnFilter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,UAAU,qBAAqB,CAAC,CAAC,SAAS,MAAM,CAAE,SAAQ,WAAW,CAAC,CAAC,CAAC;IACtE,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC;CAC5B;AAED,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAAE,EACjD,MAAM,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,EAChD,KAAK,EACL,SAAS,GACV,EAAE,qBAAqB,CAAC,CAAC,CAAC,qBA4B1B"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import React, { useEffect } from "react";
|
|
2
|
-
export function TextColumnFilter({ column: { id, filterValue, setFilter, readable }, style, className, }) {
|
|
3
|
-
const [value, setValue] = React.useState(filterValue || "");
|
|
4
|
-
const handleChange = (event) => {
|
|
5
|
-
setValue(event.target.value);
|
|
6
|
-
setFilter(event.target.value);
|
|
7
|
-
};
|
|
8
|
-
// ensure that reset loads the new value
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
setValue(filterValue || "");
|
|
11
|
-
}, [filterValue]);
|
|
12
|
-
return (React.createElement("input", { style: style, className: className, placeholder: "Filter", autoComplete: "off", "aria-label": `Filter by ${readable || id}`, type: "text", name: id, value: value, onChange: handleChange, onBlur: (e) => {
|
|
13
|
-
setFilter(e.target.value || undefined);
|
|
14
|
-
} }));
|
|
15
|
-
}
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
|
+
export function TextColumnFilter({ column: { id, filterValue, setFilter, readable }, style, className, }) {
|
|
3
|
+
const [value, setValue] = React.useState(filterValue || "");
|
|
4
|
+
const handleChange = (event) => {
|
|
5
|
+
setValue(event.target.value);
|
|
6
|
+
setFilter(event.target.value);
|
|
7
|
+
};
|
|
8
|
+
// ensure that reset loads the new value
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
setValue(filterValue || "");
|
|
11
|
+
}, [filterValue]);
|
|
12
|
+
return (React.createElement("input", { style: style, className: className, placeholder: "Filter", autoComplete: "off", "aria-label": `Filter by ${readable || id}`, type: "text", name: id, value: value, onChange: handleChange, onBlur: (e) => {
|
|
13
|
+
setFilter(e.target.value || undefined);
|
|
14
|
+
} }));
|
|
15
|
+
}
|
|
16
16
|
//# sourceMappingURL=TextColumnFilter.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FilterValue, IdType, Row } from "react-table";
|
|
2
|
-
export declare function textMatcher<T extends object>(match: string, id: IdType<T>): (row: Row<T>) => boolean;
|
|
3
|
-
export declare function textFilter<T extends object>(rows: Array<Row<T>>, id: IdType<T>, filterValue: FilterValue): Row<T>[];
|
|
1
|
+
import { FilterValue, IdType, Row } from "react-table";
|
|
2
|
+
export declare function textMatcher<T extends object>(match: string, id: IdType<T>): (row: Row<T>) => boolean;
|
|
3
|
+
export declare function textFilter<T extends object>(rows: Array<Row<T>>, id: IdType<T>, filterValue: FilterValue): Row<T>[];
|
|
4
4
|
//# sourceMappingURL=filters.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export function textMatcher(match, id) {
|
|
2
|
-
return (row) => {
|
|
3
|
-
const val = row.values[id[0]];
|
|
4
|
-
return `${val}`.toLowerCase().indexOf(match) !== -1;
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
export function textFilter(rows, id, filterValue) {
|
|
8
|
-
return rows.filter(textMatcher(filterValue, id));
|
|
9
|
-
}
|
|
1
|
+
export function textMatcher(match, id) {
|
|
2
|
+
return (row) => {
|
|
3
|
+
const val = row.values[id[0]];
|
|
4
|
+
return `${val}`.toLowerCase().indexOf(match) !== -1;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export function textFilter(rows, id, filterValue) {
|
|
8
|
+
return rows.filter(textMatcher(filterValue, id));
|
|
9
|
+
}
|
|
10
10
|
//# sourceMappingURL=filters.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./MeasurementsTable";
|
|
2
|
-
export * from "./MeasurementsTableNoldus";
|
|
1
|
+
export * from "./MeasurementsTable";
|
|
2
|
+
export * from "./MeasurementsTableNoldus";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./MeasurementsTable";
|
|
2
|
-
export * from "./MeasurementsTableNoldus";
|
|
1
|
+
export * from "./MeasurementsTable";
|
|
2
|
+
export * from "./MeasurementsTableNoldus";
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { MeasurementsChooserProps } from "./MeasurementsChooser";
|
|
3
|
-
interface ModalMeasurementsChooserProps extends MeasurementsChooserProps {
|
|
4
|
-
/**
|
|
5
|
-
* If set to true, the modal will be visible.
|
|
6
|
-
*/
|
|
7
|
-
open?: boolean;
|
|
8
|
-
/**
|
|
9
|
-
* Called when the modal is closed.
|
|
10
|
-
*/
|
|
11
|
-
onClose?: () => void;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* A modal wrapper around MeasurementsChooser.
|
|
15
|
-
* @param props
|
|
16
|
-
* @returns
|
|
17
|
-
*/
|
|
18
|
-
export declare const ModalMeasurementsChooser: React.FC<ModalMeasurementsChooserProps>;
|
|
19
|
-
export {};
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MeasurementsChooserProps } from "./MeasurementsChooser";
|
|
3
|
+
interface ModalMeasurementsChooserProps extends MeasurementsChooserProps {
|
|
4
|
+
/**
|
|
5
|
+
* If set to true, the modal will be visible.
|
|
6
|
+
*/
|
|
7
|
+
open?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Called when the modal is closed.
|
|
10
|
+
*/
|
|
11
|
+
onClose?: () => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A modal wrapper around MeasurementsChooser.
|
|
15
|
+
* @param props
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
export declare const ModalMeasurementsChooser: React.FC<ModalMeasurementsChooserProps>;
|
|
19
|
+
export {};
|
|
20
20
|
//# sourceMappingURL=ModalMeasurementChooser.d.ts.map
|