@perses-dev/components 0.55.0-beta.2 → 0.55.0-beta.3
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/ColorPicker/ColorPicker.d.ts.map +1 -1
- package/dist/ColorPicker/ColorPicker.js +2 -2
- package/dist/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/ColorPicker/OptionsColorPicker.d.ts.map +1 -1
- package/dist/ColorPicker/OptionsColorPicker.js +1 -1
- package/dist/ColorPicker/OptionsColorPicker.js.map +1 -1
- package/dist/ContentWithLegend/ContentWithLegend.d.ts.map +1 -1
- package/dist/ContentWithLegend/ContentWithLegend.js +2 -2
- package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.d.ts +1 -2
- package/dist/ContentWithLegend/model/content-with-legend-model.d.ts.map +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
- package/dist/DensitySelector/DensitySelector.d.ts.map +1 -1
- package/dist/DensitySelector/DensitySelector.js.map +1 -1
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js.map +1 -1
- package/dist/Dialog/DiscardChangesConfirmationDialog.d.ts.map +1 -1
- package/dist/Dialog/DiscardChangesConfirmationDialog.js.map +1 -1
- package/dist/DragAndDrop/DragAndDropList.d.ts.map +1 -1
- package/dist/DragAndDrop/DragAndDropList.js +4 -4
- package/dist/DragAndDrop/DragAndDropList.js.map +1 -1
- package/dist/DragAndDrop/DragButton.d.ts +0 -1
- package/dist/DragAndDrop/DragButton.d.ts.map +1 -1
- package/dist/DragAndDrop/DragButton.js.map +1 -1
- package/dist/Drawer/Drawer.d.ts.map +1 -1
- package/dist/Drawer/Drawer.js.map +1 -1
- package/dist/EChart/EChart.d.ts +2 -2
- package/dist/EChart/EChart.d.ts.map +1 -1
- package/dist/EChart/EChart.js +5 -5
- package/dist/EChart/EChart.js.map +1 -1
- package/dist/EChart/timezone-formatter.d.ts.map +1 -1
- package/dist/FontSizeSelector/FontSizeSelector.d.ts.map +1 -1
- package/dist/FontSizeSelector/FontSizeSelector.js.map +1 -1
- package/dist/FormatControls/FormatControls.d.ts.map +1 -1
- package/dist/FormatControls/FormatControls.js +1 -1
- package/dist/FormatControls/FormatControls.js.map +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/InfoTooltip/InfoTooltip.d.ts.map +1 -1
- package/dist/InfoTooltip/InfoTooltip.js +1 -1
- package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
- package/dist/JSONEditor.d.ts +1 -1
- package/dist/JSONEditor.d.ts.map +1 -1
- package/dist/JSONEditor.js +2 -2
- package/dist/JSONEditor.js.map +1 -1
- package/dist/Legend/CompactLegend.d.ts +1 -1
- package/dist/Legend/CompactLegend.d.ts.map +1 -1
- package/dist/Legend/CompactLegend.js +1 -1
- package/dist/Legend/CompactLegend.js.map +1 -1
- package/dist/Legend/Legend.d.ts +1 -1
- package/dist/Legend/Legend.d.ts.map +1 -1
- package/dist/Legend/Legend.js +1 -1
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/Legend/LegendColorBadge.d.ts +0 -1
- package/dist/Legend/LegendColorBadge.d.ts.map +1 -1
- package/dist/Legend/LegendColorBadge.js +1 -1
- package/dist/Legend/LegendColorBadge.js.map +1 -1
- package/dist/Legend/ListLegend.d.ts +1 -1
- package/dist/Legend/ListLegend.d.ts.map +1 -1
- package/dist/Legend/ListLegend.js +5 -4
- package/dist/Legend/ListLegend.js.map +1 -1
- package/dist/Legend/ListLegendItem.d.ts +1 -1
- package/dist/Legend/ListLegendItem.d.ts.map +1 -1
- package/dist/Legend/ListLegendItem.js +4 -3
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/Legend/TableLegend.d.ts.map +1 -1
- package/dist/Legend/TableLegend.js.map +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.d.ts.map +1 -1
- package/dist/LinksEditor/LinkEditorForm.js.map +1 -1
- package/dist/ModeSelector/ModeSelector.d.ts.map +1 -1
- package/dist/ModeSelector/ModeSelector.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorColumn.d.ts.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.d.ts.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js +2 -2
- package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGrid.d.ts.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGroup.d.ts.map +1 -1
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.d.ts.map +1 -1
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
- package/dist/RepeatGrid/RepeatGrid.d.ts +15 -0
- package/dist/RepeatGrid/RepeatGrid.d.ts.map +1 -0
- package/dist/RepeatGrid/RepeatGrid.js +68 -0
- package/dist/RepeatGrid/RepeatGrid.js.map +1 -0
- package/dist/RepeatGrid/index.d.ts +2 -0
- package/dist/RepeatGrid/index.d.ts.map +1 -0
- package/dist/RepeatGrid/index.js +15 -0
- package/dist/RepeatGrid/index.js.map +1 -0
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
- package/dist/SortSelector/SortSelector.d.ts.map +1 -1
- package/dist/SortSelector/SortSelector.js.map +1 -1
- package/dist/SortSelector/SortSelectorButtons.d.ts.map +1 -1
- package/dist/SortSelector/SortSelectorButtons.js.map +1 -1
- package/dist/Table/InnerTable.d.ts +0 -1
- package/dist/Table/InnerTable.d.ts.map +1 -1
- package/dist/Table/InnerTable.js.map +1 -1
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +1 -1
- package/dist/Table/Table.js.map +1 -1
- package/dist/Table/TableBody.d.ts +0 -1
- package/dist/Table/TableBody.d.ts.map +1 -1
- package/dist/Table/TableCell.d.ts.map +1 -1
- package/dist/Table/TableCell.js.map +1 -1
- package/dist/Table/TableCheckbox.d.ts.map +1 -1
- package/dist/Table/TableCheckbox.js.map +1 -1
- package/dist/Table/TableFoot.d.ts +0 -1
- package/dist/Table/TableFoot.d.ts.map +1 -1
- package/dist/Table/TableHead.d.ts +0 -1
- package/dist/Table/TableHead.d.ts.map +1 -1
- package/dist/Table/TableHeaderCell.d.ts +1 -1
- package/dist/Table/TableHeaderCell.d.ts.map +1 -1
- package/dist/Table/TableHeaderCell.js.map +1 -1
- package/dist/Table/TableRow.d.ts +0 -1
- package/dist/Table/TableRow.d.ts.map +1 -1
- package/dist/Table/TableRow.js.map +1 -1
- package/dist/Table/TableToolbar.d.ts.map +1 -1
- package/dist/Table/TableToolbar.js +4 -4
- package/dist/Table/TableToolbar.js.map +1 -1
- package/dist/Table/VirtualizedTable.d.ts +1 -1
- package/dist/Table/VirtualizedTable.d.ts.map +1 -1
- package/dist/Table/VirtualizedTable.js +8 -8
- package/dist/Table/VirtualizedTable.js.map +1 -1
- package/dist/Table/VirtualizedTableContainer.d.ts +0 -1
- package/dist/Table/VirtualizedTableContainer.d.ts.map +1 -1
- package/dist/Table/VirtualizedTableContainer.js.map +1 -1
- package/dist/Table/hooks/useFuzzySearch.d.ts +1 -1
- package/dist/Table/hooks/useFuzzySearch.d.ts.map +1 -1
- package/dist/Table/hooks/useFuzzySearch.js +1 -1
- package/dist/Table/hooks/useFuzzySearch.js.map +1 -1
- package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -1
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts +1 -1
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts.map +1 -1
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -1
- package/dist/Table/model/table-model.d.ts +1 -1
- package/dist/Table/model/table-model.d.ts.map +1 -1
- package/dist/Table/model/table-model.js.map +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.map +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js +5 -5
- package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.d.ts +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.d.ts.map +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.js +3 -3
- package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.d.ts +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.d.ts.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.js +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
- package/dist/TimeRangeSelector/utils.d.ts.map +1 -1
- package/dist/TimeRangeSelector/utils.js +1 -1
- package/dist/TimeRangeSelector/utils.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesMarker.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesMarker.js.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts +2 -2
- package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js +4 -4
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.d.ts +0 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.d.ts +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
- package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/utils.js.map +1 -1
- package/dist/TimeZoneSelector.d.ts +1 -1
- package/dist/TimeZoneSelector.d.ts.map +1 -1
- package/dist/TimeZoneSelector.js +5 -2
- package/dist/TimeZoneSelector.js.map +1 -1
- package/dist/ToolbarIconButton/ToolbarIconButton.d.ts +0 -1
- package/dist/ToolbarIconButton/ToolbarIconButton.d.ts.map +1 -1
- package/dist/ToolbarIconButton/ToolbarIconButton.js +1 -1
- package/dist/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
- package/dist/TransformsEditor/TransformEditor.d.ts.map +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.map +1 -1
- package/dist/TransformsEditor/TransformsEditor.js +1 -1
- package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.d.ts.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.js.map +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/cjs/ColorPicker/ColorPicker.js +2 -2
- package/dist/cjs/ColorPicker/OptionsColorPicker.js +1 -1
- package/dist/cjs/ContentWithLegend/ContentWithLegend.js +1 -1
- package/dist/cjs/DragAndDrop/DragAndDropList.js +4 -4
- package/dist/cjs/EChart/EChart.js +4 -4
- package/dist/cjs/FormatControls/FormatControls.js +1 -1
- package/dist/cjs/FormatControls/UnitSelector.js +1 -1
- package/dist/cjs/JSONEditor.js +2 -2
- package/dist/cjs/Legend/CompactLegend.js +1 -1
- package/dist/cjs/Legend/Legend.js +1 -1
- package/dist/cjs/Legend/LegendColorBadge.js +1 -1
- package/dist/cjs/Legend/ListLegend.js +4 -3
- package/dist/cjs/Legend/ListLegendItem.js +4 -3
- package/dist/cjs/OptionsEditorLayout/OptionsEditorControl.js +2 -2
- package/dist/cjs/RepeatGrid/RepeatGrid.js +76 -0
- package/dist/cjs/RepeatGrid/index.js +30 -0
- package/dist/cjs/Table/Table.js +1 -1
- package/dist/cjs/Table/TableToolbar.js +4 -4
- package/dist/cjs/Table/VirtualizedTable.js +8 -8
- package/dist/cjs/Table/hooks/useFuzzySearch.js +1 -1
- package/dist/cjs/ThresholdsEditor/ThresholdInput.js +1 -1
- package/dist/cjs/ThresholdsEditor/ThresholdsEditor.js +5 -5
- package/dist/cjs/TimeRangeSelector/DateTimeRangePicker.js +3 -3
- package/dist/cjs/TimeRangeSelector/TimeRangeSelector.js +1 -1
- package/dist/cjs/TimeRangeSelector/utils.js +1 -1
- package/dist/cjs/TimeSeriesTooltip/SeriesInfo.js +1 -1
- package/dist/cjs/TimeSeriesTooltip/TimeChartTooltip.js +4 -4
- package/dist/cjs/TimeSeriesTooltip/TooltipContent.js +1 -1
- package/dist/cjs/TimeZoneSelector.js +5 -2
- package/dist/cjs/ToolbarIconButton/ToolbarIconButton.js +1 -1
- package/dist/cjs/TransformsEditor/TransformEditorContainer.js +2 -2
- package/dist/cjs/TransformsEditor/TransformsEditor.js +1 -1
- package/dist/cjs/ValueMappingEditor/ValueMappingsEditor.js +1 -1
- package/dist/cjs/context/SnackbarProvider.js +1 -1
- package/dist/cjs/controls/TextField.js +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/model/bits.js +1 -1
- package/dist/cjs/model/bytes.js +1 -1
- package/dist/cjs/model/currency.js +1 -1
- package/dist/cjs/model/throughput.js +2 -2
- package/dist/cjs/model/units.js +4 -4
- package/dist/cjs/test/render.js +1 -1
- package/dist/cjs/test/setup-tests.js +9 -3
- package/dist/cjs/theme/palette/palette-options.js +4 -4
- package/dist/cjs/utils/format.js +6 -1
- package/dist/cjs/utils/memo.js +1 -1
- package/dist/cjs/utils/request-interpolation.js +1 -1
- package/dist/context/ChartsProvider.d.ts.map +1 -1
- package/dist/context/ChartsProvider.js.map +1 -1
- package/dist/context/ItemActionsProvider.js.map +1 -1
- package/dist/context/SelectionProvider.js.map +1 -1
- package/dist/context/SnackbarProvider.d.ts +1 -1
- package/dist/context/SnackbarProvider.d.ts.map +1 -1
- package/dist/context/SnackbarProvider.js +1 -1
- package/dist/context/SnackbarProvider.js.map +1 -1
- package/dist/context/TimeZoneProvider.d.ts.map +1 -1
- package/dist/context/TimeZoneProvider.js.map +1 -1
- package/dist/controls/TextField.d.ts +0 -1
- package/dist/controls/TextField.d.ts.map +1 -1
- package/dist/controls/TextField.js +1 -1
- package/dist/controls/TextField.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/model/bits.d.ts.map +1 -1
- package/dist/model/bits.js +1 -1
- package/dist/model/bits.js.map +1 -1
- package/dist/model/bytes.d.ts.map +1 -1
- package/dist/model/bytes.js +1 -1
- package/dist/model/bytes.js.map +1 -1
- package/dist/model/currency.d.ts.map +1 -1
- package/dist/model/currency.js +1 -1
- package/dist/model/currency.js.map +1 -1
- package/dist/model/formatterCache.js.map +1 -1
- package/dist/model/graph.d.ts.map +1 -1
- package/dist/model/graph.js.map +1 -1
- package/dist/model/temperature.d.ts.map +1 -1
- package/dist/model/theme.d.ts.map +1 -1
- package/dist/model/theme.js.map +1 -1
- package/dist/model/throughput.d.ts.map +1 -1
- package/dist/model/throughput.js +2 -2
- package/dist/model/throughput.js.map +1 -1
- package/dist/model/types.d.ts +1 -1
- package/dist/model/types.d.ts.map +1 -1
- package/dist/model/types.js.map +1 -1
- package/dist/model/units.d.ts +8 -8
- package/dist/model/units.d.ts.map +1 -1
- package/dist/model/units.js +4 -4
- package/dist/model/units.js.map +1 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +1 -1
- package/dist/test/render.js.map +1 -1
- package/dist/test/setup-tests.d.ts +1 -1
- package/dist/test/setup-tests.d.ts.map +1 -1
- package/dist/test/setup-tests.js +3 -2
- package/dist/test/setup-tests.js.map +1 -1
- package/dist/test-utils/theme.d.ts +1 -1
- package/dist/test-utils/theme.d.ts.map +1 -1
- package/dist/test-utils/theme.js.map +1 -1
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js.map +1 -1
- package/dist/theme/palette/background.d.ts +1 -1
- package/dist/theme/palette/background.d.ts.map +1 -1
- package/dist/theme/palette/background.js.map +1 -1
- package/dist/theme/palette/error.d.ts.map +1 -1
- package/dist/theme/palette/error.js.map +1 -1
- package/dist/theme/palette/grey.d.ts +1 -1
- package/dist/theme/palette/grey.d.ts.map +1 -1
- package/dist/theme/palette/grey.js.map +1 -1
- package/dist/theme/palette/palette-options.d.ts.map +1 -1
- package/dist/theme/palette/palette-options.js +4 -4
- package/dist/theme/palette/palette-options.js.map +1 -1
- package/dist/theme/palette/primary.d.ts.map +1 -1
- package/dist/theme/palette/primary.js.map +1 -1
- package/dist/theme/palette/secondary.d.ts.map +1 -1
- package/dist/theme/palette/secondary.js.map +1 -1
- package/dist/theme/palette/success.d.ts.map +1 -1
- package/dist/theme/palette/success.js.map +1 -1
- package/dist/theme/palette/text.d.ts +1 -1
- package/dist/theme/palette/text.d.ts.map +1 -1
- package/dist/theme/palette/text.js.map +1 -1
- package/dist/theme/palette/warning.d.ts.map +1 -1
- package/dist/theme/palette/warning.js.map +1 -1
- package/dist/theme/theme.d.ts.map +1 -1
- package/dist/theme/theme.js.map +1 -1
- package/dist/utils/axis.d.ts.map +1 -1
- package/dist/utils/axis.js.map +1 -1
- package/dist/utils/browser-storage.js.map +1 -1
- package/dist/utils/chart-actions.d.ts +1 -1
- package/dist/utils/chart-actions.d.ts.map +1 -1
- package/dist/utils/chart-actions.js.map +1 -1
- package/dist/utils/data-field-interpolation.js.map +1 -1
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +6 -1
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/mathjs.d.ts +1 -1
- package/dist/utils/memo.d.ts.map +1 -1
- package/dist/utils/memo.js +1 -1
- package/dist/utils/memo.js.map +1 -1
- package/dist/utils/request-interpolation.d.ts.map +1 -1
- package/dist/utils/request-interpolation.js +1 -1
- package/dist/utils/request-interpolation.js.map +1 -1
- package/dist/utils/selection-interpolation.js.map +1 -1
- package/dist/utils/theme-gen.d.ts.map +1 -1
- package/dist/utils/theme-gen.js.map +1 -1
- package/dist/utils/time-series-data.d.ts.map +1 -1
- package/dist/utils/time-series-data.js.map +1 -1
- package/dist/utils/transform-data.js.map +1 -1
- package/dist/utils/variable-interpolation.js.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Table/VirtualizedTableContainer.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { TableContainer as MuiTableContainer, TableContainerProps as MuiTableContainerProps } from '@mui/material';\nimport { forwardRef } from 'react';\nimport { combineSx } from '../utils/combine-sx';\n\ntype VirtualizedTableContainerProps = MuiTableContainerProps;\n\nexport const VirtualizedTableContainer = forwardRef<HTMLDivElement, VirtualizedTableContainerProps>(\n function VirtualizedTableContainer(props, ref) {\n return <MuiTableContainer {...props} tabIndex={-1} ref={ref} sx={combineSx({ flexGrow: 1 }, props.sx)} />;\n }
|
|
1
|
+
{"version":3,"sources":["../../src/Table/VirtualizedTableContainer.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { TableContainer as MuiTableContainer, TableContainerProps as MuiTableContainerProps } from '@mui/material';\nimport { forwardRef } from 'react';\n\nimport { combineSx } from '../utils/combine-sx';\n\ntype VirtualizedTableContainerProps = MuiTableContainerProps;\n\nexport const VirtualizedTableContainer = forwardRef<HTMLDivElement, VirtualizedTableContainerProps>(\n function VirtualizedTableContainer(props, ref) {\n return <MuiTableContainer {...props} tabIndex={-1} ref={ref} sx={combineSx({ flexGrow: 1 }, props.sx)} />;\n },\n);\n"],"names":["TableContainer","MuiTableContainer","forwardRef","combineSx","VirtualizedTableContainer","props","ref","tabIndex","sx","flexGrow"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,kBAAkBC,iBAAiB,QAAuD,gBAAgB;AACnH,SAASC,UAAU,QAAQ,QAAQ;AAEnC,SAASC,SAAS,QAAQ,sBAAsB;AAIhD,OAAO,MAAMC,0CAA4BF,WACvC,SAASE,0BAA0BC,KAAK,EAAEC,GAAG;IAC3C,qBAAO,KAACL;QAAmB,GAAGI,KAAK;QAAEE,UAAU,CAAC;QAAGD,KAAKA;QAAKE,IAAIL,UAAU;YAAEM,UAAU;QAAE,GAAGJ,MAAMG,EAAE;;AACtG,GACA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { FuzzyMatchThreshold } from '@perses-dev/components';
|
|
1
2
|
import { ExpandedState, TableOptions } from '@tanstack/react-table';
|
|
2
3
|
import { SetStateAction } from 'react';
|
|
3
|
-
import { FuzzyMatchThreshold } from '@perses-dev/components';
|
|
4
4
|
export interface UseFuzzySearchResult<TableData> {
|
|
5
5
|
globalFilter: string;
|
|
6
6
|
setGlobalFilter: (value: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFuzzySearch.d.ts","sourceRoot":"","sources":["../../../src/Table/hooks/useFuzzySearch.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useFuzzySearch.d.ts","sourceRoot":"","sources":["../../../src/Table/hooks/useFuzzySearch.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAiC,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACnG,OAAO,EAAE,cAAc,EAAyB,MAAM,OAAO,CAAC;AAU9D,MAAM,WAAW,oBAAoB,CAAC,SAAS;IAC7C,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,kBAAkB,EAAE,IAAI,CACtB,YAAY,CAAC,SAAS,CAAC,EACvB,WAAW,GAAG,gBAAgB,GAAG,qBAAqB,GAAG,oBAAoB,GAAG,sBAAsB,CACvG,CAAC;CACH;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,SAAS,EACtC,eAAe,EAAE,OAAO,GAAG,SAAS,EACpC,SAAS,EAAE,mBAAmB,EAC9B,QAAQ,EAAE,aAAa,EACvB,WAAW,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,aAAa,CAAC,KAAK,IAAI,GAC1D,oBAAoB,CAAC,SAAS,CAAC,CA8BjC"}
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { getFilteredRowModel } from '@tanstack/react-table';
|
|
14
13
|
import { rankings, rankItem } from '@tanstack/match-sorter-utils';
|
|
14
|
+
import { getFilteredRowModel } from '@tanstack/react-table';
|
|
15
15
|
import { useCallback, useState } from 'react';
|
|
16
16
|
const getFuzzyFilterFunction = (threshold)=>(row, columnId, value, addMeta)=>{
|
|
17
17
|
const itemRank = rankItem(row.getValue(columnId), value, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Table/hooks/useFuzzySearch.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/Table/hooks/useFuzzySearch.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FuzzyMatchThreshold } from '@perses-dev/components';\nimport { rankings, rankItem } from '@tanstack/match-sorter-utils';\nimport { ExpandedState, FilterFn, getFilteredRowModel, TableOptions } from '@tanstack/react-table';\nimport { SetStateAction, useCallback, useState } from 'react';\n\nconst getFuzzyFilterFunction =\n (threshold: FuzzyMatchThreshold): FilterFn<unknown> =>\n (row, columnId, value, addMeta) => {\n const itemRank = rankItem(row.getValue(columnId), value, { threshold: rankings[threshold] });\n addMeta({ itemRank });\n return itemRank.passed;\n };\n\nexport interface UseFuzzySearchResult<TableData> {\n globalFilter: string;\n setGlobalFilter: (value: string) => void;\n fuzzySearchOptions: Pick<\n TableOptions<TableData>,\n 'filterFns' | 'globalFilterFn' | 'getFilteredRowModel' | 'filterFromLeafRows' | 'onGlobalFilterChange'\n >;\n}\n\n/**\n * Returns fuzzy search state and the corresponding `useReactTable` options.\n * Filter options are disabled when `showSearch` is falsy.\n */\nexport function useFuzzySearch<TableData>(\n isSearchEnabled: boolean | undefined,\n threshold: FuzzyMatchThreshold,\n expanded: ExpandedState,\n setExpanded: (value: SetStateAction<ExpandedState>) => void,\n): UseFuzzySearchResult<TableData> {\n const [globalFilter, setGlobalFilter] = useState('');\n const [prevExpandedState, setPrevExpandedState] = useState<ExpandedState>(expanded);\n\n // expand all rows when a search query is entered, and restore previous expansion state when the query is cleared\n const handleGlobalFilterChange = useCallback(\n (value: string): void => {\n setGlobalFilter((prev) => {\n if (!prev) {\n setPrevExpandedState(expanded);\n setExpanded(true);\n } else if (prev && !value) {\n setExpanded(prevExpandedState);\n }\n return value;\n });\n },\n [expanded, prevExpandedState, setExpanded],\n );\n return {\n globalFilter,\n setGlobalFilter: handleGlobalFilterChange,\n fuzzySearchOptions: {\n filterFns: { fuzzy: getFuzzyFilterFunction(threshold) },\n globalFilterFn: isSearchEnabled ? 'fuzzy' : undefined,\n getFilteredRowModel: isSearchEnabled ? getFilteredRowModel() : undefined,\n filterFromLeafRows: isSearchEnabled,\n onGlobalFilterChange: handleGlobalFilterChange,\n },\n };\n}\n"],"names":["rankings","rankItem","getFilteredRowModel","useCallback","useState","getFuzzyFilterFunction","threshold","row","columnId","value","addMeta","itemRank","getValue","passed","useFuzzySearch","isSearchEnabled","expanded","setExpanded","globalFilter","setGlobalFilter","prevExpandedState","setPrevExpandedState","handleGlobalFilterChange","prev","fuzzySearchOptions","filterFns","fuzzy","globalFilterFn","undefined","filterFromLeafRows","onGlobalFilterChange"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,QAAQ,EAAEC,QAAQ,QAAQ,+BAA+B;AAClE,SAAkCC,mBAAmB,QAAsB,wBAAwB;AACnG,SAAyBC,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AAE9D,MAAMC,yBACJ,CAACC,YACD,CAACC,KAAKC,UAAUC,OAAOC;QACrB,MAAMC,WAAWV,SAASM,IAAIK,QAAQ,CAACJ,WAAWC,OAAO;YAAEH,WAAWN,QAAQ,CAACM,UAAU;QAAC;QAC1FI,QAAQ;YAAEC;QAAS;QACnB,OAAOA,SAASE,MAAM;IACxB;AAWF;;;CAGC,GACD,OAAO,SAASC,eACdC,eAAoC,EACpCT,SAA8B,EAC9BU,QAAuB,EACvBC,WAA2D;IAE3D,MAAM,CAACC,cAAcC,gBAAgB,GAAGf,SAAS;IACjD,MAAM,CAACgB,mBAAmBC,qBAAqB,GAAGjB,SAAwBY;IAE1E,iHAAiH;IACjH,MAAMM,2BAA2BnB,YAC/B,CAACM;QACCU,gBAAgB,CAACI;YACf,IAAI,CAACA,MAAM;gBACTF,qBAAqBL;gBACrBC,YAAY;YACd,OAAO,IAAIM,QAAQ,CAACd,OAAO;gBACzBQ,YAAYG;YACd;YACA,OAAOX;QACT;IACF,GACA;QAACO;QAAUI;QAAmBH;KAAY;IAE5C,OAAO;QACLC;QACAC,iBAAiBG;QACjBE,oBAAoB;YAClBC,WAAW;gBAAEC,OAAOrB,uBAAuBC;YAAW;YACtDqB,gBAAgBZ,kBAAkB,UAAUa;YAC5C1B,qBAAqBa,kBAAkBb,wBAAwB0B;YAC/DC,oBAAoBd;YACpBe,sBAAsBR;QACxB;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Table/hooks/useTableKeyboardNav.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FocusEventHandler, KeyboardEventHandler, useCallback, useState } from 'react';\n\nexport interface UseTableKeyboardNavProps {\n maxRows: number;\n maxColumns: number;\n\n /**\n * Function used to modify the active table cell based on the keyboard event,\n * the current position, and the default recommended next position (this value\n * will be `undefined` in cases where there is no default handler like `PageUp`\n * and `PageDown`). This can be used to modify the next position that will be\n * used and/or to handle side effects related to the new position (e.g.\n * pagination, scrolling the active cell into view).\n */\n onActiveCellChange?: (\n e: React.KeyboardEvent<HTMLTableElement>,\n currentActiveCell: TableCellPosition,\n defaultNextActiveCell: TableCellPosition | undefined
|
|
1
|
+
{"version":3,"sources":["../../../src/Table/hooks/useTableKeyboardNav.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FocusEventHandler, KeyboardEventHandler, useCallback, useState } from 'react';\n\nexport interface UseTableKeyboardNavProps {\n maxRows: number;\n maxColumns: number;\n\n /**\n * Function used to modify the active table cell based on the keyboard event,\n * the current position, and the default recommended next position (this value\n * will be `undefined` in cases where there is no default handler like `PageUp`\n * and `PageDown`). This can be used to modify the next position that will be\n * used and/or to handle side effects related to the new position (e.g.\n * pagination, scrolling the active cell into view).\n */\n onActiveCellChange?: (\n e: React.KeyboardEvent<HTMLTableElement>,\n currentActiveCell: TableCellPosition,\n defaultNextActiveCell: TableCellPosition | undefined,\n ) => TableCellPosition | undefined;\n}\n\ntype TableCellPosition = {\n row: number;\n column: number;\n};\n\nconst DEFAULT_ACTIVE_CELL: TableCellPosition = {\n row: 0,\n column: 0,\n};\n\nconst ARROW_KEYS = ['ArrowRight', 'ArrowLeft', 'ArrowUp', 'ArrowDown'];\n\nfunction isArrowKey(key: string): boolean {\n return ARROW_KEYS.includes(key);\n}\n\n/**\n * Hook for managing keyboard navigation for table components. It is intended\n * to be wrapped by implementation-specific tables to account for differences\n * like pagination, infinite scroll, and virtualization. See `useVirtualizedKeyboardNav`\n * for an example.\n */\nexport function useTableKeyboardNav({ maxRows, maxColumns, onActiveCellChange }: UseTableKeyboardNavProps): {\n activeCell: TableCellPosition;\n isActive: boolean;\n onTableKeyDown: KeyboardEventHandler<HTMLTableElement>;\n onCellFocus: (cellPosition: TableCellPosition) => void;\n onTableBlur: FocusEventHandler<HTMLTableElement>;\n} {\n const [activeCell, setActiveCell] = useState<TableCellPosition>(DEFAULT_ACTIVE_CELL);\n const [isActive, setIsActive] = useState(false);\n\n const handleCellFocus = (cellPosition: TableCellPosition): void => {\n if (cellPosition.column === activeCell.column && cellPosition.row === activeCell.row && isActive) {\n return;\n }\n setIsActive(true);\n setActiveCell(cellPosition);\n };\n\n const handleKeyDown: React.KeyboardEventHandler<HTMLTableElement> = useCallback(\n (e) => {\n // Including some of the basic a11y keyboard interaction patterns from:\n // https://www.w3.org/WAI/ARIA/apg/patterns/grid/\n // TODO: add other keyboard combos.\n const key = e.key;\n\n if (isArrowKey(key) || key === 'Home' || key === 'End' || key === 'PageDown' || key === 'PageUp') {\n setActiveCell((curActiveCell) => {\n let nextRow: number = curActiveCell.row;\n let nextColumn: number = curActiveCell.column;\n\n if (key === 'ArrowRight' && nextColumn < maxColumns - 1) {\n e.preventDefault();\n nextColumn += 1;\n } else if (key === 'ArrowLeft' && nextColumn > 0) {\n e.preventDefault();\n nextColumn -= 1;\n } else if (key === 'ArrowDown' && nextRow < maxRows - 1) {\n e.preventDefault();\n nextRow += 1;\n } else if (key === 'ArrowUp' && nextRow > 0) {\n e.preventDefault();\n nextRow -= 1;\n } else if (key === 'Home') {\n e.preventDefault();\n nextRow = 0;\n nextColumn = 0;\n } else if (key === 'End') {\n e.preventDefault();\n nextRow = maxRows - 1;\n nextColumn = maxColumns - 1;\n }\n\n const defaultNewPosition = { column: nextColumn, row: nextRow };\n\n const newPosition = onActiveCellChange?.(e, curActiveCell, defaultNewPosition) || defaultNewPosition;\n\n if (newPosition.row === curActiveCell.row && newPosition.column === curActiveCell.column) {\n // Return original to avoid creating a new object if nothing\n // changed.\n return curActiveCell;\n }\n\n return newPosition;\n });\n }\n },\n [maxColumns, maxRows, onActiveCellChange],\n );\n\n const handleTableBlur: FocusEventHandler<HTMLTableElement> = useCallback((e) => {\n if (!e.currentTarget.contains(e.relatedTarget as Node)) {\n setIsActive(false);\n setActiveCell(DEFAULT_ACTIVE_CELL);\n }\n }, []);\n\n return {\n activeCell,\n isActive,\n onTableKeyDown: handleKeyDown,\n onCellFocus: handleCellFocus,\n onTableBlur: handleTableBlur,\n };\n}\n"],"names":["useCallback","useState","DEFAULT_ACTIVE_CELL","row","column","ARROW_KEYS","isArrowKey","key","includes","useTableKeyboardNav","maxRows","maxColumns","onActiveCellChange","activeCell","setActiveCell","isActive","setIsActive","handleCellFocus","cellPosition","handleKeyDown","e","curActiveCell","nextRow","nextColumn","preventDefault","defaultNewPosition","newPosition","handleTableBlur","currentTarget","contains","relatedTarget","onTableKeyDown","onCellFocus","onTableBlur"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAAkDA,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AA0BvF,MAAMC,sBAAyC;IAC7CC,KAAK;IACLC,QAAQ;AACV;AAEA,MAAMC,aAAa;IAAC;IAAc;IAAa;IAAW;CAAY;AAEtE,SAASC,WAAWC,GAAW;IAC7B,OAAOF,WAAWG,QAAQ,CAACD;AAC7B;AAEA;;;;;CAKC,GACD,OAAO,SAASE,oBAAoB,EAAEC,OAAO,EAAEC,UAAU,EAAEC,kBAAkB,EAA4B;IAOvG,MAAM,CAACC,YAAYC,cAAc,GAAGb,SAA4BC;IAChE,MAAM,CAACa,UAAUC,YAAY,GAAGf,SAAS;IAEzC,MAAMgB,kBAAkB,CAACC;QACvB,IAAIA,aAAad,MAAM,KAAKS,WAAWT,MAAM,IAAIc,aAAaf,GAAG,KAAKU,WAAWV,GAAG,IAAIY,UAAU;YAChG;QACF;QACAC,YAAY;QACZF,cAAcI;IAChB;IAEA,MAAMC,gBAA8DnB,YAClE,CAACoB;QACC,uEAAuE;QACvE,iDAAiD;QAC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Z;QAChB;IACF,GAAG,EAAE;IAEL,OAAO;QACLW;QACAE;QACAgB,gBAAgBZ;QAChBa,aAAaf;QACbgB,aAAaN;IACf;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TableVirtuosoHandle } from 'react-virtuoso';
|
|
2
1
|
import { FocusEventHandler, KeyboardEventHandler, MutableRefObject, RefObject } from 'react';
|
|
2
|
+
import { TableVirtuosoHandle } from 'react-virtuoso';
|
|
3
3
|
import { UseTableKeyboardNavProps } from './useTableKeyboardNav';
|
|
4
4
|
interface UseVirtualizedTableKeyboardNavProps extends Omit<UseTableKeyboardNavProps, 'onActiveCellChange'> {
|
|
5
5
|
visibleRange: MutableRefObject<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useVirtualizedTableKeyboardNav.d.ts","sourceRoot":"","sources":["../../../src/Table/hooks/useVirtualizedTableKeyboardNav.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useVirtualizedTableKeyboardNav.d.ts","sourceRoot":"","sources":["../../../src/Table/hooks/useVirtualizedTableKeyboardNav.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAuB,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEtF,UAAU,mCAAoC,SAAQ,IAAI,CAAC,wBAAwB,EAAE,oBAAoB,CAAC;IACxG,YAAY,EAAE,gBAAgB,CAAC;QAC7B,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC,CAAC;IACH,YAAY,EAAE,SAAS,CAAC,mBAAmB,CAAC,CAAC;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,KAAK,iBAAiB,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,EAC7C,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,UAAU,GACX,EAAE,mCAAmC,GAAG;IACvC,UAAU,EAAE,iBAAiB,CAAC;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;IACvD,WAAW,EAAE,CAAC,YAAY,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACvD,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;CAClD,CA4EA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Table/hooks/useVirtualizedTableKeyboardNav.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/Table/hooks/useVirtualizedTableKeyboardNav.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FocusEventHandler, KeyboardEventHandler, MutableRefObject, RefObject } from 'react';\nimport { TableVirtuosoHandle } from 'react-virtuoso';\n\nimport { useTableKeyboardNav, UseTableKeyboardNavProps } from './useTableKeyboardNav';\n\ninterface UseVirtualizedTableKeyboardNavProps extends Omit<UseTableKeyboardNavProps, 'onActiveCellChange'> {\n visibleRange: MutableRefObject<{\n startIndex: number;\n endIndex: number;\n }>;\n virtualTable: RefObject<TableVirtuosoHandle>;\n maxRows: number;\n maxColumns: number;\n}\n\ntype TableCellPosition = {\n row: number;\n column: number;\n};\n\n/**\n * Hook for managing keyboard navigation when using a virtualized table.\n */\nexport function useVirtualizedTableKeyboardNav({\n visibleRange,\n virtualTable,\n maxRows,\n maxColumns,\n}: UseVirtualizedTableKeyboardNavProps): {\n activeCell: TableCellPosition;\n isActive: boolean;\n onTableKeyDown: KeyboardEventHandler<HTMLTableElement>;\n onCellFocus: (cellPosition: TableCellPosition) => void;\n onTableBlur: FocusEventHandler<HTMLTableElement>;\n} {\n const baseKeyboard = useTableKeyboardNav({\n maxRows,\n maxColumns,\n onActiveCellChange: (e, currentPosition, defaultNewPosition) => {\n const key = e.key;\n\n const defaultValueChanged =\n defaultNewPosition &&\n (currentPosition.column !== defaultNewPosition.column || currentPosition.row !== defaultNewPosition.row);\n const nextRow = defaultNewPosition?.row ?? currentPosition.row;\n\n if (key === 'ArrowDown' && defaultValueChanged) {\n // Use default cell position. Shift the virtual table scroll position\n // when needed to make the active cell visible.\n if (nextRow - 1 < visibleRange.current.startIndex || nextRow - 1 > visibleRange.current.endIndex) {\n virtualTable.current?.scrollToIndex({\n index: nextRow - 1,\n align: 'end',\n });\n }\n } else if (key === 'ArrowUp' && defaultValueChanged) {\n // Use default cell position. Shift the virtual table scroll position\n // when needed to make the active cell visible.\n if (nextRow - 1 < visibleRange.current.startIndex || nextRow - 1 > visibleRange.current.endIndex) {\n virtualTable.current?.scrollToIndex({\n index: nextRow - 1,\n align: 'start',\n });\n }\n } else if (defaultValueChanged && (key === 'Home' || key === 'End')) {\n // Use default cell position. Shift the virtual table scroll position\n // when needed to make the active cell visible.\n virtualTable.current?.scrollToIndex({\n index: Math.max(nextRow - 1, 0),\n align: 'start',\n });\n } else if (key === 'PageDown') {\n // Full handling of logic for `PageDown` because there is no default.\n e.preventDefault();\n\n let nextRow = currentPosition.row;\n // Add 1 to account for header\n\n nextRow = Math.min(maxRows - 1, visibleRange.current.endIndex + 1);\n\n virtualTable.current?.scrollToIndex({\n index: nextRow - 1,\n align: 'start',\n });\n\n return {\n row: nextRow,\n column: currentPosition.column,\n };\n } else if (key === 'PageUp') {\n // Full handling of logic for `PageUp` because there is no default.\n let nextRow = currentPosition.row;\n // Minus 1 to account for header\n nextRow = Math.max(0, visibleRange.current.startIndex - 1);\n virtualTable.current?.scrollToIndex({\n index: nextRow - 1,\n align: 'end',\n });\n\n return {\n row: nextRow,\n column: currentPosition.column,\n };\n }\n\n return defaultNewPosition;\n },\n });\n\n return baseKeyboard;\n}\n"],"names":["useTableKeyboardNav","useVirtualizedTableKeyboardNav","visibleRange","virtualTable","maxRows","maxColumns","baseKeyboard","onActiveCellChange","e","currentPosition","defaultNewPosition","key","defaultValueChanged","column","row","nextRow","current","startIndex","endIndex","scrollToIndex","index","align","Math","max","preventDefault","min"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAKjC,SAASA,mBAAmB,QAAkC,wBAAwB;AAiBtF;;CAEC,GACD,OAAO,SAASC,+BAA+B,EAC7CC,YAAY,EACZC,YAAY,EACZC,OAAO,EACPC,UAAU,EAC0B;IAOpC,MAAMC,eAAeN,oBAAoB;QACvCI;QACAC;QACAE,oBAAoB,CAACC,GAAGC,iBAAiBC;YACvC,MAAMC,MAAMH,EAAEG,GAAG;YAEjB,MAAMC,sBACJF,sBACCD,CAAAA,gBAAgBI,MAAM,KAAKH,mBAAmBG,M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;gBACnE,IAAII,UAAUN,gBAAgBK,GAAG;gBACjC,gCAAgC;gBAChCC,UAAUO,KAAKC,GAAG,CAAC,GAAGrB,aAAac,OAAO,CAACC,UAAU,GAAG;gBACxDd,aAAaa,OAAO,EAAEG,cAAc;oBAClCC,OAAOL,UAAU;oBACjBM,OAAO;gBACT;gBAEA,OAAO;oBACLP,KAAKC;oBACLF,QAAQJ,gBAAgBI,MAAM;gBAChC;YACF;YAEA,OAAOH;QACT;IACF;IAEA,OAAOJ;AACT"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Theme } from '@mui/material';
|
|
2
2
|
import { Link } from '@perses-dev/spec';
|
|
3
|
+
import { rankings } from '@tanstack/match-sorter-utils';
|
|
3
4
|
import { AccessorKeyColumnDef, CellContext, ColumnDef, CoreOptions, FilterFn, PaginationState, RowData, RowSelectionState, SortingState } from '@tanstack/react-table';
|
|
4
5
|
import { ReactNode } from 'react';
|
|
5
|
-
import { rankings } from '@tanstack/match-sorter-utils';
|
|
6
6
|
export declare const DEFAULT_COLUMN_WIDTH = 150;
|
|
7
7
|
export declare const DEFAULT_COLUMN_MIN_WIDTH = 60;
|
|
8
8
|
export declare const DEFAULT_COLUMN_MAX_WIDTH = 1000;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-model.d.ts","sourceRoot":"","sources":["../../../src/Table/model/table-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,SAAS,EACT,WAAW,EACX,QAAQ,EACR,eAAe,EACf,OAAO,EACP,iBAAiB,EACjB,YAAY,EACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"table-model.d.ts","sourceRoot":"","sources":["../../../src/Table/model/table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H,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAE3B;;;;;;;OAOG;IAGH,eAAe,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,WAAW,CAAC,SAAS,EAAE,GAAG,CAAC,KAAK,MAAM,CAAC,GAAG,OAAO,GAAG,SAAS,CAAC;IAEzF;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAI3B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAExB;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,SAAS,EACtD,OAAO,EAAE,KAAK,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,EAC5C,mBAAmB,CAAC,EAAE,mBAAmB,GACxC,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAiC7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Table/model/table-model.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Theme } from '@mui/material';\nimport { Link } from '@perses-dev/spec';\nimport {\n AccessorKeyColumnDef,\n CellContext,\n ColumnDef,\n CoreOptions,\n FilterFn,\n PaginationState,\n RowData,\n RowSelectionState,\n SortingState,\n} from '@tanstack/react-table';\nimport { CSSProperties, ReactNode } from 'react';\nimport { rankings } from '@tanstack/match-sorter-utils';\n\nexport const DEFAULT_COLUMN_WIDTH = 150;\nexport const DEFAULT_COLUMN_MIN_WIDTH = 60;\nexport const DEFAULT_COLUMN_MAX_WIDTH = 1000;\nexport const DEFAULT_COLUMN_HEIGHT = 40;\n\nexport type TableDensity = 'compact' | 'standard' | 'comfortable';\nexport type SortDirection = 'asc' | 'desc' | undefined;\n\nexport type TableRowEventOpts = {\n /**\n * Unique identifier for the row.\n */\n id: string;\n\n /**\n * Index of the row in the original data.\n */\n index: number;\n};\n\nexport interface TableProps<TableData> {\n /**\n * Height of the table.\n */\n height: number;\n\n /**\n * Width of the table.\n */\n width: number | string;\n\n /**\n * Array of data to render in the table. Each entry in the array will be\n * rendered as a row in the table.\n */\n data: TableData[];\n\n /**\n * Array of column configuration for the table. Each entry in the array will\n * be rendered as a column header and impact the rendering of cells within\n * table rows.\n */\n columns: Array<TableColumnConfig<TableData>>;\n\n /**\n * Custom render cell configurations. Each entry of the object should be an\n * id for cell `${rowIndex}_${columnIndex}`, can apply custom text, text color\n * and background color.\n */\n cellConfigs?: TableCellConfigs;\n\n /**\n * The density of the table layout. This impacts the size and space taken up\n * by content in the table (e.g. font size, padding).\n */\n density?: TableDensity;\n\n /**\n * When using \"auto\", the table will try to automatically adjust the width of columns to fit without overflowing.\n * If there is not enough width for each column, the display can unreadable.\n */\n defaultColumnWidth?: 'auto' | number;\n\n /**\n * When using \"auto\", the table will calculate the cell height based on the line height of the theme and the density setting of the table.\n */\n defaultColumnHeight?: 'auto' | number;\n\n /**\n * When `true`, the first column of the table will include checkboxes.\n */\n checkboxSelection?: boolean;\n\n /**\n * Determines the behavior of row selection.\n *\n * - `standard`: clicking a checkbox will toggle that rows's selected/unselected\n * state and will not impact other rows.\n * - `legend`: clicking a checkbox will \"focus\" that row by selecting it and\n * unselecting other rows. Clicking a checkbox with a modifier key pressed,\n * will change this behavior to behave like `standard`.\n *\n * @default 'standard'\n */\n rowSelectionVariant?: 'standard' | 'legend';\n\n /**\n * State of selected rows in the table when `checkboxSelection` is enabled.\n *\n * Selected row state is a controlled value that should be managed using a\n * combination of this prop and `onRowSelectionChange`.\n */\n rowSelection?: RowSelectionState;\n\n /**\n * Callback fired when the mouse is moved over a table row.\n */\n onRowMouseOver?: (e: React.MouseEvent, opts: TableRowEventOpts) => void;\n\n /**\n * Callback fired when the mouse is moved out of a table row.\n */\n onRowMouseOut?: (e: React.MouseEvent, opts: TableRowEventOpts) => void;\n\n /**\n * State of the column sorting in the table.\n *\n * The column sorting is a controlled value that should be managed using a\n * combination fo this prop and `onSortingChange`.\n */\n sorting?: SortingState;\n\n /**\n * Callback fired when the selected rows in the table changes.\n */\n onRowSelectionChange?: (rowSelection: RowSelectionState) => void;\n\n /**\n * Callback fired when the table sorting changes.\n */\n onSortingChange?: (sorting: SortingState) => void;\n\n /**\n * State of the pagination in the table.\n * Default: undefined, i.e. pagination is disabled.\n */\n pagination?: PaginationState;\n\n /**\n * Callback fired when the table pagination changes.\n */\n onPaginationChange?: (pagination: PaginationState) => void;\n\n /**\n * Function used to determine the unique identifier used for each row. This\n * value is used to key `rowSelection`. If this value is not set, the index\n * is used as the unique identifier.\n */\n getRowId?: CoreOptions<TableData>['getRowId'];\n\n /**\n * Function used to determine the color of the checkbox when `checkboxSelection`\n * is enabled. If not set, a default color is used.\n */\n getCheckboxColor?: (rowData: TableData) => string;\n\n /**\n * Item actions to render for each row.\n */\n getItemActions?: ({ id, data }: { id: string; data: unknown }) => ReactNode[];\n\n /**\n * Item actions should be created\n */\n hasItemActions?: boolean;\n\n /**\n * Returns the sub rows for a given row, or `undefined` if there are none.\n */\n getSubRows?: (originalRow: TableData, index: number) => undefined | TableData[];\n\n /**\n * List of column ids that should be hidden when the table is initially rendered.\n */\n hiddenColumns?: string[];\n\n /**\n * Configuration for the table toolbar at the top of table, which includes the search input and column filter button.\n * If not provided, the toolbar will not be rendered.\n */\n tableToolbarConfig?: TableToolbarConfig;\n\n /**\n * Determines when column resizing updates the column width.\n * When set to `onChange`, the column width will update as the user drags the resize handle.\n * When set to `onEnd`, the column width will only update when the user releases the resize handle.\n * @default 'onChange'\n */\n columnResizeMode?: 'onChange' | 'onEnd';\n\n /**\n * Default configuration applied to all columns in the table. Individual\n * column configurations can override these values. Useful for setting\n * consistent constraints (e.g. min/max width) or enabling resizing across\n * all columns without repeating the configuration per column.\n */\n defaultColumnConfig?: DefaultColumnConfig;\n}\n\nexport interface DefaultColumnConfig {\n /**\n * Minimum width of a column in pixels.\n * @default 60\n */\n minWidth?: number;\n\n /**\n * Maximum width of a column in pixels.\n * @default 1000\n */\n maxWidth?: number;\n\n /**\n * When `true`, columns will be resizable by dragging the column header border.\n * @default false\n */\n enableResizing?: boolean;\n}\n\nexport type FuzzyMatchThreshold = keyof typeof rankings;\n\nexport type TableToolbarConfig = {\n /**\n * When `true`, a search bar will be rendered above the table that allows\n * the user to filter rows using a fuzzy global filter.\n */\n isSearchEnabled?: boolean;\n\n /**\n * When `isSearchEnabled` is `true`, this determines how fuzzy the matching should be when filtering results.\n * @default 'CONTAINS'\n */\n fuzzyMatchThreshold?: FuzzyMatchThreshold;\n\n /**\n * When `true`, a \"Columns\" button will be rendered above the table that\n * opens a dropdown allowing the user to toggle column visibility.\n */\n isColumnFilterEnabled?: boolean;\n\n /**\n * Max height for the column filter menu.\n */\n columnFilterMenuMaxHeight?: number | string;\n};\n\nfunction calculateTableCellHeight(lineHeight: CSSProperties['lineHeight'], paddingY: string): number {\n // Doing a bunch of math to enforce height to avoid weirdness with mismatched\n // heights based on customization of cell contents.\n const lineHeightNum = typeof lineHeight === 'string' ? parseInt(lineHeight, 10) : (lineHeight ?? 0);\n const verticalPaddingNum = typeof paddingY === 'string' ? parseInt(paddingY, 10) : paddingY;\n\n return lineHeightNum + verticalPaddingNum * 2;\n}\n\ntype TableCellLayout = NonNullable<Pick<React.CSSProperties, 'padding' | 'fontSize' | 'lineHeight'>> & {\n height: number;\n};\n\ntype GetTableCellLayoutOpts = {\n isHeader?: boolean;\n isLastColumn?: boolean;\n isFirstColumn?: boolean;\n defaultColumnHeight?: 'auto' | number;\n};\n\n/**\n * Returns the properties to lay out the content of table cells based on the\n * theme and density.\n */\nexport function getTableCellLayout(\n theme: Theme,\n density: TableDensity,\n { isHeader, isLastColumn, isFirstColumn, defaultColumnHeight }: GetTableCellLayoutOpts = {}\n): TableCellLayout {\n // Density Standard\n let paddingY = theme.spacing(1);\n let basePaddingX = theme.spacing(1.25);\n let edgePaddingX = theme.spacing(2);\n let paddingLeft = isFirstColumn ? edgePaddingX : basePaddingX;\n let paddingRight = isLastColumn ? edgePaddingX : basePaddingX;\n let lineHeight = theme.typography.body1.lineHeight;\n let fontSize = theme.typography.body1.fontSize;\n\n if (density === 'compact') {\n paddingY = theme.spacing(0.5);\n basePaddingX = theme.spacing(0.5);\n edgePaddingX = theme.spacing(1);\n paddingLeft = isFirstColumn ? edgePaddingX : basePaddingX;\n paddingRight = isLastColumn ? edgePaddingX : basePaddingX;\n lineHeight = theme.typography.body2.lineHeight;\n fontSize = theme.typography.body2.fontSize;\n }\n\n if (density === 'comfortable') {\n paddingY = theme.spacing(2);\n basePaddingX = theme.spacing(1.5);\n edgePaddingX = theme.spacing(2);\n paddingLeft = isFirstColumn ? edgePaddingX : basePaddingX;\n paddingRight = isLastColumn ? edgePaddingX : basePaddingX;\n lineHeight = theme.typography.body1.lineHeight;\n fontSize = theme.typography.body1.fontSize;\n }\n\n const height =\n isHeader || !defaultColumnHeight || defaultColumnHeight === 'auto'\n ? calculateTableCellHeight(lineHeight, paddingY)\n : defaultColumnHeight;\n\n return {\n padding: `${paddingY} ${paddingRight} ${paddingY} ${paddingLeft}`,\n height: height,\n fontSize: fontSize,\n lineHeight: lineHeight,\n };\n}\n\nexport type TableCellAlignment = 'left' | 'right' | 'center';\n\nexport interface TableCellConfigs {\n [id: string]: TableCellConfig;\n}\n\nexport interface TableCellConfig {\n text?: string;\n textColor?: string;\n backgroundColor?: string;\n}\n\n// Overrides of meta value, so it can have a meaningful type in our code instead\n// of `any`. Putting this in the model instead of a separate .d.ts file because\n// I couldn't get it to work properly that way and punted on figuring it out\n// after trying several things.\ndeclare module '@tanstack/table-core' {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: TableColumnConfig<TData>['align'];\n headerDescription?: TableColumnConfig<TData>['headerDescription'];\n cellDescription?: TableColumnConfig<TData>['cellDescription'];\n dataLink?: TableColumnConfig<TData>['dataLink'];\n }\n}\n\ndeclare module '@tanstack/react-table' {\n //add fuzzy filter to the filterFns. Allows us to use \"fuzzy\" as a value for `globalFilterFn` in our table options.\n interface FilterFns {\n fuzzy: FilterFn<unknown>;\n }\n}\n\n// Column link settings\n// The URL could be set to a static link or could be constructed dynamically\n// The URL may include reference to the variables or neighboring cells in the row\nexport type DataLink = Omit<Link, 'name'>;\n\n// Only exposing a very simplified version of the very extensive column definitions\n// possible with tanstack table to make it easier for us to control rendering\n// and functionality.\nexport interface TableColumnConfig<TableData>\n // Any needed to work around some typing issues with tanstack query.\n // https://github.com/TanStack/table/issues/4241\n // TODO: revisit issue thread and see if there are any workarounds we can\n // use.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n extends Pick<AccessorKeyColumnDef<TableData, any>, 'accessorKey' | 'cell' | 'sortingFn' | 'id' | 'enableResizing'> {\n /**\n * Text to display in the header for the column.\n */\n header: string;\n\n /**\n * Alignment of the content in the cell.\n */\n align?: TableCellAlignment;\n\n /**\n * Text to display when hovering over a cell. This can be useful for\n * providing additional information about the column when the content is\n * ellipsized to fit in the space.\n *\n * If set to `true`, it will use the value generated by the `cell` prop if it\n * can be treated as a string.\n */\n // `any` needed for same reason as no-explicit-any higher up in this type.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n cellDescription?: ((props: CellContext<TableData, any>) => string) | boolean | undefined;\n\n /**\n * When `true`, the column will be sortable.\n * @default false\n */\n enableSorting?: boolean;\n\n /**\n * Text to display when hovering over the header text. This can be useful for\n * providing additional information about the column when you want to keep the\n * header text relatively short to manage the column width.\n */\n headerDescription?: string;\n\n // Tanstack Table does not support an \"auto\" value to naturally size to fit\n // the space in a table. Adding a custom setting to manage this ourselves.\n /**\n * Width of the column when rendered in a table. It should be a number in pixels\n * or \"auto\" to allow the table to automatically adjust the width to fill\n * space.\n * @default 'auto'\n */\n width?: number | 'auto';\n\n /**\n * Dynamic link setting. If available the the cell content should turn into\n * a link with the value of the cell as the dynamic section\n */\n dataLink?: DataLink;\n}\n\n/**\n * Takes in a perses table column and transforms it into a tanstack column.\n */\nexport function persesColumnsToTanstackColumns<TableData>(\n columns: Array<TableColumnConfig<TableData>>,\n defaultColumnConfig?: DefaultColumnConfig\n): Array<ColumnDef<TableData>> {\n return columns.map(\n ({ width, align, headerDescription, cellDescription, enableSorting, dataLink, enableResizing, ...otherProps }) => {\n const isResizingEnabled = enableResizing ?? defaultColumnConfig?.enableResizing ?? false;\n const sizeProps =\n width === 'auto' || width === undefined\n ? getDefaultSizeProps(isResizingEnabled, defaultColumnConfig?.minWidth, defaultColumnConfig?.maxWidth)\n : getUserProvidedSizeProps(\n isResizingEnabled,\n width,\n defaultColumnConfig?.minWidth,\n defaultColumnConfig?.maxWidth\n );\n\n return {\n ...otherProps,\n ...sizeProps,\n\n // Default sorting to false, so it is very explicitly set per column.\n enableSorting: !!enableSorting,\n enableResizing: isResizingEnabled,\n\n // Open-ended store for extra metadata in TanStack Table, so you can bake\n // in your own features.\n meta: {\n align,\n headerDescription,\n cellDescription,\n dataLink,\n },\n };\n }\n );\n}\n\nfunction getUserProvidedSizeProps<TableData>(\n isResizingEnabled: boolean,\n width: number,\n minWidth?: number,\n maxWidth?: number\n): Pick<ColumnDef<TableData>, 'size' | 'minSize' | 'maxSize'> {\n // When resizing is enabled, we need to set min and max size to ensure the column can be resized within a reasonable range.\n return isResizingEnabled\n ? {\n size: width,\n minSize: minWidth ?? DEFAULT_COLUMN_MIN_WIDTH,\n maxSize: maxWidth ?? DEFAULT_COLUMN_MAX_WIDTH,\n }\n : {\n size: width,\n };\n}\n\nfunction getDefaultSizeProps<TableData>(\n isResizingEnabled: boolean,\n minWidth?: number,\n maxWidth?: number\n): Pick<ColumnDef<TableData>, 'size' | 'minSize' | 'maxSize'> {\n return isResizingEnabled\n ? {\n // When resizing is enabled, we need to set a default size for the column\n // so that relative value can be calculated when resizing and column is visible.\n size: DEFAULT_COLUMN_WIDTH,\n minSize: minWidth ?? DEFAULT_COLUMN_MIN_WIDTH,\n maxSize: maxWidth ?? DEFAULT_COLUMN_MAX_WIDTH,\n }\n : // Tanstack Table does not support an \"auto\" value to naturally size to fit\n // the space in a table. We translate our custom \"auto\" setting to 0 size\n // for these columns, so it is easy to fall back to auto when rendering.\n // Taking from a recommendation in this github discussion:\n // https://github.com/TanStack/table/discussions/4179#discussioncomment-3631326\n {\n // All zero values are used as shorthand for \"auto\" when rendering\n // because it makes it easy to fall back. (e.g. `row.size || \"auto\"`)\n size: 0,\n minSize: 0,\n maxSize: 0,\n };\n}\n"],"names":["DEFAULT_COLUMN_WIDTH","DEFAULT_COLUMN_MIN_WIDTH","DEFAULT_COLUMN_MAX_WIDTH","DEFAULT_COLUMN_HEIGHT","calculateTableCellHeight","lineHeight","paddingY","lineHeightNum","parseInt","verticalPaddingNum","getTableCellLayout","theme","density","isHeader","isLastColumn","isFirstColumn","defaultColumnHeight","spacing","basePaddingX","edgePaddingX","paddingLeft","paddingRight","typography","body1","fontSize","body2","height","padding","persesColumnsToTanstackColumns","columns","defaultColumnConfig","map","width","align","headerDescription","cellDescription","enableSorting","dataLink","enableResizing","otherProps","isResizingEnabled","sizeProps","undefined","getDefaultSizeProps","minWidth","maxWidth","getUserProvidedSizeProps","meta","size","minSize","maxSize"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAkBjC,OAAO,MA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ASL,YAAY3C;IACvB,IACA;QACE8C,MAAMhB;IACR;AACN;AAEA,SAASW,oBACPH,iBAA0B,EAC1BI,QAAiB,EACjBC,QAAiB;IAEjB,OAAOL,oBACH;QACE,yEAAyE;QACzE,gFAAgF;QAChFQ,MAAMhD;QACNiD,SAASL,YAAY3C;QACrBiD,SAASL,YAAY3C;IACvB,IAEA,yEAAyE;IACzE,wEAAwE;IACxE,0DAA0D;IAC1D,+EAA+E;IAC/E;QACE,kEAAkE;QAClE,qEAAqE;QACrE8C,MAAM;QACNC,SAAS;QACTC,SAAS;IACX;AACN"}
|
|
1
|
+
{"version":3,"sources":["../../../src/Table/model/table-model.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Theme } from '@mui/material';\nimport { Link } from '@perses-dev/spec';\nimport { rankings } from '@tanstack/match-sorter-utils';\nimport {\n AccessorKeyColumnDef,\n CellContext,\n ColumnDef,\n CoreOptions,\n FilterFn,\n PaginationState,\n RowData,\n RowSelectionState,\n SortingState,\n} from '@tanstack/react-table';\nimport { CSSProperties, ReactNode } from 'react';\n\nexport const DEFAULT_COLUMN_WIDTH = 150;\nexport const DEFAULT_COLUMN_MIN_WIDTH = 60;\nexport const DEFAULT_COLUMN_MAX_WIDTH = 1000;\nexport const DEFAULT_COLUMN_HEIGHT = 40;\n\nexport type TableDensity = 'compact' | 'standard' | 'comfortable';\nexport type SortDirection = 'asc' | 'desc' | undefined;\n\nexport type TableRowEventOpts = {\n /**\n * Unique identifier for the row.\n */\n id: string;\n\n /**\n * Index of the row in the original data.\n */\n index: number;\n};\n\nexport interface TableProps<TableData> {\n /**\n * Height of the table.\n */\n height: number;\n\n /**\n * Width of the table.\n */\n width: number | string;\n\n /**\n * Array of data to render in the table. Each entry in the array will be\n * rendered as a row in the table.\n */\n data: TableData[];\n\n /**\n * Array of column configuration for the table. Each entry in the array will\n * be rendered as a column header and impact the rendering of cells within\n * table rows.\n */\n columns: Array<TableColumnConfig<TableData>>;\n\n /**\n * Custom render cell configurations. Each entry of the object should be an\n * id for cell `${rowIndex}_${columnIndex}`, can apply custom text, text color\n * and background color.\n */\n cellConfigs?: TableCellConfigs;\n\n /**\n * The density of the table layout. This impacts the size and space taken up\n * by content in the table (e.g. font size, padding).\n */\n density?: TableDensity;\n\n /**\n * When using \"auto\", the table will try to automatically adjust the width of columns to fit without overflowing.\n * If there is not enough width for each column, the display can unreadable.\n */\n defaultColumnWidth?: 'auto' | number;\n\n /**\n * When using \"auto\", the table will calculate the cell height based on the line height of the theme and the density setting of the table.\n */\n defaultColumnHeight?: 'auto' | number;\n\n /**\n * When `true`, the first column of the table will include checkboxes.\n */\n checkboxSelection?: boolean;\n\n /**\n * Determines the behavior of row selection.\n *\n * - `standard`: clicking a checkbox will toggle that rows's selected/unselected\n * state and will not impact other rows.\n * - `legend`: clicking a checkbox will \"focus\" that row by selecting it and\n * unselecting other rows. Clicking a checkbox with a modifier key pressed,\n * will change this behavior to behave like `standard`.\n *\n * @default 'standard'\n */\n rowSelectionVariant?: 'standard' | 'legend';\n\n /**\n * State of selected rows in the table when `checkboxSelection` is enabled.\n *\n * Selected row state is a controlled value that should be managed using a\n * combination of this prop and `onRowSelectionChange`.\n */\n rowSelection?: RowSelectionState;\n\n /**\n * Callback fired when the mouse is moved over a table row.\n */\n onRowMouseOver?: (e: React.MouseEvent, opts: TableRowEventOpts) => void;\n\n /**\n * Callback fired when the mouse is moved out of a table row.\n */\n onRowMouseOut?: (e: React.MouseEvent, opts: TableRowEventOpts) => void;\n\n /**\n * State of the column sorting in the table.\n *\n * The column sorting is a controlled value that should be managed using a\n * combination fo this prop and `onSortingChange`.\n */\n sorting?: SortingState;\n\n /**\n * Callback fired when the selected rows in the table changes.\n */\n onRowSelectionChange?: (rowSelection: RowSelectionState) => void;\n\n /**\n * Callback fired when the table sorting changes.\n */\n onSortingChange?: (sorting: SortingState) => void;\n\n /**\n * State of the pagination in the table.\n * Default: undefined, i.e. pagination is disabled.\n */\n pagination?: PaginationState;\n\n /**\n * Callback fired when the table pagination changes.\n */\n onPaginationChange?: (pagination: PaginationState) => void;\n\n /**\n * Function used to determine the unique identifier used for each row. This\n * value is used to key `rowSelection`. If this value is not set, the index\n * is used as the unique identifier.\n */\n getRowId?: CoreOptions<TableData>['getRowId'];\n\n /**\n * Function used to determine the color of the checkbox when `checkboxSelection`\n * is enabled. If not set, a default color is used.\n */\n getCheckboxColor?: (rowData: TableData) => string;\n\n /**\n * Item actions to render for each row.\n */\n getItemActions?: ({ id, data }: { id: string; data: unknown }) => ReactNode[];\n\n /**\n * Item actions should be created\n */\n hasItemActions?: boolean;\n\n /**\n * Returns the sub rows for a given row, or `undefined` if there are none.\n */\n getSubRows?: (originalRow: TableData, index: number) => undefined | TableData[];\n\n /**\n * List of column ids that should be hidden when the table is initially rendered.\n */\n hiddenColumns?: string[];\n\n /**\n * Configuration for the table toolbar at the top of table, which includes the search input and column filter button.\n * If not provided, the toolbar will not be rendered.\n */\n tableToolbarConfig?: TableToolbarConfig;\n\n /**\n * Determines when column resizing updates the column width.\n * When set to `onChange`, the column width will update as the user drags the resize handle.\n * When set to `onEnd`, the column width will only update when the user releases the resize handle.\n * @default 'onChange'\n */\n columnResizeMode?: 'onChange' | 'onEnd';\n\n /**\n * Default configuration applied to all columns in the table. Individual\n * column configurations can override these values. Useful for setting\n * consistent constraints (e.g. min/max width) or enabling resizing across\n * all columns without repeating the configuration per column.\n */\n defaultColumnConfig?: DefaultColumnConfig;\n}\n\nexport interface DefaultColumnConfig {\n /**\n * Minimum width of a column in pixels.\n * @default 60\n */\n minWidth?: number;\n\n /**\n * Maximum width of a column in pixels.\n * @default 1000\n */\n maxWidth?: number;\n\n /**\n * When `true`, columns will be resizable by dragging the column header border.\n * @default false\n */\n enableResizing?: boolean;\n}\n\nexport type FuzzyMatchThreshold = keyof typeof rankings;\n\nexport type TableToolbarConfig = {\n /**\n * When `true`, a search bar will be rendered above the table that allows\n * the user to filter rows using a fuzzy global filter.\n */\n isSearchEnabled?: boolean;\n\n /**\n * When `isSearchEnabled` is `true`, this determines how fuzzy the matching should be when filtering results.\n * @default 'CONTAINS'\n */\n fuzzyMatchThreshold?: FuzzyMatchThreshold;\n\n /**\n * When `true`, a \"Columns\" button will be rendered above the table that\n * opens a dropdown allowing the user to toggle column visibility.\n */\n isColumnFilterEnabled?: boolean;\n\n /**\n * Max height for the column filter menu.\n */\n columnFilterMenuMaxHeight?: number | string;\n};\n\nfunction calculateTableCellHeight(lineHeight: CSSProperties['lineHeight'], paddingY: string): number {\n // Doing a bunch of math to enforce height to avoid weirdness with mismatched\n // heights based on customization of cell contents.\n const lineHeightNum = typeof lineHeight === 'string' ? parseInt(lineHeight, 10) : (lineHeight ?? 0);\n const verticalPaddingNum = typeof paddingY === 'string' ? parseInt(paddingY, 10) : paddingY;\n\n return lineHeightNum + verticalPaddingNum * 2;\n}\n\ntype TableCellLayout = NonNullable<Pick<React.CSSProperties, 'padding' | 'fontSize' | 'lineHeight'>> & {\n height: number;\n};\n\ntype GetTableCellLayoutOpts = {\n isHeader?: boolean;\n isLastColumn?: boolean;\n isFirstColumn?: boolean;\n defaultColumnHeight?: 'auto' | number;\n};\n\n/**\n * Returns the properties to lay out the content of table cells based on the\n * theme and density.\n */\nexport function getTableCellLayout(\n theme: Theme,\n density: TableDensity,\n { isHeader, isLastColumn, isFirstColumn, defaultColumnHeight }: GetTableCellLayoutOpts = {},\n): TableCellLayout {\n // Density Standard\n let paddingY = theme.spacing(1);\n let basePaddingX = theme.spacing(1.25);\n let edgePaddingX = theme.spacing(2);\n let paddingLeft = isFirstColumn ? edgePaddingX : basePaddingX;\n let paddingRight = isLastColumn ? edgePaddingX : basePaddingX;\n let lineHeight = theme.typography.body1.lineHeight;\n let fontSize = theme.typography.body1.fontSize;\n\n if (density === 'compact') {\n paddingY = theme.spacing(0.5);\n basePaddingX = theme.spacing(0.5);\n edgePaddingX = theme.spacing(1);\n paddingLeft = isFirstColumn ? edgePaddingX : basePaddingX;\n paddingRight = isLastColumn ? edgePaddingX : basePaddingX;\n lineHeight = theme.typography.body2.lineHeight;\n fontSize = theme.typography.body2.fontSize;\n }\n\n if (density === 'comfortable') {\n paddingY = theme.spacing(2);\n basePaddingX = theme.spacing(1.5);\n edgePaddingX = theme.spacing(2);\n paddingLeft = isFirstColumn ? edgePaddingX : basePaddingX;\n paddingRight = isLastColumn ? edgePaddingX : basePaddingX;\n lineHeight = theme.typography.body1.lineHeight;\n fontSize = theme.typography.body1.fontSize;\n }\n\n const height =\n isHeader || !defaultColumnHeight || defaultColumnHeight === 'auto'\n ? calculateTableCellHeight(lineHeight, paddingY)\n : defaultColumnHeight;\n\n return {\n padding: `${paddingY} ${paddingRight} ${paddingY} ${paddingLeft}`,\n height: height,\n fontSize: fontSize,\n lineHeight: lineHeight,\n };\n}\n\nexport type TableCellAlignment = 'left' | 'right' | 'center';\n\nexport interface TableCellConfigs {\n [id: string]: TableCellConfig;\n}\n\nexport interface TableCellConfig {\n text?: string;\n textColor?: string;\n backgroundColor?: string;\n}\n\n// Overrides of meta value, so it can have a meaningful type in our code instead\n// of `any`. Putting this in the model instead of a separate .d.ts file because\n// I couldn't get it to work properly that way and punted on figuring it out\n// after trying several things.\ndeclare module '@tanstack/table-core' {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: TableColumnConfig<TData>['align'];\n headerDescription?: TableColumnConfig<TData>['headerDescription'];\n cellDescription?: TableColumnConfig<TData>['cellDescription'];\n dataLink?: TableColumnConfig<TData>['dataLink'];\n }\n}\n\ndeclare module '@tanstack/react-table' {\n //add fuzzy filter to the filterFns. Allows us to use \"fuzzy\" as a value for `globalFilterFn` in our table options.\n interface FilterFns {\n fuzzy: FilterFn<unknown>;\n }\n}\n\n// Column link settings\n// The URL could be set to a static link or could be constructed dynamically\n// The URL may include reference to the variables or neighboring cells in the row\nexport type DataLink = Omit<Link, 'name'>;\n\n// Only exposing a very simplified version of the very extensive column definitions\n// possible with tanstack table to make it easier for us to control rendering\n// and functionality.\nexport interface TableColumnConfig<TableData>\n // Any needed to work around some typing issues with tanstack query.\n // https://github.com/TanStack/table/issues/4241\n // TODO: revisit issue thread and see if there are any workarounds we can\n // use.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n extends Pick<AccessorKeyColumnDef<TableData, any>, 'accessorKey' | 'cell' | 'sortingFn' | 'id' | 'enableResizing'> {\n /**\n * Text to display in the header for the column.\n */\n header: string;\n\n /**\n * Alignment of the content in the cell.\n */\n align?: TableCellAlignment;\n\n /**\n * Text to display when hovering over a cell. This can be useful for\n * providing additional information about the column when the content is\n * ellipsized to fit in the space.\n *\n * If set to `true`, it will use the value generated by the `cell` prop if it\n * can be treated as a string.\n */\n // `any` needed for same reason as no-explicit-any higher up in this type.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n cellDescription?: ((props: CellContext<TableData, any>) => string) | boolean | undefined;\n\n /**\n * When `true`, the column will be sortable.\n * @default false\n */\n enableSorting?: boolean;\n\n /**\n * Text to display when hovering over the header text. This can be useful for\n * providing additional information about the column when you want to keep the\n * header text relatively short to manage the column width.\n */\n headerDescription?: string;\n\n // Tanstack Table does not support an \"auto\" value to naturally size to fit\n // the space in a table. Adding a custom setting to manage this ourselves.\n /**\n * Width of the column when rendered in a table. It should be a number in pixels\n * or \"auto\" to allow the table to automatically adjust the width to fill\n * space.\n * @default 'auto'\n */\n width?: number | 'auto';\n\n /**\n * Dynamic link setting. If available the the cell content should turn into\n * a link with the value of the cell as the dynamic section\n */\n dataLink?: DataLink;\n}\n\n/**\n * Takes in a perses table column and transforms it into a tanstack column.\n */\nexport function persesColumnsToTanstackColumns<TableData>(\n columns: Array<TableColumnConfig<TableData>>,\n defaultColumnConfig?: DefaultColumnConfig,\n): Array<ColumnDef<TableData>> {\n return columns.map(\n ({ width, align, headerDescription, cellDescription, enableSorting, dataLink, enableResizing, ...otherProps }) => {\n const isResizingEnabled = enableResizing ?? defaultColumnConfig?.enableResizing ?? false;\n const sizeProps =\n width === 'auto' || width === undefined\n ? getDefaultSizeProps(isResizingEnabled, defaultColumnConfig?.minWidth, defaultColumnConfig?.maxWidth)\n : getUserProvidedSizeProps(\n isResizingEnabled,\n width,\n defaultColumnConfig?.minWidth,\n defaultColumnConfig?.maxWidth,\n );\n\n return {\n ...otherProps,\n ...sizeProps,\n\n // Default sorting to false, so it is very explicitly set per column.\n enableSorting: !!enableSorting,\n enableResizing: isResizingEnabled,\n\n // Open-ended store for extra metadata in TanStack Table, so you can bake\n // in your own features.\n meta: {\n align,\n headerDescription,\n cellDescription,\n dataLink,\n },\n };\n },\n );\n}\n\nfunction getUserProvidedSizeProps<TableData>(\n isResizingEnabled: boolean,\n width: number,\n minWidth?: number,\n maxWidth?: number,\n): Pick<ColumnDef<TableData>, 'size' | 'minSize' | 'maxSize'> {\n // When resizing is enabled, we need to set min and max size to ensure the column can be resized within a reasonable range.\n return isResizingEnabled\n ? {\n size: width,\n minSize: minWidth ?? DEFAULT_COLUMN_MIN_WIDTH,\n maxSize: maxWidth ?? DEFAULT_COLUMN_MAX_WIDTH,\n }\n : {\n size: width,\n };\n}\n\nfunction getDefaultSizeProps<TableData>(\n isResizingEnabled: boolean,\n minWidth?: number,\n maxWidth?: number,\n): Pick<ColumnDef<TableData>, 'size' | 'minSize' | 'maxSize'> {\n return isResizingEnabled\n ? {\n // When resizing is enabled, we need to set a default size for the column\n // so that relative value can be calculated when resizing and column is visible.\n size: DEFAULT_COLUMN_WIDTH,\n minSize: minWidth ?? DEFAULT_COLUMN_MIN_WIDTH,\n maxSize: maxWidth ?? DEFAULT_COLUMN_MAX_WIDTH,\n }\n : // Tanstack Table does not support an \"auto\" value to naturally size to fit\n // the space in a table. We translate our custom \"auto\" setting to 0 size\n // for these columns, so it is easy to fall back to auto when rendering.\n // Taking from a recommendation in this github discussion:\n // https://github.com/TanStack/table/discussions/4179#discussioncomment-3631326\n {\n // All zero values are used as shorthand for \"auto\" when rendering\n // because it makes it easy to fall back. (e.g. `row.size || \"auto\"`)\n size: 0,\n minSize: 0,\n maxSize: 0,\n };\n}\n"],"names":["DEFAULT_COLUMN_WIDTH","DEFAULT_COLUMN_MIN_WIDTH","DEFAULT_COLUMN_MAX_WIDTH","DEFAULT_COLUMN_HEIGHT","calculateTableCellHeight","lineHeight","paddingY","lineHeightNum","parseInt","verticalPaddingNum","getTableCellLayout","theme","density","isHeader","isLastColumn","isFirstColumn","defaultColumnHeight","spacing","basePaddingX","edgePaddingX","paddingLeft","paddingRight","typography","body1","fontSize","body2","height","padding","persesColumnsToTanstackColumns","columns","defaultColumnConfig","map","width","align","headerDescription","cellDescription","enableSorting","dataLink","enableResizing","otherProps","isResizingEnabled","sizeProps","undefined","getDefaultSizeProps","minWidth","maxWidth","getUserProvidedSizeProps","meta","size","minSize","maxSize"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAkBjC,OAAO,MAAMA,uBAAuB,IAAI;AACxC,OAAO,MAAMC,2BAA2B,GAAG;AAC3C,OAAO,MAAMC,2BAA2B,KAAK;AAC7C,OAAO,MAAMC,wBAAwB,GAAG;AAyOxC,SAASC,yBAAyBC,UAAuC,EAAEC,QAAgB;IACzF,6EAA6E;IAC7E,mDAAmD;IACnD,MAAMC,gBAAgB,OAAOF,eAAe,WAAWG,SAASH,YAAY,MAAOA,cAAc;IACjG,MAAMI,qBAAqB,OAAOH,aAAa,WAAWE,SA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AqE;QACrE8C,MAAM;QACNC,SAAS;QACTC,SAAS;IACX;AACN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThresholdInput.d.ts","sourceRoot":"","sources":["../../src/ThresholdsEditor/ThresholdInput.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ThresholdInput.d.ts","sourceRoot":"","sources":["../../src/ThresholdsEditor/ThresholdInput.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAG1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAC3D,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IAC9C,IAAI,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;CACjC;AAED,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,KAAK,EACL,KAAK,EACL,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,aAAa,EACb,MAAM,EACN,QAAQ,GACT,EAAE,mBAAmB,GAAG,YAAY,CA8BpC"}
|
|
@@ -11,9 +11,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import { useState } from 'react';
|
|
15
14
|
import { Stack, FormLabel, TextField, IconButton, Box } from '@mui/material';
|
|
16
15
|
import DeleteIcon from 'mdi-material-ui/DeleteOutline';
|
|
16
|
+
import { useState } from 'react';
|
|
17
17
|
import { OptionsColorPicker } from '../ColorPicker/OptionsColorPicker';
|
|
18
18
|
export function ThresholdInput({ inputRef, label, color, value, mode, onChange, onColorChange, onBlur, onDelete }) {
|
|
19
19
|
const [key, setKey] = useState(0); // use key to cause input to lose focus when pressing enter
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ThresholdsEditor/ThresholdInput.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/ThresholdsEditor/ThresholdInput.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Stack, FormLabel, TextField, IconButton, Box } from '@mui/material';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport { ReactElement, RefObject, useState } from 'react';\n\nimport { OptionsColorPicker } from '../ColorPicker/OptionsColorPicker';\nimport { ThresholdOptions } from '../model';\n\nexport interface ThresholdInputProps {\n label: string;\n color: string;\n value: number;\n onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n onColorChange: (color: string) => void;\n onBlur: () => void;\n onDelete: () => void;\n inputRef?: RefObject<HTMLInputElement | null>;\n mode?: ThresholdOptions['mode'];\n}\n\nexport function ThresholdInput({\n inputRef,\n label,\n color,\n value,\n mode,\n onChange,\n onColorChange,\n onBlur,\n onDelete,\n}: ThresholdInputProps): ReactElement {\n const [key, setKey] = useState(0); // use key to cause input to lose focus when pressing enter\n return (\n <Stack flex={1} direction=\"row\" alignItems=\"center\" justifyContent=\"space-between\" spacing={1}>\n <OptionsColorPicker label={label} color={color} onColorChange={onColorChange} />\n <FormLabel htmlFor={label}>{label}</FormLabel>\n <TextField\n id={label}\n key={key}\n inputRef={inputRef}\n type=\"number\"\n value={value === 0 ? '' : value}\n placeholder=\"0\"\n onChange={onChange}\n onBlur={onBlur}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n onBlur();\n setKey(key + 1);\n }\n }}\n InputProps={{\n endAdornment: mode === 'percent' ? <Box paddingX={1}>%</Box> : undefined,\n }}\n />\n <IconButton aria-label={`delete threshold ${label}`} size=\"small\" onClick={onDelete}>\n <DeleteIcon />\n </IconButton>\n </Stack>\n );\n}\n"],"names":["Stack","FormLabel","TextField","IconButton","Box","DeleteIcon","useState","OptionsColorPicker","ThresholdInput","inputRef","label","color","value","mode","onChange","onColorChange","onBlur","onDelete","key","setKey","flex","direction","alignItems","justifyContent","spacing","htmlFor","id","type","placeholder","onKeyDown","e","InputProps","endAdornment","paddingX","undefined","aria-label","size","onClick"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,KAAK,EAAEC,SAAS,EAAEC,SAAS,EAAEC,UAAU,EAAEC,GAAG,QAAQ,gBAAgB;AAC7E,OAAOC,gBAAgB,gCAAgC;AACvD,SAAkCC,QAAQ,QAAQ,QAAQ;AAE1D,SAASC,kBAAkB,QAAQ,oCAAoC;AAevE,OAAO,SAASC,eAAe,EAC7BC,QAAQ,EACRC,KAAK,EACLC,KAAK,EACLC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,aAAa,EACbC,MAAM,EACNC,QAAQ,EACY;IACpB,MAAM,CAACC,KAAKC,OAAO,GAAGb,SAAS,IAAI,2DAA2D;IAC9F,qBACE,MAACN;QAAMoB,MAAM;QAAGC,WAAU;QAAMC,YAAW;QAASC,gBAAe;QAAgBC,SAAS;;0BAC1F,KAACjB;gBAAmBG,OAAOA;gBAAOC,OAAOA;gBAAOI,eAAeA;;0BAC/D,KAACd;gBAAUwB,SAASf;0BAAQA;;0BAC5B,KAACR;gBACCwB,IAAIhB;gBAEJD,UAAUA;gBACVkB,MAAK;gBACLf,OAAOA,UAAU,IAAI,KAAKA;gBAC1BgB,aAAY;gBACZd,UAAUA;gBACVE,QAAQA;gBACRa,WAAW,CAACC;oBACV,IAAIA,EAAEZ,GAAG,KAAK,SAAS;wBACrBF;wBACAG,OAAOD,MAAM;oBACf;gBACF;gBACAa,YAAY;oBACVC,cAAcnB,SAAS,0BAAY,KAACT;wBAAI6B,UAAU;kCAAG;yBAAUC;gBACjE;eAfKhB;0BAiBP,KAACf;gBAAWgC,cAAY,CAAC,iBAAiB,EAAEzB,OAAO;gBAAE0B,MAAK;gBAAQC,SAASpB;0BACzE,cAAA,KAACZ;;;;AAIT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThresholdsEditor.d.ts","sourceRoot":"","sources":["../../src/ThresholdsEditor/ThresholdsEditor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ThresholdsEditor.d.ts","sourceRoot":"","sources":["../../src/ThresholdsEditor/ThresholdsEditor.tsx"],"names":[],"mappings":"AAiBA,OAAc,EAAE,YAAY,EAAqB,MAAM,OAAO,CAAC;AAK/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAI5C,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,CAAC,UAAU,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACjD,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAID,wBAAgB,gBAAgB,CAAC,EAC/B,UAAU,EACV,QAAQ,EACR,WAAW,EACX,kBAAkB,GACnB,EAAE,qBAAqB,GAAG,YAAY,CA0LtC"}
|
|
@@ -11,15 +11,15 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import React, { useEffect, useRef } from 'react';
|
|
15
|
-
import { produce } from 'immer';
|
|
16
14
|
import { IconButton, ToggleButton, ToggleButtonGroup, Typography } from '@mui/material';
|
|
17
|
-
import PlusIcon from 'mdi-material-ui/Plus';
|
|
18
15
|
import { Stack } from '@mui/system';
|
|
16
|
+
import { produce } from 'immer';
|
|
17
|
+
import PlusIcon from 'mdi-material-ui/Plus';
|
|
18
|
+
import React, { useEffect, useRef } from 'react';
|
|
19
|
+
import { OptionsColorPicker } from '../ColorPicker/OptionsColorPicker';
|
|
19
20
|
import { useChartsTheme } from '../context/ChartsProvider';
|
|
20
|
-
import { OptionsEditorControl, OptionsEditorGroup } from '../OptionsEditorLayout';
|
|
21
21
|
import { InfoTooltip } from '../InfoTooltip';
|
|
22
|
-
import {
|
|
22
|
+
import { OptionsEditorControl, OptionsEditorGroup } from '../OptionsEditorLayout';
|
|
23
23
|
import { ThresholdInput } from './ThresholdInput';
|
|
24
24
|
const DEFAULT_STEP = 10;
|
|
25
25
|
export function ThresholdsEditor({ thresholds, onChange, hideDefault, disablePercentMode }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ThresholdsEditor/ThresholdsEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { ReactElement, useEffect, useRef } from 'react';\nimport { produce } from 'immer';\nimport { IconButton, ToggleButton, ToggleButtonGroup, Typography } from '@mui/material';\nimport PlusIcon from 'mdi-material-ui/Plus';\nimport { Stack } from '@mui/system';\nimport { useChartsTheme } from '../context/ChartsProvider';\nimport { OptionsEditorControl, OptionsEditorGroup } from '../OptionsEditorLayout';\nimport { InfoTooltip } from '../InfoTooltip';\nimport { OptionsColorPicker } from '../ColorPicker/OptionsColorPicker';\nimport { ThresholdOptions } from '../model';\nimport { ThresholdInput } from './ThresholdInput';\n\nexport interface ThresholdsEditorProps {\n onChange: (thresholds: ThresholdOptions) => void;\n thresholds?: ThresholdOptions;\n hideDefault?: boolean;\n disablePercentMode?: boolean;\n}\n\nconst DEFAULT_STEP = 10;\n\nexport function ThresholdsEditor({\n thresholds,\n onChange,\n hideDefault,\n disablePercentMode,\n}: ThresholdsEditorProps): ReactElement {\n const chartsTheme = useChartsTheme();\n const {\n thresholds: { defaultColor, palette },\n } = chartsTheme;\n const defaultThresholdColor = thresholds?.defaultColor ?? defaultColor;\n\n const steps = thresholds?.steps;\n // every time a new threshold is added, we want to focus the recently added input\n const recentlyAddedInputRef = useRef<HTMLInputElement | null>(null);\n const focusRef = useRef(false);\n useEffect(() => {\n if (!recentlyAddedInputRef.current || !focusRef.current) return;\n recentlyAddedInputRef.current?.focus();\n focusRef.current = false;\n }, [steps?.length]);\n\n const handleThresholdValueChange = (e: React.ChangeEvent<HTMLInputElement>, i: number): void => {\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n const step = draft.steps?.[i];\n if (step) {\n step.value = Number(e.target.value);\n }\n })\n );\n }\n };\n\n const handleThresholdColorChange = (color: string, i: number): void => {\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n if (draft.steps !== undefined) {\n const step = draft.steps[i];\n if (step) {\n step.color = color;\n }\n }\n })\n );\n }\n };\n\n const handleDefaultColorChange = (color: string): void => {\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.defaultColor = color;\n })\n );\n } else {\n onChange({\n defaultColor: color,\n });\n }\n };\n\n // sort thresholds in ascending order every time an input blurs\n const handleThresholdBlur = (): void => {\n if (steps !== undefined) {\n const sortedSteps = [...steps];\n sortedSteps.sort((a, b) => a.value - b.value);\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.steps = sortedSteps;\n })\n );\n }\n }\n };\n\n const deleteThreshold = (i: number): void => {\n if (thresholds !== undefined) {\n const updatedThresholds = produce(thresholds, (draft) => {\n if (draft.steps) {\n draft.steps.splice(i, 1);\n }\n });\n onChange(updatedThresholds);\n }\n };\n\n const addThresholdInput = (): void => {\n focusRef.current = true;\n if (thresholds === undefined) {\n onChange({\n steps: [{ value: DEFAULT_STEP }],\n });\n } else if (thresholds && thresholds.steps === undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.steps = [{ value: DEFAULT_STEP }];\n })\n );\n } else {\n onChange(\n produce(thresholds, (draft) => {\n const steps = draft.steps;\n if (steps?.length) {\n const lastStep = steps[steps.length - 1];\n const color = palette[steps.length] ?? getRandomColor(); // we will assign color from the palette first, then generate random color\n steps.push({ color, value: (lastStep?.value ?? 0) + DEFAULT_STEP }); // set new threshold value to last step value + 10\n } else if (steps) {\n steps.push({ value: DEFAULT_STEP });\n }\n })\n );\n }\n };\n\n const handleModeChange = (event: React.MouseEvent, value: string): void => {\n const mode = value === 'percent' ? 'percent' : undefined;\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.mode = mode;\n })\n );\n } else {\n onChange({ mode });\n }\n };\n\n return (\n <OptionsEditorGroup\n title=\"Thresholds\"\n icon={\n <InfoTooltip description=\"Add threshold\">\n <IconButton size=\"small\" aria-label=\"add threshold\" onClick={addThresholdInput}>\n <PlusIcon />\n </IconButton>\n </InfoTooltip>\n }\n >\n <OptionsEditorControl\n label=\"Mode\"\n description=\"Percentage means thresholds relative to min & max\"\n control={\n <ToggleButtonGroup\n exclusive\n disabled={disablePercentMode}\n value={thresholds?.mode ?? 'absolute'}\n onChange={handleModeChange}\n sx={{ height: '36px', marginLeft: 'auto' }}\n >\n <ToggleButton aria-label=\"absolute\" value=\"absolute\" sx={{ fontWeight: 500 }}>\n Absolute\n </ToggleButton>\n <ToggleButton aria-label=\"percent\" value=\"percent\" sx={{ fontWeight: 500 }}>\n Percent\n </ToggleButton>\n </ToggleButtonGroup>\n }\n />\n {steps &&\n steps\n .map((step, i) => (\n <ThresholdInput\n inputRef={i === steps.length - 1 ? recentlyAddedInputRef : undefined}\n key={i}\n label={`T${i + 1}`}\n color={step.color ?? palette[i] ?? defaultThresholdColor}\n value={step.value}\n mode={thresholds?.mode}\n onColorChange={(color) => handleThresholdColorChange(color, i)}\n onChange={(e) => {\n handleThresholdValueChange(e, i);\n }}\n onDelete={() => {\n deleteThreshold(i);\n }}\n onBlur={handleThresholdBlur}\n />\n ))\n .reverse()}\n {!hideDefault && (\n <Stack flex={1} direction=\"row\" alignItems=\"center\" spacing={1}>\n <OptionsColorPicker label=\"default\" color={defaultThresholdColor} onColorChange={handleDefaultColorChange} />\n <Typography>Default</Typography>\n </Stack>\n )}\n </OptionsEditorGroup>\n );\n}\n\n// https://www.paulirish.com/2009/random-hex-color-code-snippets/\nconst getRandomColor = (): string => {\n return (\n '#' +\n Math.floor(Math.random() * 16777216)\n .toString(16)\n .padStart(6, '0')\n );\n};\n"],"names":["React","useEffect","useRef","produce","IconButton","ToggleButton","ToggleButtonGroup","Typography","PlusIcon","Stack","useChartsTheme","OptionsEditorControl","OptionsEditorGroup","InfoTooltip","OptionsColorPicker","ThresholdInput","DEFAULT_STEP","ThresholdsEditor","thresholds","onChange","hideDefault","disablePercentMode","chartsTheme","defaultColor","palette","defaultThresholdColor","steps","recentlyAddedInputRef","focusRef","current","focus","length","handleThresholdValueChange","e","i","undefined","draft","step","value","Number","target","handleThresholdColorChange","color","handleDefaultColorChange","handleThresholdBlur","sortedSteps","sort","a","b","deleteThreshold","updatedThresholds","splice","addThresholdInput","lastStep","getRandomColor","push","handleModeChange","event","mode","title","icon","description","size","aria-label","onClick","label","control","exclusive","disabled","sx","height","marginLeft","fontWeight","map","inputRef","onColorChange","onDelete","onBlur","reverse","flex","direction","alignItems","spacing","Math","floor","random","toString","padStart"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAOA,SAAuBC,SAAS,EAAEC,MAAM,QAAQ,QAAQ;AAC/D,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAASC,UAAU,EAAEC,YAAY,EAAEC,iBAAiB,EAAEC,UAAU,QAAQ,gBAAgB;AACxF,OAAOC,cAAc,uBAAuB;AAC5C,SAASC,KAAK,QAAQ,cAAc;AACpC,SAASC,cAAc,QAAQ,4BAA4B;AAC3D,SAASC,oBAAoB,EAAEC,kBAAkB,QAAQ,yBAAyB;AAClF,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,kBAAkB,QAAQ,oCAAoC;AAEvE,SAASC,cAAc,QAAQ,mBAAmB;AASlD,MAAMC,eAAe;AAErB,OAAO,SAASC,iBAAiB,EAC/BC,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oBACA2C,QAAQjC;mBAZHV,IAeR4C,OAAO;YACX,CAAC1D,6BACA,MAACX;gBAAMsE,MAAM;gBAAGC,WAAU;gBAAMC,YAAW;gBAASC,SAAS;;kCAC3D,KAACpE;wBAAmBmD,OAAM;wBAAUvB,OAAOjB;wBAAuBkD,eAAehC;;kCACjF,KAACpC;kCAAW;;;;;;AAKtB;AAEA,iEAAiE;AACjE,MAAM+C,iBAAiB;IACrB,OACE,MACA6B,KAAKC,KAAK,CAACD,KAAKE,MAAM,KAAK,UACxBC,QAAQ,CAAC,IACTC,QAAQ,CAAC,GAAG;AAEnB"}
|
|
1
|
+
{"version":3,"sources":["../../src/ThresholdsEditor/ThresholdsEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { IconButton, ToggleButton, ToggleButtonGroup, Typography } from '@mui/material';\nimport { Stack } from '@mui/system';\nimport { produce } from 'immer';\nimport PlusIcon from 'mdi-material-ui/Plus';\nimport React, { ReactElement, useEffect, useRef } from 'react';\n\nimport { OptionsColorPicker } from '../ColorPicker/OptionsColorPicker';\nimport { useChartsTheme } from '../context/ChartsProvider';\nimport { InfoTooltip } from '../InfoTooltip';\nimport { ThresholdOptions } from '../model';\nimport { OptionsEditorControl, OptionsEditorGroup } from '../OptionsEditorLayout';\nimport { ThresholdInput } from './ThresholdInput';\n\nexport interface ThresholdsEditorProps {\n onChange: (thresholds: ThresholdOptions) => void;\n thresholds?: ThresholdOptions;\n hideDefault?: boolean;\n disablePercentMode?: boolean;\n}\n\nconst DEFAULT_STEP = 10;\n\nexport function ThresholdsEditor({\n thresholds,\n onChange,\n hideDefault,\n disablePercentMode,\n}: ThresholdsEditorProps): ReactElement {\n const chartsTheme = useChartsTheme();\n const {\n thresholds: { defaultColor, palette },\n } = chartsTheme;\n const defaultThresholdColor = thresholds?.defaultColor ?? defaultColor;\n\n const steps = thresholds?.steps;\n // every time a new threshold is added, we want to focus the recently added input\n const recentlyAddedInputRef = useRef<HTMLInputElement | null>(null);\n const focusRef = useRef(false);\n useEffect(() => {\n if (!recentlyAddedInputRef.current || !focusRef.current) return;\n recentlyAddedInputRef.current?.focus();\n focusRef.current = false;\n }, [steps?.length]);\n\n const handleThresholdValueChange = (e: React.ChangeEvent<HTMLInputElement>, i: number): void => {\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n const step = draft.steps?.[i];\n if (step) {\n step.value = Number(e.target.value);\n }\n }),\n );\n }\n };\n\n const handleThresholdColorChange = (color: string, i: number): void => {\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n if (draft.steps !== undefined) {\n const step = draft.steps[i];\n if (step) {\n step.color = color;\n }\n }\n }),\n );\n }\n };\n\n const handleDefaultColorChange = (color: string): void => {\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.defaultColor = color;\n }),\n );\n } else {\n onChange({\n defaultColor: color,\n });\n }\n };\n\n // sort thresholds in ascending order every time an input blurs\n const handleThresholdBlur = (): void => {\n if (steps !== undefined) {\n const sortedSteps = [...steps];\n sortedSteps.sort((a, b) => a.value - b.value);\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.steps = sortedSteps;\n }),\n );\n }\n }\n };\n\n const deleteThreshold = (i: number): void => {\n if (thresholds !== undefined) {\n const updatedThresholds = produce(thresholds, (draft) => {\n if (draft.steps) {\n draft.steps.splice(i, 1);\n }\n });\n onChange(updatedThresholds);\n }\n };\n\n const addThresholdInput = (): void => {\n focusRef.current = true;\n if (thresholds === undefined) {\n onChange({\n steps: [{ value: DEFAULT_STEP }],\n });\n } else if (thresholds && thresholds.steps === undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.steps = [{ value: DEFAULT_STEP }];\n }),\n );\n } else {\n onChange(\n produce(thresholds, (draft) => {\n const steps = draft.steps;\n if (steps?.length) {\n const lastStep = steps[steps.length - 1];\n const color = palette[steps.length] ?? getRandomColor(); // we will assign color from the palette first, then generate random color\n steps.push({ color, value: (lastStep?.value ?? 0) + DEFAULT_STEP }); // set new threshold value to last step value + 10\n } else if (steps) {\n steps.push({ value: DEFAULT_STEP });\n }\n }),\n );\n }\n };\n\n const handleModeChange = (event: React.MouseEvent, value: string): void => {\n const mode = value === 'percent' ? 'percent' : undefined;\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.mode = mode;\n }),\n );\n } else {\n onChange({ mode });\n }\n };\n\n return (\n <OptionsEditorGroup\n title=\"Thresholds\"\n icon={\n <InfoTooltip description=\"Add threshold\">\n <IconButton size=\"small\" aria-label=\"add threshold\" onClick={addThresholdInput}>\n <PlusIcon />\n </IconButton>\n </InfoTooltip>\n }\n >\n <OptionsEditorControl\n label=\"Mode\"\n description=\"Percentage means thresholds relative to min & max\"\n control={\n <ToggleButtonGroup\n exclusive\n disabled={disablePercentMode}\n value={thresholds?.mode ?? 'absolute'}\n onChange={handleModeChange}\n sx={{ height: '36px', marginLeft: 'auto' }}\n >\n <ToggleButton aria-label=\"absolute\" value=\"absolute\" sx={{ fontWeight: 500 }}>\n Absolute\n </ToggleButton>\n <ToggleButton aria-label=\"percent\" value=\"percent\" sx={{ fontWeight: 500 }}>\n Percent\n </ToggleButton>\n </ToggleButtonGroup>\n }\n />\n {steps &&\n steps\n .map((step, i) => (\n <ThresholdInput\n inputRef={i === steps.length - 1 ? recentlyAddedInputRef : undefined}\n key={i}\n label={`T${i + 1}`}\n color={step.color ?? palette[i] ?? defaultThresholdColor}\n value={step.value}\n mode={thresholds?.mode}\n onColorChange={(color) => handleThresholdColorChange(color, i)}\n onChange={(e) => {\n handleThresholdValueChange(e, i);\n }}\n onDelete={() => {\n deleteThreshold(i);\n }}\n onBlur={handleThresholdBlur}\n />\n ))\n .reverse()}\n {!hideDefault && (\n <Stack flex={1} direction=\"row\" alignItems=\"center\" spacing={1}>\n <OptionsColorPicker label=\"default\" color={defaultThresholdColor} onColorChange={handleDefaultColorChange} />\n <Typography>Default</Typography>\n </Stack>\n )}\n </OptionsEditorGroup>\n );\n}\n\n// https://www.paulirish.com/2009/random-hex-color-code-snippets/\nconst getRandomColor = (): string => {\n return (\n '#' +\n Math.floor(Math.random() * 16777216)\n .toString(16)\n .padStart(6, '0')\n );\n};\n"],"names":["IconButton","ToggleButton","ToggleButtonGroup","Typography","Stack","produce","PlusIcon","React","useEffect","useRef","OptionsColorPicker","useChartsTheme","InfoTooltip","OptionsEditorControl","OptionsEditorGroup","ThresholdInput","DEFAULT_STEP","ThresholdsEditor","thresholds","onChange","hideDefault","disablePercentMode","chartsTheme","defaultColor","palette","defaultThresholdColor","steps","recentlyAddedInputRef","focusRef","current","focus","length","handleThresholdValueChange","e","i","undefined","draft","step","value","Number","target","handleThresholdColorChange","color","handleDefaultColorChange","handleThresholdBlur","sortedSteps","sort","a","b","deleteThreshold","updatedThresholds","splice","addThresholdInput","lastStep","getRandomColor","push","handleModeChange","event","mode","title","icon","description","size","aria-label","onClick","label","control","exclusive","disabled","sx","height","marginLeft","fontWeight","map","inputRef","onColorChange","onDelete","onBlur","reverse","flex","direction","alignItems","spacing","Math","floor","random","toString","padStart"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,UAAU,EAAEC,YAAY,EAAEC,iBAAiB,EAAEC,UAAU,QAAQ,gBAAgB;AACxF,SAASC,KAAK,QAAQ,cAAc;AACpC,SAASC,OAAO,QAA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,IAAIJ,wBAAwBQ;oBAE3D8B,OAAO,CAAC,CAAC,EAAE/B,IAAI,GAAG;oBAClBQ,OAAOL,KAAKK,KAAK,IAAIlB,OAAO,CAACU,EAAE,IAAIT;oBACnCa,OAAOD,KAAKC,KAAK;oBACjBoB,MAAMxC,YAAYwC;oBAClBiB,eAAe,CAACjC,QAAUD,2BAA2BC,OAAOR;oBAC5Df,UAAU,CAACc;wBACTD,2BAA2BC,GAAGC;oBAChC;oBACA0C,UAAU;wBACR3B,gBAAgBf;oBAClB;oBACA2C,QAAQjC;mBAZHV,IAeR4C,OAAO;YACX,CAAC1D,6BACA,MAAChB;gBAAM2E,MAAM;gBAAGC,WAAU;gBAAMC,YAAW;gBAASC,SAAS;;kCAC3D,KAACxE;wBAAmBuD,OAAM;wBAAUvB,OAAOjB;wBAAuBkD,eAAehC;;kCACjF,KAACxC;kCAAW;;;;;;AAKtB;AAEA,iEAAiE;AACjE,MAAMmD,iBAAiB;IACrB,OACE,MACA6B,KAAKC,KAAK,CAACD,KAAKE,MAAM,KAAK,UACxBC,QAAQ,CAAC,IACTC,QAAQ,CAAC,GAAG;AAEnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTimeRangePicker.d.ts","sourceRoot":"","sources":["../../src/TimeRangeSelector/DateTimeRangePicker.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DateTimeRangePicker.d.ts","sourceRoot":"","sources":["../../src/TimeRangeSelector/DateTimeRangePicker.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAM/C,MAAM,WAAW,qBAAqB;IACpC,gBAAgB,EAAE,iBAAiB,CAAC;IACpC,QAAQ,EAAE,CAAC,SAAS,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACjD,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,GAAI,qDAKjC,qBAAqB,KAAG,YAuJ1B,CAAC"}
|
|
@@ -11,13 +11,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import {
|
|
14
|
+
import { TZDate } from '@date-fns/tz';
|
|
15
15
|
import { Box, Stack, Typography, Button } from '@mui/material';
|
|
16
16
|
import { DateTimeField, LocalizationProvider, StaticDateTimePicker } from '@mui/x-date-pickers';
|
|
17
17
|
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFnsV3';
|
|
18
|
-
import {
|
|
19
|
-
import { ErrorBoundary } from '../ErrorBoundary';
|
|
18
|
+
import { useState } from 'react';
|
|
20
19
|
import { ErrorAlert } from '../ErrorAlert';
|
|
20
|
+
import { ErrorBoundary } from '../ErrorBoundary';
|
|
21
21
|
import { DATE_TIME_FORMAT, validateDateRange } from './utils';
|
|
22
22
|
/**
|
|
23
23
|
* Start and End datetime picker, allowing use to select a specific time range selecting two absolute dates and times.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/TimeRangeSelector/DateTimeRangePicker.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement, useState } from 'react';\nimport { Box, Stack, Typography, Button } from '@mui/material';\nimport { DateTimeField, LocalizationProvider, StaticDateTimePicker } from '@mui/x-date-pickers';\nimport { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFnsV3';\nimport { AbsoluteTimeRange } from '@perses-dev/spec';\nimport { TZDate } from '@date-fns/tz';\nimport { ErrorBoundary } from '../ErrorBoundary';\nimport { ErrorAlert } from '../ErrorAlert';\nimport { DATE_TIME_FORMAT, validateDateRange } from './utils';\n\nexport interface AbsoluteTimeFormProps {\n initialTimeRange: AbsoluteTimeRange;\n onChange: (timeRange: AbsoluteTimeRange) => void;\n onCancel: () => void;\n timeZone: string;\n}\n\n/**\n * Start and End datetime picker, allowing use to select a specific time range selecting two absolute dates and times.\n * TODO: Use directly the MUI X ``DateTimePicker`` for datetime selection which is better. https://next.mui.com/x/react-date-pickers/date-time-picker/\n * Use ``DateTimeRangePicker`` directly would be cool but paid https://next.mui.com/x/react-date-pickers/date-time-range-picker/\n * @param initialTimeRange initial time range to pre-select.\n * @param onChange event received when start and end has been selected (click on apply)\n * @param onCancel event received when user click on cancel\n * @constructor\n */\nexport const DateTimeRangePicker = ({\n initialTimeRange,\n onChange,\n onCancel,\n timeZone,\n}: AbsoluteTimeFormProps): ReactElement => {\n const stdTimeZone = ['local', 'browser'].includes(timeZone.toLowerCase())\n ? Intl.DateTimeFormat().resolvedOptions().timeZone\n : timeZone;\n const [timeRange, setTimeRange] = useState<AbsoluteTimeRange>(initialTimeRange);\n const [showStartCalendar, setShowStartCalendar] = useState<boolean>(true);\n\n const changeTimeRange = (newTime: Date, segment: keyof AbsoluteTimeRange): void => {\n setTimeRange((prevTimeRange) => {\n return {\n ...prevTimeRange,\n [segment]: newTime,\n };\n });\n };\n\n const onChangeStartTime = (newStartTime: Date): void => {\n changeTimeRange(newStartTime, 'start');\n };\n\n const onChangeEndTime = (newEndTime: Date): void => {\n changeTimeRange(newEndTime, 'end');\n };\n\n const updateDateRange = (): { start: Date; end: Date } | undefined => {\n const newDates = {\n start: timeRange.start,\n end: timeRange.end,\n };\n const isValidDateRange = validateDateRange(newDates.start, newDates.end);\n if (isValidDateRange) {\n return newDates;\n }\n };\n\n const onApply = (): void => {\n const newDates = updateDateRange();\n if (newDates) {\n onChange(newDates);\n }\n };\n\n return (\n <LocalizationProvider dateAdapter={AdapterDateFns}>\n <Stack\n spacing={2}\n sx={(theme) => ({\n padding: theme.spacing(1, 0, 2),\n })}\n >\n {showStartCalendar && (\n <Box\n sx={(theme) => ({\n // TODO: create separate reusable calendar component\n '.MuiPickersLayout-contentWrapper': {\n backgroundColor: theme.palette.background.default,\n },\n })}\n >\n <Typography variant=\"h3\" padding={1} paddingLeft={2}>\n Select Start Time\n </Typography>\n <StaticDateTimePicker\n timezone={stdTimeZone}\n displayStaticWrapperAs=\"desktop\"\n openTo=\"day\"\n disableHighlightToday={true}\n value={new TZDate(timeRange.start, stdTimeZone)}\n onChange={(newValue) => {\n if (newValue === null) return;\n onChangeStartTime(newValue);\n }}\n onAccept={() => {\n setShowStartCalendar(false);\n }}\n />\n </Box>\n )}\n {!showStartCalendar && (\n <Box\n sx={(theme) => ({\n '.MuiPickersLayout-contentWrapper': {\n backgroundColor: theme.palette.background.default,\n },\n })}\n >\n <Typography variant=\"h3\" padding={1} paddingLeft={2}>\n Select End Time\n </Typography>\n <StaticDateTimePicker\n timezone={stdTimeZone}\n displayStaticWrapperAs=\"desktop\"\n openTo=\"day\"\n disableHighlightToday={true}\n value={new TZDate(timeRange.end, stdTimeZone)}\n minDateTime={new TZDate(timeRange.start, stdTimeZone)}\n onChange={(newValue) => {\n if (newValue === null) return;\n onChangeEndTime(newValue);\n }}\n onAccept={(newValue) => {\n if (newValue === null) return;\n setShowStartCalendar(true);\n onChangeEndTime(newValue);\n }}\n />\n </Box>\n )}\n <Stack direction=\"row\" alignItems=\"center\" gap={1} pl={1} pr={1}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <DateTimeField\n data-testid=\"start_time_input\"\n timezone={stdTimeZone}\n label=\"Start Time\"\n value={new TZDate(timeRange.start, stdTimeZone)}\n onChange={(event: Date | null) => {\n if (event) {\n onChangeStartTime(event);\n }\n }}\n onBlur={() => updateDateRange()}\n format={DATE_TIME_FORMAT}\n />\n </ErrorBoundary>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <DateTimeField\n data-testid=\"end_time_input\"\n timezone={stdTimeZone}\n label=\"End Time\"\n value={new TZDate(timeRange.end, stdTimeZone)}\n onChange={(event: Date | null) => {\n if (event) {\n onChangeEndTime(event);\n }\n }}\n onBlur={() => updateDateRange()}\n format={DATE_TIME_FORMAT}\n />\n </ErrorBoundary>\n </Stack>\n <Stack direction=\"row\" sx={{ padding: (theme) => theme.spacing(0, 1) }} gap={1}>\n <Button variant=\"contained\" onClick={() => onApply()} fullWidth>\n Apply\n </Button>\n <Button variant=\"outlined\" onClick={() => onCancel()} fullWidth>\n Cancel\n </Button>\n </Stack>\n </Stack>\n </LocalizationProvider>\n );\n};\n"],"names":["useState","Box","Stack","Typography","Button","DateTimeField","LocalizationProvider","StaticDateTimePicker","AdapterDateFns","TZDate","ErrorBoundary","ErrorAlert","DATE_TIME_FORMAT","validateDateRange","DateTimeRangePicker","initialTimeRange","onChange","onCancel","timeZone","stdTimeZone","includes","toLowerCase","Intl","DateTimeFormat","resolvedOptions","timeRange","setTimeRange","showStartCalendar","setShowStartCalendar","changeTimeRange","newTime","segment","prevTimeRange","onChangeStartTime","newStartTime","onChangeEndTime","newEndTime","updateDateRange","newDates","start","end","isValidDateRange","onApply","dateAdapter","spacing","sx","theme","padding","backgroundColor","palette","background","default","variant","paddingLeft","timezone","displayStaticWrapperAs","openTo","disableHighlightToday","value","newValue","onAccept","minDateTime","direction","alignItems","gap","pl","pr","FallbackComponent","data-testid","label","event","onBlur","format","onClick","fullWidth"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCA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ACzD;oBAAM4D,WAAU;oBAAMC,YAAW;oBAASC,KAAK;oBAAGC,IAAI;oBAAGC,IAAI;;sCAC5D,KAACxD;4BAAcyD,mBAAmBxD;sCAChC,cAAA,KAACN;gCACC+D,eAAY;gCACZd,UAAUnC;gCACVkD,OAAM;gCACNX,OAAO,IAAIjD,OAAOgB,UAAUc,KAAK,EAAEpB;gCACnCH,UAAU,CAACsD;oCACT,IAAIA,OAAO;wCACTrC,kBAAkBqC;oCACpB;gCACF;gCACAC,QAAQ,IAAMlC;gCACdmC,QAAQ5D;;;sCAGZ,KAACF;4BAAcyD,mBAAmBxD;sCAChC,cAAA,KAACN;gCACC+D,eAAY;gCACZd,UAAUnC;gCACVkD,OAAM;gCACNX,OAAO,IAAIjD,OAAOgB,UAAUe,GAAG,EAAErB;gCACjCH,UAAU,CAACsD;oCACT,IAAIA,OAAO;wCACTnC,gBAAgBmC;oCAClB;gCACF;gCACAC,QAAQ,IAAMlC;gCACdmC,QAAQ5D;;;;;8BAId,MAACV;oBAAM4D,WAAU;oBAAMjB,IAAI;wBAAEE,SAAS,CAACD,QAAUA,MAAMF,OAAO,CAAC,GAAG;oBAAG;oBAAGoB,KAAK;;sCAC3E,KAAC5D;4BAAOgD,SAAQ;4BAAYqB,SAAS,IAAM/B;4BAAWgC,SAAS;sCAAC;;sCAGhE,KAACtE;4BAAOgD,SAAQ;4BAAWqB,SAAS,IAAMxD;4BAAYyD,SAAS;sCAAC;;;;;;;AAO1E,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../src/TimeRangeSelector/DateTimeRangePicker.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { TZDate } from '@date-fns/tz';\nimport { Box, Stack, Typography, Button } from '@mui/material';\nimport { DateTimeField, LocalizationProvider, StaticDateTimePicker } from '@mui/x-date-pickers';\nimport { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFnsV3';\nimport { AbsoluteTimeRange } from '@perses-dev/spec';\nimport { ReactElement, useState } from 'react';\n\nimport { ErrorAlert } from '../ErrorAlert';\nimport { ErrorBoundary } from '../ErrorBoundary';\nimport { DATE_TIME_FORMAT, validateDateRange } from './utils';\n\nexport interface AbsoluteTimeFormProps {\n initialTimeRange: AbsoluteTimeRange;\n onChange: (timeRange: AbsoluteTimeRange) => void;\n onCancel: () => void;\n timeZone: string;\n}\n\n/**\n * Start and End datetime picker, allowing use to select a specific time range selecting two absolute dates and times.\n * TODO: Use directly the MUI X ``DateTimePicker`` for datetime selection which is better. https://next.mui.com/x/react-date-pickers/date-time-picker/\n * Use ``DateTimeRangePicker`` directly would be cool but paid https://next.mui.com/x/react-date-pickers/date-time-range-picker/\n * @param initialTimeRange initial time range to pre-select.\n * @param onChange event received when start and end has been selected (click on apply)\n * @param onCancel event received when user click on cancel\n * @constructor\n */\nexport const DateTimeRangePicker = ({\n initialTimeRange,\n onChange,\n onCancel,\n timeZone,\n}: AbsoluteTimeFormProps): ReactElement => {\n const stdTimeZone = ['local', 'browser'].includes(timeZone.toLowerCase())\n ? Intl.DateTimeFormat().resolvedOptions().timeZone\n : timeZone;\n const [timeRange, setTimeRange] = useState<AbsoluteTimeRange>(initialTimeRange);\n const [showStartCalendar, setShowStartCalendar] = useState<boolean>(true);\n\n const changeTimeRange = (newTime: Date, segment: keyof AbsoluteTimeRange): void => {\n setTimeRange((prevTimeRange) => {\n return {\n ...prevTimeRange,\n [segment]: newTime,\n };\n });\n };\n\n const onChangeStartTime = (newStartTime: Date): void => {\n changeTimeRange(newStartTime, 'start');\n };\n\n const onChangeEndTime = (newEndTime: Date): void => {\n changeTimeRange(newEndTime, 'end');\n };\n\n const updateDateRange = (): { start: Date; end: Date } | undefined => {\n const newDates = {\n start: timeRange.start,\n end: timeRange.end,\n };\n const isValidDateRange = validateDateRange(newDates.start, newDates.end);\n if (isValidDateRange) {\n return newDates;\n }\n };\n\n const onApply = (): void => {\n const newDates = updateDateRange();\n if (newDates) {\n onChange(newDates);\n }\n };\n\n return (\n <LocalizationProvider dateAdapter={AdapterDateFns}>\n <Stack\n spacing={2}\n sx={(theme) => ({\n padding: theme.spacing(1, 0, 2),\n })}\n >\n {showStartCalendar && (\n <Box\n sx={(theme) => ({\n // TODO: create separate reusable calendar component\n '.MuiPickersLayout-contentWrapper': {\n backgroundColor: theme.palette.background.default,\n },\n })}\n >\n <Typography variant=\"h3\" padding={1} paddingLeft={2}>\n Select Start Time\n </Typography>\n <StaticDateTimePicker\n timezone={stdTimeZone}\n displayStaticWrapperAs=\"desktop\"\n openTo=\"day\"\n disableHighlightToday={true}\n value={new TZDate(timeRange.start, stdTimeZone)}\n onChange={(newValue) => {\n if (newValue === null) return;\n onChangeStartTime(newValue);\n }}\n onAccept={() => {\n setShowStartCalendar(false);\n }}\n />\n </Box>\n )}\n {!showStartCalendar && (\n <Box\n sx={(theme) => ({\n '.MuiPickersLayout-contentWrapper': {\n backgroundColor: theme.palette.background.default,\n },\n })}\n >\n <Typography variant=\"h3\" padding={1} paddingLeft={2}>\n Select End Time\n </Typography>\n <StaticDateTimePicker\n timezone={stdTimeZone}\n displayStaticWrapperAs=\"desktop\"\n openTo=\"day\"\n disableHighlightToday={true}\n value={new TZDate(timeRange.end, stdTimeZone)}\n minDateTime={new TZDate(timeRange.start, stdTimeZone)}\n onChange={(newValue) => {\n if (newValue === null) return;\n onChangeEndTime(newValue);\n }}\n onAccept={(newValue) => {\n if (newValue === null) return;\n setShowStartCalendar(true);\n onChangeEndTime(newValue);\n }}\n />\n </Box>\n )}\n <Stack direction=\"row\" alignItems=\"center\" gap={1} pl={1} pr={1}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <DateTimeField\n data-testid=\"start_time_input\"\n timezone={stdTimeZone}\n label=\"Start Time\"\n value={new TZDate(timeRange.start, stdTimeZone)}\n onChange={(event: Date | null) => {\n if (event) {\n onChangeStartTime(event);\n }\n }}\n onBlur={() => updateDateRange()}\n format={DATE_TIME_FORMAT}\n />\n </ErrorBoundary>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <DateTimeField\n data-testid=\"end_time_input\"\n timezone={stdTimeZone}\n label=\"End Time\"\n value={new TZDate(timeRange.end, stdTimeZone)}\n onChange={(event: Date | null) => {\n if (event) {\n onChangeEndTime(event);\n }\n }}\n onBlur={() => updateDateRange()}\n format={DATE_TIME_FORMAT}\n />\n </ErrorBoundary>\n </Stack>\n <Stack direction=\"row\" sx={{ padding: (theme) => theme.spacing(0, 1) }} gap={1}>\n <Button variant=\"contained\" onClick={() => onApply()} fullWidth>\n Apply\n </Button>\n <Button variant=\"outlined\" onClick={() => onCancel()} fullWidth>\n Cancel\n </Button>\n </Stack>\n </Stack>\n </LocalizationProvider>\n );\n};\n"],"names":["TZDate","Box","Stack","Typography","Button","DateTimeField","LocalizationProvider","StaticDateTimePicker","AdapterDateFns","useState","ErrorAlert","ErrorBoundary","DATE_TIME_FORMAT","validateDateRange","DateTimeRangePicker","initialTimeRange","onChange","onCancel","timeZone","stdTimeZone","includes","toLowerCase","Intl","DateTimeFormat","resolvedOptions","timeRange","setTimeRange","showStartCalendar","setShowStartCalendar","changeTimeRange","newTime","segment","prevTimeRange","onChangeStartTime","newStartTime","onChangeEndTime","newEndTime","updateDateRange","newDates","start","end","isValidDateRange","onApply","dateAdapter","spacing","sx","theme","padding","backgroundColor","palette","background","default","variant","paddingLeft","timezone","displayStaticWrapperAs","openTo","disableHighlightToday","value","newValue","onAccept","minDateTime","direction","alignItems","gap","pl","pr","FallbackComponent","data-testid","label","event","onBlur","format","onClick","fullWidth"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,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gBwB;4BAClB;4BACAC,UAAU,CAACD;gCACT,IAAIA,aAAa,MAAM;gCACvB/B,qBAAqB;gCACrBO,gBAAgBwB;4BAClB;;;;8BAIN,MAACzD;oBAAM4D,WAAU;oBAAMC,YAAW;oBAASC,KAAK;oBAAGC,IAAI;oBAAGC,IAAI;;sCAC5D,KAACvD;4BAAcwD,mBAAmBzD;sCAChC,cAAA,KAACL;gCACC+D,eAAY;gCACZd,UAAUnC;gCACVkD,OAAM;gCACNX,OAAO,IAAI1D,OAAOyB,UAAUc,KAAK,EAAEpB;gCACnCH,UAAU,CAACsD;oCACT,IAAIA,OAAO;wCACTrC,kBAAkBqC;oCACpB;gCACF;gCACAC,QAAQ,IAAMlC;gCACdmC,QAAQ5D;;;sCAGZ,KAACD;4BAAcwD,mBAAmBzD;sCAChC,cAAA,KAACL;gCACC+D,eAAY;gCACZd,UAAUnC;gCACVkD,OAAM;gCACNX,OAAO,IAAI1D,OAAOyB,UAAUe,GAAG,EAAErB;gCACjCH,UAAU,CAACsD;oCACT,IAAIA,OAAO;wCACTnC,gBAAgBmC;oCAClB;gCACF;gCACAC,QAAQ,IAAMlC;gCACdmC,QAAQ5D;;;;;8BAId,MAACV;oBAAM4D,WAAU;oBAAMjB,IAAI;wBAAEE,SAAS,CAACD,QAAUA,MAAMF,OAAO,CAAC,GAAG;oBAAG;oBAAGoB,KAAK;;sCAC3E,KAAC5D;4BAAOgD,SAAQ;4BAAYqB,SAAS,IAAM/B;4BAAWgC,SAAS;sCAAC;;sCAGhE,KAACtE;4BAAOgD,SAAQ;4BAAWqB,SAAS,IAAMxD;4BAAYyD,SAAS;sCAAC;;;;;;;AAO1E,EAAE"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TimeRangeValue } from '@perses-dev/spec';
|
|
2
2
|
import { ReactElement } from 'react';
|
|
3
|
-
import { TimeZoneOption } from '../model/timeZoneOption';
|
|
4
3
|
import { TimeOption } from '../model';
|
|
4
|
+
import { TimeZoneOption } from '../model/timeZoneOption';
|
|
5
5
|
interface TimeRangeSelectorProps {
|
|
6
6
|
/**
|
|
7
7
|
* The current value of the time range.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeRangeSelector.d.ts","sourceRoot":"","sources":["../../src/TimeRangeSelector/TimeRangeSelector.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TimeRangeSelector.d.ts","sourceRoot":"","sources":["../../src/TimeRangeSelector/TimeRangeSelector.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,cAAc,EAA+D,MAAM,kBAAkB,CAAC;AAG/G,OAAO,EAAE,YAAY,EAA6B,MAAM,OAAO,CAAC;AAGhE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,cAAc,EAAsB,MAAM,yBAAyB,CAAC;AAM7E,UAAU,sBAAsB;IAC9B;;OAEG;IACH,KAAK,EAAE,cAAc,CAAC;IACtB;;;OAGG;IACH,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B;;OAEG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC1C;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,4FAA4F;IAC5F,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IACnC,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;CACvD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,WAAW,EACX,QAAQ,EACR,MAAM,EACN,mBAA0B,EAC1B,QAAQ,EAAE,YAAY,EACtB,eAAe,EACf,gBAAgB,GACjB,EAAE,sBAAsB,GAAG,YAAY,CA0JvC"}
|