@perses-dev/components 0.54.0-beta.0 → 0.54.0-beta.2
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/AlignSelector/AlignSelector.js +1 -1
- package/dist/AlignSelector/AlignSelector.js.map +1 -1
- package/dist/ColorPicker/ColorPicker.js +1 -1
- package/dist/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/ColorPicker/OptionsColorPicker.js +1 -1
- package/dist/ColorPicker/OptionsColorPicker.js.map +1 -1
- package/dist/ContentWithLegend/ContentWithLegend.js +1 -1
- package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.d.ts +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.d.ts.map +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.js +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
- package/dist/Dialog/DiscardChangesConfirmationDialog.js +1 -1
- package/dist/Dialog/DiscardChangesConfirmationDialog.js.map +1 -1
- package/dist/DragAndDrop/DragAndDropList.js +1 -1
- package/dist/DragAndDrop/DragAndDropList.js.map +1 -1
- package/dist/DragAndDrop/DragButton.js +1 -1
- package/dist/DragAndDrop/DragButton.js.map +1 -1
- package/dist/DragAndDrop/DropIndicator.js +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.js +1 -1
- package/dist/EChart/EChart.js.map +1 -1
- package/dist/ErrorAlert.js +1 -1
- package/dist/ErrorAlert.js.map +1 -1
- package/dist/FormEditor/FormActions.d.ts +1 -1
- package/dist/FormEditor/FormActions.d.ts.map +1 -1
- package/dist/FormEditor/FormActions.js +1 -1
- package/dist/FormEditor/FormActions.js.map +1 -1
- package/dist/FormatControls/FormatControls.d.ts +1 -1
- package/dist/FormatControls/FormatControls.d.ts.map +1 -1
- package/dist/FormatControls/FormatControls.js +2 -2
- package/dist/FormatControls/FormatControls.js.map +1 -1
- package/dist/FormatControls/UnitSelector.d.ts +1 -1
- package/dist/FormatControls/UnitSelector.d.ts.map +1 -1
- package/dist/FormatControls/UnitSelector.js +1 -1
- package/dist/FormatControls/UnitSelector.js.map +1 -1
- package/dist/JSONEditor.js +1 -1
- package/dist/JSONEditor.js.map +1 -1
- package/dist/Legend/CompactLegend.js +1 -1
- package/dist/Legend/CompactLegend.js.map +1 -1
- package/dist/Legend/Legend.js +2 -2
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/Legend/LegendColorBadge.js +1 -1
- package/dist/Legend/LegendColorBadge.js.map +1 -1
- package/dist/Legend/ListLegend.js +1 -1
- package/dist/Legend/ListLegend.js.map +1 -1
- package/dist/Legend/ListLegendItem.js +1 -1
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/Legend/TableLegend.d.ts.map +1 -1
- package/dist/Legend/TableLegend.js +18 -4
- package/dist/Legend/TableLegend.js.map +1 -1
- package/dist/Legend/legend-model.d.ts +1 -1
- package/dist/Legend/legend-model.d.ts.map +1 -1
- package/dist/Legend/legend-model.js.map +1 -1
- package/dist/LinksEditor/LinkEditorForm.js +1 -1
- package/dist/LinksEditor/LinkEditorForm.js.map +1 -1
- package/dist/LinksEditor/LinksEditor.js +1 -1
- package/dist/LinksEditor/LinksEditor.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorColumn.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGrid.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -1
- package/dist/Overlay/Overlay.js +1 -1
- package/dist/Overlay/Overlay.js.map +1 -1
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js +1 -1
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js +1 -1
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
- package/dist/SortSelector/SortSelectorButtons.js +1 -1
- package/dist/SortSelector/SortSelectorButtons.js.map +1 -1
- package/dist/Table/InnerTable.js +1 -1
- package/dist/Table/InnerTable.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 +47 -14
- package/dist/Table/Table.js.map +1 -1
- package/dist/Table/TableBody.js +1 -1
- package/dist/Table/TableBody.js.map +1 -1
- package/dist/Table/TableCell.js +1 -1
- package/dist/Table/TableCell.js.map +1 -1
- package/dist/Table/TableCheckbox.js +1 -1
- package/dist/Table/TableCheckbox.js.map +1 -1
- package/dist/Table/TableFoot.js +1 -1
- package/dist/Table/TableFoot.js.map +1 -1
- package/dist/Table/TableHead.js +1 -1
- package/dist/Table/TableHead.js.map +1 -1
- package/dist/Table/TableHeaderCell.d.ts +20 -1
- package/dist/Table/TableHeaderCell.d.ts.map +1 -1
- package/dist/Table/TableHeaderCell.js +56 -24
- package/dist/Table/TableHeaderCell.js.map +1 -1
- package/dist/Table/TableRow.js +1 -1
- package/dist/Table/TableRow.js.map +1 -1
- package/dist/Table/TableToolbar.d.ts +46 -0
- package/dist/Table/TableToolbar.d.ts.map +1 -0
- package/dist/Table/TableToolbar.js +138 -0
- package/dist/Table/TableToolbar.js.map +1 -0
- package/dist/Table/VirtualizedTable.d.ts +7 -3
- package/dist/Table/VirtualizedTable.d.ts.map +1 -1
- package/dist/Table/VirtualizedTable.js +157 -123
- package/dist/Table/VirtualizedTable.js.map +1 -1
- package/dist/Table/VirtualizedTableContainer.d.ts.map +1 -1
- package/dist/Table/VirtualizedTableContainer.js +6 -2
- package/dist/Table/VirtualizedTableContainer.js.map +1 -1
- package/dist/Table/hooks/useFuzzySearch.d.ts +14 -0
- package/dist/Table/hooks/useFuzzySearch.d.ts.map +1 -0
- package/dist/Table/hooks/useFuzzySearch.js +62 -0
- package/dist/Table/hooks/useFuzzySearch.js.map +1 -0
- package/dist/Table/model/table-model.d.ts +78 -4
- package/dist/Table/model/table-model.d.ts.map +1 -1
- package/dist/Table/model/table-model.js +37 -19
- package/dist/Table/model/table-model.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.d.ts +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.d.ts.map +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.js +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.d.ts +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.d.ts.map +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.js +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.d.ts.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.js +25 -2
- package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.js +1 -1
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesMarker.js +1 -1
- package/dist/TimeSeriesTooltip/SeriesMarker.js.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts +1 -2
- package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.js +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.d.ts +2 -2
- package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.js +1 -2
- package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
- package/dist/TimeZoneSelector.js +1 -1
- package/dist/TimeZoneSelector.js.map +1 -1
- package/dist/ToolbarIconButton/ToolbarIconButton.js +1 -1
- package/dist/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
- package/dist/TransformsEditor/TransformEditor.d.ts +1 -1
- package/dist/TransformsEditor/TransformEditor.d.ts.map +1 -1
- package/dist/TransformsEditor/TransformEditor.js +1 -1
- package/dist/TransformsEditor/TransformEditor.js.map +1 -1
- package/dist/TransformsEditor/TransformEditorContainer.d.ts.map +1 -1
- package/dist/TransformsEditor/TransformEditorContainer.js +2 -2
- package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
- package/dist/TransformsEditor/TransformsEditor.d.ts +1 -1
- package/dist/TransformsEditor/TransformsEditor.d.ts.map +1 -1
- package/dist/TransformsEditor/TransformsEditor.js +1 -1
- package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.d.ts +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.d.ts.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.js +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.d.ts +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.d.ts.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.js +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.js.map +1 -1
- package/dist/YAxisLabel.js +1 -1
- package/dist/YAxisLabel.js.map +1 -1
- package/dist/cjs/ContentWithLegend/ContentWithLegend.js +2 -2
- package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +2 -2
- package/dist/cjs/FormatControls/FormatControls.js +4 -4
- package/dist/cjs/FormatControls/UnitSelector.js +3 -3
- package/dist/cjs/Legend/Legend.js +2 -2
- package/dist/cjs/Legend/TableLegend.js +16 -2
- package/dist/cjs/Table/Table.js +44 -11
- package/dist/cjs/Table/TableHeaderCell.js +54 -22
- package/dist/cjs/Table/TableToolbar.js +151 -0
- package/dist/cjs/Table/VirtualizedTable.js +155 -121
- package/dist/cjs/Table/VirtualizedTableContainer.js +5 -1
- package/dist/cjs/Table/hooks/useFuzzySearch.js +67 -0
- package/dist/cjs/Table/model/table-model.js +43 -19
- package/dist/cjs/TimeRangeSelector/TimeRangeSelector.js +23 -0
- package/dist/cjs/TimeSeriesTooltip/nearby-series.js +2 -3
- package/dist/cjs/TransformsEditor/TransformEditorContainer.js +2 -2
- package/dist/cjs/model/action.js +43 -0
- package/dist/cjs/model/bits.js +113 -0
- package/dist/cjs/model/bytes.js +115 -0
- package/dist/cjs/model/constants.js +23 -0
- package/dist/cjs/model/currency.js +126 -0
- package/dist/cjs/model/date.js +297 -0
- package/dist/cjs/model/decimal.js +72 -0
- package/dist/cjs/model/formatterCache.js +120 -0
- package/dist/cjs/model/index.js +17 -0
- package/dist/cjs/model/legend.js +101 -0
- package/dist/cjs/model/percent.js +82 -0
- package/dist/cjs/model/temperature.js +72 -0
- package/dist/cjs/model/thresholds.js +16 -0
- package/dist/cjs/model/throughput.js +161 -0
- package/dist/cjs/model/time.js +178 -0
- package/dist/cjs/model/transforms.js +29 -0
- package/dist/cjs/model/types.js +16 -0
- package/dist/cjs/model/units.js +186 -0
- package/dist/cjs/model/utils.js +48 -0
- package/dist/cjs/model/value-mapping.js +16 -0
- package/dist/cjs/theme/typography.js +1 -1
- package/dist/cjs/utils/axis.js +5 -5
- package/dist/cjs/utils/format.js +20 -0
- package/dist/cjs/utils/index.js +1 -0
- package/dist/cjs/utils/request-interpolation.js +49 -0
- package/dist/context/ChartsProvider.js +1 -1
- package/dist/context/ChartsProvider.js.map +1 -1
- package/dist/context/ItemActionsProvider.js +1 -1
- package/dist/context/ItemActionsProvider.js.map +1 -1
- package/dist/context/SelectionProvider.js +1 -1
- package/dist/context/SelectionProvider.js.map +1 -1
- package/dist/context/SnackbarProvider.js +1 -1
- 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/action.d.ts +4 -0
- package/dist/model/action.d.ts.map +1 -0
- package/dist/model/action.js +27 -0
- package/dist/model/action.js.map +1 -0
- package/dist/model/bits.d.ts +12 -0
- package/dist/model/bits.d.ts.map +1 -0
- package/dist/model/bits.js +89 -0
- package/dist/model/bits.js.map +1 -0
- package/dist/model/bytes.d.ts +12 -0
- package/dist/model/bytes.d.ts.map +1 -0
- package/dist/model/bytes.js +91 -0
- package/dist/model/bytes.js.map +1 -0
- package/dist/model/constants.d.ts +2 -0
- package/dist/model/constants.d.ts.map +1 -0
- package/dist/model/constants.js +15 -0
- package/dist/model/constants.js.map +1 -0
- package/dist/model/currency.d.ts +11 -0
- package/dist/model/currency.d.ts.map +1 -0
- package/dist/model/currency.js +107 -0
- package/dist/model/currency.js.map +1 -0
- package/dist/model/date.d.ts +28 -0
- package/dist/model/date.d.ts.map +1 -0
- package/dist/model/date.js +278 -0
- package/dist/model/date.js.map +1 -0
- package/dist/model/decimal.d.ts +12 -0
- package/dist/model/decimal.d.ts.map +1 -0
- package/dist/model/decimal.js +53 -0
- package/dist/model/decimal.js.map +1 -0
- package/dist/model/formatterCache.d.ts +11 -0
- package/dist/model/formatterCache.d.ts.map +1 -0
- package/dist/model/formatterCache.js +104 -0
- package/dist/model/formatterCache.js.map +1 -0
- package/dist/model/index.d.ts +17 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +17 -0
- package/dist/model/index.js.map +1 -1
- package/dist/model/legend.d.ts +19 -0
- package/dist/model/legend.d.ts.map +1 -0
- package/dist/model/legend.js +61 -0
- package/dist/model/legend.js.map +1 -0
- package/dist/model/percent.d.ts +11 -0
- package/dist/model/percent.d.ts.map +1 -0
- package/dist/model/percent.js +63 -0
- package/dist/model/percent.js.map +1 -0
- package/dist/model/temperature.d.ts +11 -0
- package/dist/model/temperature.d.ts.map +1 -0
- package/dist/model/temperature.js +53 -0
- package/dist/model/temperature.js.map +1 -0
- package/dist/model/theme.d.ts +1 -1
- package/dist/model/theme.d.ts.map +1 -1
- package/dist/model/theme.js.map +1 -1
- package/dist/model/thresholds.d.ts +16 -0
- package/dist/model/thresholds.d.ts.map +1 -0
- package/dist/model/thresholds.js +15 -0
- package/dist/model/thresholds.js.map +1 -0
- package/dist/model/throughput.d.ts +12 -0
- package/dist/model/throughput.d.ts.map +1 -0
- package/dist/model/throughput.js +142 -0
- package/dist/model/throughput.js.map +1 -0
- package/dist/model/time.d.ts +23 -0
- package/dist/model/time.d.ts.map +1 -0
- package/dist/model/time.js +158 -0
- package/dist/model/time.js.map +1 -0
- package/dist/model/transforms.d.ts +43 -0
- package/dist/model/transforms.d.ts.map +1 -0
- package/dist/model/transforms.js +22 -0
- package/dist/model/transforms.js.map +1 -0
- package/dist/model/types.d.ts +56 -0
- package/dist/model/types.d.ts.map +1 -0
- package/dist/model/types.js +15 -0
- package/dist/model/types.js.map +1 -0
- package/dist/model/units.d.ts +105 -0
- package/dist/model/units.d.ts.map +1 -0
- package/dist/model/units.js +132 -0
- package/dist/model/units.js.map +1 -0
- package/dist/model/utils.d.ts +4 -0
- package/dist/model/utils.d.ts.map +1 -0
- package/dist/model/utils.js +32 -0
- package/dist/model/utils.js.map +1 -0
- package/dist/model/value-mapping.d.ts +35 -0
- package/dist/model/value-mapping.d.ts.map +1 -0
- package/dist/model/value-mapping.js +15 -0
- package/dist/model/value-mapping.js.map +1 -0
- package/dist/test/render.js +1 -1
- package/dist/test/render.js.map +1 -1
- package/dist/theme/typography.js +1 -1
- package/dist/theme/typography.js.map +1 -1
- package/dist/utils/axis.d.ts +1 -1
- package/dist/utils/axis.d.ts.map +1 -1
- package/dist/utils/axis.js +1 -1
- package/dist/utils/axis.js.map +1 -1
- package/dist/utils/format.d.ts +1 -0
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +17 -0
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/request-interpolation.d.ts +6 -0
- package/dist/utils/request-interpolation.d.ts.map +1 -0
- package/dist/utils/request-interpolation.js +33 -0
- package/dist/utils/request-interpolation.js.map +1 -0
- package/package.json +4 -2
|
@@ -25,6 +25,7 @@ const _reacttable = require("@tanstack/react-table");
|
|
|
25
25
|
const _material = require("@mui/material");
|
|
26
26
|
const _reactvirtuoso = require("react-virtuoso");
|
|
27
27
|
const _react = require("react");
|
|
28
|
+
const _TableToolbar = require("./TableToolbar");
|
|
28
29
|
const _TableRow = require("./TableRow");
|
|
29
30
|
const _TableBody = require("./TableBody");
|
|
30
31
|
const _InnerTable = require("./InnerTable");
|
|
@@ -34,7 +35,7 @@ const _TableCell = require("./TableCell");
|
|
|
34
35
|
const _VirtualizedTableContainer = require("./VirtualizedTableContainer");
|
|
35
36
|
const _useVirtualizedTableKeyboardNav = require("./hooks/useVirtualizedTableKeyboardNav");
|
|
36
37
|
const _TableFoot = require("./TableFoot");
|
|
37
|
-
function VirtualizedTable({ width, height, density, defaultColumnWidth, defaultColumnHeight, onRowClick, onRowMouseOver, onRowMouseOut, rows, columns, headers, cellConfigs, pagination, onPaginationChange, rowCount }) {
|
|
38
|
+
function VirtualizedTable({ width, height, density, defaultColumnWidth, defaultColumnHeight, onRowClick, onRowMouseOver, onRowMouseOut, rows, columns, headers, columnSizing, columnSizingInfo, cellConfigs, pagination, onPaginationChange, rowCount, toolbarConfig }) {
|
|
38
39
|
const virtuosoRef = (0, _react.useRef)(null);
|
|
39
40
|
// Use a ref for these values because they are only needed for keyboard
|
|
40
41
|
// focus interactions and setting them on state will lead to a significant
|
|
@@ -122,129 +123,162 @@ function VirtualizedTable({ width, height, density, defaultColumnWidth, defaultC
|
|
|
122
123
|
pageSize: parseInt(event.target.value, 10)
|
|
123
124
|
});
|
|
124
125
|
};
|
|
125
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Instead of calling `column.getSize()` on every render for every header
|
|
128
|
+
* and especially every data cell (very expensive),
|
|
129
|
+
* we will calculate all column sizes at once at the root table level in a useMemo
|
|
130
|
+
* and pass the column sizes down as CSS variables to the <table> element.
|
|
131
|
+
*/ const columnSizeVars = (0, _react.useMemo)(()=>{
|
|
132
|
+
const colSizes = {};
|
|
133
|
+
headers.forEach((headerGroup)=>{
|
|
134
|
+
headerGroup.headers.filter((header)=>header.column.getCanResize()).forEach((header)=>{
|
|
135
|
+
colSizes[`--header-${header.id}-size`] = header.getSize();
|
|
136
|
+
colSizes[`--col-${header.column.id}-size`] = header.column.getSize();
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
return colSizes;
|
|
140
|
+
// We want to recalculate column sizes whenever column sizes or column resizing info changes.
|
|
141
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
142
|
+
}, [
|
|
143
|
+
columnSizingInfo,
|
|
144
|
+
columnSizing,
|
|
145
|
+
headers
|
|
146
|
+
]);
|
|
147
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
126
148
|
style: {
|
|
127
149
|
width,
|
|
128
|
-
height
|
|
150
|
+
height,
|
|
151
|
+
...columnSizeVars
|
|
129
152
|
},
|
|
130
|
-
children:
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
153
|
+
children: [
|
|
154
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_TableToolbar.TableToolbar, {
|
|
155
|
+
...toolbarConfig,
|
|
156
|
+
width: width
|
|
157
|
+
}),
|
|
158
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactvirtuoso.TableVirtuoso, {
|
|
159
|
+
ref: virtuosoRef,
|
|
160
|
+
totalCount: rows.length,
|
|
161
|
+
components: VirtuosoTableComponents,
|
|
162
|
+
// Note: this value is impacted by overscan. See this issue if overscan
|
|
163
|
+
// is added.
|
|
164
|
+
// https://github.com/petyosi/react-virtuoso/issues/118#issuecomment-642156138
|
|
165
|
+
rangeChanged: setVisibleRange,
|
|
166
|
+
fixedHeaderContent: ()=>{
|
|
167
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
|
|
168
|
+
children: headers.map((headerGroup)=>{
|
|
169
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_TableRow.TableRow, {
|
|
170
|
+
density: density,
|
|
171
|
+
children: headerGroup.headers.map((header, i, headers)=>{
|
|
172
|
+
const column = header.column;
|
|
173
|
+
const position = {
|
|
174
|
+
row: 0,
|
|
175
|
+
column: i
|
|
176
|
+
};
|
|
177
|
+
const isSorted = column.getIsSorted();
|
|
178
|
+
const nextSorting = column.getNextSortingOrder();
|
|
179
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_TableHeaderCell.TableHeaderCell, {
|
|
180
|
+
onSort: column.getCanSort() ? column.getToggleSortingHandler() : undefined,
|
|
181
|
+
sortDirection: typeof isSorted === 'string' ? isSorted : undefined,
|
|
182
|
+
nextSortDirection: typeof nextSorting === 'string' ? nextSorting : undefined,
|
|
183
|
+
width: header.column.getCanResize() ? `calc(var(--header-${header?.id}-size) * 1px)` : column.getSize() || defaultColumnWidth,
|
|
184
|
+
defaultColumnHeight: defaultColumnHeight,
|
|
185
|
+
align: column.columnDef.meta?.align,
|
|
186
|
+
variant: "head",
|
|
187
|
+
density: density,
|
|
188
|
+
description: column.columnDef.meta?.headerDescription,
|
|
189
|
+
focusState: getFocusState(position),
|
|
190
|
+
onFocusTrigger: ()=>keyboardNav.onCellFocus(position),
|
|
191
|
+
isFirstColumn: i === 0,
|
|
192
|
+
isLastColumn: i === headers.length - 1,
|
|
193
|
+
resizeConfig: header.column.getCanResize() ? {
|
|
194
|
+
resizeHandler: header.getResizeHandler(),
|
|
195
|
+
resetSizeHandler: header.column.resetSize,
|
|
196
|
+
isResizing: header.column.getIsResizing()
|
|
197
|
+
} : undefined,
|
|
198
|
+
children: (0, _reacttable.flexRender)(column.columnDef.header, header.getContext())
|
|
199
|
+
}, header.id);
|
|
200
|
+
})
|
|
201
|
+
}, headerGroup.id);
|
|
202
|
+
})
|
|
203
|
+
});
|
|
204
|
+
},
|
|
205
|
+
fixedFooterContent: pagination ? ()=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TableRow, {
|
|
206
|
+
sx: {
|
|
207
|
+
backgroundColor: (theme)=>theme.palette.background.default
|
|
208
|
+
},
|
|
209
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TablePagination, {
|
|
210
|
+
colSpan: columns.length,
|
|
211
|
+
count: rowCount,
|
|
212
|
+
page: pagination.pageIndex,
|
|
213
|
+
rowsPerPage: pagination.pageSize,
|
|
214
|
+
onPageChange: handleChangePage,
|
|
215
|
+
onRowsPerPageChange: handleChangeRowsPerPage
|
|
216
|
+
})
|
|
217
|
+
}) : undefined,
|
|
218
|
+
itemContent: (index)=>{
|
|
219
|
+
const row = rows[index];
|
|
220
|
+
if (!row) {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
|
|
224
|
+
children: row.getVisibleCells().map((cell, i, cells)=>{
|
|
225
|
+
const position = {
|
|
226
|
+
row: index + 1,
|
|
227
|
+
column: i
|
|
228
|
+
};
|
|
229
|
+
const cellContext = cell.getContext();
|
|
230
|
+
const cellConfig = cellConfigs?.[cellContext.cell.id];
|
|
231
|
+
const cellRenderFn = cell.column.columnDef.cell;
|
|
232
|
+
const cellContent = typeof cellRenderFn === 'function' ? cellRenderFn(cellContext) : null;
|
|
233
|
+
/*
|
|
234
|
+
IMPORTANT:
|
|
235
|
+
If Variables exist in the link, they should have been translated by the plugin already. (Being developed at the moment)
|
|
236
|
+
Components have no access to any context (Which is intentional and correct)
|
|
237
|
+
We may want to add parameters to a link from neighboring cells in the future as well.
|
|
238
|
+
If this is the case, the value of the neighboring cells should be read from here and be replaced. (Bing discussed at the moment, not decided yet)
|
|
239
|
+
*/ const cellDescriptionDef = cell.column.columnDef.meta?.cellDescription;
|
|
240
|
+
let description = undefined;
|
|
241
|
+
if (typeof cellDescriptionDef === 'function') {
|
|
242
|
+
// If the cell description is a function, set the value using
|
|
243
|
+
// the function.
|
|
244
|
+
description = cellDescriptionDef(cellContext);
|
|
245
|
+
} else if (cellDescriptionDef && typeof cellContent === 'string') {
|
|
246
|
+
// If the cell description is `true` AND the cell content is
|
|
247
|
+
// a string (and thus viable as a `title` attribute), use the
|
|
248
|
+
// cell content.
|
|
249
|
+
description = cellContent;
|
|
250
|
+
}
|
|
251
|
+
/* this has been specifically added for the data link,
|
|
252
|
+
therefore, non string and numeric values should be excluded
|
|
253
|
+
*/ const adjacentCellsValuesMap = Object.entries(row.original)?.filter(([_, value])=>[
|
|
254
|
+
'string',
|
|
255
|
+
'number'
|
|
256
|
+
].includes(typeof value)).reduce((acc, [key, value])=>({
|
|
257
|
+
...acc,
|
|
258
|
+
[key]: String(value)
|
|
259
|
+
}), {});
|
|
260
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_TableCell.TableCell, {
|
|
261
|
+
"data-testid": cell.id,
|
|
262
|
+
title: description || cellConfig?.text || cellContent,
|
|
263
|
+
width: cell.column.getCanResize() ? `calc(var(--col-${cell.column.id}-size) * 1px)` : cell.column.getSize() || defaultColumnWidth,
|
|
264
|
+
defaultColumnHeight: defaultColumnHeight,
|
|
265
|
+
align: cell.column.columnDef.meta?.align,
|
|
266
|
+
density: density,
|
|
267
|
+
focusState: getFocusState(position),
|
|
268
|
+
onFocusTrigger: ()=>keyboardNav.onCellFocus(position),
|
|
269
|
+
isFirstColumn: i === 0,
|
|
270
|
+
isLastColumn: i === cells.length - 1,
|
|
271
|
+
description: description,
|
|
272
|
+
color: cellConfig?.textColor ?? undefined,
|
|
273
|
+
backgroundColor: cellConfig?.backgroundColor ?? undefined,
|
|
274
|
+
dataLink: cell.column.columnDef.meta?.dataLink,
|
|
275
|
+
adjacentCellsValuesMap: adjacentCellsValuesMap,
|
|
276
|
+
children: cellConfig?.text || cellContent
|
|
277
|
+
}, cell.id);
|
|
278
|
+
})
|
|
279
|
+
});
|
|
189
280
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
const position = {
|
|
193
|
-
row: index + 1,
|
|
194
|
-
column: i
|
|
195
|
-
};
|
|
196
|
-
const cellContext = cell.getContext();
|
|
197
|
-
const cellConfig = cellConfigs?.[cellContext.cell.id];
|
|
198
|
-
const cellRenderFn = cell.column.columnDef.cell;
|
|
199
|
-
const cellContent = typeof cellRenderFn === 'function' ? cellRenderFn(cellContext) : null;
|
|
200
|
-
/*
|
|
201
|
-
IMPORTANT:
|
|
202
|
-
If Variables exist in the link, they should have been translated by the plugin already. (Being developed at the moment)
|
|
203
|
-
Components have no access to any context (Which is intentional and correct)
|
|
204
|
-
We may want to add parameters to a link from neighboring cells in the future as well.
|
|
205
|
-
If this is the case, the value of the neighboring cells should be read from here and be replaced. (Bing discussed at the moment, not decided yet)
|
|
206
|
-
*/ const cellDescriptionDef = cell.column.columnDef.meta?.cellDescription;
|
|
207
|
-
let description = undefined;
|
|
208
|
-
if (typeof cellDescriptionDef === 'function') {
|
|
209
|
-
// If the cell description is a function, set the value using
|
|
210
|
-
// the function.
|
|
211
|
-
description = cellDescriptionDef(cellContext);
|
|
212
|
-
} else if (cellDescriptionDef && typeof cellContent === 'string') {
|
|
213
|
-
// If the cell description is `true` AND the cell content is
|
|
214
|
-
// a string (and thus viable as a `title` attribute), use the
|
|
215
|
-
// cell content.
|
|
216
|
-
description = cellContent;
|
|
217
|
-
}
|
|
218
|
-
/* this has been specifically added for the data link,
|
|
219
|
-
therefore, non string and numeric values should be excluded
|
|
220
|
-
*/ const adjacentCellsValuesMap = Object.entries(row.original)?.filter(([_, value])=>[
|
|
221
|
-
'string',
|
|
222
|
-
'number'
|
|
223
|
-
].includes(typeof value)).reduce((acc, [key, value])=>({
|
|
224
|
-
...acc,
|
|
225
|
-
[key]: String(value)
|
|
226
|
-
}), {});
|
|
227
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_TableCell.TableCell, {
|
|
228
|
-
"data-testid": cell.id,
|
|
229
|
-
title: description || cellConfig?.text || cellContent,
|
|
230
|
-
width: cell.column.getSize() || defaultColumnWidth,
|
|
231
|
-
defaultColumnHeight: defaultColumnHeight,
|
|
232
|
-
align: cell.column.columnDef.meta?.align,
|
|
233
|
-
density: density,
|
|
234
|
-
focusState: getFocusState(position),
|
|
235
|
-
onFocusTrigger: ()=>keyboardNav.onCellFocus(position),
|
|
236
|
-
isFirstColumn: i === 0,
|
|
237
|
-
isLastColumn: i === cells.length - 1,
|
|
238
|
-
description: description,
|
|
239
|
-
color: cellConfig?.textColor ?? undefined,
|
|
240
|
-
backgroundColor: cellConfig?.backgroundColor ?? undefined,
|
|
241
|
-
dataLink: cell.column.columnDef.meta?.dataLink,
|
|
242
|
-
adjacentCellsValuesMap: adjacentCellsValuesMap,
|
|
243
|
-
children: cellConfig?.text || cellContent
|
|
244
|
-
}, cell.id);
|
|
245
|
-
})
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
})
|
|
281
|
+
})
|
|
282
|
+
]
|
|
249
283
|
});
|
|
250
284
|
}
|
|
@@ -23,10 +23,14 @@ Object.defineProperty(exports, "VirtualizedTableContainer", {
|
|
|
23
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
24
24
|
const _material = require("@mui/material");
|
|
25
25
|
const _react = require("react");
|
|
26
|
+
const _combinesx = require("../utils/combine-sx");
|
|
26
27
|
const VirtualizedTableContainer = /*#__PURE__*/ (0, _react.forwardRef)(function VirtualizedTableContainer(props, ref) {
|
|
27
28
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TableContainer, {
|
|
28
29
|
...props,
|
|
29
30
|
tabIndex: -1,
|
|
30
|
-
ref: ref
|
|
31
|
+
ref: ref,
|
|
32
|
+
sx: (0, _combinesx.combineSx)({
|
|
33
|
+
flexGrow: 1
|
|
34
|
+
}, props.sx)
|
|
31
35
|
});
|
|
32
36
|
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "useFuzzySearch", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return useFuzzySearch;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _reacttable = require("@tanstack/react-table");
|
|
24
|
+
const _matchsorterutils = require("@tanstack/match-sorter-utils");
|
|
25
|
+
const _react = require("react");
|
|
26
|
+
const getFuzzyFilterFunction = (threshold)=>(row, columnId, value, addMeta)=>{
|
|
27
|
+
const itemRank = (0, _matchsorterutils.rankItem)(row.getValue(columnId), value, {
|
|
28
|
+
threshold: _matchsorterutils.rankings[threshold]
|
|
29
|
+
});
|
|
30
|
+
addMeta({
|
|
31
|
+
itemRank
|
|
32
|
+
});
|
|
33
|
+
return itemRank.passed;
|
|
34
|
+
};
|
|
35
|
+
function useFuzzySearch(isSearchEnabled, threshold, expanded, setExpanded) {
|
|
36
|
+
const [globalFilter, setGlobalFilter] = (0, _react.useState)('');
|
|
37
|
+
const [prevExpandedState, setPrevExpandedState] = (0, _react.useState)(expanded);
|
|
38
|
+
// expand all rows when a search query is entered, and restore previous expansion state when the query is cleared
|
|
39
|
+
const handleGlobalFilterChange = (0, _react.useCallback)((value)=>{
|
|
40
|
+
setGlobalFilter((prev)=>{
|
|
41
|
+
if (!prev) {
|
|
42
|
+
setPrevExpandedState(expanded);
|
|
43
|
+
setExpanded(true);
|
|
44
|
+
} else if (prev && !value) {
|
|
45
|
+
setExpanded(prevExpandedState);
|
|
46
|
+
}
|
|
47
|
+
return value;
|
|
48
|
+
});
|
|
49
|
+
}, [
|
|
50
|
+
expanded,
|
|
51
|
+
prevExpandedState,
|
|
52
|
+
setExpanded
|
|
53
|
+
]);
|
|
54
|
+
return {
|
|
55
|
+
globalFilter,
|
|
56
|
+
setGlobalFilter: handleGlobalFilterChange,
|
|
57
|
+
fuzzySearchOptions: {
|
|
58
|
+
filterFns: {
|
|
59
|
+
fuzzy: getFuzzyFilterFunction(threshold)
|
|
60
|
+
},
|
|
61
|
+
globalFilterFn: isSearchEnabled ? 'fuzzy' : undefined,
|
|
62
|
+
getFilteredRowModel: isSearchEnabled ? (0, _reacttable.getFilteredRowModel)() : undefined,
|
|
63
|
+
filterFromLeafRows: isSearchEnabled,
|
|
64
|
+
onGlobalFilterChange: handleGlobalFilterChange
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -24,6 +24,12 @@ _export(exports, {
|
|
|
24
24
|
get DEFAULT_COLUMN_HEIGHT () {
|
|
25
25
|
return DEFAULT_COLUMN_HEIGHT;
|
|
26
26
|
},
|
|
27
|
+
get DEFAULT_COLUMN_MAX_WIDTH () {
|
|
28
|
+
return DEFAULT_COLUMN_MAX_WIDTH;
|
|
29
|
+
},
|
|
30
|
+
get DEFAULT_COLUMN_MIN_WIDTH () {
|
|
31
|
+
return DEFAULT_COLUMN_MIN_WIDTH;
|
|
32
|
+
},
|
|
27
33
|
get DEFAULT_COLUMN_WIDTH () {
|
|
28
34
|
return DEFAULT_COLUMN_WIDTH;
|
|
29
35
|
},
|
|
@@ -35,6 +41,8 @@ _export(exports, {
|
|
|
35
41
|
}
|
|
36
42
|
});
|
|
37
43
|
const DEFAULT_COLUMN_WIDTH = 150;
|
|
44
|
+
const DEFAULT_COLUMN_MIN_WIDTH = 60;
|
|
45
|
+
const DEFAULT_COLUMN_MAX_WIDTH = 1000;
|
|
38
46
|
const DEFAULT_COLUMN_HEIGHT = 40;
|
|
39
47
|
function calculateTableCellHeight(lineHeight, paddingY) {
|
|
40
48
|
// Doing a bunch of math to enforce height to avoid weirdness with mismatched
|
|
@@ -78,27 +86,16 @@ function getTableCellLayout(theme, density, { isHeader, isLastColumn, isFirstCol
|
|
|
78
86
|
lineHeight: lineHeight
|
|
79
87
|
};
|
|
80
88
|
}
|
|
81
|
-
function persesColumnsToTanstackColumns(columns) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
// Taking from a recommendation in this github discussion:
|
|
87
|
-
// https://github.com/TanStack/table/discussions/4179#discussioncomment-3631326
|
|
88
|
-
const sizeProps = width === 'auto' || width === undefined ? {
|
|
89
|
-
// All zero values are used as shorthand for "auto" when rendering
|
|
90
|
-
// because it makes it easy to fall back. (e.g. `row.size || "auto"`)
|
|
91
|
-
size: 0,
|
|
92
|
-
minSize: 0,
|
|
93
|
-
maxSize: 0
|
|
94
|
-
} : {
|
|
95
|
-
size: width
|
|
96
|
-
};
|
|
97
|
-
const result = {
|
|
89
|
+
function persesColumnsToTanstackColumns(columns, defaultColumnConfig) {
|
|
90
|
+
return columns.map(({ width, align, headerDescription, cellDescription, enableSorting, dataLink, enableResizing, ...otherProps })=>{
|
|
91
|
+
const isResizingEnabled = enableResizing ?? defaultColumnConfig?.enableResizing ?? false;
|
|
92
|
+
const sizeProps = width === 'auto' || width === undefined ? getDefaultSizeProps(isResizingEnabled, defaultColumnConfig?.minWidth, defaultColumnConfig?.maxWidth) : getUserProvidedSizeProps(isResizingEnabled, width, defaultColumnConfig?.minWidth, defaultColumnConfig?.maxWidth);
|
|
93
|
+
return {
|
|
98
94
|
...otherProps,
|
|
99
95
|
...sizeProps,
|
|
100
96
|
// Default sorting to false, so it is very explicitly set per column.
|
|
101
97
|
enableSorting: !!enableSorting,
|
|
98
|
+
enableResizing: isResizingEnabled,
|
|
102
99
|
// Open-ended store for extra metadata in TanStack Table, so you can bake
|
|
103
100
|
// in your own features.
|
|
104
101
|
meta: {
|
|
@@ -108,7 +105,34 @@ function persesColumnsToTanstackColumns(columns) {
|
|
|
108
105
|
dataLink
|
|
109
106
|
}
|
|
110
107
|
};
|
|
111
|
-
return result;
|
|
112
108
|
});
|
|
113
|
-
|
|
109
|
+
}
|
|
110
|
+
function getUserProvidedSizeProps(isResizingEnabled, width, minWidth, maxWidth) {
|
|
111
|
+
// When resizing is enabled, we need to set min and max size to ensure the column can be resized within a reasonable range.
|
|
112
|
+
return isResizingEnabled ? {
|
|
113
|
+
size: width,
|
|
114
|
+
minSize: minWidth ?? DEFAULT_COLUMN_MIN_WIDTH,
|
|
115
|
+
maxSize: maxWidth ?? DEFAULT_COLUMN_MAX_WIDTH
|
|
116
|
+
} : {
|
|
117
|
+
size: width
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function getDefaultSizeProps(isResizingEnabled, minWidth, maxWidth) {
|
|
121
|
+
return isResizingEnabled ? {
|
|
122
|
+
// When resizing is enabled, we need to set a default size for the column
|
|
123
|
+
// so that relative value can be calculated when resizing and column is visible.
|
|
124
|
+
size: DEFAULT_COLUMN_WIDTH,
|
|
125
|
+
minSize: minWidth ?? DEFAULT_COLUMN_MIN_WIDTH,
|
|
126
|
+
maxSize: maxWidth ?? DEFAULT_COLUMN_MAX_WIDTH
|
|
127
|
+
} : // the space in a table. We translate our custom "auto" setting to 0 size
|
|
128
|
+
// for these columns, so it is easy to fall back to auto when rendering.
|
|
129
|
+
// Taking from a recommendation in this github discussion:
|
|
130
|
+
// https://github.com/TanStack/table/discussions/4179#discussioncomment-3631326
|
|
131
|
+
{
|
|
132
|
+
// All zero values are used as shorthand for "auto" when rendering
|
|
133
|
+
// because it makes it easy to fall back. (e.g. `row.size || "auto"`)
|
|
134
|
+
size: 0,
|
|
135
|
+
minSize: 0,
|
|
136
|
+
maxSize: 0
|
|
137
|
+
};
|
|
114
138
|
}
|
|
@@ -29,6 +29,7 @@ const _react = require("react");
|
|
|
29
29
|
const _context = require("../context");
|
|
30
30
|
const _timeZoneOption = require("../model/timeZoneOption");
|
|
31
31
|
const _SettingsAutocomplete = require("../SettingsAutocomplete");
|
|
32
|
+
const _format = require("../utils/format");
|
|
32
33
|
const _DateTimeRangePicker = require("./DateTimeRangePicker");
|
|
33
34
|
const _utils = require("./utils");
|
|
34
35
|
function _interop_require_default(obj) {
|
|
@@ -55,6 +56,8 @@ function TimeRangeSelector({ value, timeOptions, onChange, height, showCustomTim
|
|
|
55
56
|
const [tzAnchorEl, setTzAnchorEl] = (0, _react.useState)(null);
|
|
56
57
|
const tzOpen = Boolean(tzAnchorEl);
|
|
57
58
|
const tzLabel = tzOptions.find((o)=>o.value === timeZone)?.display ?? timeZone;
|
|
59
|
+
const tzOffset = (0, _format.getGMTOffset)(timeZone);
|
|
60
|
+
const localOffset = (0, _format.getGMTOffset)('local');
|
|
58
61
|
const tzAutocompleteOptions = tzOptions.map((o)=>({
|
|
59
62
|
id: o.value,
|
|
60
63
|
label: o.display
|
|
@@ -140,6 +143,26 @@ function TimeRangeSelector({ value, timeOptions, onChange, height, showCustomTim
|
|
|
140
143
|
value: (0, _utils.formatTimeRange)(value, timeZone),
|
|
141
144
|
onClick: ()=>setOpen(!open),
|
|
142
145
|
IconComponent: _Calendar.default,
|
|
146
|
+
renderValue: ()=>/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
147
|
+
direction: "row",
|
|
148
|
+
alignItems: "center",
|
|
149
|
+
spacing: 1,
|
|
150
|
+
children: [
|
|
151
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
|
|
152
|
+
children: timeOptions.find((opt)=>(0, _utils.formatTimeRange)(opt.value, timeZone) === (0, _utils.formatTimeRange)(value, timeZone))?.display ?? (0, _utils.formatTimeRange)(value, timeZone)
|
|
153
|
+
}),
|
|
154
|
+
tzOffset !== localOffset && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
155
|
+
sx: {
|
|
156
|
+
typography: 'caption',
|
|
157
|
+
color: 'text.secondary'
|
|
158
|
+
},
|
|
159
|
+
children: [
|
|
160
|
+
"· ",
|
|
161
|
+
tzOffset
|
|
162
|
+
]
|
|
163
|
+
})
|
|
164
|
+
]
|
|
165
|
+
}),
|
|
143
166
|
inputProps: {
|
|
144
167
|
'aria-label': `Select time range. Currently set to ${value}`
|
|
145
168
|
},
|
|
@@ -46,7 +46,6 @@ _export(exports, {
|
|
|
46
46
|
return legacyCheckforNearbySeries;
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
|
-
const _core = require("@perses-dev/core");
|
|
50
49
|
const _model = require("../model");
|
|
51
50
|
const _utils = require("../utils");
|
|
52
51
|
const _tooltipmodel = require("./tooltip-model");
|
|
@@ -197,7 +196,7 @@ cursorPixelY) {
|
|
|
197
196
|
seriesIndex: seriesIdx
|
|
198
197
|
});
|
|
199
198
|
}
|
|
200
|
-
const formattedY = (0,
|
|
199
|
+
const formattedY = (0, _model.formatValue)(yValue, seriesFormat);
|
|
201
200
|
currentNearbySeriesData.push({
|
|
202
201
|
seriesIdx: seriesIdx,
|
|
203
202
|
datumIdx: datumIdx,
|
|
@@ -266,7 +265,7 @@ function legacyCheckforNearbySeries(data, pointInGrid, yBuffer, chart, format) {
|
|
|
266
265
|
}
|
|
267
266
|
// determine whether to convert timestamp to ms, see: https://stackoverflow.com/a/23982005/17575201
|
|
268
267
|
const xValueMilliSeconds = xValue > 99999999999 ? xValue : xValue * 1000;
|
|
269
|
-
const formattedY = (0,
|
|
268
|
+
const formattedY = (0, _model.formatValue)(yValue, format);
|
|
270
269
|
currentNearbySeriesData.push({
|
|
271
270
|
seriesIdx: seriesIdx,
|
|
272
271
|
datumIdx: datumIdx,
|
|
@@ -27,7 +27,7 @@ const _ChevronDown = /*#__PURE__*/ _interop_require_default(require("mdi-materia
|
|
|
27
27
|
const _EyeOffOutline = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/EyeOffOutline"));
|
|
28
28
|
const _EyeOutline = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/EyeOutline"));
|
|
29
29
|
const _DeleteOutline = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/DeleteOutline"));
|
|
30
|
-
const
|
|
30
|
+
const _model = require("../model");
|
|
31
31
|
const _TransformEditor = require("./TransformEditor");
|
|
32
32
|
function _interop_require_default(obj) {
|
|
33
33
|
return obj && obj.__esModule ? obj : {
|
|
@@ -73,7 +73,7 @@ function TransformEditorContainer({ index, value, isCollapsed, onChange, onColla
|
|
|
73
73
|
},
|
|
74
74
|
children: value.kind ? /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
|
|
75
75
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)("strong", {
|
|
76
|
-
children:
|
|
76
|
+
children: _model.TRANSFORM_TEXT[value.kind]
|
|
77
77
|
})
|
|
78
78
|
}) : /*#__PURE__*/ (0, _jsxruntime.jsx)("strong", {
|
|
79
79
|
children: "Select a transformation kind"
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
get getSubmitText () {
|
|
25
|
+
return getSubmitText;
|
|
26
|
+
},
|
|
27
|
+
get getTitleAction () {
|
|
28
|
+
return getTitleAction;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
function getTitleAction(action, isDraft) {
|
|
32
|
+
if (action === 'read') return 'View';
|
|
33
|
+
if (isDraft && action === 'create') return 'Add';
|
|
34
|
+
if (!isDraft && action === 'create') return 'Create';
|
|
35
|
+
if (action === 'update') return 'Edit';
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
38
|
+
function getSubmitText(action, isDraft) {
|
|
39
|
+
if (isDraft && action === 'create') return 'Add';
|
|
40
|
+
if (isDraft && action === 'update') return 'Apply';
|
|
41
|
+
if (!isDraft) return 'Save';
|
|
42
|
+
return '';
|
|
43
|
+
}
|