@perses-dev/components 0.50.3 → 0.51.0-beta.1
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/dist/BarChart/BarChart.js.map +1 -1
- package/dist/ColorPicker/ColorPicker.js +2 -2
- package/dist/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/ColorPicker/OptionsColorPicker.js.map +1 -1
- package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.js +2 -3
- package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
- package/dist/DragAndDrop/DragButton.js +1 -1
- package/dist/DragAndDrop/DragButton.js.map +1 -1
- package/dist/DragAndDrop/DropIndicator.js.map +1 -1
- package/dist/Drawer/Drawer.js +1 -1
- package/dist/Drawer/Drawer.js.map +1 -1
- package/dist/EChart/EChart.d.ts.map +1 -1
- package/dist/EChart/EChart.js +19 -5
- package/dist/EChart/EChart.js.map +1 -1
- package/dist/GaugeChart/GaugeChart.js +2 -5
- package/dist/GaugeChart/GaugeChart.js.map +1 -1
- package/dist/InfoTooltip/InfoTooltip.js +5 -4
- package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
- package/dist/JSONEditor.js.map +1 -1
- package/dist/Legend/ListLegendItem.js +3 -4
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/LineChart/LineChart.js +4 -8
- package/dist/LineChart/LineChart.js.map +1 -1
- package/dist/LinksEditor/LinksEditor.js +9 -18
- package/dist/LinksEditor/LinksEditor.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
- package/dist/Overlay/Overlay.js +1 -1
- package/dist/Overlay/Overlay.js.map +1 -1
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js +1 -2
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
- package/dist/StatChart/StatChart.js +3 -5
- package/dist/StatChart/StatChart.js.map +1 -1
- package/dist/StatChart/calculateFontSize.js +2 -4
- package/dist/StatChart/calculateFontSize.js.map +1 -1
- package/dist/StatusHistoryChart/StatusHistoryChart.js +1 -2
- package/dist/StatusHistoryChart/StatusHistoryChart.js.map +1 -1
- package/dist/StatusHistoryChart/utils/get-color.js.map +1 -1
- package/dist/Table/Table.d.ts +1 -1
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +7 -6
- package/dist/Table/Table.js.map +1 -1
- package/dist/Table/TableCell.d.ts +2 -1
- package/dist/Table/TableCell.d.ts.map +1 -1
- package/dist/Table/TableCell.js +9 -8
- package/dist/Table/TableCell.js.map +1 -1
- package/dist/Table/TableHeaderCell.js.map +1 -1
- package/dist/Table/VirtualizedTable.d.ts +2 -2
- package/dist/Table/VirtualizedTable.d.ts.map +1 -1
- package/dist/Table/VirtualizedTable.js +14 -15
- package/dist/Table/VirtualizedTable.js.map +1 -1
- package/dist/Table/hooks/useTableKeyboardNav.js +1 -1
- package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -1
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js +7 -13
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -1
- package/dist/Table/model/table-model.d.ts +8 -1
- package/dist/Table/model/table-model.d.ts.map +1 -1
- package/dist/Table/model/table-model.js +5 -3
- package/dist/Table/model/table-model.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js +16 -24
- package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
- package/dist/TimeChart/TimeChart.js +7 -10
- package/dist/TimeChart/TimeChart.js.map +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.js +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
- package/dist/TimeRangeSelector/utils.js.map +1 -1
- package/dist/TimeSeriesTooltip/LineChartTooltip.js +6 -11
- package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js +1 -2
- package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js +2 -3
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.js +4 -10
- package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.js +13 -23
- package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
- package/dist/TimeSeriesTooltip/utils.js +2 -4
- package/dist/TimeSeriesTooltip/utils.js.map +1 -1
- package/dist/TransformsEditor/TransformEditor.js +4 -7
- package/dist/TransformsEditor/TransformEditor.js.map +1 -1
- package/dist/TransformsEditor/TransformEditorContainer.js +3 -5
- package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
- package/dist/TransformsEditor/TransformsEditor.js +3 -6
- package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.js +11 -24
- package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -1
- package/dist/cjs/ColorPicker/ColorPicker.js +2 -2
- package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +2 -3
- package/dist/cjs/DragAndDrop/DragButton.js +1 -1
- package/dist/cjs/Drawer/Drawer.js +1 -1
- package/dist/cjs/EChart/EChart.js +18 -4
- package/dist/cjs/GaugeChart/GaugeChart.js +2 -5
- package/dist/cjs/InfoTooltip/InfoTooltip.js +5 -4
- package/dist/cjs/Legend/ListLegendItem.js +3 -4
- package/dist/cjs/LineChart/LineChart.js +4 -8
- package/dist/cjs/LinksEditor/LinksEditor.js +9 -18
- package/dist/cjs/Overlay/Overlay.js +1 -1
- package/dist/cjs/SettingsAutocomplete/SettingsAutocomplete.js +1 -2
- package/dist/cjs/StatChart/StatChart.js +3 -5
- package/dist/cjs/StatChart/calculateFontSize.js +2 -4
- package/dist/cjs/StatusHistoryChart/StatusHistoryChart.js +1 -2
- package/dist/cjs/Table/Table.js +7 -6
- package/dist/cjs/Table/TableCell.js +9 -8
- package/dist/cjs/Table/VirtualizedTable.js +14 -15
- package/dist/cjs/Table/hooks/useTableKeyboardNav.js +1 -1
- package/dist/cjs/Table/hooks/useVirtualizedTableKeyboardNav.js +7 -13
- package/dist/cjs/Table/model/table-model.js +8 -3
- package/dist/cjs/ThresholdsEditor/ThresholdsEditor.js +24 -32
- package/dist/cjs/TimeChart/TimeChart.js +6 -9
- package/dist/cjs/TimeRangeSelector/DateTimeRangePicker.js +2 -2
- package/dist/cjs/TimeSeriesTooltip/LineChartTooltip.js +6 -11
- package/dist/cjs/TimeSeriesTooltip/SeriesInfo.js +1 -2
- package/dist/cjs/TimeSeriesTooltip/TimeChartTooltip.js +2 -3
- package/dist/cjs/TimeSeriesTooltip/TooltipHeader.js +4 -10
- package/dist/cjs/TimeSeriesTooltip/nearby-series.js +13 -23
- package/dist/cjs/TimeSeriesTooltip/utils.js +2 -4
- package/dist/cjs/TransformsEditor/TransformEditor.js +4 -7
- package/dist/cjs/TransformsEditor/TransformEditorContainer.js +3 -5
- package/dist/cjs/TransformsEditor/TransformsEditor.js +3 -6
- package/dist/cjs/ValueMappingEditor/ValueMappingEditor.js +11 -24
- package/dist/cjs/context/TimeZoneProvider.js +1 -1
- package/dist/cjs/controls/TextField.js +1 -1
- package/dist/cjs/utils/chart-actions.js +1 -2
- package/dist/cjs/utils/format.js +1 -1
- package/dist/cjs/utils/theme-gen.js +5 -7
- package/dist/context/SnackbarProvider.js.map +1 -1
- package/dist/context/TimeZoneProvider.js +1 -1
- package/dist/context/TimeZoneProvider.js.map +1 -1
- package/dist/controls/TextField.js +1 -1
- package/dist/controls/TextField.js.map +1 -1
- package/dist/model/timeOption.js.map +1 -1
- package/dist/theme/component-overrides/alert.js.map +1 -1
- package/dist/utils/chart-actions.js +1 -2
- package/dist/utils/chart-actions.js.map +1 -1
- package/dist/utils/component-ids.js.map +1 -1
- package/dist/utils/format.js +1 -1
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/theme-gen.js +5 -7
- package/dist/utils/theme-gen.js.map +1 -1
- package/package.json +5 -8
|
@@ -45,7 +45,6 @@ const _utils = require("../utils");
|
|
|
45
45
|
_renderers.CanvasRenderer
|
|
46
46
|
]);
|
|
47
47
|
const LineChart = /*#__PURE__*/ (0, _react.forwardRef)(function LineChart({ height, data, yAxis, format, grid, legend, tooltipConfig = _TimeSeriesTooltip.DEFAULT_TOOLTIP_CONFIG, noDataVariant = 'message', syncGroup, onDataZoom, onDoubleClick, __experimentalEChartsOptionsOverride }, ref) {
|
|
48
|
-
var _option_tooltip;
|
|
49
48
|
const chartsTheme = (0, _context.useChartsTheme)();
|
|
50
49
|
const chartRef = (0, _react.useRef)();
|
|
51
50
|
const [showTooltip, setShowTooltip] = (0, _react.useState)(true);
|
|
@@ -84,10 +83,8 @@ const LineChart = /*#__PURE__*/ (0, _react.forwardRef)(function LineChart({ heig
|
|
|
84
83
|
}, 10);
|
|
85
84
|
}
|
|
86
85
|
if (onDataZoom === undefined || params.batch[0] === undefined) return;
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
var _params_batch__endValue;
|
|
90
|
-
const endIndex = (_params_batch__endValue = params.batch[0].endValue) !== null && _params_batch__endValue !== void 0 ? _params_batch__endValue : data.xAxis.length - 1;
|
|
86
|
+
const startIndex = params.batch[0].startValue ?? 0;
|
|
87
|
+
const endIndex = params.batch[0].endValue ?? data.xAxis.length - 1;
|
|
91
88
|
const xAxisStartValue = data.xAxis[startIndex];
|
|
92
89
|
const xAxisEndValue = data.xAxis[endIndex];
|
|
93
90
|
if (xAxisStartValue !== undefined && xAxisEndValue !== undefined) {
|
|
@@ -115,8 +112,7 @@ const LineChart = /*#__PURE__*/ (0, _react.forwardRef)(function LineChart({ heig
|
|
|
115
112
|
// The "chart" `noDataVariant` is only used when the `timeSeries` is an
|
|
116
113
|
// empty array because a `null` value will throw an error.
|
|
117
114
|
if (data.timeSeries === null || data.timeSeries.length === 0 && noDataVariant === 'message') return noDataOption;
|
|
118
|
-
|
|
119
|
-
const rangeMs = (_data_rangeMs = data.rangeMs) !== null && _data_rangeMs !== void 0 ? _data_rangeMs : (0, _utils.getDateRange)(data.xAxis);
|
|
115
|
+
const rangeMs = data.rangeMs ?? (0, _utils.getDateRange)(data.xAxis);
|
|
120
116
|
const option = {
|
|
121
117
|
series: data.timeSeries,
|
|
122
118
|
xAxis: {
|
|
@@ -250,7 +246,7 @@ const LineChart = /*#__PURE__*/ (0, _react.forwardRef)(function LineChart({ heig
|
|
|
250
246
|
}
|
|
251
247
|
},
|
|
252
248
|
children: [
|
|
253
|
-
showTooltip === true &&
|
|
249
|
+
showTooltip === true && option.tooltip?.showContent === false && tooltipConfig.hidden !== true && /*#__PURE__*/ (0, _jsxruntime.jsx)(_TimeSeriesTooltip.LineChartTooltip, {
|
|
254
250
|
chartRef: chartRef,
|
|
255
251
|
chartData: data,
|
|
256
252
|
wrapLabels: tooltipConfig.wrapLabels,
|
|
@@ -94,56 +94,47 @@ function LinkControl({ control, index }) {
|
|
|
94
94
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
95
95
|
control: control,
|
|
96
96
|
name: `panelDefinition.spec.links.${index}.url`,
|
|
97
|
-
render: ({ field, fieldState })
|
|
98
|
-
var _fieldState_error;
|
|
99
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
97
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
100
98
|
...field,
|
|
101
99
|
required: true,
|
|
102
100
|
fullWidth: true,
|
|
103
101
|
label: "URL",
|
|
104
102
|
error: !!fieldState.error,
|
|
105
|
-
helperText:
|
|
103
|
+
helperText: fieldState.error?.message,
|
|
106
104
|
onChange: (event)=>{
|
|
107
105
|
field.onChange(event);
|
|
108
106
|
}
|
|
109
|
-
})
|
|
110
|
-
}
|
|
107
|
+
})
|
|
111
108
|
}),
|
|
112
109
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
113
110
|
control: control,
|
|
114
111
|
name: `panelDefinition.spec.links.${index}.name`,
|
|
115
|
-
render: ({ field, fieldState })
|
|
116
|
-
var _fieldState_error;
|
|
117
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
112
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
118
113
|
...field,
|
|
119
114
|
fullWidth: true,
|
|
120
115
|
label: "Name",
|
|
121
116
|
defaultValue: "",
|
|
122
117
|
error: !!fieldState.error,
|
|
123
|
-
helperText:
|
|
118
|
+
helperText: fieldState.error?.message,
|
|
124
119
|
onChange: (event)=>{
|
|
125
120
|
field.onChange(event);
|
|
126
121
|
}
|
|
127
|
-
})
|
|
128
|
-
}
|
|
122
|
+
})
|
|
129
123
|
}),
|
|
130
124
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
131
125
|
control: control,
|
|
132
126
|
name: `panelDefinition.spec.links.${index}.tooltip`,
|
|
133
|
-
render: ({ field, fieldState })
|
|
134
|
-
var _fieldState_error;
|
|
135
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
127
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
136
128
|
...field,
|
|
137
129
|
fullWidth: true,
|
|
138
130
|
label: "Tooltip",
|
|
139
131
|
defaultValue: "",
|
|
140
132
|
error: !!fieldState.error,
|
|
141
|
-
helperText:
|
|
133
|
+
helperText: fieldState.error?.message,
|
|
142
134
|
onChange: (event)=>{
|
|
143
135
|
field.onChange(event);
|
|
144
136
|
}
|
|
145
|
-
})
|
|
146
|
-
}
|
|
137
|
+
})
|
|
147
138
|
})
|
|
148
139
|
]
|
|
149
140
|
}),
|
|
@@ -26,8 +26,7 @@ function SettingsAutocomplete({ options, renderInput = (params)=>/*#__PURE__*/ (
|
|
|
26
26
|
...params
|
|
27
27
|
}), ...otherProps }) {
|
|
28
28
|
const getOptionLabel = (option)=>{
|
|
29
|
-
|
|
30
|
-
return (_option_label = option.label) !== null && _option_label !== void 0 ? _option_label : option.id;
|
|
29
|
+
return option.label ?? option.id;
|
|
31
30
|
};
|
|
32
31
|
// Note: this component currently is not virtualized because it is specific
|
|
33
32
|
// to being used for settings, which generally have a pretty small list of
|
|
@@ -50,16 +50,14 @@ const SERIES_NAME_MAX_FONT_SIZE = 30;
|
|
|
50
50
|
const SERIES_NAME_FONT_WEIGHT = 400;
|
|
51
51
|
const VALUE_FONT_WEIGHT = 700;
|
|
52
52
|
const StatChart = (props)=>{
|
|
53
|
-
var _data_seriesData, _data_seriesData1;
|
|
54
53
|
const { width, height, data, sparkline, showSeriesName, format, valueFontSize } = props;
|
|
55
54
|
const chartsTheme = (0, _context.useChartsTheme)();
|
|
56
55
|
const color = data.color;
|
|
57
56
|
const formattedValue = (0, _formatStatChartValue.formatStatChartValue)(data.calculatedValue, format);
|
|
58
57
|
const containerPadding = chartsTheme.container.padding.default;
|
|
59
|
-
var _data_seriesData_name;
|
|
60
58
|
// calculate series name font size and height
|
|
61
59
|
let seriesNameFontSize = (0, _calculateFontSize.useOptimalFontSize)({
|
|
62
|
-
text:
|
|
60
|
+
text: data?.seriesData?.name ?? '',
|
|
63
61
|
fontWeight: SERIES_NAME_FONT_WEIGHT,
|
|
64
62
|
width,
|
|
65
63
|
height: height * 0.125,
|
|
@@ -158,7 +156,7 @@ const StatChart = (props)=>{
|
|
|
158
156
|
showSeriesName && /*#__PURE__*/ (0, _jsxruntime.jsx)(SeriesName, {
|
|
159
157
|
padding: containerPadding,
|
|
160
158
|
fontSize: seriesNameFontSize,
|
|
161
|
-
children:
|
|
159
|
+
children: data.seriesData?.name
|
|
162
160
|
}),
|
|
163
161
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(Value, {
|
|
164
162
|
variant: "h3",
|
|
@@ -192,7 +190,7 @@ const SeriesName = (0, _material.styled)(_material.Typography, {
|
|
|
192
190
|
const Value = (0, _material.styled)(_material.Typography, {
|
|
193
191
|
shouldForwardProp: (prop)=>prop !== 'color' && prop !== 'padding' && prop !== 'fontSize' && prop !== 'sparkline'
|
|
194
192
|
})(({ theme, color, padding, fontSize, sparkline })=>({
|
|
195
|
-
color: color
|
|
193
|
+
color: color ?? theme.palette.text.primary,
|
|
196
194
|
fontSize: `${fontSize}px`,
|
|
197
195
|
padding: sparkline ? `${padding}px ${padding}px 0 ${padding}px` : ` 0 ${padding}px`,
|
|
198
196
|
whiteSpace: 'nowrap',
|
|
@@ -39,10 +39,8 @@ function useOptimalFontSize({ text, fontWeight, width, height, lineHeight, maxSi
|
|
|
39
39
|
return Number(fontSizeOverride);
|
|
40
40
|
}
|
|
41
41
|
const textStyle = echartsTheme.textStyle;
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
var _textStyle_fontFamily;
|
|
45
|
-
const fontFamily = (_textStyle_fontFamily = textStyle === null || textStyle === void 0 ? void 0 : textStyle.fontFamily) !== null && _textStyle_fontFamily !== void 0 ? _textStyle_fontFamily : 'Lato';
|
|
42
|
+
const fontSize = Number(textStyle?.fontSize) ?? 12;
|
|
43
|
+
const fontFamily = textStyle?.fontFamily ?? 'Lato';
|
|
46
44
|
// set the font on the canvas context
|
|
47
45
|
const fontStyle = `${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
48
46
|
ctx.font = fontStyle;
|
|
@@ -45,7 +45,6 @@ const StatusHistoryChart = (props)=>{
|
|
|
45
45
|
const { timeZone } = (0, _TimeZoneProvider.useTimeZone)();
|
|
46
46
|
const chartsTheme = (0, _ChartsProvider.useChartsTheme)();
|
|
47
47
|
const theme = (0, _material.useTheme)();
|
|
48
|
-
var _timeScale_rangeMs;
|
|
49
48
|
const option = {
|
|
50
49
|
tooltip: {
|
|
51
50
|
appendToBody: true,
|
|
@@ -75,7 +74,7 @@ const StatusHistoryChart = (props)=>{
|
|
|
75
74
|
},
|
|
76
75
|
axisLabel: {
|
|
77
76
|
hideOverlap: true,
|
|
78
|
-
formatter: (0, _getformattedaxislabel.getFormattedStatusHistoryAxisLabel)(
|
|
77
|
+
formatter: (0, _getformattedaxislabel.getFormattedStatusHistoryAxisLabel)(timeScale?.rangeMs ?? 0, timeZone)
|
|
79
78
|
}
|
|
80
79
|
},
|
|
81
80
|
yAxis: {
|
package/dist/cjs/Table/Table.js
CHANGED
|
@@ -35,11 +35,11 @@ const DEFAULT_GET_ROW_ID = (data, index)=>{
|
|
|
35
35
|
// does not do deep equality checking for objects and arrays.
|
|
36
36
|
const DEFAULT_ROW_SELECTION = {};
|
|
37
37
|
const DEFAULT_SORTING = [];
|
|
38
|
-
function Table({ data, columns, cellConfigs, density = 'standard', defaultColumnWidth = _tablemodel.DEFAULT_COLUMN_WIDTH, checkboxSelection, onRowSelectionChange, onSortingChange, getCheckboxColor, getRowId = DEFAULT_GET_ROW_ID, rowSelection = DEFAULT_ROW_SELECTION, sorting = DEFAULT_SORTING, rowSelectionVariant = 'standard', ...otherProps }) {
|
|
38
|
+
function Table({ data, columns, cellConfigs, density = 'standard', defaultColumnWidth = _tablemodel.DEFAULT_COLUMN_WIDTH, defaultColumnHeight = 'auto', checkboxSelection, onRowSelectionChange, onSortingChange, getCheckboxColor, getRowId = DEFAULT_GET_ROW_ID, rowSelection = DEFAULT_ROW_SELECTION, sorting = DEFAULT_SORTING, rowSelectionVariant = 'standard', ...otherProps }) {
|
|
39
39
|
const theme = (0, _material.useTheme)();
|
|
40
40
|
const handleRowSelectionChange = (rowSelectionUpdater)=>{
|
|
41
41
|
const newRowSelection = typeof rowSelectionUpdater === 'function' ? rowSelectionUpdater(rowSelection) : rowSelectionUpdater;
|
|
42
|
-
onRowSelectionChange
|
|
42
|
+
onRowSelectionChange?.(newRowSelection);
|
|
43
43
|
};
|
|
44
44
|
const handleRowSelectionEvent = (0, _react.useCallback)((table, row, isModified)=>{
|
|
45
45
|
if (rowSelectionVariant === 'standard' || isModified) {
|
|
@@ -53,7 +53,7 @@ function Table({ data, columns, cellConfigs, density = 'standard', defaultColumn
|
|
|
53
53
|
table.toggleAllRowsSelected();
|
|
54
54
|
} else {
|
|
55
55
|
// Focus the selected row.
|
|
56
|
-
onRowSelectionChange
|
|
56
|
+
onRowSelectionChange?.({
|
|
57
57
|
[row.id]: true
|
|
58
58
|
});
|
|
59
59
|
}
|
|
@@ -64,14 +64,14 @@ function Table({ data, columns, cellConfigs, density = 'standard', defaultColumn
|
|
|
64
64
|
]);
|
|
65
65
|
const handleCheckboxChange = (0, _react.useCallback)((e, table, row)=>{
|
|
66
66
|
const nativePointerEvent = e.nativeEvent && (e.nativeEvent instanceof MouseEvent || e.nativeEvent instanceof KeyboardEvent) ? e.nativeEvent : undefined;
|
|
67
|
-
const isModifed = !!
|
|
67
|
+
const isModifed = !!nativePointerEvent?.metaKey || !!nativePointerEvent?.shiftKey;
|
|
68
68
|
handleRowSelectionEvent(table, row, isModifed);
|
|
69
69
|
}, [
|
|
70
70
|
handleRowSelectionEvent
|
|
71
71
|
]);
|
|
72
72
|
const handleSortingChange = (sortingUpdater)=>{
|
|
73
73
|
const newSorting = typeof sortingUpdater === 'function' ? sortingUpdater(sorting) : sortingUpdater;
|
|
74
|
-
onSortingChange
|
|
74
|
+
onSortingChange?.(newSorting);
|
|
75
75
|
};
|
|
76
76
|
const checkboxColumn = (0, _react.useMemo)(()=>{
|
|
77
77
|
return {
|
|
@@ -93,7 +93,7 @@ function Table({ data, columns, cellConfigs, density = 'standard', defaultColumn
|
|
|
93
93
|
onChange: (e)=>{
|
|
94
94
|
handleCheckboxChange(e, table, row);
|
|
95
95
|
},
|
|
96
|
-
color: getCheckboxColor
|
|
96
|
+
color: getCheckboxColor?.(row.original),
|
|
97
97
|
density: density
|
|
98
98
|
});
|
|
99
99
|
},
|
|
@@ -145,6 +145,7 @@ function Table({ data, columns, cellConfigs, density = 'standard', defaultColumn
|
|
|
145
145
|
...otherProps,
|
|
146
146
|
density: density,
|
|
147
147
|
defaultColumnWidth: defaultColumnWidth,
|
|
148
|
+
defaultColumnHeight: defaultColumnHeight,
|
|
148
149
|
onRowClick: handleRowClick,
|
|
149
150
|
rows: table.getRowModel().rows,
|
|
150
151
|
columns: table.getAllFlatColumns(),
|
|
@@ -39,7 +39,7 @@ const StyledMuiTableCell = (0, _material.styled)(_material.TableCell)(({ theme }
|
|
|
39
39
|
borderRadius: 0
|
|
40
40
|
}
|
|
41
41
|
}));
|
|
42
|
-
function TableCell({ children, density, variant, width, focusState = 'none', onFocusTrigger, isFirstColumn, isLastColumn, description, align, color, backgroundColor, ...otherProps }) {
|
|
42
|
+
function TableCell({ children, density, variant, width, defaultColumnHeight, focusState = 'none', onFocusTrigger, isFirstColumn, isLastColumn, description, align, color, backgroundColor, ...otherProps }) {
|
|
43
43
|
const theme = (0, _material.useTheme)();
|
|
44
44
|
const elRef = (0, _react.useRef)();
|
|
45
45
|
const isHeader = variant === 'head';
|
|
@@ -51,9 +51,8 @@ function TableCell({ children, density, variant, width, focusState = 'none', onF
|
|
|
51
51
|
focusState
|
|
52
52
|
]);
|
|
53
53
|
const handleFocus = (e)=>{
|
|
54
|
-
var _e_currentTarget;
|
|
55
54
|
// From https://zellwk.com/blog/keyboard-focusable-elements/
|
|
56
|
-
const nestedFocusTarget =
|
|
55
|
+
const nestedFocusTarget = e.currentTarget?.querySelector('a[href], button, input, textarea, select, details,[role="button"]');
|
|
57
56
|
if (nestedFocusTarget) {
|
|
58
57
|
// If the cell has a focusable child, focus it instead. Mostly used for
|
|
59
58
|
// checkbox cells, but could have other uses.
|
|
@@ -66,7 +65,7 @@ function TableCell({ children, density, variant, width, focusState = 'none', onF
|
|
|
66
65
|
// plays with the triggering of focus with keyboard interactions.
|
|
67
66
|
// These report that a focus event happened, so we can adjust the current
|
|
68
67
|
// tabindex and focuses to the right cell.
|
|
69
|
-
onFocusTrigger
|
|
68
|
+
onFocusTrigger?.(e);
|
|
70
69
|
};
|
|
71
70
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(StyledMuiTableCell, {
|
|
72
71
|
...otherProps,
|
|
@@ -93,7 +92,7 @@ function TableCell({ children, density, variant, width, focusState = 'none', onF
|
|
|
93
92
|
minWidth: '100%',
|
|
94
93
|
whiteSpace: 'nowrap',
|
|
95
94
|
overflow: 'visible',
|
|
96
|
-
backgroundColor: `${backgroundColor
|
|
95
|
+
backgroundColor: `${backgroundColor ?? theme.palette.background.default} !important`,
|
|
97
96
|
outline: `solid 1px ${theme.palette.info.main}`,
|
|
98
97
|
outlineOffset: '-1px'
|
|
99
98
|
}
|
|
@@ -103,8 +102,10 @@ function TableCell({ children, density, variant, width, focusState = 'none', onF
|
|
|
103
102
|
id: "original-cell",
|
|
104
103
|
sx: {
|
|
105
104
|
...(0, _tablemodel.getTableCellLayout)(theme, density, {
|
|
105
|
+
isHeader,
|
|
106
106
|
isLastColumn,
|
|
107
|
-
isFirstColumn
|
|
107
|
+
isFirstColumn,
|
|
108
|
+
defaultColumnHeight
|
|
108
109
|
}),
|
|
109
110
|
position: 'relative',
|
|
110
111
|
// Text truncation. Currently enforced on all cells. We may control
|
|
@@ -118,8 +119,8 @@ function TableCell({ children, density, variant, width, focusState = 'none', onF
|
|
|
118
119
|
flexDirection: 'inherit'
|
|
119
120
|
},
|
|
120
121
|
style: {
|
|
121
|
-
backgroundColor: backgroundColor
|
|
122
|
-
color: color
|
|
122
|
+
backgroundColor: backgroundColor ?? 'inherit',
|
|
123
|
+
color: color ?? 'inherit'
|
|
123
124
|
},
|
|
124
125
|
title: description,
|
|
125
126
|
"aria-label": description,
|
|
@@ -33,7 +33,7 @@ const _TableHeaderCell = require("./TableHeaderCell");
|
|
|
33
33
|
const _TableCell = require("./TableCell");
|
|
34
34
|
const _VirtualizedTableContainer = require("./VirtualizedTableContainer");
|
|
35
35
|
const _useVirtualizedTableKeyboardNav = require("./hooks/useVirtualizedTableKeyboardNav");
|
|
36
|
-
function VirtualizedTable({ width, height, density, defaultColumnWidth, onRowClick, onRowMouseOver, onRowMouseOut, rows, columns, headers, cellConfigs }) {
|
|
36
|
+
function VirtualizedTable({ width, height, density, defaultColumnWidth, defaultColumnHeight, onRowClick, onRowMouseOver, onRowMouseOut, rows, columns, headers, cellConfigs }) {
|
|
37
37
|
const virtuosoRef = (0, _react.useRef)(null);
|
|
38
38
|
// Use a ref for these values because they are only needed for keyboard
|
|
39
39
|
// focus interactions and setting them on state will lead to a significant
|
|
@@ -86,10 +86,10 @@ function VirtualizedTable({ width, height, density, defaultColumnWidth, onRowCli
|
|
|
86
86
|
onClick: (e)=>onRowClick(e, row.id),
|
|
87
87
|
density: density,
|
|
88
88
|
onMouseOver: (e)=>{
|
|
89
|
-
onRowMouseOver
|
|
89
|
+
onRowMouseOver?.(e, rowEventOpts);
|
|
90
90
|
},
|
|
91
91
|
onMouseOut: (e)=>{
|
|
92
|
-
onRowMouseOut
|
|
92
|
+
onRowMouseOut?.(e, rowEventOpts);
|
|
93
93
|
}
|
|
94
94
|
});
|
|
95
95
|
},
|
|
@@ -123,7 +123,6 @@ function VirtualizedTable({ width, height, density, defaultColumnWidth, onRowCli
|
|
|
123
123
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_TableRow.TableRow, {
|
|
124
124
|
density: density,
|
|
125
125
|
children: headerGroup.headers.map((header, i, headers)=>{
|
|
126
|
-
var _column_columnDef_meta, _column_columnDef_meta1;
|
|
127
126
|
const column = header.column;
|
|
128
127
|
const position = {
|
|
129
128
|
row: 0,
|
|
@@ -136,10 +135,11 @@ function VirtualizedTable({ width, height, density, defaultColumnWidth, onRowCli
|
|
|
136
135
|
sortDirection: typeof isSorted === 'string' ? isSorted : undefined,
|
|
137
136
|
nextSortDirection: typeof nextSorting === 'string' ? nextSorting : undefined,
|
|
138
137
|
width: column.getSize() || defaultColumnWidth,
|
|
139
|
-
|
|
138
|
+
defaultColumnHeight: defaultColumnHeight,
|
|
139
|
+
align: column.columnDef.meta?.align,
|
|
140
140
|
variant: "head",
|
|
141
141
|
density: density,
|
|
142
|
-
description:
|
|
142
|
+
description: column.columnDef.meta?.headerDescription,
|
|
143
143
|
focusState: getFocusState(position),
|
|
144
144
|
onFocusTrigger: ()=>keyboardNav.onCellFocus(position),
|
|
145
145
|
isFirstColumn: i === 0,
|
|
@@ -158,17 +158,16 @@ function VirtualizedTable({ width, height, density, defaultColumnWidth, onRowCli
|
|
|
158
158
|
}
|
|
159
159
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
|
|
160
160
|
children: row.getVisibleCells().map((cell, i, cells)=>{
|
|
161
|
-
var _cell_column_columnDef_meta, _cell_column_columnDef_meta1;
|
|
162
161
|
const position = {
|
|
163
162
|
// Add 1 to the row index because the header is row 0
|
|
164
163
|
row: index + 1,
|
|
165
164
|
column: i
|
|
166
165
|
};
|
|
167
166
|
const cellContext = cell.getContext();
|
|
168
|
-
const cellConfig = cellConfigs
|
|
167
|
+
const cellConfig = cellConfigs?.[cellContext.cell.id];
|
|
169
168
|
const cellRenderFn = cell.column.columnDef.cell;
|
|
170
169
|
const cellContent = typeof cellRenderFn === 'function' ? cellRenderFn(cellContext) : null;
|
|
171
|
-
const cellDescriptionDef =
|
|
170
|
+
const cellDescriptionDef = cell.column.columnDef.meta?.cellDescription;
|
|
172
171
|
let description = undefined;
|
|
173
172
|
if (typeof cellDescriptionDef === 'function') {
|
|
174
173
|
// If the cell description is a function, set the value using
|
|
@@ -180,21 +179,21 @@ function VirtualizedTable({ width, height, density, defaultColumnWidth, onRowCli
|
|
|
180
179
|
// cell content.
|
|
181
180
|
description = cellContent;
|
|
182
181
|
}
|
|
183
|
-
var _cellConfig_textColor, _cellConfig_backgroundColor;
|
|
184
182
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_TableCell.TableCell, {
|
|
185
183
|
"data-testid": cell.id,
|
|
186
|
-
title: description ||
|
|
184
|
+
title: description || cellConfig?.text || cellContent,
|
|
187
185
|
width: cell.column.getSize() || defaultColumnWidth,
|
|
188
|
-
|
|
186
|
+
defaultColumnHeight: defaultColumnHeight,
|
|
187
|
+
align: cell.column.columnDef.meta?.align,
|
|
189
188
|
density: density,
|
|
190
189
|
focusState: getFocusState(position),
|
|
191
190
|
onFocusTrigger: ()=>keyboardNav.onCellFocus(position),
|
|
192
191
|
isFirstColumn: i === 0,
|
|
193
192
|
isLastColumn: i === cells.length - 1,
|
|
194
193
|
description: description,
|
|
195
|
-
color:
|
|
196
|
-
backgroundColor:
|
|
197
|
-
children:
|
|
194
|
+
color: cellConfig?.textColor ?? undefined,
|
|
195
|
+
backgroundColor: cellConfig?.backgroundColor ?? undefined,
|
|
196
|
+
children: cellConfig?.text || cellContent
|
|
198
197
|
}, cell.id);
|
|
199
198
|
})
|
|
200
199
|
});
|
|
@@ -78,7 +78,7 @@ function useTableKeyboardNav({ maxRows, maxColumns, onActiveCellChange }) {
|
|
|
78
78
|
column: nextColumn,
|
|
79
79
|
row: nextRow
|
|
80
80
|
};
|
|
81
|
-
const newPosition =
|
|
81
|
+
const newPosition = onActiveCellChange?.(e, curActiveCell, defaultNewPosition) || defaultNewPosition;
|
|
82
82
|
if (newPosition.row === curActiveCell.row && newPosition.column === curActiveCell.column) {
|
|
83
83
|
// Return original to avoid creating a new object if nothing
|
|
84
84
|
// changed.
|
|
@@ -28,14 +28,12 @@ function useVirtualizedTableKeyboardNav({ visibleRange, virtualTable, maxRows, m
|
|
|
28
28
|
onActiveCellChange: (e, currentPosition, defaultNewPosition)=>{
|
|
29
29
|
const key = e.key;
|
|
30
30
|
const defaultValueChanged = defaultNewPosition && (currentPosition.column !== defaultNewPosition.column || currentPosition.row !== defaultNewPosition.row);
|
|
31
|
-
|
|
32
|
-
const nextRow = (_defaultNewPosition_row = defaultNewPosition === null || defaultNewPosition === void 0 ? void 0 : defaultNewPosition.row) !== null && _defaultNewPosition_row !== void 0 ? _defaultNewPosition_row : currentPosition.row;
|
|
31
|
+
const nextRow = defaultNewPosition?.row ?? currentPosition.row;
|
|
33
32
|
if (key === 'ArrowDown' && defaultValueChanged) {
|
|
34
33
|
// Use default cell position. Shift the virtual table scroll position
|
|
35
34
|
// when needed to make the active cell visible.
|
|
36
35
|
if (nextRow - 1 < visibleRange.current.startIndex || nextRow - 1 > visibleRange.current.endIndex) {
|
|
37
|
-
|
|
38
|
-
(_virtualTable_current = virtualTable.current) === null || _virtualTable_current === void 0 ? void 0 : _virtualTable_current.scrollToIndex({
|
|
36
|
+
virtualTable.current?.scrollToIndex({
|
|
39
37
|
index: nextRow - 1,
|
|
40
38
|
align: 'end'
|
|
41
39
|
});
|
|
@@ -44,28 +42,25 @@ function useVirtualizedTableKeyboardNav({ visibleRange, virtualTable, maxRows, m
|
|
|
44
42
|
// Use default cell position. Shift the virtual table scroll position
|
|
45
43
|
// when needed to make the active cell visible.
|
|
46
44
|
if (nextRow - 1 < visibleRange.current.startIndex || nextRow - 1 > visibleRange.current.endIndex) {
|
|
47
|
-
|
|
48
|
-
(_virtualTable_current1 = virtualTable.current) === null || _virtualTable_current1 === void 0 ? void 0 : _virtualTable_current1.scrollToIndex({
|
|
45
|
+
virtualTable.current?.scrollToIndex({
|
|
49
46
|
index: nextRow - 1,
|
|
50
47
|
align: 'start'
|
|
51
48
|
});
|
|
52
49
|
}
|
|
53
50
|
} else if (defaultValueChanged && (key === 'Home' || key === 'End')) {
|
|
54
|
-
|
|
51
|
+
// Use default cell position. Shift the virtual table scroll position
|
|
55
52
|
// when needed to make the active cell visible.
|
|
56
|
-
|
|
57
|
-
(_virtualTable_current2 = virtualTable.current) === null || _virtualTable_current2 === void 0 ? void 0 : _virtualTable_current2.scrollToIndex({
|
|
53
|
+
virtualTable.current?.scrollToIndex({
|
|
58
54
|
index: Math.max(nextRow - 1, 0),
|
|
59
55
|
align: 'start'
|
|
60
56
|
});
|
|
61
57
|
} else if (key === 'PageDown') {
|
|
62
|
-
var _virtualTable_current3;
|
|
63
58
|
// Full handling of logic for `PageDown` because there is no default.
|
|
64
59
|
e.preventDefault();
|
|
65
60
|
let nextRow = currentPosition.row;
|
|
66
61
|
// Add 1 to account for header
|
|
67
62
|
nextRow = Math.min(maxRows - 1, visibleRange.current.endIndex + 1);
|
|
68
|
-
|
|
63
|
+
virtualTable.current?.scrollToIndex({
|
|
69
64
|
index: nextRow - 1,
|
|
70
65
|
align: 'start'
|
|
71
66
|
});
|
|
@@ -74,12 +69,11 @@ function useVirtualizedTableKeyboardNav({ visibleRange, virtualTable, maxRows, m
|
|
|
74
69
|
column: currentPosition.column
|
|
75
70
|
};
|
|
76
71
|
} else if (key === 'PageUp') {
|
|
77
|
-
var _virtualTable_current4;
|
|
78
72
|
// Full handling of logic for `PageUp` because there is no default.
|
|
79
73
|
let nextRow = currentPosition.row;
|
|
80
74
|
// Minus 1 to account for header
|
|
81
75
|
nextRow = Math.max(0, visibleRange.current.startIndex - 1);
|
|
82
|
-
|
|
76
|
+
virtualTable.current?.scrollToIndex({
|
|
83
77
|
index: nextRow - 1,
|
|
84
78
|
align: 'end'
|
|
85
79
|
});
|
|
@@ -21,6 +21,9 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
+
DEFAULT_COLUMN_HEIGHT: function() {
|
|
25
|
+
return DEFAULT_COLUMN_HEIGHT;
|
|
26
|
+
},
|
|
24
27
|
DEFAULT_COLUMN_WIDTH: function() {
|
|
25
28
|
return DEFAULT_COLUMN_WIDTH;
|
|
26
29
|
},
|
|
@@ -32,14 +35,15 @@ _export(exports, {
|
|
|
32
35
|
}
|
|
33
36
|
});
|
|
34
37
|
const DEFAULT_COLUMN_WIDTH = 150;
|
|
38
|
+
const DEFAULT_COLUMN_HEIGHT = 40;
|
|
35
39
|
function calculateTableCellHeight(lineHeight, paddingY) {
|
|
36
40
|
// Doing a bunch of math to enforce height to avoid weirdness with mismatched
|
|
37
41
|
// heights based on customization of cell contents.
|
|
38
|
-
const lineHeightNum = typeof lineHeight === 'string' ? parseInt(lineHeight, 10) : lineHeight
|
|
42
|
+
const lineHeightNum = typeof lineHeight === 'string' ? parseInt(lineHeight, 10) : lineHeight ?? 0;
|
|
39
43
|
const verticalPaddingNum = typeof paddingY === 'string' ? parseInt(paddingY, 10) : paddingY;
|
|
40
44
|
return lineHeightNum + verticalPaddingNum * 2;
|
|
41
45
|
}
|
|
42
|
-
function getTableCellLayout(theme, density, { isLastColumn, isFirstColumn } = {}) {
|
|
46
|
+
function getTableCellLayout(theme, density, { isHeader, isLastColumn, isFirstColumn, defaultColumnHeight } = {}) {
|
|
43
47
|
// Density Standard
|
|
44
48
|
let paddingY = theme.spacing(1);
|
|
45
49
|
let basePaddingX = theme.spacing(1.25);
|
|
@@ -66,9 +70,10 @@ function getTableCellLayout(theme, density, { isLastColumn, isFirstColumn } = {}
|
|
|
66
70
|
lineHeight = theme.typography.body1.lineHeight;
|
|
67
71
|
fontSize = theme.typography.body1.fontSize;
|
|
68
72
|
}
|
|
73
|
+
const height = isHeader || !defaultColumnHeight || defaultColumnHeight === 'auto' ? calculateTableCellHeight(lineHeight, paddingY) : defaultColumnHeight;
|
|
69
74
|
return {
|
|
70
75
|
padding: `${paddingY} ${paddingRight} ${paddingY} ${paddingLeft}`,
|
|
71
|
-
height:
|
|
76
|
+
height: height,
|
|
72
77
|
fontSize: fontSize,
|
|
73
78
|
lineHeight: lineHeight
|
|
74
79
|
};
|