@perses-dev/components 0.54.0-beta.0 → 0.54.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AlignSelector/AlignSelector.js +1 -1
- package/dist/AlignSelector/AlignSelector.js.map +1 -1
- package/dist/ColorPicker/ColorPicker.js +1 -1
- package/dist/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/ColorPicker/OptionsColorPicker.d.ts +2 -1
- package/dist/ColorPicker/OptionsColorPicker.d.ts.map +1 -1
- package/dist/ColorPicker/OptionsColorPicker.js +3 -3
- package/dist/ColorPicker/OptionsColorPicker.js.map +1 -1
- package/dist/ContentWithLegend/ContentWithLegend.js +1 -1
- package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.d.ts +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.d.ts.map +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.js +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
- package/dist/Dialog/DiscardChangesConfirmationDialog.js +1 -1
- package/dist/Dialog/DiscardChangesConfirmationDialog.js.map +1 -1
- package/dist/DragAndDrop/DragAndDropList.js +1 -1
- package/dist/DragAndDrop/DragAndDropList.js.map +1 -1
- package/dist/DragAndDrop/DragButton.js +1 -1
- package/dist/DragAndDrop/DragButton.js.map +1 -1
- package/dist/DragAndDrop/DropIndicator.js +1 -1
- package/dist/DragAndDrop/DropIndicator.js.map +1 -1
- package/dist/Drawer/Drawer.js +1 -1
- package/dist/Drawer/Drawer.js.map +1 -1
- package/dist/EChart/EChart.js +1 -1
- package/dist/EChart/EChart.js.map +1 -1
- package/dist/ErrorAlert.js +1 -1
- package/dist/ErrorAlert.js.map +1 -1
- package/dist/FormEditor/FormActions.d.ts +1 -1
- package/dist/FormEditor/FormActions.d.ts.map +1 -1
- package/dist/FormEditor/FormActions.js +1 -1
- package/dist/FormEditor/FormActions.js.map +1 -1
- package/dist/FormatControls/FormatControls.d.ts +1 -1
- package/dist/FormatControls/FormatControls.d.ts.map +1 -1
- package/dist/FormatControls/FormatControls.js +2 -2
- package/dist/FormatControls/FormatControls.js.map +1 -1
- package/dist/FormatControls/UnitSelector.d.ts +1 -1
- package/dist/FormatControls/UnitSelector.d.ts.map +1 -1
- package/dist/FormatControls/UnitSelector.js +1 -1
- package/dist/FormatControls/UnitSelector.js.map +1 -1
- package/dist/JSONEditor.js +1 -1
- package/dist/JSONEditor.js.map +1 -1
- package/dist/Legend/CompactLegend.js +1 -1
- package/dist/Legend/CompactLegend.js.map +1 -1
- package/dist/Legend/Legend.js +2 -2
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/Legend/LegendColorBadge.js +1 -1
- package/dist/Legend/LegendColorBadge.js.map +1 -1
- package/dist/Legend/ListLegend.js +1 -1
- package/dist/Legend/ListLegend.js.map +1 -1
- package/dist/Legend/ListLegendItem.js +1 -1
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/Legend/TableLegend.d.ts.map +1 -1
- package/dist/Legend/TableLegend.js +18 -4
- package/dist/Legend/TableLegend.js.map +1 -1
- package/dist/Legend/legend-model.d.ts +1 -1
- package/dist/Legend/legend-model.d.ts.map +1 -1
- package/dist/Legend/legend-model.js.map +1 -1
- package/dist/LinksEditor/LinkEditorForm.js +1 -1
- package/dist/LinksEditor/LinkEditorForm.js.map +1 -1
- package/dist/LinksEditor/LinksEditor.js +1 -1
- package/dist/LinksEditor/LinksEditor.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorColumn.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGrid.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -1
- package/dist/Overlay/Overlay.js +1 -1
- package/dist/Overlay/Overlay.js.map +1 -1
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js +1 -1
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js +1 -1
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
- package/dist/SortSelector/SortSelectorButtons.js +1 -1
- package/dist/SortSelector/SortSelectorButtons.js.map +1 -1
- package/dist/Table/InnerTable.js +1 -1
- package/dist/Table/InnerTable.js.map +1 -1
- package/dist/Table/Table.d.ts +1 -1
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +47 -14
- package/dist/Table/Table.js.map +1 -1
- package/dist/Table/TableBody.js +1 -1
- package/dist/Table/TableBody.js.map +1 -1
- package/dist/Table/TableCell.js +1 -1
- package/dist/Table/TableCell.js.map +1 -1
- package/dist/Table/TableCheckbox.js +1 -1
- package/dist/Table/TableCheckbox.js.map +1 -1
- package/dist/Table/TableFoot.js +1 -1
- package/dist/Table/TableFoot.js.map +1 -1
- package/dist/Table/TableHead.js +1 -1
- package/dist/Table/TableHead.js.map +1 -1
- package/dist/Table/TableHeaderCell.d.ts +20 -1
- package/dist/Table/TableHeaderCell.d.ts.map +1 -1
- package/dist/Table/TableHeaderCell.js +56 -24
- package/dist/Table/TableHeaderCell.js.map +1 -1
- package/dist/Table/TableRow.js +1 -1
- package/dist/Table/TableRow.js.map +1 -1
- package/dist/Table/TableToolbar.d.ts +46 -0
- package/dist/Table/TableToolbar.d.ts.map +1 -0
- package/dist/Table/TableToolbar.js +138 -0
- package/dist/Table/TableToolbar.js.map +1 -0
- package/dist/Table/VirtualizedTable.d.ts +7 -3
- package/dist/Table/VirtualizedTable.d.ts.map +1 -1
- package/dist/Table/VirtualizedTable.js +157 -123
- package/dist/Table/VirtualizedTable.js.map +1 -1
- package/dist/Table/VirtualizedTableContainer.d.ts.map +1 -1
- package/dist/Table/VirtualizedTableContainer.js +6 -2
- package/dist/Table/VirtualizedTableContainer.js.map +1 -1
- package/dist/Table/hooks/useFuzzySearch.d.ts +14 -0
- package/dist/Table/hooks/useFuzzySearch.d.ts.map +1 -0
- package/dist/Table/hooks/useFuzzySearch.js +62 -0
- package/dist/Table/hooks/useFuzzySearch.js.map +1 -0
- package/dist/Table/model/table-model.d.ts +78 -4
- package/dist/Table/model/table-model.d.ts.map +1 -1
- package/dist/Table/model/table-model.js +37 -19
- package/dist/Table/model/table-model.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.d.ts +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.d.ts.map +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.js +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.d.ts +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.d.ts.map +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.js +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.d.ts.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.js +25 -2
- package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.js +1 -1
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesMarker.js +1 -1
- package/dist/TimeSeriesTooltip/SeriesMarker.js.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts +1 -2
- package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.js +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.d.ts +2 -2
- package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.js +1 -2
- package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
- package/dist/TimeZoneSelector.js +1 -1
- package/dist/TimeZoneSelector.js.map +1 -1
- package/dist/ToolbarIconButton/ToolbarIconButton.js +1 -1
- package/dist/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
- package/dist/TransformsEditor/TransformEditor.d.ts +1 -1
- package/dist/TransformsEditor/TransformEditor.d.ts.map +1 -1
- package/dist/TransformsEditor/TransformEditor.js +1 -1
- package/dist/TransformsEditor/TransformEditor.js.map +1 -1
- package/dist/TransformsEditor/TransformEditorContainer.d.ts.map +1 -1
- package/dist/TransformsEditor/TransformEditorContainer.js +2 -2
- package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
- package/dist/TransformsEditor/TransformsEditor.d.ts +1 -1
- package/dist/TransformsEditor/TransformsEditor.d.ts.map +1 -1
- package/dist/TransformsEditor/TransformsEditor.js +1 -1
- package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.d.ts +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.d.ts.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.js +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.d.ts +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.d.ts.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.js +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.js.map +1 -1
- package/dist/YAxisLabel.js +1 -1
- package/dist/YAxisLabel.js.map +1 -1
- package/dist/cjs/ColorPicker/OptionsColorPicker.js +2 -2
- package/dist/cjs/ContentWithLegend/ContentWithLegend.js +2 -2
- package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +2 -2
- package/dist/cjs/FormatControls/FormatControls.js +4 -4
- package/dist/cjs/FormatControls/UnitSelector.js +3 -3
- package/dist/cjs/Legend/Legend.js +2 -2
- package/dist/cjs/Legend/TableLegend.js +16 -2
- package/dist/cjs/Table/Table.js +44 -11
- package/dist/cjs/Table/TableHeaderCell.js +54 -22
- package/dist/cjs/Table/TableToolbar.js +151 -0
- package/dist/cjs/Table/VirtualizedTable.js +155 -121
- package/dist/cjs/Table/VirtualizedTableContainer.js +5 -1
- package/dist/cjs/Table/hooks/useFuzzySearch.js +67 -0
- package/dist/cjs/Table/model/table-model.js +43 -19
- package/dist/cjs/TimeRangeSelector/TimeRangeSelector.js +23 -0
- package/dist/cjs/TimeSeriesTooltip/nearby-series.js +2 -3
- package/dist/cjs/TransformsEditor/TransformEditorContainer.js +2 -2
- package/dist/cjs/model/action.js +43 -0
- package/dist/cjs/model/bits.js +113 -0
- package/dist/cjs/model/bytes.js +115 -0
- package/dist/cjs/model/constants.js +23 -0
- package/dist/cjs/model/currency.js +126 -0
- package/dist/cjs/model/date.js +297 -0
- package/dist/cjs/model/decimal.js +72 -0
- package/dist/cjs/model/formatterCache.js +120 -0
- package/dist/cjs/model/index.js +17 -0
- package/dist/cjs/model/legend.js +101 -0
- package/dist/cjs/model/percent.js +82 -0
- package/dist/cjs/model/temperature.js +72 -0
- package/dist/cjs/model/thresholds.js +16 -0
- package/dist/cjs/model/throughput.js +161 -0
- package/dist/cjs/model/time.js +178 -0
- package/dist/cjs/model/transforms.js +29 -0
- package/dist/cjs/model/types.js +16 -0
- package/dist/cjs/model/units.js +186 -0
- package/dist/cjs/model/utils.js +48 -0
- package/dist/cjs/model/value-mapping.js +16 -0
- package/dist/cjs/theme/typography.js +1 -1
- package/dist/cjs/utils/axis.js +5 -5
- package/dist/cjs/utils/format.js +23 -5
- package/dist/cjs/utils/index.js +8 -0
- package/dist/cjs/utils/mathjs.js +14 -3
- package/dist/cjs/utils/regexp.js +54 -0
- package/dist/cjs/utils/request-interpolation.js +99 -0
- package/dist/cjs/utils/text.js +52 -0
- package/dist/cjs/utils/time-series-data.js +141 -0
- package/dist/cjs/utils/trace-data.js +25 -0
- package/dist/cjs/utils/transform-data.js +157 -0
- package/dist/cjs/utils/types.js +16 -0
- package/dist/cjs/utils/value-mapping.js +105 -0
- package/dist/context/ChartsProvider.js +1 -1
- package/dist/context/ChartsProvider.js.map +1 -1
- package/dist/context/ItemActionsProvider.js +1 -1
- package/dist/context/ItemActionsProvider.js.map +1 -1
- package/dist/context/SelectionProvider.js +1 -1
- package/dist/context/SelectionProvider.js.map +1 -1
- package/dist/context/SnackbarProvider.js +1 -1
- package/dist/context/SnackbarProvider.js.map +1 -1
- package/dist/context/TimeZoneProvider.js +1 -1
- package/dist/context/TimeZoneProvider.js.map +1 -1
- package/dist/controls/TextField.js +1 -1
- package/dist/controls/TextField.js.map +1 -1
- package/dist/model/action.d.ts +4 -0
- package/dist/model/action.d.ts.map +1 -0
- package/dist/model/action.js +27 -0
- package/dist/model/action.js.map +1 -0
- package/dist/model/bits.d.ts +12 -0
- package/dist/model/bits.d.ts.map +1 -0
- package/dist/model/bits.js +89 -0
- package/dist/model/bits.js.map +1 -0
- package/dist/model/bytes.d.ts +12 -0
- package/dist/model/bytes.d.ts.map +1 -0
- package/dist/model/bytes.js +91 -0
- package/dist/model/bytes.js.map +1 -0
- package/dist/model/constants.d.ts +2 -0
- package/dist/model/constants.d.ts.map +1 -0
- package/dist/model/constants.js +15 -0
- package/dist/model/constants.js.map +1 -0
- package/dist/model/currency.d.ts +11 -0
- package/dist/model/currency.d.ts.map +1 -0
- package/dist/model/currency.js +107 -0
- package/dist/model/currency.js.map +1 -0
- package/dist/model/date.d.ts +28 -0
- package/dist/model/date.d.ts.map +1 -0
- package/dist/model/date.js +278 -0
- package/dist/model/date.js.map +1 -0
- package/dist/model/decimal.d.ts +12 -0
- package/dist/model/decimal.d.ts.map +1 -0
- package/dist/model/decimal.js +53 -0
- package/dist/model/decimal.js.map +1 -0
- package/dist/model/formatterCache.d.ts +11 -0
- package/dist/model/formatterCache.d.ts.map +1 -0
- package/dist/model/formatterCache.js +104 -0
- package/dist/model/formatterCache.js.map +1 -0
- package/dist/model/index.d.ts +17 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +17 -0
- package/dist/model/index.js.map +1 -1
- package/dist/model/legend.d.ts +19 -0
- package/dist/model/legend.d.ts.map +1 -0
- package/dist/model/legend.js +61 -0
- package/dist/model/legend.js.map +1 -0
- package/dist/model/percent.d.ts +11 -0
- package/dist/model/percent.d.ts.map +1 -0
- package/dist/model/percent.js +63 -0
- package/dist/model/percent.js.map +1 -0
- package/dist/model/temperature.d.ts +11 -0
- package/dist/model/temperature.d.ts.map +1 -0
- package/dist/model/temperature.js +53 -0
- package/dist/model/temperature.js.map +1 -0
- package/dist/model/theme.d.ts +1 -1
- package/dist/model/theme.d.ts.map +1 -1
- package/dist/model/theme.js.map +1 -1
- package/dist/model/thresholds.d.ts +16 -0
- package/dist/model/thresholds.d.ts.map +1 -0
- package/dist/model/thresholds.js +15 -0
- package/dist/model/thresholds.js.map +1 -0
- package/dist/model/throughput.d.ts +12 -0
- package/dist/model/throughput.d.ts.map +1 -0
- package/dist/model/throughput.js +142 -0
- package/dist/model/throughput.js.map +1 -0
- package/dist/model/time.d.ts +23 -0
- package/dist/model/time.d.ts.map +1 -0
- package/dist/model/time.js +158 -0
- package/dist/model/time.js.map +1 -0
- package/dist/model/transforms.d.ts +43 -0
- package/dist/model/transforms.d.ts.map +1 -0
- package/dist/model/transforms.js +22 -0
- package/dist/model/transforms.js.map +1 -0
- package/dist/model/types.d.ts +56 -0
- package/dist/model/types.d.ts.map +1 -0
- package/dist/model/types.js +15 -0
- package/dist/model/types.js.map +1 -0
- package/dist/model/units.d.ts +105 -0
- package/dist/model/units.d.ts.map +1 -0
- package/dist/model/units.js +132 -0
- package/dist/model/units.js.map +1 -0
- package/dist/model/utils.d.ts +4 -0
- package/dist/model/utils.d.ts.map +1 -0
- package/dist/model/utils.js +32 -0
- package/dist/model/utils.js.map +1 -0
- package/dist/model/value-mapping.d.ts +35 -0
- package/dist/model/value-mapping.d.ts.map +1 -0
- package/dist/model/value-mapping.js +15 -0
- package/dist/model/value-mapping.js.map +1 -0
- package/dist/test/render.js +1 -1
- package/dist/test/render.js.map +1 -1
- package/dist/theme/typography.js +1 -1
- package/dist/theme/typography.js.map +1 -1
- package/dist/utils/axis.d.ts +1 -1
- package/dist/utils/axis.d.ts.map +1 -1
- package/dist/utils/axis.js +1 -1
- package/dist/utils/axis.js.map +1 -1
- package/dist/utils/format.d.ts +2 -1
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +20 -5
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +8 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/mathjs.d.ts +8 -1
- package/dist/utils/mathjs.d.ts.map +1 -1
- package/dist/utils/mathjs.js +5 -2
- package/dist/utils/mathjs.js.map +1 -1
- package/dist/utils/regexp.d.ts +11 -0
- package/dist/utils/regexp.d.ts.map +1 -0
- package/dist/utils/regexp.js +42 -0
- package/dist/utils/regexp.js.map +1 -0
- package/dist/utils/request-interpolation.d.ts +6 -0
- package/dist/utils/request-interpolation.d.ts.map +1 -0
- package/dist/utils/request-interpolation.js +83 -0
- package/dist/utils/request-interpolation.js.map +1 -0
- package/dist/utils/text.d.ts +8 -0
- package/dist/utils/text.d.ts.map +1 -0
- package/dist/utils/text.js +39 -0
- package/dist/utils/text.js.map +1 -0
- package/dist/utils/time-series-data.d.ts +15 -0
- package/dist/utils/time-series-data.d.ts.map +1 -0
- package/dist/utils/time-series-data.js +130 -0
- package/dist/utils/time-series-data.js.map +1 -0
- package/dist/utils/trace-data.d.ts +37 -0
- package/dist/utils/trace-data.d.ts.map +1 -0
- package/dist/utils/trace-data.js +17 -0
- package/dist/utils/trace-data.js.map +1 -0
- package/dist/utils/transform-data.d.ts +7 -0
- package/dist/utils/transform-data.d.ts.map +1 -0
- package/dist/utils/transform-data.js +214 -0
- package/dist/utils/transform-data.js.map +1 -0
- package/dist/utils/types.d.ts +2 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +15 -0
- package/dist/utils/types.js.map +1 -0
- package/dist/utils/value-mapping.d.ts +3 -0
- package/dist/utils/value-mapping.d.ts.map +1 -0
- package/dist/utils/value-mapping.js +97 -0
- package/dist/utils/value-mapping.js.map +1 -0
- package/dist/utils/variable-interpolation.d.ts +1 -0
- package/dist/utils/variable-interpolation.d.ts.map +1 -1
- package/dist/utils/variable-interpolation.js.map +1 -1
- package/package.json +5 -3
package/dist/Table/Table.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Table/Table.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, useTheme } from '@mui/material';\nimport {\n ColumnDef,\n OnChangeFn,\n Row,\n RowSelectionState,\n SortingState,\n Table as TanstackTable,\n getCoreRowModel,\n getPaginationRowModel,\n getSortedRowModel,\n useReactTable,\n} from '@tanstack/react-table';\nimport { ReactElement, useCallback, useMemo } from 'react';\nimport { TableCheckbox } from './TableCheckbox';\nimport { VirtualizedTable } from './VirtualizedTable';\nimport { DEFAULT_COLUMN_WIDTH, TableProps, persesColumnsToTanstackColumns } from './model/table-model';\n\nconst DEFAULT_GET_ROW_ID = (data: unknown, index: number): string => {\n return `${index}`;\n};\n\n// Setting these defaults one enables them to be consistent across renders instead\n// of being recreated every time, which can be important for perf because react\n// does not do deep equality checking for objects and arrays.\nconst DEFAULT_ROW_SELECTION: NonNullable<TableProps<unknown>['rowSelection']> = {};\nconst DEFAULT_SORTING: NonNullable<TableProps<unknown>['sorting']> = [];\n\n/**\n * Component used to render tabular data in Perses use cases. This component is\n * **not** intended to be a general use data table for use cases unrelated to Perses.\n *\n * **Note: This component is currently experimental and is likely to have significant breaking changes in the near future. Use with caution outside of the core Perses codebase.**\n */\nexport function Table<TableData>({\n data,\n columns,\n cellConfigs,\n density = 'standard',\n defaultColumnWidth = DEFAULT_COLUMN_WIDTH,\n defaultColumnHeight = 'auto',\n checkboxSelection,\n onRowSelectionChange,\n onSortingChange,\n getCheckboxColor,\n getRowId = DEFAULT_GET_ROW_ID,\n rowSelection = DEFAULT_ROW_SELECTION,\n sorting = DEFAULT_SORTING,\n getItemActions,\n hasItemActions,\n pagination,\n onPaginationChange,\n rowSelectionVariant = 'standard',\n ...otherProps\n}: TableProps<TableData>): ReactElement {\n const theme = useTheme();\n\n const handleRowSelectionChange: OnChangeFn<RowSelectionState> = (rowSelectionUpdater) => {\n const newRowSelection =\n typeof rowSelectionUpdater === 'function' ? rowSelectionUpdater(rowSelection) : rowSelectionUpdater;\n onRowSelectionChange?.(newRowSelection);\n };\n\n const handleRowSelectionEvent = useCallback(\n (table: TanstackTable<TableData>, row: Row<TableData>, isModified: boolean) => {\n if (rowSelectionVariant === 'standard' || isModified) {\n row.toggleSelected();\n } else {\n // Legend variant (when action not modified with shift/meta key).\n // Note that this behavior needs to be kept in sync with behavior in\n // the Legend component for list-based legends.\n if (row.getIsSelected() && !table.getIsAllRowsSelected()) {\n // Row was already selected. Revert to select all.\n table.toggleAllRowsSelected();\n } else {\n // Focus the selected row.\n onRowSelectionChange?.({\n [row.id]: true,\n });\n }\n }\n },\n [onRowSelectionChange, rowSelectionVariant]\n );\n\n const handleCheckboxChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>, table: TanstackTable<TableData>, row: Row<TableData>) => {\n const nativePointerEvent =\n e.nativeEvent && (e.nativeEvent instanceof MouseEvent || e.nativeEvent instanceof KeyboardEvent)\n ? (e.nativeEvent as PointerEvent)\n : undefined;\n const isModifed = !!nativePointerEvent?.metaKey || !!nativePointerEvent?.shiftKey;\n handleRowSelectionEvent(table, row, isModifed);\n },\n [handleRowSelectionEvent]\n );\n\n const handleSortingChange: OnChangeFn<SortingState> = (sortingUpdater) => {\n const newSorting = typeof sortingUpdater === 'function' ? sortingUpdater(sorting) : sortingUpdater;\n onSortingChange?.(newSorting);\n };\n\n const actionsColumn: ColumnDef<TableData> = useMemo(() => {\n return {\n id: 'itemActions',\n header: 'Actions',\n cell: ({ row }): ReactElement => {\n return (\n <Stack direction=\"row\" alignItems=\"center\">\n {getItemActions?.({ id: row.id, data: row.original })}\n </Stack>\n );\n },\n enableSorting: false,\n };\n }, [getItemActions]);\n\n const checkboxColumn: ColumnDef<TableData> = useMemo(() => {\n return {\n id: 'checkboxRowSelect',\n size: 28,\n header: ({ table }): ReactElement => {\n return (\n <TableCheckbox\n checked={table.getIsAllRowsSelected()}\n indeterminate={table.getIsSomeRowsSelected()}\n onChange={table.getToggleAllRowsSelectedHandler()}\n color={theme.palette.text.primary}\n density={density}\n />\n );\n },\n cell: ({ row, table }): ReactElement => {\n return (\n <TableCheckbox\n checked={row.getIsSelected()}\n indeterminate={row.getIsSomeSelected()}\n onChange={(e) => {\n handleCheckboxChange(e, table, row);\n }}\n color={getCheckboxColor?.(row.original)}\n density={density}\n />\n );\n },\n enableSorting: false,\n };\n }, [theme.palette.text.primary, density, getCheckboxColor, handleCheckboxChange]);\n\n const tableColumns: Array<ColumnDef<TableData>> = useMemo(() => {\n const initTableColumns = persesColumnsToTanstackColumns(columns);\n\n if (hasItemActions) {\n initTableColumns.unshift(actionsColumn);\n }\n\n if (checkboxSelection) {\n initTableColumns.unshift(checkboxColumn);\n }\n\n return initTableColumns;\n }, [checkboxColumn, checkboxSelection, columns, hasItemActions, actionsColumn]);\n\n const table = useReactTable({\n data,\n columns: tableColumns,\n getRowId,\n getCoreRowModel: getCoreRowModel(),\n getSortedRowModel: getSortedRowModel(),\n getPaginationRowModel: pagination ? getPaginationRowModel() : undefined,\n // without this setting, the getPaginationRowModel setting persists and it is not possible to switch from paginated to unpaginated\n // can be removed once https://github.com/TanStack/table/pull/5974 is merged\n manualPagination: !pagination,\n enableRowSelection: !!checkboxSelection,\n onRowSelectionChange: handleRowSelectionChange,\n onSortingChange: handleSortingChange,\n // For now, defaulting to sort by descending first. We can expose the ability\n // to customize it if/when we have use cases for it.\n sortDescFirst: true,\n state: {\n rowSelection,\n sorting,\n ...(pagination ? { pagination } : {}),\n },\n });\n\n const handleRowClick = useCallback(\n (e: React.MouseEvent<HTMLDivElement, MouseEvent>, rowId: string) => {\n const row = table.getRow(rowId);\n const isModifiedClick = e.metaKey || e.shiftKey;\n handleRowSelectionEvent(table, row, isModifiedClick);\n },\n [handleRowSelectionEvent, table]\n );\n\n return (\n <VirtualizedTable\n {...otherProps}\n density={density}\n defaultColumnWidth={defaultColumnWidth}\n defaultColumnHeight={defaultColumnHeight}\n onRowClick={handleRowClick}\n rows={table.getRowModel().rows}\n columns={table.getAllFlatColumns()}\n headers={table.getHeaderGroups()}\n cellConfigs={cellConfigs}\n pagination={pagination}\n onPaginationChange={onPaginationChange}\n rowCount={table.getRowCount()}\n />\n );\n}\n"],"names":["Stack","useTheme","getCoreRowModel","getPaginationRowModel","getSortedRowModel","useReactTable","useCallback","useMemo","TableCheckbox","VirtualizedTable","DEFAULT_COLUMN_WIDTH","persesColumnsToTanstackColumns","DEFAULT_GET_ROW_ID","data","index","DEFAULT_ROW_SELECTION","DEFAULT_SORTING","Table","columns","cellConfigs","density","defaultColumnWidth","defaultColumnHeight","checkboxSelection","onRowSelectionChange","onSortingChange","getCheckboxColor","getRowId","rowSelection","sorting","getItemActions","hasItemActions","pagination","onPaginationChange","rowSelectionVariant","otherProps","theme","handleRowSelectionChange","rowSelectionUpdater","newRowSelection","handleRowSelectionEvent","table","row","isModified","toggleSelected","getIsSelected","getIsAllRowsSelected","toggleAllRowsSelected","id","handleCheckboxChange","e","nativePointerEvent","nativeEvent","MouseEvent","KeyboardEvent","undefined","isModifed","metaKey","shiftKey","handleSortingChange","sortingUpdater","newSorting","actionsColumn","header","cell","direction","alignItems","original","enableSorting","checkboxColumn","size","checked","indeterminate","getIsSomeRowsSelected","onChange","getToggleAllRowsSelectedHandler","color","palette","text","primary","getIsSomeSelected","tableColumns","initTableColumns","unshift","manualPagination","enableRowSelection","sortDescFirst","state","handleRowClick","rowId","getRow","isModifiedClick","onRowClick","rows","getRowModel","getAllFlatColumns","headers","getHeaderGroups","rowCount","getRowCount"],"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,QAAQ,QAAQ,gBAAgB;AAChD,SAOEC,eAAe,EACfC,qBAAqB,EACrBC,iBAAiB,EACjBC,aAAa,QACR,wBAAwB;AAC/B,SAAuBC,WAAW,EAAEC,OAAO,QAAQ,QAAQ;AAC3D,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,oBAAoB,EAAcC,8BAA8B,QAAQ,sBAAsB;AAEvG,MAAMC,qBAAqB,CAACC,M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F,MAAMgC,eAA4C1E,QAAQ;QACxD,MAAM2E,mBAAmBvE,+BAA+BO;QAExD,IAAIa,gBAAgB;YAClBmD,iBAAiBC,OAAO,CAACrB;QAC3B;QAEA,IAAIvC,mBAAmB;YACrB2D,iBAAiBC,OAAO,CAACd;QAC3B;QAEA,OAAOa;IACT,GAAG;QAACb;QAAgB9C;QAAmBL;QAASa;QAAgB+B;KAAc;IAE9E,MAAMrB,QAAQpC,cAAc;QAC1BQ;QACAK,SAAS+D;QACTtD;QACAzB,iBAAiBA;QACjBE,mBAAmBA;QACnBD,uBAAuB6B,aAAa7B,0BAA0BoD;QAC9D,kIAAkI;QAClI,4EAA4E;QAC5E6B,kBAAkB,CAACpD;QACnBqD,oBAAoB,CAAC,CAAC9D;QACtBC,sBAAsBa;QACtBZ,iBAAiBkC;QACjB,6EAA6E;QAC7E,oDAAoD;QACpD2B,eAAe;QACfC,OAAO;YACL3D;YACAC;YACA,GAAIG,aAAa;gBAAEA;YAAW,IAAI,CAAC,CAAC;QACtC;IACF;IAEA,MAAMwD,iBAAiBlF,YACrB,CAAC4C,GAAiDuC;QAChD,MAAM/C,MAAMD,MAAMiD,MAAM,CAACD;QACzB,MAAME,kBAAkBzC,EAAEO,OAAO,IAAIP,EAAEQ,QAAQ;QAC/ClB,wBAAwBC,OAAOC,KAAKiD;IACtC,GACA;QAACnD;QAAyBC;KAAM;IAGlC,qBACE,KAAChC;QACE,GAAG0B,UAAU;QACdf,SAASA;QACTC,oBAAoBA;QACpBC,qBAAqBA;QACrBsE,YAAYJ;QACZK,MAAMpD,MAAMqD,WAAW,GAAGD,IAAI;QAC9B3E,SAASuB,MAAMsD,iBAAiB;QAChCC,SAASvD,MAAMwD,eAAe;QAC9B9E,aAAaA;QACba,YAAYA;QACZC,oBAAoBA;QACpBiE,UAAUzD,MAAM0D,WAAW;;AAGjC"}
|
|
1
|
+
{"version":3,"sources":["../../src/Table/Table.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, useTheme } from '@mui/material';\nimport {\n ColumnDef,\n ExpandedState,\n getCoreRowModel,\n getExpandedRowModel,\n getPaginationRowModel,\n getSortedRowModel,\n OnChangeFn,\n Row,\n RowSelectionState,\n SortingState,\n Table as TanstackTable,\n useReactTable,\n VisibilityState,\n} from '@tanstack/react-table';\nimport { ReactElement, useCallback, useMemo, useState } from 'react';\nimport { useFuzzySearch } from './hooks/useFuzzySearch';\nimport { TableCheckbox } from './TableCheckbox';\nimport { VirtualizedTable } from './VirtualizedTable';\nimport { DEFAULT_COLUMN_WIDTH, persesColumnsToTanstackColumns, TableProps } from './model/table-model';\n\nconst DEFAULT_GET_ROW_ID = (data: unknown, index: number): string => {\n return `${index}`;\n};\n\n// Setting these defaults one enables them to be consistent across renders instead\n// of being recreated every time, which can be important for perf because react\n// does not do deep equality checking for objects and arrays.\nconst DEFAULT_ROW_SELECTION: NonNullable<TableProps<unknown>['rowSelection']> = {};\nconst DEFAULT_SORTING: NonNullable<TableProps<unknown>['sorting']> = [];\n\n/**\n * Component used to render tabular data in Perses use cases. This component is\n * **not** intended to be a general use data table for use cases unrelated to Perses.\n *\n * **Note: This component is currently experimental and is likely to have significant breaking changes in the near future. Use with caution outside of the core Perses codebase.**\n */\nexport function Table<TableData>({\n data,\n columns,\n cellConfigs,\n density = 'standard',\n defaultColumnWidth = DEFAULT_COLUMN_WIDTH,\n defaultColumnHeight = 'auto',\n checkboxSelection,\n onRowSelectionChange,\n onSortingChange,\n getCheckboxColor,\n getRowId = DEFAULT_GET_ROW_ID,\n rowSelection = DEFAULT_ROW_SELECTION,\n sorting = DEFAULT_SORTING,\n getItemActions,\n hasItemActions,\n pagination,\n onPaginationChange,\n rowSelectionVariant = 'standard',\n getSubRows,\n hiddenColumns,\n tableToolbarConfig,\n columnResizeMode = 'onChange',\n defaultColumnConfig,\n ...otherProps\n}: TableProps<TableData>): ReactElement {\n const theme = useTheme();\n\n const hasSubRows = !!getSubRows;\n\n const [expanded, setExpanded] = useState<ExpandedState>({});\n\n const { globalFilter, setGlobalFilter, fuzzySearchOptions } = useFuzzySearch<TableData>(\n tableToolbarConfig?.isSearchEnabled,\n tableToolbarConfig?.fuzzyMatchThreshold ?? 'CONTAINS',\n expanded,\n setExpanded\n );\n\n const [columnVisibility, setColumnVisibility] = useState<VisibilityState>(\n hiddenColumns?.reduce((acc, columnId) => ({ ...acc, [columnId]: false }), {}) ?? {}\n );\n\n const handleRowSelectionChange: OnChangeFn<RowSelectionState> = (rowSelectionUpdater) => {\n const newRowSelection =\n typeof rowSelectionUpdater === 'function' ? rowSelectionUpdater(rowSelection) : rowSelectionUpdater;\n onRowSelectionChange?.(newRowSelection);\n };\n\n const handleRowSelectionEvent = useCallback(\n (table: TanstackTable<TableData>, row: Row<TableData>, isModified: boolean) => {\n if (rowSelectionVariant === 'standard' || isModified) {\n row.toggleSelected();\n } else {\n // Legend variant (when action not modified with shift/meta key).\n // Note that this behavior needs to be kept in sync with behavior in\n // the Legend component for list-based legends.\n if (row.getIsSelected() && !table.getIsAllRowsSelected()) {\n // Row was already selected. Revert to select all.\n table.toggleAllRowsSelected();\n } else {\n // Focus the selected row.\n onRowSelectionChange?.({\n [row.id]: true,\n });\n }\n }\n },\n [onRowSelectionChange, rowSelectionVariant]\n );\n\n const handleCheckboxChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>, table: TanstackTable<TableData>, row: Row<TableData>) => {\n const nativePointerEvent =\n e.nativeEvent && (e.nativeEvent instanceof MouseEvent || e.nativeEvent instanceof KeyboardEvent)\n ? (e.nativeEvent as PointerEvent)\n : undefined;\n const isModifed = !!nativePointerEvent?.metaKey || !!nativePointerEvent?.shiftKey;\n handleRowSelectionEvent(table, row, isModifed);\n },\n [handleRowSelectionEvent]\n );\n\n const handleSortingChange: OnChangeFn<SortingState> = (sortingUpdater) => {\n const newSorting = typeof sortingUpdater === 'function' ? sortingUpdater(sorting) : sortingUpdater;\n onSortingChange?.(newSorting);\n };\n\n const actionsColumn: ColumnDef<TableData> = useMemo(() => {\n return {\n id: 'itemActions',\n header: 'Actions',\n cell: ({ row }): ReactElement => {\n return (\n <Stack direction=\"row\" alignItems=\"center\">\n {getItemActions?.({ id: row.id, data: row.original })}\n </Stack>\n );\n },\n enableSorting: false,\n enableResizing: false,\n };\n }, [getItemActions]);\n\n const checkboxColumn: ColumnDef<TableData> = useMemo(() => {\n return {\n id: 'checkboxRowSelect',\n size: 28,\n header: ({ table }): ReactElement => {\n return (\n <TableCheckbox\n checked={table.getIsAllRowsSelected()}\n indeterminate={table.getIsSomeRowsSelected()}\n onChange={table.getToggleAllRowsSelectedHandler()}\n color={theme.palette.text.primary}\n density={density}\n />\n );\n },\n cell: ({ row, table }): ReactElement => {\n return (\n <TableCheckbox\n checked={row.getIsSelected()}\n indeterminate={row.getIsSomeSelected()}\n onChange={(e) => {\n handleCheckboxChange(e, table, row);\n }}\n color={getCheckboxColor?.(row.original)}\n density={density}\n />\n );\n },\n enableSorting: false,\n enableResizing: false,\n };\n }, [theme.palette.text.primary, density, getCheckboxColor, handleCheckboxChange]);\n\n const tableColumns: Array<ColumnDef<TableData>> = useMemo(() => {\n const initTableColumns = persesColumnsToTanstackColumns(columns, defaultColumnConfig);\n\n if (hasItemActions) {\n initTableColumns.unshift(actionsColumn);\n }\n\n if (checkboxSelection) {\n initTableColumns.unshift(checkboxColumn);\n }\n\n return initTableColumns;\n }, [columns, defaultColumnConfig, hasItemActions, checkboxSelection, actionsColumn, checkboxColumn]);\n\n const table = useReactTable({\n data,\n columns: tableColumns,\n getRowId: getRowId,\n getCoreRowModel: getCoreRowModel(),\n getSortedRowModel: getSortedRowModel(),\n getPaginationRowModel: pagination ? getPaginationRowModel() : undefined,\n // without this setting, the getPaginationRowModel setting persists and it is not possible to switch from paginated to unpaginated\n // can be removed once https://github.com/TanStack/table/pull/5974 is merged\n manualPagination: !pagination,\n enableRowSelection: !!checkboxSelection,\n onRowSelectionChange: handleRowSelectionChange,\n onSortingChange: handleSortingChange,\n onColumnVisibilityChange: setColumnVisibility,\n getSubRows: getSubRows,\n getExpandedRowModel: hasSubRows ? getExpandedRowModel() : undefined,\n ...fuzzySearchOptions,\n // For now, defaulting to sort by descending first. We can expose the ability\n // to customize it if/when we have use cases for it.\n sortDescFirst: true,\n columnResizeMode,\n onExpandedChange: setExpanded,\n state: {\n rowSelection,\n sorting,\n globalFilter: tableToolbarConfig?.isSearchEnabled ? globalFilter : undefined,\n columnVisibility,\n ...(pagination ? { pagination } : {}),\n expanded,\n },\n });\n\n const handleRowClick = useCallback(\n (e: React.MouseEvent<HTMLDivElement, MouseEvent>, rowId: string) => {\n const row = table.getRow(rowId);\n const isModifiedClick = e.metaKey || e.shiftKey;\n handleRowSelectionEvent(table, row, isModifiedClick);\n },\n [handleRowSelectionEvent, table]\n );\n\n return (\n <VirtualizedTable\n {...otherProps}\n density={density}\n defaultColumnWidth={defaultColumnWidth}\n defaultColumnHeight={defaultColumnHeight}\n onRowClick={handleRowClick}\n rows={table.getRowModel().rows}\n columns={table.getVisibleFlatColumns()}\n columnSizing={table.getState().columnSizing}\n columnSizingInfo={table.getState().columnSizingInfo}\n headers={table.getHeaderGroups()}\n cellConfigs={cellConfigs}\n pagination={pagination}\n onPaginationChange={onPaginationChange}\n rowCount={table.getRowCount()}\n toolbarConfig={{\n isSearchEnabled: tableToolbarConfig?.isSearchEnabled,\n globalFilter,\n onGlobalFilterChange: setGlobalFilter,\n isColumnFilterEnabled: tableToolbarConfig?.isColumnFilterEnabled,\n columns: table.getAllColumns(),\n columnFilterMenuMaxHeight: tableToolbarConfig?.columnFilterMenuMaxHeight,\n isExpandAllEnabled: hasSubRows,\n isAllExpanded: table.getIsAllRowsExpanded(),\n onExpandAllChange: table.getToggleAllRowsExpandedHandler(),\n }}\n />\n );\n}\n"],"names":["Stack","useTheme","getCoreRowModel","getExpandedRowModel","getPaginationRowModel","getSortedRowModel","useReactTable","useCallback","useMemo","useState","useFuzzySearch","TableCheckbox","VirtualizedTable","DEFAULT_COLUMN_WIDTH","persesColumnsToTanstackColumns","DEFAULT_GET_ROW_ID","data","index","DEFAULT_ROW_SELECTION","DEFAULT_SORTING","Table","columns","cellConfigs","density","defaultColumnWidth","defaultColumnHeight","checkboxSelection","onRowSelectionChange","onSortingChange","getCheckboxColor","getRowId","rowSelection","sorting","getItemActions","hasItemActions","pagination","onPaginationChange","rowSelectionVariant","getSubRows","hiddenColumns","tableToolbarConfig","columnResizeMode","defaultColumnConfig","otherProps","theme","hasSubRows","expanded","setExpanded","globalFilter","setGlobalFilter","fuzzySearchOptions","isSearchEnabled","fuzzyMatchThreshold","columnVisibility","setColumnVisibility","reduce","acc","columnId","handleRowSelectionChange","rowSelectionUpdater","newRowSelection","handleRowSelectionEvent","table","row","isModified","toggleSelected","getIsSelected","getIsAllRowsSelected","toggleAllRowsSelected","id","handleCheckboxChange","e","nativePointerEvent","nativeEvent","MouseEvent","KeyboardEvent","undefined","isModifed","metaKey","shiftKey","handleSortingChange","sortingUpdater","newSorting","actionsColumn","header","cell","direction","alignItems","original","enableSorting","enableResizing","checkboxColumn","size","checked","indeterminate","getIsSomeRowsSelected","onChange","getToggleAllRowsSelectedHandler","color","palette","text","primary","getIsSomeSelected","tableColumns","initTableColumns","unshift","manualPagination","enableRowSelection","onColumnVisibilityChange","sortDescFirst","onExpandedChange","state","handleRowClick","rowId","getRow","isModifiedClick","onRowClick","rows","getRowModel","getVisibleFlatColumns","columnSizing","getState","columnSizingInfo","headers","getHeaderGroups","rowCount","getRowCount","toolbarConfig","onGlobalFilterChange","isColumnFilterEnabled","getAllColumns","columnFilterMenuMaxHeight","isExpandAllEnabled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ACnDC,SAAS7D,MAAM8D,eAAe;QAC9BtG,aAAaA;QACba,YAAYA;QACZC,oBAAoBA;QACpByF,UAAU/D,MAAMgE,WAAW;QAC3BC,eAAe;YACb5E,iBAAiBX,oBAAoBW;YACrCH;YACAgF,sBAAsB/E;YACtBgF,uBAAuBzF,oBAAoByF;YAC3C5G,SAASyC,MAAMoE,aAAa;YAC5BC,2BAA2B3F,oBAAoB2F;YAC/CC,oBAAoBvF;YACpBwF,eAAevE,MAAMwE,oBAAoB;YACzCC,mBAAmBzE,MAAM0E,+BAA+B;QAC1D;;AAGN"}
|
package/dist/Table/TableBody.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { TableBody as MuiTableBody } from '@mui/material';
|
|
15
15
|
import { forwardRef } from 'react';
|
|
16
16
|
export const TableBody = /*#__PURE__*/ forwardRef(function TableBody(props, ref) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Table/TableBody.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 { TableBody as MuiTableBody, TableBodyProps as MuiTableBodyProps } from '@mui/material';\nimport { forwardRef } from 'react';\n\ntype TableBodyProps = MuiTableBodyProps;\n\nexport const TableBody = forwardRef<HTMLTableSectionElement, TableBodyProps>(function TableBody(props, ref) {\n return <MuiTableBody {...props} ref={ref} />;\n});\n"],"names":["TableBody","MuiTableBody","forwardRef","props","ref"],"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
|
|
1
|
+
{"version":3,"sources":["../../src/Table/TableBody.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 { TableBody as MuiTableBody, TableBodyProps as MuiTableBodyProps } from '@mui/material';\nimport { forwardRef } from 'react';\n\ntype TableBodyProps = MuiTableBodyProps;\n\nexport const TableBody = forwardRef<HTMLTableSectionElement, TableBodyProps>(function TableBody(props, ref) {\n return <MuiTableBody {...props} ref={ref} />;\n});\n"],"names":["TableBody","MuiTableBody","forwardRef","props","ref"],"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,aAAaC,YAAY,QAA6C,gBAAgB;AAC/F,SAASC,UAAU,QAAQ,QAAQ;AAInC,OAAO,MAAMF,0BAAYE,WAAoD,SAASF,UAAUG,KAAK,EAAEC,GAAG;IACxG,qBAAO,KAACH;QAAc,GAAGE,KAAK;QAAEC,KAAKA;;AACvC,GAAG"}
|
package/dist/Table/TableCell.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { Box, Link, TableCell as MuiTableCell, styled, useTheme } from '@mui/material';
|
|
15
15
|
import { useEffect, useMemo, useRef } from 'react';
|
|
16
16
|
import { hasDataFieldPatterns, replaceDataFields } from '../utils/data-field-interpolation';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Table/TableCell.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 {\n Box,\n Link,\n TableCell as MuiTableCell,\n TableCellProps as MuiTableCellProps,\n styled,\n useTheme,\n} from '@mui/material';\nimport { ReactElement, useEffect, useMemo, useRef } from 'react';\nimport { hasDataFieldPatterns, replaceDataFields } from '../utils/data-field-interpolation';\nimport { DataLink, TableCellAlignment, TableDensity, getTableCellLayout } from './model/table-model';\n\nconst StyledMuiTableCell = styled(MuiTableCell)(({ theme }) => ({\n padding: 0,\n backgroundColor: 'inherit',\n\n '&.MuiTableCell-head': {\n // Important to avoid scrolling behind the header showing through.\n backgroundColor: theme.palette.background.default,\n },\n '&:focus-visible': {\n outline: `solid 1px ${theme.palette.primary.main}`,\n // Move inward a little to avoid getting cut off when focusing on items\n // at the edge of the table.\n outlineOffset: '-1px',\n borderRadius: 0,\n },\n}));\n\nexport interface TableCellProps extends Omit<MuiTableCellProps, 'tabIndex' | 'align'> {\n density: TableDensity;\n defaultColumnHeight?: 'auto' | number;\n\n // These values are used to adjust the spacing for the first/last columns.\n isLastColumn: boolean;\n isFirstColumn: boolean;\n\n align?: TableCellAlignment;\n\n /**\n * Additional information to be displayed when hovering over the cell. This\n * may be the full cell value (e.g. to enable the user to see the full value\n * if it is ellipsized to fit into the space) or some other descriptive text\n * that is useful for the user.\n *\n * The hover behavior is currently managed with the `title` attribute, but this\n * may be changed to a tooltip in the future.\n */\n description?: string;\n\n /**\n * How the cell should behave related to focus.\n * - `trigger-focus`: the cell should be auto-focused when it renders.\n * - `focus-next`: the cell should have tabindex=\"0\", so that it will be\n * focused the next time someone tabs with a keyboard.\n * - `none`: the cell should have tabindex=\"-1\", so it is not focused by\n * keyboard interactions at this time.\n */\n focusState?: 'trigger-focus' | 'focus-next' | 'none';\n onFocusTrigger?: (e: React.MouseEvent<HTMLTableCellElement> | React.KeyboardEvent<HTMLTableCellElement>) => void;\n color?: string;\n backgroundColor?: string;\n dataLink?: DataLink;\n adjacentCellsValuesMap?: Record<string, string>;\n}\n\nexport function TableCell({\n children,\n density,\n variant,\n width,\n defaultColumnHeight,\n focusState = 'none',\n onFocusTrigger,\n isFirstColumn,\n isLastColumn,\n description,\n align,\n color,\n backgroundColor,\n dataLink,\n adjacentCellsValuesMap,\n ...otherProps\n}: TableCellProps): ReactElement {\n const theme = useTheme();\n const elRef = useRef<HTMLTableCellElement>();\n\n const isHeader = variant === 'head';\n\n useEffect(() => {\n if (focusState === 'trigger-focus' && elRef.current) {\n elRef.current.focus();\n }\n }, [focusState]);\n\n const handleFocus: React.FocusEventHandler<HTMLTableCellElement> = (e) => {\n // From https://zellwk.com/blog/keyboard-focusable-elements/\n const nestedFocusTarget = e.currentTarget?.querySelector<HTMLElement>(\n 'a[href], button, input, textarea, select, details,[role=\"button\"]'\n );\n if (nestedFocusTarget) {\n // If the cell has a focusable child, focus it instead. Mostly used for\n // checkbox cells, but could have other uses.\n nestedFocusTarget.focus();\n }\n };\n\n const handleInteractionFocusTrigger: TableCellProps['onFocusTrigger'] = (e) => {\n // We use `onClick` and `onKeyUp` events instead of `onFocus` because of\n // some ordering issues with when the browser calls events and how this\n // plays with the triggering of focus with keyboard interactions.\n // These report that a focus event happened, so we can adjust the current\n // tabindex and focuses to the right cell.\n onFocusTrigger?.(e);\n };\n\n const modifiedDataLink = useMemo((): DataLink | undefined => {\n if (!dataLink) return undefined;\n\n if (adjacentCellsValuesMap && hasDataFieldPatterns(dataLink.url)) {\n const { text } = replaceDataFields(dataLink.url, adjacentCellsValuesMap, { urlEncode: true });\n return { ...dataLink, url: text };\n }\n return dataLink;\n }, [dataLink, adjacentCellsValuesMap]);\n\n return (\n <StyledMuiTableCell\n {...otherProps}\n // Modify the tab index based on the currently focused cell. It's important\n // to avoid having tabindex 0 on everything because it essentially traps\n // a keyboard user in the table until they hit \"tab\" for every single\n // cell.\n tabIndex={focusState !== 'none' ? 0 : -1}\n onFocus={handleFocus}\n onClick={handleInteractionFocusTrigger}\n onKeyUp={handleInteractionFocusTrigger}\n style={{ width: width }}\n sx={{\n position: 'relative',\n borderBottom: isHeader ? `solid 1px ${theme.palette.grey[100]}` : `solid 1px ${theme.palette.grey[50]}`,\n '&:hover #original-cell': {\n position: 'absolute',\n top: 0,\n left: 0,\n zIndex: 10,\n width: 'fit-content',\n minWidth: '100%',\n whiteSpace: 'nowrap',\n overflow: 'visible',\n backgroundColor: `${backgroundColor ?? theme.palette.background.default} !important`,\n outline: `solid 1px ${theme.palette.info.main}`,\n outlineOffset: '-1px',\n },\n }}\n ref={elRef}\n >\n <Box\n id=\"original-cell\"\n sx={{\n ...getTableCellLayout(theme, density, { isHeader, isLastColumn, isFirstColumn, defaultColumnHeight }),\n position: 'relative',\n\n // Text truncation. Currently enforced on all cells. We may control\n // this with a prop on column config in the future.\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n\n // Need to inherit from the MUI cell because this manages some ordering\n // that the `TableSortLabel` uses to determine the location of the icon\n // in headers.\n flexDirection: 'inherit',\n }}\n style={{\n backgroundColor: backgroundColor ?? 'inherit',\n color: color ?? 'inherit',\n }}\n title={description}\n aria-label={description}\n textAlign={align}\n >\n {modifiedDataLink ? (\n <Link\n href={modifiedDataLink.url}\n target={modifiedDataLink.targetBlank ? '_blank' : '_self'}\n rel={modifiedDataLink.targetBlank ? 'noopener noreferrer' : undefined}\n >\n {children}\n </Link>\n ) : (\n children\n )}\n </Box>\n </StyledMuiTableCell>\n );\n}\n"],"names":["Box","Link","TableCell","MuiTableCell","styled","useTheme","useEffect","useMemo","useRef","hasDataFieldPatterns","replaceDataFields","getTableCellLayout","StyledMuiTableCell","theme","padding","backgroundColor","palette","background","default","outline","primary","main","outlineOffset","borderRadius","children","density","variant","width","defaultColumnHeight","focusState","onFocusTrigger","isFirstColumn","isLastColumn","description","align","color","dataLink","adjacentCellsValuesMap","otherProps","elRef","isHeader","current","focus","handleFocus","e","nestedFocusTarget","currentTarget","querySelector","handleInteractionFocusTrigger","modifiedDataLink","undefined","url","text","urlEncode","tabIndex","onFocus","onClick","onKeyUp","style","sx","position","borderBottom","grey","top","left","zIndex","minWidth","whiteSpace","overflow","info","ref","id","textOverflow","flexDirection","title","aria-label","textAlign","href","target","targetBlank","rel"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AA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Z,IAAI;gBACF,GAAGhD,mBAAmBE,OAAOY,SAAS;oBAAEe;oBAAUR;oBAAcD;oBAAeH;gBAAoB,EAAE;gBACrGgC,UAAU;gBAEV,mEAAmE;gBACnE,mDAAmD;gBACnDO,YAAY;gBACZC,UAAU;gBACVI,cAAc;gBAEd,uEAAuE;gBACvE,uEAAuE;gBACvE,cAAc;gBACdC,eAAe;YACjB;YACAf,OAAO;gBACL3C,iBAAiBA,mBAAmB;gBACpCoB,OAAOA,SAAS;YAClB;YACAuC,OAAOzC;YACP0C,cAAY1C;YACZ2C,WAAW1C;sBAEVe,iCACC,KAAChD;gBACC4E,MAAM5B,iBAAiBE,GAAG;gBAC1B2B,QAAQ7B,iBAAiB8B,WAAW,GAAG,WAAW;gBAClDC,KAAK/B,iBAAiB8B,WAAW,GAAG,wBAAwB7B;0BAE3D1B;iBAGHA;;;AAKV"}
|
|
1
|
+
{"version":3,"sources":["../../src/Table/TableCell.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 {\n Box,\n Link,\n TableCell as MuiTableCell,\n TableCellProps as MuiTableCellProps,\n styled,\n useTheme,\n} from '@mui/material';\nimport { ReactElement, useEffect, useMemo, useRef } from 'react';\nimport { hasDataFieldPatterns, replaceDataFields } from '../utils/data-field-interpolation';\nimport { DataLink, TableCellAlignment, TableDensity, getTableCellLayout } from './model/table-model';\n\nconst StyledMuiTableCell = styled(MuiTableCell)(({ theme }) => ({\n padding: 0,\n backgroundColor: 'inherit',\n\n '&.MuiTableCell-head': {\n // Important to avoid scrolling behind the header showing through.\n backgroundColor: theme.palette.background.default,\n },\n '&:focus-visible': {\n outline: `solid 1px ${theme.palette.primary.main}`,\n // Move inward a little to avoid getting cut off when focusing on items\n // at the edge of the table.\n outlineOffset: '-1px',\n borderRadius: 0,\n },\n}));\n\nexport interface TableCellProps extends Omit<MuiTableCellProps, 'tabIndex' | 'align'> {\n density: TableDensity;\n defaultColumnHeight?: 'auto' | number;\n\n // These values are used to adjust the spacing for the first/last columns.\n isLastColumn: boolean;\n isFirstColumn: boolean;\n\n align?: TableCellAlignment;\n\n /**\n * Additional information to be displayed when hovering over the cell. This\n * may be the full cell value (e.g. to enable the user to see the full value\n * if it is ellipsized to fit into the space) or some other descriptive text\n * that is useful for the user.\n *\n * The hover behavior is currently managed with the `title` attribute, but this\n * may be changed to a tooltip in the future.\n */\n description?: string;\n\n /**\n * How the cell should behave related to focus.\n * - `trigger-focus`: the cell should be auto-focused when it renders.\n * - `focus-next`: the cell should have tabindex=\"0\", so that it will be\n * focused the next time someone tabs with a keyboard.\n * - `none`: the cell should have tabindex=\"-1\", so it is not focused by\n * keyboard interactions at this time.\n */\n focusState?: 'trigger-focus' | 'focus-next' | 'none';\n onFocusTrigger?: (e: React.MouseEvent<HTMLTableCellElement> | React.KeyboardEvent<HTMLTableCellElement>) => void;\n color?: string;\n backgroundColor?: string;\n dataLink?: DataLink;\n adjacentCellsValuesMap?: Record<string, string>;\n}\n\nexport function TableCell({\n children,\n density,\n variant,\n width,\n defaultColumnHeight,\n focusState = 'none',\n onFocusTrigger,\n isFirstColumn,\n isLastColumn,\n description,\n align,\n color,\n backgroundColor,\n dataLink,\n adjacentCellsValuesMap,\n ...otherProps\n}: TableCellProps): ReactElement {\n const theme = useTheme();\n const elRef = useRef<HTMLTableCellElement>();\n\n const isHeader = variant === 'head';\n\n useEffect(() => {\n if (focusState === 'trigger-focus' && elRef.current) {\n elRef.current.focus();\n }\n }, [focusState]);\n\n const handleFocus: React.FocusEventHandler<HTMLTableCellElement> = (e) => {\n // From https://zellwk.com/blog/keyboard-focusable-elements/\n const nestedFocusTarget = e.currentTarget?.querySelector<HTMLElement>(\n 'a[href], button, input, textarea, select, details,[role=\"button\"]'\n );\n if (nestedFocusTarget) {\n // If the cell has a focusable child, focus it instead. Mostly used for\n // checkbox cells, but could have other uses.\n nestedFocusTarget.focus();\n }\n };\n\n const handleInteractionFocusTrigger: TableCellProps['onFocusTrigger'] = (e) => {\n // We use `onClick` and `onKeyUp` events instead of `onFocus` because of\n // some ordering issues with when the browser calls events and how this\n // plays with the triggering of focus with keyboard interactions.\n // These report that a focus event happened, so we can adjust the current\n // tabindex and focuses to the right cell.\n onFocusTrigger?.(e);\n };\n\n const modifiedDataLink = useMemo((): DataLink | undefined => {\n if (!dataLink) return undefined;\n\n if (adjacentCellsValuesMap && hasDataFieldPatterns(dataLink.url)) {\n const { text } = replaceDataFields(dataLink.url, adjacentCellsValuesMap, { urlEncode: true });\n return { ...dataLink, url: text };\n }\n return dataLink;\n }, [dataLink, adjacentCellsValuesMap]);\n\n return (\n <StyledMuiTableCell\n {...otherProps}\n // Modify the tab index based on the currently focused cell. It's important\n // to avoid having tabindex 0 on everything because it essentially traps\n // a keyboard user in the table until they hit \"tab\" for every single\n // cell.\n tabIndex={focusState !== 'none' ? 0 : -1}\n onFocus={handleFocus}\n onClick={handleInteractionFocusTrigger}\n onKeyUp={handleInteractionFocusTrigger}\n style={{ width: width }}\n sx={{\n position: 'relative',\n borderBottom: isHeader ? `solid 1px ${theme.palette.grey[100]}` : `solid 1px ${theme.palette.grey[50]}`,\n '&:hover #original-cell': {\n position: 'absolute',\n top: 0,\n left: 0,\n zIndex: 10,\n width: 'fit-content',\n minWidth: '100%',\n whiteSpace: 'nowrap',\n overflow: 'visible',\n backgroundColor: `${backgroundColor ?? theme.palette.background.default} !important`,\n outline: `solid 1px ${theme.palette.info.main}`,\n outlineOffset: '-1px',\n },\n }}\n ref={elRef}\n >\n <Box\n id=\"original-cell\"\n sx={{\n ...getTableCellLayout(theme, density, { isHeader, isLastColumn, isFirstColumn, defaultColumnHeight }),\n position: 'relative',\n\n // Text truncation. Currently enforced on all cells. We may control\n // this with a prop on column config in the future.\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n\n // Need to inherit from the MUI cell because this manages some ordering\n // that the `TableSortLabel` uses to determine the location of the icon\n // in headers.\n flexDirection: 'inherit',\n }}\n style={{\n backgroundColor: backgroundColor ?? 'inherit',\n color: color ?? 'inherit',\n }}\n title={description}\n aria-label={description}\n textAlign={align}\n >\n {modifiedDataLink ? (\n <Link\n href={modifiedDataLink.url}\n target={modifiedDataLink.targetBlank ? '_blank' : '_self'}\n rel={modifiedDataLink.targetBlank ? 'noopener noreferrer' : undefined}\n >\n {children}\n </Link>\n ) : (\n children\n )}\n </Box>\n </StyledMuiTableCell>\n );\n}\n"],"names":["Box","Link","TableCell","MuiTableCell","styled","useTheme","useEffect","useMemo","useRef","hasDataFieldPatterns","replaceDataFields","getTableCellLayout","StyledMuiTableCell","theme","padding","backgroundColor","palette","background","default","outline","primary","main","outlineOffset","borderRadius","children","density","variant","width","defaultColumnHeight","focusState","onFocusTrigger","isFirstColumn","isLastColumn","description","align","color","dataLink","adjacentCellsValuesMap","otherProps","elRef","isHeader","current","focus","handleFocus","e","nestedFocusTarget","currentTarget","querySelector","handleInteractionFocusTrigger","modifiedDataLink","undefined","url","text","urlEncode","tabIndex","onFocus","onClick","onKeyUp","style","sx","position","borderBottom","grey","top","left","zIndex","minWidth","whiteSpace","overflow","info","ref","id","textOverflow","flexDirection","title","aria-label","textAlign","href","target","targetBlank","rel"],"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,SACEA,GAAG,EACHC,IAAI,EACJC,aAAaC,YAAY,EAEzBC,MAAM,EACNC,QAAQ,QACH,gBAAg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mEAAmE;gBACnE,mDAAmD;gBACnDO,YAAY;gBACZC,UAAU;gBACVI,cAAc;gBAEd,uEAAuE;gBACvE,uEAAuE;gBACvE,cAAc;gBACdC,eAAe;YACjB;YACAf,OAAO;gBACL3C,iBAAiBA,mBAAmB;gBACpCoB,OAAOA,SAAS;YAClB;YACAuC,OAAOzC;YACP0C,cAAY1C;YACZ2C,WAAW1C;sBAEVe,iCACC,KAAChD;gBACC4E,MAAM5B,iBAAiBE,GAAG;gBAC1B2B,QAAQ7B,iBAAiB8B,WAAW,GAAG,WAAW;gBAClDC,KAAK/B,iBAAiB8B,WAAW,GAAG,wBAAwB7B;0BAE3D1B;iBAGHA;;;AAKV"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { Checkbox, alpha } from '@mui/material';
|
|
15
15
|
export function TableCheckbox({ color, density, ...otherProps }) {
|
|
16
16
|
const isCompact = density === 'compact';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Table/TableCheckbox.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 { Checkbox, CheckboxProps, alpha } from '@mui/material';\nimport { ReactElement } from 'react';\nimport { TableDensity } from './model/table-model';\n\nexport interface TableCheckboxProps extends Pick<CheckboxProps, 'checked' | 'indeterminate' | 'onChange'> {\n color?: string;\n density: TableDensity;\n}\n\nexport function TableCheckbox({ color, density, ...otherProps }: TableCheckboxProps): ReactElement {\n const isCompact = density === 'compact';\n\n return (\n <Checkbox\n size={isCompact ? 'small' : 'medium'}\n {...otherProps}\n // Disable ripple and set background color below because of some issues\n // with re-rendering with the keyboard interactions that causes the ripple\n // animation to stutter.\n focusRipple={false}\n // Tab index is handled by the overall keyboard interactions for the table\n // to avoid trapping a keyboard user in a table by requiring them to tab\n // through every single checkbox.\n tabIndex={-1}\n sx={{\n color: color,\n\n padding: (theme) => theme.spacing(isCompact ? 0.25 : 0.5),\n\n // Centering.\n position: 'absolute',\n top: '50%',\n left: '50%',\n transform: 'translate(-50%, -50%)',\n\n '&.Mui-checked': {\n color: color,\n },\n\n '&.Mui-focusVisible': {\n background: color ? alpha(color, 0.5) : undefined,\n },\n\n '& .MuiSvgIcon-root': { fontSize: isCompact ? 16 : 18 },\n }}\n />\n );\n}\n"],"names":["Checkbox","alpha","TableCheckbox","color","density","otherProps","isCompact","size","focusRipple","tabIndex","sx","padding","theme","spacing","position","top","left","transform","background","undefined","fontSize"],"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
|
|
1
|
+
{"version":3,"sources":["../../src/Table/TableCheckbox.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 { Checkbox, CheckboxProps, alpha } from '@mui/material';\nimport { ReactElement } from 'react';\nimport { TableDensity } from './model/table-model';\n\nexport interface TableCheckboxProps extends Pick<CheckboxProps, 'checked' | 'indeterminate' | 'onChange'> {\n color?: string;\n density: TableDensity;\n}\n\nexport function TableCheckbox({ color, density, ...otherProps }: TableCheckboxProps): ReactElement {\n const isCompact = density === 'compact';\n\n return (\n <Checkbox\n size={isCompact ? 'small' : 'medium'}\n {...otherProps}\n // Disable ripple and set background color below because of some issues\n // with re-rendering with the keyboard interactions that causes the ripple\n // animation to stutter.\n focusRipple={false}\n // Tab index is handled by the overall keyboard interactions for the table\n // to avoid trapping a keyboard user in a table by requiring them to tab\n // through every single checkbox.\n tabIndex={-1}\n sx={{\n color: color,\n\n padding: (theme) => theme.spacing(isCompact ? 0.25 : 0.5),\n\n // Centering.\n position: 'absolute',\n top: '50%',\n left: '50%',\n transform: 'translate(-50%, -50%)',\n\n '&.Mui-checked': {\n color: color,\n },\n\n '&.Mui-focusVisible': {\n background: color ? alpha(color, 0.5) : undefined,\n },\n\n '& .MuiSvgIcon-root': { fontSize: isCompact ? 16 : 18 },\n }}\n />\n );\n}\n"],"names":["Checkbox","alpha","TableCheckbox","color","density","otherProps","isCompact","size","focusRipple","tabIndex","sx","padding","theme","spacing","position","top","left","transform","background","undefined","fontSize"],"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,QAAQ,EAAiBC,KAAK,QAAQ,gBAAgB;AAS/D,OAAO,SAASC,cAAc,EAAEC,KAAK,EAAEC,OAAO,EAAE,GAAGC,YAAgC;IACjF,MAAMC,YAAYF,YAAY;IAE9B,qBACE,KAACJ;QACCO,MAAMD,YAAY,UAAU;QAC3B,GAAGD,UAAU;QACd,uEAAuE;QACvE,0EAA0E;QAC1E,wBAAwB;QACxBG,aAAa;QACb,0EAA0E;QAC1E,wEAAwE;QACxE,iCAAiC;QACjCC,UAAU,CAAC;QACXC,IAAI;YACFP,OAAOA;YAEPQ,SAAS,CAACC,QAAUA,MAAMC,OAAO,CAACP,YAAY,OAAO;YAErD,aAAa;YACbQ,UAAU;YACVC,KAAK;YACLC,MAAM;YACNC,WAAW;YAEX,iBAAiB;gBACfd,OAAOA;YACT;YAEA,sBAAsB;gBACpBe,YAAYf,QAAQF,MAAME,OAAO,OAAOgB;YAC1C;YAEA,sBAAsB;gBAAEC,UAAUd,YAAY,KAAK;YAAG;QACxD;;AAGN"}
|
package/dist/Table/TableFoot.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { TableFooter as MuiTableFooter } from '@mui/material';
|
|
15
15
|
import { forwardRef } from 'react';
|
|
16
16
|
export const TableFoot = /*#__PURE__*/ forwardRef(function TableFoot(props, ref) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Table/TableFoot.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 { TableFooter as MuiTableFooter, TableFooterProps as MuiTableFooterProps } from '@mui/material';\nimport { forwardRef } from 'react';\n\nexport const TableFoot = forwardRef<HTMLTableSectionElement, MuiTableFooterProps>(function TableFoot(props, ref) {\n return <MuiTableFooter {...props} ref={ref} />;\n});\n"],"names":["TableFooter","MuiTableFooter","forwardRef","TableFoot","props","ref"],"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
|
|
1
|
+
{"version":3,"sources":["../../src/Table/TableFoot.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 { TableFooter as MuiTableFooter, TableFooterProps as MuiTableFooterProps } from '@mui/material';\nimport { forwardRef } from 'react';\n\nexport const TableFoot = forwardRef<HTMLTableSectionElement, MuiTableFooterProps>(function TableFoot(props, ref) {\n return <MuiTableFooter {...props} ref={ref} />;\n});\n"],"names":["TableFooter","MuiTableFooter","forwardRef","TableFoot","props","ref"],"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,eAAeC,cAAc,QAAiD,gBAAgB;AACvG,SAASC,UAAU,QAAQ,QAAQ;AAEnC,OAAO,MAAMC,0BAAYD,WAAyD,SAASC,UAAUC,KAAK,EAAEC,GAAG;IAC7G,qBAAO,KAACJ;QAAgB,GAAGG,KAAK;QAAEC,KAAKA;;AACzC,GAAG"}
|
package/dist/Table/TableHead.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { TableHead as MuiTableHead } from '@mui/material';
|
|
15
15
|
import { forwardRef } from 'react';
|
|
16
16
|
export const TableHead = /*#__PURE__*/ forwardRef(function TableHead(props, ref) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Table/TableHead.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 { TableHead as MuiTableHead, TableHeadProps as MuiTableHeadProps } from '@mui/material';\nimport { forwardRef } from 'react';\n\ntype TableHeadProps = MuiTableHeadProps;\n\nexport const TableHead = forwardRef<HTMLTableSectionElement, TableHeadProps>(function TableHead(props, ref) {\n return <MuiTableHead {...props} ref={ref} />;\n});\n"],"names":["TableHead","MuiTableHead","forwardRef","props","ref"],"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
|
|
1
|
+
{"version":3,"sources":["../../src/Table/TableHead.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 { TableHead as MuiTableHead, TableHeadProps as MuiTableHeadProps } from '@mui/material';\nimport { forwardRef } from 'react';\n\ntype TableHeadProps = MuiTableHeadProps;\n\nexport const TableHead = forwardRef<HTMLTableSectionElement, TableHeadProps>(function TableHead(props, ref) {\n return <MuiTableHead {...props} ref={ref} />;\n});\n"],"names":["TableHead","MuiTableHead","forwardRef","props","ref"],"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,aAAaC,YAAY,QAA6C,gBAAgB;AAC/F,SAASC,UAAU,QAAQ,QAAQ;AAInC,OAAO,MAAMF,0BAAYE,WAAoD,SAASF,UAAUG,KAAK,EAAEC,GAAG;IACxG,qBAAO,KAACH;QAAc,GAAGE,KAAK;QAAEC,KAAKA;;AACvC,GAAG"}
|
|
@@ -18,6 +18,25 @@ export interface TableHeaderCellProps extends TableCellProps {
|
|
|
18
18
|
* unsorted.)
|
|
19
19
|
*/
|
|
20
20
|
nextSortDirection?: SortDirection;
|
|
21
|
+
/**
|
|
22
|
+
* Configuration for column resizing interactions.
|
|
23
|
+
* When included, the header will include a resize handle (divider).
|
|
24
|
+
*/
|
|
25
|
+
resizeConfig?: ResizeConfig;
|
|
26
|
+
}
|
|
27
|
+
export interface ResizeConfig {
|
|
28
|
+
/**
|
|
29
|
+
* Handler called when a column resize event is triggered.
|
|
30
|
+
*/
|
|
31
|
+
resizeHandler: (event: unknown) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Handler called when a column reset size event is triggered (double-click on the resize handle).
|
|
34
|
+
*/
|
|
35
|
+
resetSizeHandler: () => void;
|
|
36
|
+
/**
|
|
37
|
+
* Indicates whether the column is currently being resized.
|
|
38
|
+
*/
|
|
39
|
+
isResizing: boolean;
|
|
21
40
|
}
|
|
22
|
-
export declare function TableHeaderCell({ onSort, sortDirection, nextSortDirection, children, ...cellProps }: TableHeaderCellProps): ReactElement;
|
|
41
|
+
export declare function TableHeaderCell({ onSort, sortDirection, nextSortDirection, children, resizeConfig, ...cellProps }: TableHeaderCellProps): ReactElement;
|
|
23
42
|
//# sourceMappingURL=TableHeaderCell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableHeaderCell.d.ts","sourceRoot":"","sources":["../../src/Table/TableHeaderCell.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAAa,cAAc,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAEhD;;OAEG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"TableHeaderCell.d.ts","sourceRoot":"","sources":["../../src/Table/TableHeaderCell.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAAa,cAAc,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAEhD;;OAEG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,aAAa,CAAC;IAElC;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,aAAa,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC;;OAEG;IACH,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAE7B;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACR,YAAY,EACZ,GAAG,SAAS,EACb,EAAE,oBAAoB,GAAG,YAAY,CA6ErC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
2
|
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,10 +11,9 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import {
|
|
14
|
-
import { TableSortLabel, Typography, tableSortLabelClasses } from '@mui/material';
|
|
14
|
+
import { TableSortLabel, Typography, tableSortLabelClasses, Box, Divider } from '@mui/material';
|
|
15
15
|
import { TableCell } from './TableCell';
|
|
16
|
-
export function TableHeaderCell({ onSort, sortDirection, nextSortDirection, children, ...cellProps }) {
|
|
16
|
+
export function TableHeaderCell({ onSort, sortDirection, nextSortDirection, children, resizeConfig, ...cellProps }) {
|
|
17
17
|
const showSortLabel = !!onSort;
|
|
18
18
|
const headerText = /*#__PURE__*/ _jsx(Typography, {
|
|
19
19
|
noWrap: true,
|
|
@@ -24,29 +24,61 @@ export function TableHeaderCell({ onSort, sortDirection, nextSortDirection, chil
|
|
|
24
24
|
});
|
|
25
25
|
const isActive = !!sortDirection;
|
|
26
26
|
const direction = isActive ? sortDirection : nextSortDirection;
|
|
27
|
-
return /*#__PURE__*/
|
|
27
|
+
return /*#__PURE__*/ _jsxs(TableCell, {
|
|
28
28
|
...cellProps,
|
|
29
|
-
children:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
29
|
+
children: [
|
|
30
|
+
showSortLabel ? /*#__PURE__*/ _jsx(TableSortLabel, {
|
|
31
|
+
onClick: onSort,
|
|
32
|
+
direction: direction,
|
|
33
|
+
active: isActive,
|
|
34
|
+
sx: {
|
|
35
|
+
// Overrides a default vertical alignment in the CSS that changes
|
|
36
|
+
// the header vertical rhythm in a way that's inconsistent with
|
|
37
|
+
// non-sorting headers.
|
|
38
|
+
verticalAlign: 'unset',
|
|
39
|
+
// Makes it possible to ellipsize the text if it's too long.
|
|
40
|
+
maxWidth: '100%',
|
|
41
|
+
// Make the arrow visible when focused using the keyboard to assist
|
|
42
|
+
// with a11y.
|
|
43
|
+
'&:focus-visible': {
|
|
44
|
+
[`& .${tableSortLabelClasses.icon}`]: {
|
|
45
|
+
opacity: isActive ? 1 : 0.5
|
|
46
|
+
}
|
|
45
47
|
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
},
|
|
49
|
+
children: headerText
|
|
50
|
+
}) : headerText,
|
|
51
|
+
resizeConfig && /*#__PURE__*/ _jsx(Box, {
|
|
52
|
+
onMouseDown: (e)=>{
|
|
53
|
+
if (e.detail === 2) {
|
|
54
|
+
resizeConfig.resetSizeHandler();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
resizeConfig.resizeHandler(e);
|
|
58
|
+
},
|
|
59
|
+
onTouchStart: resizeConfig.resizeHandler,
|
|
60
|
+
sx: {
|
|
61
|
+
position: 'absolute',
|
|
62
|
+
height: '100%',
|
|
63
|
+
top: 0,
|
|
64
|
+
right: '4px',
|
|
65
|
+
cursor: 'col-resize'
|
|
66
|
+
},
|
|
67
|
+
children: /*#__PURE__*/ _jsx(Divider, {
|
|
68
|
+
flexItem: true,
|
|
69
|
+
orientation: "vertical",
|
|
70
|
+
sx: (theme)=>({
|
|
71
|
+
backgroundColor: resizeConfig.isResizing ? theme.palette.action.active : theme.palette.divider,
|
|
72
|
+
borderRadius: '2px',
|
|
73
|
+
borderWidth: '2px',
|
|
74
|
+
height: '100%',
|
|
75
|
+
touchAction: 'none',
|
|
76
|
+
transform: 'translateX(4px)',
|
|
77
|
+
userSelect: 'none'
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
]
|
|
50
82
|
});
|
|
51
83
|
}
|
|
52
84
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Table/TableHeaderCell.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 { TableSortLabel, Typography, tableSortLabelClasses } from '@mui/material';\nimport { ReactElement } from 'react';\nimport { TableCell, TableCellProps } from './TableCell';\nimport { SortDirection } from './model/table-model';\n\nexport interface TableHeaderCellProps extends TableCellProps {\n /**\n * Handler called when a sort event is triggered.\n * When specified, the header will include sorting interactions and indicators.\n */\n onSort?: ((event: unknown) => void) | undefined;\n\n /**\n * The current direction the header is sorted.\n */\n sortDirection?: SortDirection;\n\n /**\n * The next direction the header will be sorted when another sort action\n * is triggered via click/keyboard. This impacts some UI interactions (e.g.\n * the direction of the sort arrow on hover f the column is currently\n * unsorted.)\n */\n nextSortDirection?: SortDirection;\n}\n\nexport function TableHeaderCell({\n onSort,\n sortDirection,\n nextSortDirection,\n children,\n ...cellProps\n}: TableHeaderCellProps): ReactElement {\n const showSortLabel = !!onSort;\n\n const headerText = (\n <Typography noWrap variant=\"inherit\" component=\"div\" color=\"inherit\">\n {children}\n </Typography>\n );\n\n const isActive = !!sortDirection;\n const direction = isActive ? sortDirection : nextSortDirection;\n\n return (\n <TableCell {...cellProps}>\n {showSortLabel ? (\n <TableSortLabel\n onClick={onSort}\n direction={direction}\n active={isActive}\n sx={{\n // Overrides a default vertical alignment in the CSS that changes\n // the header vertical rhythm in a way that's inconsistent with\n // non-sorting headers.\n verticalAlign: 'unset',\n\n // Makes it possible to ellipsize the text if it's too long.\n maxWidth: '100%',\n\n // Make the arrow visible when focused using the keyboard to assist\n // with a11y.\n '&:focus-visible': {\n [`& .${tableSortLabelClasses.icon}`]: {\n opacity: isActive ? 1 : 0.5,\n },\n },\n }}\n >\n {headerText}\n </TableSortLabel>\n ) : (\n headerText\n )}\n </TableCell>\n );\n}\n"],"names":["TableSortLabel","Typography","tableSortLabelClasses","TableCell","TableHeaderCell","onSort","sortDirection","nextSortDirection","children","cellProps","showSortLabel","headerText","noWrap","variant","component","color","isActive","direction","onClick","active","sx","verticalAlign","maxWidth","icon","opacity"],"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
|
|
1
|
+
{"version":3,"sources":["../../src/Table/TableHeaderCell.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 { TableSortLabel, Typography, tableSortLabelClasses, Box, Divider } from '@mui/material';\nimport { ReactElement } from 'react';\nimport { TableCell, TableCellProps } from './TableCell';\nimport { SortDirection } from './model/table-model';\n\nexport interface TableHeaderCellProps extends TableCellProps {\n /**\n * Handler called when a sort event is triggered.\n * When specified, the header will include sorting interactions and indicators.\n */\n onSort?: ((event: unknown) => void) | undefined;\n\n /**\n * The current direction the header is sorted.\n */\n sortDirection?: SortDirection;\n\n /**\n * The next direction the header will be sorted when another sort action\n * is triggered via click/keyboard. This impacts some UI interactions (e.g.\n * the direction of the sort arrow on hover f the column is currently\n * unsorted.)\n */\n nextSortDirection?: SortDirection;\n\n /**\n * Configuration for column resizing interactions.\n * When included, the header will include a resize handle (divider).\n */\n resizeConfig?: ResizeConfig;\n}\n\nexport interface ResizeConfig {\n /**\n * Handler called when a column resize event is triggered.\n */\n resizeHandler: (event: unknown) => void;\n /**\n * Handler called when a column reset size event is triggered (double-click on the resize handle).\n */\n resetSizeHandler: () => void;\n\n /**\n * Indicates whether the column is currently being resized.\n */\n isResizing: boolean;\n}\n\nexport function TableHeaderCell({\n onSort,\n sortDirection,\n nextSortDirection,\n children,\n resizeConfig,\n ...cellProps\n}: TableHeaderCellProps): ReactElement {\n const showSortLabel = !!onSort;\n\n const headerText = (\n <Typography noWrap variant=\"inherit\" component=\"div\" color=\"inherit\">\n {children}\n </Typography>\n );\n\n const isActive = !!sortDirection;\n const direction = isActive ? sortDirection : nextSortDirection;\n\n return (\n <TableCell {...cellProps}>\n {showSortLabel ? (\n <TableSortLabel\n onClick={onSort}\n direction={direction}\n active={isActive}\n sx={{\n // Overrides a default vertical alignment in the CSS that changes\n // the header vertical rhythm in a way that's inconsistent with\n // non-sorting headers.\n verticalAlign: 'unset',\n\n // Makes it possible to ellipsize the text if it's too long.\n maxWidth: '100%',\n\n // Make the arrow visible when focused using the keyboard to assist\n // with a11y.\n '&:focus-visible': {\n [`& .${tableSortLabelClasses.icon}`]: {\n opacity: isActive ? 1 : 0.5,\n },\n },\n }}\n >\n {headerText}\n </TableSortLabel>\n ) : (\n headerText\n )}\n {resizeConfig && (\n <Box\n onMouseDown={(e) => {\n if (e.detail === 2) {\n resizeConfig.resetSizeHandler();\n return;\n }\n resizeConfig.resizeHandler(e);\n }}\n onTouchStart={resizeConfig.resizeHandler}\n sx={{\n position: 'absolute',\n height: '100%',\n top: 0,\n right: '4px',\n cursor: 'col-resize',\n }}\n >\n <Divider\n flexItem\n orientation=\"vertical\"\n sx={(theme) => ({\n backgroundColor: resizeConfig.isResizing ? theme.palette.action.active : theme.palette.divider,\n borderRadius: '2px',\n borderWidth: '2px',\n height: '100%',\n touchAction: 'none',\n transform: 'translateX(4px)',\n userSelect: 'none',\n })}\n />\n </Box>\n )}\n </TableCell>\n );\n}\n"],"names":["TableSortLabel","Typography","tableSortLabelClasses","Box","Divider","TableCell","TableHeaderCell","onSort","sortDirection","nextSortDirection","children","resizeConfig","cellProps","showSortLabel","headerText","noWrap","variant","component","color","isActive","direction","onClick","active","sx","verticalAlign","maxWidth","icon","opacity","onMouseDown","e","detail","resetSizeHandler","resizeHandler","onTouchStart","position","height","top","right","cursor","flexItem","orientation","theme","backgroundColor","isResizing","palette","action","divider","borderRadius","borderWidth","touchAction","transform","userSelect"],"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,cAAc,EAAEC,UAAU,EAAEC,qBAAqB,EAAEC,GAAG,EAAEC,OAAO,QAAQ,gBAAgB;AAEhG,SAASC,SAAS,QAAwB,cAAc;AA8CxD,OAAO,SAASC,gBAAgB,EAC9BC,MAAM,EACNC,aAAa,EACbC,iBAAiB,EACjBC,QAAQ,EACRC,YAAY,EACZ,GAAGC,WACkB;IACrB,MAAMC,gBAAgB,CAAC,CAACN;IAExB,MAAMO,2BACJ,KAACb;QAAWc,MAAM;QAACC,SAAQ;QAAUC,WAAU;QAAMC,OAAM;kBACxDR;;IAIL,MAAMS,WAAW,CAAC,CAACX;IACnB,MAAMY,YAAYD,WAAWX,gBAAgBC;IAE7C,qBACE,MAACJ;QAAW,GAAGO,SAAS;;YACrBC,8BACC,KAACb;gBACCqB,SAASd;gBACTa,WAAWA;gBACXE,QAAQH;gBACRI,IAAI;oBACF,iEAAiE;oBACjE,+DAA+D;oBAC/D,uBAAuB;oBACvBC,eAAe;oBAEf,4DAA4D;oBAC5DC,UAAU;oBAEV,mEAAmE;oBACnE,aAAa;oBACb,mBAAmB;wBACjB,CAAC,CAAC,GAAG,EAAEvB,sBAAsBwB,IAAI,EAAE,CAAC,EAAE;4BACpCC,SAASR,WAAW,IAAI;wBAC1B;oBACF;gBACF;0BAECL;iBAGHA;YAEDH,8BACC,KAACR;gBACCyB,aAAa,CAACC;oBACZ,IAAIA,EAAEC,MAAM,KAAK,GAAG;wBAClBnB,aAAaoB,gBAAgB;wBAC7B;oBACF;oBACApB,aAAaqB,aAAa,CAACH;gBAC7B;gBACAI,cAActB,aAAaqB,aAAa;gBACxCT,IAAI;oBACFW,UAAU;oBACVC,QAAQ;oBACRC,KAAK;oBACLC,OAAO;oBACPC,QAAQ;gBACV;0BAEA,cAAA,KAAClC;oBACCmC,QAAQ;oBACRC,aAAY;oBACZjB,IAAI,CAACkB,QAAW,CAAA;4BACdC,iBAAiB/B,aAAagC,UAAU,GAAGF,MAAMG,OAAO,CAACC,MAAM,CAACvB,MAAM,GAAGmB,MAAMG,OAAO,CAACE,OAAO;4BAC9FC,cAAc;4BACdC,aAAa;4BACbb,QAAQ;4BACRc,aAAa;4BACbC,WAAW;4BACXC,YAAY;wBACd,CAAA;;;;;AAMZ"}
|
package/dist/Table/TableRow.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { TableRow as MuiTableRow, alpha } from '@mui/material';
|
|
15
15
|
import { forwardRef } from 'react';
|
|
16
16
|
export const TableRow = /*#__PURE__*/ forwardRef(function TableRow(props, ref) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Table/TableRow.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 { TableRow as MuiTableRow, TableRowProps as MuiTableRowProps, alpha } from '@mui/material';\nimport { forwardRef } from 'react';\nimport { TableDensity } from './model/table-model';\n\ninterface TableRowProps extends MuiTableRowProps<'div'> {\n density: TableDensity;\n}\n\nexport const TableRow = forwardRef<HTMLTableRowElement, TableRowProps>(function TableRow(props, ref) {\n return (\n <MuiTableRow\n {...props}\n ref={ref}\n sx={{\n backgroundColor: (theme) => theme.palette.background.default,\n '&:hover': {\n backgroundColor: (theme) => alpha(theme.palette.primary.main, theme.palette.action.hoverOpacity),\n },\n }}\n />\n );\n});\n"],"names":["TableRow","MuiTableRow","alpha","forwardRef","props","ref","sx","backgroundColor","theme","palette","background","default","primary","main","action","hoverOpacity"],"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
|
|
1
|
+
{"version":3,"sources":["../../src/Table/TableRow.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 { TableRow as MuiTableRow, TableRowProps as MuiTableRowProps, alpha } from '@mui/material';\nimport { forwardRef } from 'react';\nimport { TableDensity } from './model/table-model';\n\ninterface TableRowProps extends MuiTableRowProps<'div'> {\n density: TableDensity;\n}\n\nexport const TableRow = forwardRef<HTMLTableRowElement, TableRowProps>(function TableRow(props, ref) {\n return (\n <MuiTableRow\n {...props}\n ref={ref}\n sx={{\n backgroundColor: (theme) => theme.palette.background.default,\n '&:hover': {\n backgroundColor: (theme) => alpha(theme.palette.primary.main, theme.palette.action.hoverOpacity),\n },\n }}\n />\n );\n});\n"],"names":["TableRow","MuiTableRow","alpha","forwardRef","props","ref","sx","backgroundColor","theme","palette","background","default","primary","main","action","hoverOpacity"],"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,YAAYC,WAAW,EAAqCC,KAAK,QAAQ,gBAAgB;AAClG,SAASC,UAAU,QAAQ,QAAQ;AAOnC,OAAO,MAAMH,yBAAWG,WAA+C,SAASH,SAASI,KAAK,EAAEC,GAAG;IACjG,qBACE,KAACJ;QACE,GAAGG,KAAK;QACTC,KAAKA;QACLC,IAAI;YACFC,iBAAiB,CAACC,QAAUA,MAAMC,OAAO,CAACC,UAAU,CAACC,OAAO;YAC5D,WAAW;gBACTJ,iBAAiB,CAACC,QAAUN,MAAMM,MAAMC,OAAO,CAACG,OAAO,CAACC,IAAI,EAAEL,MAAMC,OAAO,CAACK,MAAM,CAACC,YAAY;YACjG;QACF;;AAGN,GAAG"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Column } from '@tanstack/react-table';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
export interface TableToolbarProps<TableData> {
|
|
4
|
+
/**
|
|
5
|
+
* When `true`, a search input is rendered.
|
|
6
|
+
*/
|
|
7
|
+
isSearchEnabled?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Current value of the global filter / search query.
|
|
10
|
+
*/
|
|
11
|
+
globalFilter: string;
|
|
12
|
+
/**
|
|
13
|
+
* Callback fired when the search query changes.
|
|
14
|
+
*/
|
|
15
|
+
onGlobalFilterChange: (value: string) => void;
|
|
16
|
+
/**
|
|
17
|
+
* When `true`, a "Columns" button is rendered that opens a column visibility dropdown.
|
|
18
|
+
*/
|
|
19
|
+
isColumnFilterEnabled?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* All columns from the table instance, used to build the visibility menu.
|
|
22
|
+
*/
|
|
23
|
+
columns: Array<Column<TableData>>;
|
|
24
|
+
/**
|
|
25
|
+
* The width of the toolbar, used to determine when to switch to a more compact layout.
|
|
26
|
+
*/
|
|
27
|
+
width: number | string;
|
|
28
|
+
/**
|
|
29
|
+
* Max height for the column filter menu.
|
|
30
|
+
*/
|
|
31
|
+
columnFilterMenuMaxHeight?: number | string;
|
|
32
|
+
/**
|
|
33
|
+
* When `true`, an "Expand All" / "Collapse All" toggle button is rendered.
|
|
34
|
+
*/
|
|
35
|
+
isExpandAllEnabled?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Whether all rows are currently expanded.
|
|
38
|
+
*/
|
|
39
|
+
isAllExpanded?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Callback to toggle expand/collapse all rows.
|
|
42
|
+
*/
|
|
43
|
+
onExpandAllChange?: (event: unknown) => void;
|
|
44
|
+
}
|
|
45
|
+
export declare function TableToolbar<TableData>({ isSearchEnabled, globalFilter, onGlobalFilterChange, isColumnFilterEnabled, columns, width, columnFilterMenuMaxHeight, isExpandAllEnabled, isAllExpanded, onExpandAllChange, }: TableToolbarProps<TableData>): ReactElement | null;
|
|
46
|
+
//# sourceMappingURL=TableToolbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableToolbar.d.ts","sourceRoot":"","sources":["../../src/Table/TableToolbar.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAyB,MAAM,OAAO,CAAC;AAQ5D,MAAM,WAAW,iBAAiB,CAAC,SAAS;IAC1C;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,oBAAoB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAE9C;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC;;OAEG;IACH,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;IAClC;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAEvB;;OAEG;IACH,yBAAyB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAE5C;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9C;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,EACtC,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,qBAAqB,EACrB,OAAO,EACP,KAAK,EACL,yBAA+B,EAC/B,kBAAkB,EAClB,aAAa,EACb,iBAAiB,GAClB,EAAE,iBAAiB,CAAC,SAAS,CAAC,GAAG,YAAY,GAAG,IAAI,CAyGpD"}
|