@perses-dev/components 0.54.0-beta.0 → 0.54.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AlignSelector/AlignSelector.js +1 -1
- package/dist/AlignSelector/AlignSelector.js.map +1 -1
- package/dist/ColorPicker/ColorPicker.js +1 -1
- package/dist/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/ColorPicker/OptionsColorPicker.js +1 -1
- package/dist/ColorPicker/OptionsColorPicker.js.map +1 -1
- package/dist/ContentWithLegend/ContentWithLegend.js +1 -1
- package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.d.ts +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.d.ts.map +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.js +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
- package/dist/Dialog/DiscardChangesConfirmationDialog.js +1 -1
- package/dist/Dialog/DiscardChangesConfirmationDialog.js.map +1 -1
- package/dist/DragAndDrop/DragAndDropList.js +1 -1
- package/dist/DragAndDrop/DragAndDropList.js.map +1 -1
- package/dist/DragAndDrop/DragButton.js +1 -1
- package/dist/DragAndDrop/DragButton.js.map +1 -1
- package/dist/DragAndDrop/DropIndicator.js +1 -1
- package/dist/DragAndDrop/DropIndicator.js.map +1 -1
- package/dist/Drawer/Drawer.js +1 -1
- package/dist/Drawer/Drawer.js.map +1 -1
- package/dist/EChart/EChart.js +1 -1
- package/dist/EChart/EChart.js.map +1 -1
- package/dist/ErrorAlert.js +1 -1
- package/dist/ErrorAlert.js.map +1 -1
- package/dist/FormEditor/FormActions.d.ts +1 -1
- package/dist/FormEditor/FormActions.d.ts.map +1 -1
- package/dist/FormEditor/FormActions.js +1 -1
- package/dist/FormEditor/FormActions.js.map +1 -1
- package/dist/FormatControls/FormatControls.d.ts +1 -1
- package/dist/FormatControls/FormatControls.d.ts.map +1 -1
- package/dist/FormatControls/FormatControls.js +2 -2
- package/dist/FormatControls/FormatControls.js.map +1 -1
- package/dist/FormatControls/UnitSelector.d.ts +1 -1
- package/dist/FormatControls/UnitSelector.d.ts.map +1 -1
- package/dist/FormatControls/UnitSelector.js +1 -1
- package/dist/FormatControls/UnitSelector.js.map +1 -1
- package/dist/JSONEditor.js +1 -1
- package/dist/JSONEditor.js.map +1 -1
- package/dist/Legend/CompactLegend.js +1 -1
- package/dist/Legend/CompactLegend.js.map +1 -1
- package/dist/Legend/Legend.js +2 -2
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/Legend/LegendColorBadge.js +1 -1
- package/dist/Legend/LegendColorBadge.js.map +1 -1
- package/dist/Legend/ListLegend.js +1 -1
- package/dist/Legend/ListLegend.js.map +1 -1
- package/dist/Legend/ListLegendItem.js +1 -1
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/Legend/TableLegend.d.ts.map +1 -1
- package/dist/Legend/TableLegend.js +18 -4
- package/dist/Legend/TableLegend.js.map +1 -1
- package/dist/Legend/legend-model.d.ts +1 -1
- package/dist/Legend/legend-model.d.ts.map +1 -1
- package/dist/Legend/legend-model.js.map +1 -1
- package/dist/LinksEditor/LinkEditorForm.js +1 -1
- package/dist/LinksEditor/LinkEditorForm.js.map +1 -1
- package/dist/LinksEditor/LinksEditor.js +1 -1
- package/dist/LinksEditor/LinksEditor.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorColumn.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGrid.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -1
- package/dist/Overlay/Overlay.js +1 -1
- package/dist/Overlay/Overlay.js.map +1 -1
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js +1 -1
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js +1 -1
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
- package/dist/SortSelector/SortSelectorButtons.js +1 -1
- package/dist/SortSelector/SortSelectorButtons.js.map +1 -1
- package/dist/Table/InnerTable.js +1 -1
- package/dist/Table/InnerTable.js.map +1 -1
- package/dist/Table/Table.d.ts +1 -1
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +47 -14
- package/dist/Table/Table.js.map +1 -1
- package/dist/Table/TableBody.js +1 -1
- package/dist/Table/TableBody.js.map +1 -1
- package/dist/Table/TableCell.js +1 -1
- package/dist/Table/TableCell.js.map +1 -1
- package/dist/Table/TableCheckbox.js +1 -1
- package/dist/Table/TableCheckbox.js.map +1 -1
- package/dist/Table/TableFoot.js +1 -1
- package/dist/Table/TableFoot.js.map +1 -1
- package/dist/Table/TableHead.js +1 -1
- package/dist/Table/TableHead.js.map +1 -1
- package/dist/Table/TableHeaderCell.d.ts +20 -1
- package/dist/Table/TableHeaderCell.d.ts.map +1 -1
- package/dist/Table/TableHeaderCell.js +56 -24
- package/dist/Table/TableHeaderCell.js.map +1 -1
- package/dist/Table/TableRow.js +1 -1
- package/dist/Table/TableRow.js.map +1 -1
- package/dist/Table/TableToolbar.d.ts +46 -0
- package/dist/Table/TableToolbar.d.ts.map +1 -0
- package/dist/Table/TableToolbar.js +138 -0
- package/dist/Table/TableToolbar.js.map +1 -0
- package/dist/Table/VirtualizedTable.d.ts +7 -3
- package/dist/Table/VirtualizedTable.d.ts.map +1 -1
- package/dist/Table/VirtualizedTable.js +157 -123
- package/dist/Table/VirtualizedTable.js.map +1 -1
- package/dist/Table/VirtualizedTableContainer.d.ts.map +1 -1
- package/dist/Table/VirtualizedTableContainer.js +6 -2
- package/dist/Table/VirtualizedTableContainer.js.map +1 -1
- package/dist/Table/hooks/useFuzzySearch.d.ts +14 -0
- package/dist/Table/hooks/useFuzzySearch.d.ts.map +1 -0
- package/dist/Table/hooks/useFuzzySearch.js +62 -0
- package/dist/Table/hooks/useFuzzySearch.js.map +1 -0
- package/dist/Table/model/table-model.d.ts +78 -4
- package/dist/Table/model/table-model.d.ts.map +1 -1
- package/dist/Table/model/table-model.js +37 -19
- package/dist/Table/model/table-model.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.d.ts +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.d.ts.map +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.js +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.d.ts +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.d.ts.map +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.js +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.d.ts.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.js +25 -2
- package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.js +1 -1
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesMarker.js +1 -1
- package/dist/TimeSeriesTooltip/SeriesMarker.js.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts +1 -2
- package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.js +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.d.ts +2 -2
- package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.js +1 -2
- package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
- package/dist/TimeZoneSelector.js +1 -1
- package/dist/TimeZoneSelector.js.map +1 -1
- package/dist/ToolbarIconButton/ToolbarIconButton.js +1 -1
- package/dist/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
- package/dist/TransformsEditor/TransformEditor.d.ts +1 -1
- package/dist/TransformsEditor/TransformEditor.d.ts.map +1 -1
- package/dist/TransformsEditor/TransformEditor.js +1 -1
- package/dist/TransformsEditor/TransformEditor.js.map +1 -1
- package/dist/TransformsEditor/TransformEditorContainer.d.ts.map +1 -1
- package/dist/TransformsEditor/TransformEditorContainer.js +2 -2
- package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
- package/dist/TransformsEditor/TransformsEditor.d.ts +1 -1
- package/dist/TransformsEditor/TransformsEditor.d.ts.map +1 -1
- package/dist/TransformsEditor/TransformsEditor.js +1 -1
- package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.d.ts +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.d.ts.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.js +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.d.ts +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.d.ts.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.js +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.js.map +1 -1
- package/dist/YAxisLabel.js +1 -1
- package/dist/YAxisLabel.js.map +1 -1
- package/dist/cjs/ContentWithLegend/ContentWithLegend.js +2 -2
- package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +2 -2
- package/dist/cjs/FormatControls/FormatControls.js +4 -4
- package/dist/cjs/FormatControls/UnitSelector.js +3 -3
- package/dist/cjs/Legend/Legend.js +2 -2
- package/dist/cjs/Legend/TableLegend.js +16 -2
- package/dist/cjs/Table/Table.js +44 -11
- package/dist/cjs/Table/TableHeaderCell.js +54 -22
- package/dist/cjs/Table/TableToolbar.js +151 -0
- package/dist/cjs/Table/VirtualizedTable.js +155 -121
- package/dist/cjs/Table/VirtualizedTableContainer.js +5 -1
- package/dist/cjs/Table/hooks/useFuzzySearch.js +67 -0
- package/dist/cjs/Table/model/table-model.js +43 -19
- package/dist/cjs/TimeRangeSelector/TimeRangeSelector.js +23 -0
- package/dist/cjs/TimeSeriesTooltip/nearby-series.js +2 -3
- package/dist/cjs/TransformsEditor/TransformEditorContainer.js +2 -2
- package/dist/cjs/model/action.js +43 -0
- package/dist/cjs/model/bits.js +113 -0
- package/dist/cjs/model/bytes.js +115 -0
- package/dist/cjs/model/constants.js +23 -0
- package/dist/cjs/model/currency.js +126 -0
- package/dist/cjs/model/date.js +297 -0
- package/dist/cjs/model/decimal.js +72 -0
- package/dist/cjs/model/formatterCache.js +120 -0
- package/dist/cjs/model/index.js +17 -0
- package/dist/cjs/model/legend.js +101 -0
- package/dist/cjs/model/percent.js +82 -0
- package/dist/cjs/model/temperature.js +72 -0
- package/dist/cjs/model/thresholds.js +16 -0
- package/dist/cjs/model/throughput.js +161 -0
- package/dist/cjs/model/time.js +178 -0
- package/dist/cjs/model/transforms.js +29 -0
- package/dist/cjs/model/types.js +16 -0
- package/dist/cjs/model/units.js +186 -0
- package/dist/cjs/model/utils.js +48 -0
- package/dist/cjs/model/value-mapping.js +16 -0
- package/dist/cjs/theme/typography.js +1 -1
- package/dist/cjs/utils/axis.js +5 -5
- package/dist/cjs/utils/format.js +20 -0
- package/dist/cjs/utils/index.js +1 -0
- package/dist/cjs/utils/request-interpolation.js +49 -0
- package/dist/context/ChartsProvider.js +1 -1
- package/dist/context/ChartsProvider.js.map +1 -1
- package/dist/context/ItemActionsProvider.js +1 -1
- package/dist/context/ItemActionsProvider.js.map +1 -1
- package/dist/context/SelectionProvider.js +1 -1
- package/dist/context/SelectionProvider.js.map +1 -1
- package/dist/context/SnackbarProvider.js +1 -1
- package/dist/context/SnackbarProvider.js.map +1 -1
- package/dist/context/TimeZoneProvider.js +1 -1
- package/dist/context/TimeZoneProvider.js.map +1 -1
- package/dist/controls/TextField.js +1 -1
- package/dist/controls/TextField.js.map +1 -1
- package/dist/model/action.d.ts +4 -0
- package/dist/model/action.d.ts.map +1 -0
- package/dist/model/action.js +27 -0
- package/dist/model/action.js.map +1 -0
- package/dist/model/bits.d.ts +12 -0
- package/dist/model/bits.d.ts.map +1 -0
- package/dist/model/bits.js +89 -0
- package/dist/model/bits.js.map +1 -0
- package/dist/model/bytes.d.ts +12 -0
- package/dist/model/bytes.d.ts.map +1 -0
- package/dist/model/bytes.js +91 -0
- package/dist/model/bytes.js.map +1 -0
- package/dist/model/constants.d.ts +2 -0
- package/dist/model/constants.d.ts.map +1 -0
- package/dist/model/constants.js +15 -0
- package/dist/model/constants.js.map +1 -0
- package/dist/model/currency.d.ts +11 -0
- package/dist/model/currency.d.ts.map +1 -0
- package/dist/model/currency.js +107 -0
- package/dist/model/currency.js.map +1 -0
- package/dist/model/date.d.ts +28 -0
- package/dist/model/date.d.ts.map +1 -0
- package/dist/model/date.js +278 -0
- package/dist/model/date.js.map +1 -0
- package/dist/model/decimal.d.ts +12 -0
- package/dist/model/decimal.d.ts.map +1 -0
- package/dist/model/decimal.js +53 -0
- package/dist/model/decimal.js.map +1 -0
- package/dist/model/formatterCache.d.ts +11 -0
- package/dist/model/formatterCache.d.ts.map +1 -0
- package/dist/model/formatterCache.js +104 -0
- package/dist/model/formatterCache.js.map +1 -0
- package/dist/model/index.d.ts +17 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +17 -0
- package/dist/model/index.js.map +1 -1
- package/dist/model/legend.d.ts +19 -0
- package/dist/model/legend.d.ts.map +1 -0
- package/dist/model/legend.js +61 -0
- package/dist/model/legend.js.map +1 -0
- package/dist/model/percent.d.ts +11 -0
- package/dist/model/percent.d.ts.map +1 -0
- package/dist/model/percent.js +63 -0
- package/dist/model/percent.js.map +1 -0
- package/dist/model/temperature.d.ts +11 -0
- package/dist/model/temperature.d.ts.map +1 -0
- package/dist/model/temperature.js +53 -0
- package/dist/model/temperature.js.map +1 -0
- package/dist/model/theme.d.ts +1 -1
- package/dist/model/theme.d.ts.map +1 -1
- package/dist/model/theme.js.map +1 -1
- package/dist/model/thresholds.d.ts +16 -0
- package/dist/model/thresholds.d.ts.map +1 -0
- package/dist/model/thresholds.js +15 -0
- package/dist/model/thresholds.js.map +1 -0
- package/dist/model/throughput.d.ts +12 -0
- package/dist/model/throughput.d.ts.map +1 -0
- package/dist/model/throughput.js +142 -0
- package/dist/model/throughput.js.map +1 -0
- package/dist/model/time.d.ts +23 -0
- package/dist/model/time.d.ts.map +1 -0
- package/dist/model/time.js +158 -0
- package/dist/model/time.js.map +1 -0
- package/dist/model/transforms.d.ts +43 -0
- package/dist/model/transforms.d.ts.map +1 -0
- package/dist/model/transforms.js +22 -0
- package/dist/model/transforms.js.map +1 -0
- package/dist/model/types.d.ts +56 -0
- package/dist/model/types.d.ts.map +1 -0
- package/dist/model/types.js +15 -0
- package/dist/model/types.js.map +1 -0
- package/dist/model/units.d.ts +105 -0
- package/dist/model/units.d.ts.map +1 -0
- package/dist/model/units.js +132 -0
- package/dist/model/units.js.map +1 -0
- package/dist/model/utils.d.ts +4 -0
- package/dist/model/utils.d.ts.map +1 -0
- package/dist/model/utils.js +32 -0
- package/dist/model/utils.js.map +1 -0
- package/dist/model/value-mapping.d.ts +35 -0
- package/dist/model/value-mapping.d.ts.map +1 -0
- package/dist/model/value-mapping.js +15 -0
- package/dist/model/value-mapping.js.map +1 -0
- package/dist/test/render.js +1 -1
- package/dist/test/render.js.map +1 -1
- package/dist/theme/typography.js +1 -1
- package/dist/theme/typography.js.map +1 -1
- package/dist/utils/axis.d.ts +1 -1
- package/dist/utils/axis.d.ts.map +1 -1
- package/dist/utils/axis.js +1 -1
- package/dist/utils/axis.js.map +1 -1
- package/dist/utils/format.d.ts +1 -0
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +17 -0
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/request-interpolation.d.ts +6 -0
- package/dist/utils/request-interpolation.d.ts.map +1 -0
- package/dist/utils/request-interpolation.js +33 -0
- package/dist/utils/request-interpolation.js.map +1 -0
- package/package.json +4 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ValueMappingEditor/ValueMappingsEditor.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 { Button, Divider, Stack, Typography, Grid2 as Grid } from '@mui/material';\nimport { FC, useState } from 'react';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport { ValueMapping } from '
|
|
1
|
+
{"version":3,"sources":["../../src/ValueMappingEditor/ValueMappingsEditor.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 { Button, Divider, Stack, Typography, Grid2 as Grid } from '@mui/material';\nimport { FC, useState } from 'react';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport { ValueMapping } from '../model';\nimport { ValueMappingEditor } from './ValueMappingEditor';\n\nexport interface ValueMappingsEditorProps {\n mappings: ValueMapping[];\n onChange: (valueMappings: ValueMapping[]) => void;\n}\n\nexport const ValueMappingsEditor: FC<ValueMappingsEditorProps> = ({ mappings, onChange }) => {\n const [valueMappings, setValueMappings] = useState<ValueMapping[]>(mappings);\n\n function handleValueMappingChange(index: number, mapping: ValueMapping): void {\n const updatedValueMapings = [...valueMappings];\n updatedValueMapings[index] = mapping;\n setValueMappings(updatedValueMapings);\n onChange(updatedValueMapings);\n }\n\n function handleAddValueMappingEditor(): void {\n const updatedValueMapings = [...valueMappings];\n updatedValueMapings.push({ kind: 'Value', spec: { result: { value: '' } } } as ValueMapping);\n setValueMappings(updatedValueMapings);\n onChange(updatedValueMapings);\n }\n\n function handleValueMappingDelete(index: number): void {\n const updatedValueMapings = [...valueMappings];\n updatedValueMapings.splice(index, 1);\n setValueMappings(updatedValueMapings);\n onChange(updatedValueMapings);\n }\n\n return (\n <Stack spacing={1}>\n <Grid container spacing={2}>\n <Grid size={{ xs: 5 }}>\n <Typography variant=\"subtitle1\">Condition</Typography>\n </Grid>\n <Grid size={{ xs: 4 }}>\n <Typography variant=\"subtitle1\">Display Text</Typography>\n </Grid>\n <Grid size={{ xs: 1 }} textAlign=\"center\">\n <Typography variant=\"subtitle1\">Color</Typography>\n </Grid>\n <Grid size={{ xs: 1 }}></Grid>\n </Grid>\n <Stack gap={1.5} divider={<Divider flexItem orientation=\"horizontal\" />}>\n {valueMappings.map((mapping, i) => (\n <ValueMappingEditor\n key={i}\n mapping={mapping}\n onChange={(updatedMapping: ValueMapping) => handleValueMappingChange(i, updatedMapping)}\n onDelete={() => handleValueMappingDelete(i)}\n />\n ))}\n </Stack>\n\n <Button variant=\"contained\" startIcon={<AddIcon />} sx={{ marginTop: 1 }} onClick={handleAddValueMappingEditor}>\n Add value mappings\n </Button>\n </Stack>\n );\n};\n"],"names":["Button","Divider","Stack","Typography","Grid2","Grid","useState","AddIcon","ValueMappingEditor","ValueMappingsEditor","mappings","onChange","valueMappings","setValueMappings","handleValueMappingChange","index","mapping","updatedValueMapings","handleAddValueMappingEditor","push","kind","spec","result","value","handleValueMappingDelete","splice","spacing","container","size","xs","variant","textAlign","gap","divider","flexItem","orientation","map","i","updatedMapping","onDelete","startIcon","sx","marginTop","onClick"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,MAAM,EAAEC,OAAO,EAAEC,KAAK,EAAEC,UAAU,EAAEC,SAASC,IAAI,QAAQ,gBAAgB;AAClF,SAAaC,QAAQ,QAAQ,QAAQ;AACrC,OAAOC,aAAa,uBAAuB;AAE3C,SAASC,kBAAkB,QAAQ,uBAAuB;AAO1D,OAAO,MAAMC,sBAAoD,CAAC,EAAEC,QAAQ,EAAEC,QAAQ,EAAE;IACtF,MAAM,CAACC,eAAeC,iBAAiB,GAAGP,SAAyBI;IAEnE,SAASI,yBAAyBC,KAAa,EAAEC,OAAqB;QACpE,MAAMC,sBAAsB;eAAIL;SAAc;QAC9CK,mBAAmB,CAACF,MAAM,GAAGC;QAC7BH,iBAAiBI;QACjBN,SAASM;IACX;IAEA,SAASC;QACP,MAAMD,sBAAsB;eAAIL;SAAc;QAC9CK,oBAAoBE,IAAI,CAAC;YAAEC,MAAM;YAASC,MAAM;gBAAEC,QAAQ;oBAAEC,OAAO;gBAAG;YAAE;QAAE;QAC1EV,iBAAiBI;QACjBN,SAASM;IACX;IAEA,SAASO,yBAAyBT,KAAa;QAC7C,MAAME,sBAAsB;eAAIL;SAAc;QAC9CK,oBAAoBQ,MAAM,CAACV,OAAO;QAClCF,iBAAiBI;QACjBN,SAASM;IACX;IAEA,qBACE,MAACf;QAAMwB,SAAS;;0BACd,MAACrB;gBAAKsB,SAAS;gBAACD,SAAS;;kCACvB,KAACrB;wBAAKuB,MAAM;4BAAEC,IAAI;wBAAE;kCAClB,cAAA,KAAC1B;4BAAW2B,SAAQ;sCAAY;;;kCAElC,KAACzB;wBAAKuB,MAAM;4BAAEC,IAAI;wBAAE;kCAClB,cAAA,KAAC1B;4BAAW2B,SAAQ;sCAAY;;;kCAElC,KAACzB;wBAAKuB,MAAM;4BAAEC,IAAI;wBAAE;wBAAGE,WAAU;kCAC/B,cAAA,KAAC5B;4BAAW2B,SAAQ;sCAAY;;;kCAElC,KAACzB;wBAAKuB,MAAM;4BAAEC,IAAI;wBAAE;;;;0BAEtB,KAAC3B;gBAAM8B,KAAK;gBAAKC,uBAAS,KAAChC;oBAAQiC,QAAQ;oBAACC,aAAY;;0BACrDvB,cAAcwB,GAAG,CAAC,CAACpB,SAASqB,kBAC3B,KAAC7B;wBAECQ,SAASA;wBACTL,UAAU,CAAC2B,iBAAiCxB,yBAAyBuB,GAAGC;wBACxEC,UAAU,IAAMf,yBAAyBa;uBAHpCA;;0BAQX,KAACrC;gBAAO8B,SAAQ;gBAAYU,yBAAW,KAACjC;gBAAYkC,IAAI;oBAAEC,WAAW;gBAAE;gBAAGC,SAASzB;0BAA6B;;;;AAKtH,EAAE"}
|
package/dist/YAxisLabel.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, Typography } from '@mui/material';
|
|
15
15
|
export function YAxisLabel({ name, height }) {
|
|
16
16
|
return /*#__PURE__*/ _jsx(Box, {
|
package/dist/YAxisLabel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/YAxisLabel.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 { Box, Typography } from '@mui/material';\nimport { ReactElement } from 'react';\n\ninterface YAxisLabelProps {\n name: string;\n height: number;\n}\n\nexport function YAxisLabel({ name, height }: YAxisLabelProps): ReactElement {\n return (\n <Box\n style={{\n maxWidth: height, // allows rotated text to truncate instead of causing overlap\n top: `calc(${height}px / 2)`,\n }}\n sx={{\n display: 'inline-block',\n position: 'absolute',\n transform: 'translateX(-50%) rotate(-90deg)',\n transformOrigin: 'top',\n textAlign: 'center',\n zIndex: 1,\n }}\n >\n <Typography\n variant=\"body1\"\n aria-label=\"y axis label\"\n sx={{\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n }}\n >\n {name}\n </Typography>\n </Box>\n );\n}\n"],"names":["Box","Typography","YAxisLabel","name","height","style","maxWidth","top","sx","display","position","transform","transformOrigin","textAlign","zIndex","variant","aria-label","whiteSpace","overflow","textOverflow"],"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/YAxisLabel.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 { Box, Typography } from '@mui/material';\nimport { ReactElement } from 'react';\n\ninterface YAxisLabelProps {\n name: string;\n height: number;\n}\n\nexport function YAxisLabel({ name, height }: YAxisLabelProps): ReactElement {\n return (\n <Box\n style={{\n maxWidth: height, // allows rotated text to truncate instead of causing overlap\n top: `calc(${height}px / 2)`,\n }}\n sx={{\n display: 'inline-block',\n position: 'absolute',\n transform: 'translateX(-50%) rotate(-90deg)',\n transformOrigin: 'top',\n textAlign: 'center',\n zIndex: 1,\n }}\n >\n <Typography\n variant=\"body1\"\n aria-label=\"y axis label\"\n sx={{\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n }}\n >\n {name}\n </Typography>\n </Box>\n );\n}\n"],"names":["Box","Typography","YAxisLabel","name","height","style","maxWidth","top","sx","display","position","transform","transformOrigin","textAlign","zIndex","variant","aria-label","whiteSpace","overflow","textOverflow"],"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,GAAG,EAAEC,UAAU,QAAQ,gBAAgB;AAQhD,OAAO,SAASC,WAAW,EAAEC,IAAI,EAAEC,MAAM,EAAmB;IAC1D,qBACE,KAACJ;QACCK,OAAO;YACLC,UAAUF;YACVG,KAAK,CAAC,KAAK,EAAEH,OAAO,OAAO,CAAC;QAC9B;QACAI,IAAI;YACFC,SAAS;YACTC,UAAU;YACVC,WAAW;YACXC,iBAAiB;YACjBC,WAAW;YACXC,QAAQ;QACV;kBAEA,cAAA,KAACb;YACCc,SAAQ;YACRC,cAAW;YACXR,IAAI;gBACFS,YAAY;gBACZC,UAAU;gBACVC,cAAc;YAChB;sBAEChB;;;AAIT"}
|
|
@@ -22,7 +22,7 @@ Object.defineProperty(exports, "ContentWithLegend", {
|
|
|
22
22
|
});
|
|
23
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
24
24
|
const _material = require("@mui/material");
|
|
25
|
-
const
|
|
25
|
+
const _model = require("../model");
|
|
26
26
|
const _Legend = require("../Legend");
|
|
27
27
|
const _contentwithlegendmodel = require("./model/content-with-legend-model");
|
|
28
28
|
function ContentWithLegend({ children, legendProps, width, height, spacing = 0, legendSize, minChildrenWidth = 100, minChildrenHeight = 100 }) {
|
|
@@ -35,7 +35,7 @@ function ContentWithLegend({ children, legendProps, width, height, spacing = 0,
|
|
|
35
35
|
minChildrenWidth,
|
|
36
36
|
spacing,
|
|
37
37
|
theme,
|
|
38
|
-
legendSize: (0,
|
|
38
|
+
legendSize: (0, _model.getLegendSize)(legendSize)
|
|
39
39
|
});
|
|
40
40
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
41
41
|
style: {
|
|
@@ -28,7 +28,7 @@ _export(exports, {
|
|
|
28
28
|
return getContentWithLegendLayout;
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
|
-
const
|
|
31
|
+
const _model = require("../../model");
|
|
32
32
|
const _Table = require("../../Table");
|
|
33
33
|
const TABLE_LEGEND_SIZE = {
|
|
34
34
|
medium: {
|
|
@@ -69,7 +69,7 @@ function getContentWithLegendLayout({ width, height, legendProps, legendSize, mi
|
|
|
69
69
|
return noLegendLayout;
|
|
70
70
|
}
|
|
71
71
|
const { position } = legendOptions;
|
|
72
|
-
const mode = (0,
|
|
72
|
+
const mode = (0, _model.getLegendMode)(legendOptions.mode);
|
|
73
73
|
let legendWidth;
|
|
74
74
|
let legendHeight;
|
|
75
75
|
if (mode === 'list') {
|
|
@@ -22,9 +22,9 @@ Object.defineProperty(exports, "FormatControls", {
|
|
|
22
22
|
});
|
|
23
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
24
24
|
const _material = require("@mui/material");
|
|
25
|
-
const _core = require("@perses-dev/core");
|
|
26
25
|
const _OptionsEditorLayout = require("../OptionsEditorLayout");
|
|
27
26
|
const _SettingsAutocomplete = require("../SettingsAutocomplete");
|
|
27
|
+
const _model = require("../model");
|
|
28
28
|
const _UnitSelector = require("./UnitSelector");
|
|
29
29
|
const DECIMAL_PLACES_OPTIONS = [
|
|
30
30
|
{
|
|
@@ -62,8 +62,8 @@ function getOptionByDecimalPlaces(decimalPlaces) {
|
|
|
62
62
|
return DECIMAL_PLACES_OPTIONS.find((o)=>o.decimalPlaces === decimalPlaces);
|
|
63
63
|
}
|
|
64
64
|
function FormatControls({ value, onChange, disabled = false }) {
|
|
65
|
-
const hasDecimalPlaces = (0,
|
|
66
|
-
const hasShortValues = (0,
|
|
65
|
+
const hasDecimalPlaces = (0, _model.isUnitWithDecimalPlaces)(value);
|
|
66
|
+
const hasShortValues = (0, _model.isUnitWithShortValues)(value);
|
|
67
67
|
const handleUnitChange = (newValue)=>{
|
|
68
68
|
onChange(newValue || {
|
|
69
69
|
unit: 'decimal'
|
|
@@ -90,7 +90,7 @@ function FormatControls({ value, onChange, disabled = false }) {
|
|
|
90
90
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_OptionsEditorLayout.OptionsEditorControl, {
|
|
91
91
|
label: "Short values",
|
|
92
92
|
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
|
|
93
|
-
checked: hasShortValues ? (0,
|
|
93
|
+
checked: hasShortValues ? (0, _model.shouldShortenValues)(value.shortValues) : false,
|
|
94
94
|
onChange: handleShortValuesChange,
|
|
95
95
|
disabled: !hasShortValues
|
|
96
96
|
})
|
|
@@ -21,9 +21,9 @@ Object.defineProperty(exports, "UnitSelector", {
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
-
const _core = require("@perses-dev/core");
|
|
25
24
|
const _SettingsAutocomplete = require("../SettingsAutocomplete");
|
|
26
|
-
const
|
|
25
|
+
const _model = require("../model");
|
|
26
|
+
const KIND_OPTIONS = Object.entries(_model.UNIT_CONFIG).map(([id, config])=>{
|
|
27
27
|
return {
|
|
28
28
|
...config,
|
|
29
29
|
id: id,
|
|
@@ -31,7 +31,7 @@ const KIND_OPTIONS = Object.entries(_core.UNIT_CONFIG).map(([id, config])=>{
|
|
|
31
31
|
};
|
|
32
32
|
}).filter((config)=>!config.disableSelectorOption);
|
|
33
33
|
function UnitSelector({ value, onChange, disabled = false, ...otherProps }) {
|
|
34
|
-
const unitConfig =
|
|
34
|
+
const unitConfig = _model.UNIT_CONFIG[value?.unit || 'decimal'];
|
|
35
35
|
const handleChange = (_, newValue)=>{
|
|
36
36
|
if (newValue === null) {
|
|
37
37
|
onChange(undefined);
|
|
@@ -23,7 +23,7 @@ Object.defineProperty(exports, "Legend", {
|
|
|
23
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
24
24
|
const _material = require("@mui/material");
|
|
25
25
|
const _immer = require("immer");
|
|
26
|
-
const
|
|
26
|
+
const _model = require("../model");
|
|
27
27
|
const _ListLegend = require("./ListLegend");
|
|
28
28
|
const _CompactLegend = require("./CompactLegend");
|
|
29
29
|
const _TableLegend = require("./TableLegend");
|
|
@@ -66,7 +66,7 @@ function Legend({ width, height, options, data, selectedItems, onSelectedItemsCh
|
|
|
66
66
|
});
|
|
67
67
|
onSelectedItemsChange(newSelected);
|
|
68
68
|
};
|
|
69
|
-
const mode = (0,
|
|
69
|
+
const mode = (0, _model.getLegendMode)(options.mode);
|
|
70
70
|
// The bottom legend is displayed as a list when the number of items is too
|
|
71
71
|
// large and requires virtualization. Otherwise, it is rendered more compactly.
|
|
72
72
|
// We do not need this check for the right-side legend because it is always
|
|
@@ -28,6 +28,7 @@ const COLUMNS = [
|
|
|
28
28
|
accessorKey: 'label',
|
|
29
29
|
header: 'Name',
|
|
30
30
|
enableSorting: true,
|
|
31
|
+
enableResizing: true,
|
|
31
32
|
// Starting with `title` attr instead of a tooltip because it is easier to
|
|
32
33
|
// implement. We should try adding a tooltip in the future, but we'll need
|
|
33
34
|
// to be very careful about performance when doing so with large tables.
|
|
@@ -43,6 +44,8 @@ const getRowId = (data)=>{
|
|
|
43
44
|
const getCheckboxColor = (data)=>{
|
|
44
45
|
return data.color;
|
|
45
46
|
};
|
|
47
|
+
// This is a rough estimate of value that needs to be subtracted from the total width to avoid horizontal scrolling on initial render
|
|
48
|
+
const TABLE_PADDING = 45;
|
|
46
49
|
function TableLegend({ items, selectedItems: initRowSelection, onSelectedItemsChange, onItemMouseOver, onItemMouseOut, height, width, columns: additionalColumns = [], sorting, onSortingChange }) {
|
|
47
50
|
const rowSelection = (0, _react.useMemo)(()=>{
|
|
48
51
|
return typeof initRowSelection !== 'string' ? initRowSelection : // items for checkboxes.
|
|
@@ -56,12 +59,23 @@ function TableLegend({ items, selectedItems: initRowSelection, onSelectedItemsCh
|
|
|
56
59
|
items
|
|
57
60
|
]);
|
|
58
61
|
const columns = (0, _react.useMemo)(()=>{
|
|
62
|
+
// Calculate column widths to fit the container on initial render, avoiding unnecessary horizontal scrolling.
|
|
63
|
+
// Falls back to a default width if available width is too small; the user can resize columns as needed.
|
|
64
|
+
const additionalColumnsLength = additionalColumns?.reduce((colWidth, col)=>{
|
|
65
|
+
return colWidth + (typeof col.width === 'number' ? col.width : _Table.DEFAULT_COLUMN_WIDTH);
|
|
66
|
+
}, 0) ?? 0;
|
|
67
|
+
const availableWidth = Math.max(width - additionalColumnsLength - TABLE_PADDING, _Table.DEFAULT_COLUMN_MIN_WIDTH * COLUMNS.length);
|
|
68
|
+
const columnWidth = availableWidth / COLUMNS.length;
|
|
59
69
|
return [
|
|
60
|
-
...COLUMNS
|
|
70
|
+
...COLUMNS.map((column)=>({
|
|
71
|
+
...column,
|
|
72
|
+
width: columnWidth
|
|
73
|
+
})),
|
|
61
74
|
...additionalColumns
|
|
62
75
|
];
|
|
63
76
|
}, [
|
|
64
|
-
additionalColumns
|
|
77
|
+
additionalColumns,
|
|
78
|
+
width
|
|
65
79
|
]);
|
|
66
80
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_Table.Table, {
|
|
67
81
|
height: height,
|
package/dist/cjs/Table/Table.js
CHANGED
|
@@ -24,6 +24,7 @@ const _jsxruntime = require("react/jsx-runtime");
|
|
|
24
24
|
const _material = require("@mui/material");
|
|
25
25
|
const _reacttable = require("@tanstack/react-table");
|
|
26
26
|
const _react = require("react");
|
|
27
|
+
const _useFuzzySearch = require("./hooks/useFuzzySearch");
|
|
27
28
|
const _TableCheckbox = require("./TableCheckbox");
|
|
28
29
|
const _VirtualizedTable = require("./VirtualizedTable");
|
|
29
30
|
const _tablemodel = require("./model/table-model");
|
|
@@ -35,8 +36,15 @@ const DEFAULT_GET_ROW_ID = (data, index)=>{
|
|
|
35
36
|
// does not do deep equality checking for objects and arrays.
|
|
36
37
|
const DEFAULT_ROW_SELECTION = {};
|
|
37
38
|
const DEFAULT_SORTING = [];
|
|
38
|
-
function Table({ data, columns, cellConfigs, density = 'standard', defaultColumnWidth = _tablemodel.DEFAULT_COLUMN_WIDTH, defaultColumnHeight = 'auto', checkboxSelection, onRowSelectionChange, onSortingChange, getCheckboxColor, getRowId = DEFAULT_GET_ROW_ID, rowSelection = DEFAULT_ROW_SELECTION, sorting = DEFAULT_SORTING, getItemActions, hasItemActions, pagination, onPaginationChange, rowSelectionVariant = 'standard', ...otherProps }) {
|
|
39
|
+
function Table({ data, columns, cellConfigs, density = 'standard', defaultColumnWidth = _tablemodel.DEFAULT_COLUMN_WIDTH, defaultColumnHeight = 'auto', checkboxSelection, onRowSelectionChange, onSortingChange, getCheckboxColor, getRowId = DEFAULT_GET_ROW_ID, rowSelection = DEFAULT_ROW_SELECTION, sorting = DEFAULT_SORTING, getItemActions, hasItemActions, pagination, onPaginationChange, rowSelectionVariant = 'standard', getSubRows, hiddenColumns, tableToolbarConfig, columnResizeMode = 'onChange', defaultColumnConfig, ...otherProps }) {
|
|
39
40
|
const theme = (0, _material.useTheme)();
|
|
41
|
+
const hasSubRows = !!getSubRows;
|
|
42
|
+
const [expanded, setExpanded] = (0, _react.useState)({});
|
|
43
|
+
const { globalFilter, setGlobalFilter, fuzzySearchOptions } = (0, _useFuzzySearch.useFuzzySearch)(tableToolbarConfig?.isSearchEnabled, tableToolbarConfig?.fuzzyMatchThreshold ?? 'CONTAINS', expanded, setExpanded);
|
|
44
|
+
const [columnVisibility, setColumnVisibility] = (0, _react.useState)(hiddenColumns?.reduce((acc, columnId)=>({
|
|
45
|
+
...acc,
|
|
46
|
+
[columnId]: false
|
|
47
|
+
}), {}) ?? {});
|
|
40
48
|
const handleRowSelectionChange = (rowSelectionUpdater)=>{
|
|
41
49
|
const newRowSelection = typeof rowSelectionUpdater === 'function' ? rowSelectionUpdater(rowSelection) : rowSelectionUpdater;
|
|
42
50
|
onRowSelectionChange?.(newRowSelection);
|
|
@@ -87,7 +95,8 @@ function Table({ data, columns, cellConfigs, density = 'standard', defaultColumn
|
|
|
87
95
|
})
|
|
88
96
|
});
|
|
89
97
|
},
|
|
90
|
-
enableSorting: false
|
|
98
|
+
enableSorting: false,
|
|
99
|
+
enableResizing: false
|
|
91
100
|
};
|
|
92
101
|
}, [
|
|
93
102
|
getItemActions
|
|
@@ -116,7 +125,8 @@ function Table({ data, columns, cellConfigs, density = 'standard', defaultColumn
|
|
|
116
125
|
density: density
|
|
117
126
|
});
|
|
118
127
|
},
|
|
119
|
-
enableSorting: false
|
|
128
|
+
enableSorting: false,
|
|
129
|
+
enableResizing: false
|
|
120
130
|
};
|
|
121
131
|
}, [
|
|
122
132
|
theme.palette.text.primary,
|
|
@@ -125,7 +135,7 @@ function Table({ data, columns, cellConfigs, density = 'standard', defaultColumn
|
|
|
125
135
|
handleCheckboxChange
|
|
126
136
|
]);
|
|
127
137
|
const tableColumns = (0, _react.useMemo)(()=>{
|
|
128
|
-
const initTableColumns = (0, _tablemodel.persesColumnsToTanstackColumns)(columns);
|
|
138
|
+
const initTableColumns = (0, _tablemodel.persesColumnsToTanstackColumns)(columns, defaultColumnConfig);
|
|
129
139
|
if (hasItemActions) {
|
|
130
140
|
initTableColumns.unshift(actionsColumn);
|
|
131
141
|
}
|
|
@@ -134,16 +144,17 @@ function Table({ data, columns, cellConfigs, density = 'standard', defaultColumn
|
|
|
134
144
|
}
|
|
135
145
|
return initTableColumns;
|
|
136
146
|
}, [
|
|
137
|
-
checkboxColumn,
|
|
138
|
-
checkboxSelection,
|
|
139
147
|
columns,
|
|
148
|
+
defaultColumnConfig,
|
|
140
149
|
hasItemActions,
|
|
141
|
-
|
|
150
|
+
checkboxSelection,
|
|
151
|
+
actionsColumn,
|
|
152
|
+
checkboxColumn
|
|
142
153
|
]);
|
|
143
154
|
const table = (0, _reacttable.useReactTable)({
|
|
144
155
|
data,
|
|
145
156
|
columns: tableColumns,
|
|
146
|
-
getRowId,
|
|
157
|
+
getRowId: getRowId,
|
|
147
158
|
getCoreRowModel: (0, _reacttable.getCoreRowModel)(),
|
|
148
159
|
getSortedRowModel: (0, _reacttable.getSortedRowModel)(),
|
|
149
160
|
getPaginationRowModel: pagination ? (0, _reacttable.getPaginationRowModel)() : undefined,
|
|
@@ -153,15 +164,24 @@ function Table({ data, columns, cellConfigs, density = 'standard', defaultColumn
|
|
|
153
164
|
enableRowSelection: !!checkboxSelection,
|
|
154
165
|
onRowSelectionChange: handleRowSelectionChange,
|
|
155
166
|
onSortingChange: handleSortingChange,
|
|
167
|
+
onColumnVisibilityChange: setColumnVisibility,
|
|
168
|
+
getSubRows: getSubRows,
|
|
169
|
+
getExpandedRowModel: hasSubRows ? (0, _reacttable.getExpandedRowModel)() : undefined,
|
|
170
|
+
...fuzzySearchOptions,
|
|
156
171
|
// For now, defaulting to sort by descending first. We can expose the ability
|
|
157
172
|
// to customize it if/when we have use cases for it.
|
|
158
173
|
sortDescFirst: true,
|
|
174
|
+
columnResizeMode,
|
|
175
|
+
onExpandedChange: setExpanded,
|
|
159
176
|
state: {
|
|
160
177
|
rowSelection,
|
|
161
178
|
sorting,
|
|
179
|
+
globalFilter: tableToolbarConfig?.isSearchEnabled ? globalFilter : undefined,
|
|
180
|
+
columnVisibility,
|
|
162
181
|
...pagination ? {
|
|
163
182
|
pagination
|
|
164
|
-
} : {}
|
|
183
|
+
} : {},
|
|
184
|
+
expanded
|
|
165
185
|
}
|
|
166
186
|
});
|
|
167
187
|
const handleRowClick = (0, _react.useCallback)((e, rowId)=>{
|
|
@@ -179,11 +199,24 @@ function Table({ data, columns, cellConfigs, density = 'standard', defaultColumn
|
|
|
179
199
|
defaultColumnHeight: defaultColumnHeight,
|
|
180
200
|
onRowClick: handleRowClick,
|
|
181
201
|
rows: table.getRowModel().rows,
|
|
182
|
-
columns: table.
|
|
202
|
+
columns: table.getVisibleFlatColumns(),
|
|
203
|
+
columnSizing: table.getState().columnSizing,
|
|
204
|
+
columnSizingInfo: table.getState().columnSizingInfo,
|
|
183
205
|
headers: table.getHeaderGroups(),
|
|
184
206
|
cellConfigs: cellConfigs,
|
|
185
207
|
pagination: pagination,
|
|
186
208
|
onPaginationChange: onPaginationChange,
|
|
187
|
-
rowCount: table.getRowCount()
|
|
209
|
+
rowCount: table.getRowCount(),
|
|
210
|
+
toolbarConfig: {
|
|
211
|
+
isSearchEnabled: tableToolbarConfig?.isSearchEnabled,
|
|
212
|
+
globalFilter,
|
|
213
|
+
onGlobalFilterChange: setGlobalFilter,
|
|
214
|
+
isColumnFilterEnabled: tableToolbarConfig?.isColumnFilterEnabled,
|
|
215
|
+
columns: table.getAllColumns(),
|
|
216
|
+
columnFilterMenuMaxHeight: tableToolbarConfig?.columnFilterMenuMaxHeight,
|
|
217
|
+
isExpandAllEnabled: hasSubRows,
|
|
218
|
+
isAllExpanded: table.getIsAllRowsExpanded(),
|
|
219
|
+
onExpandAllChange: table.getToggleAllRowsExpandedHandler()
|
|
220
|
+
}
|
|
188
221
|
});
|
|
189
222
|
}
|
|
@@ -23,7 +23,7 @@ Object.defineProperty(exports, "TableHeaderCell", {
|
|
|
23
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
24
24
|
const _material = require("@mui/material");
|
|
25
25
|
const _TableCell = require("./TableCell");
|
|
26
|
-
function TableHeaderCell({ onSort, sortDirection, nextSortDirection, children, ...cellProps }) {
|
|
26
|
+
function TableHeaderCell({ onSort, sortDirection, nextSortDirection, children, resizeConfig, ...cellProps }) {
|
|
27
27
|
const showSortLabel = !!onSort;
|
|
28
28
|
const headerText = /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
29
29
|
noWrap: true,
|
|
@@ -34,28 +34,60 @@ function TableHeaderCell({ onSort, sortDirection, nextSortDirection, children, .
|
|
|
34
34
|
});
|
|
35
35
|
const isActive = !!sortDirection;
|
|
36
36
|
const direction = isActive ? sortDirection : nextSortDirection;
|
|
37
|
-
return /*#__PURE__*/ (0, _jsxruntime.
|
|
37
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_TableCell.TableCell, {
|
|
38
38
|
...cellProps,
|
|
39
|
-
children:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
39
|
+
children: [
|
|
40
|
+
showSortLabel ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TableSortLabel, {
|
|
41
|
+
onClick: onSort,
|
|
42
|
+
direction: direction,
|
|
43
|
+
active: isActive,
|
|
44
|
+
sx: {
|
|
45
|
+
// Overrides a default vertical alignment in the CSS that changes
|
|
46
|
+
// the header vertical rhythm in a way that's inconsistent with
|
|
47
|
+
// non-sorting headers.
|
|
48
|
+
verticalAlign: 'unset',
|
|
49
|
+
// Makes it possible to ellipsize the text if it's too long.
|
|
50
|
+
maxWidth: '100%',
|
|
51
|
+
// Make the arrow visible when focused using the keyboard to assist
|
|
52
|
+
// with a11y.
|
|
53
|
+
'&:focus-visible': {
|
|
54
|
+
[`& .${_material.tableSortLabelClasses.icon}`]: {
|
|
55
|
+
opacity: isActive ? 1 : 0.5
|
|
56
|
+
}
|
|
55
57
|
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
},
|
|
59
|
+
children: headerText
|
|
60
|
+
}) : headerText,
|
|
61
|
+
resizeConfig && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
62
|
+
onMouseDown: (e)=>{
|
|
63
|
+
if (e.detail === 2) {
|
|
64
|
+
resizeConfig.resetSizeHandler();
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
resizeConfig.resizeHandler(e);
|
|
68
|
+
},
|
|
69
|
+
onTouchStart: resizeConfig.resizeHandler,
|
|
70
|
+
sx: {
|
|
71
|
+
position: 'absolute',
|
|
72
|
+
height: '100%',
|
|
73
|
+
top: 0,
|
|
74
|
+
right: '4px',
|
|
75
|
+
cursor: 'col-resize'
|
|
76
|
+
},
|
|
77
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Divider, {
|
|
78
|
+
flexItem: true,
|
|
79
|
+
orientation: "vertical",
|
|
80
|
+
sx: (theme)=>({
|
|
81
|
+
backgroundColor: resizeConfig.isResizing ? theme.palette.action.active : theme.palette.divider,
|
|
82
|
+
borderRadius: '2px',
|
|
83
|
+
borderWidth: '2px',
|
|
84
|
+
height: '100%',
|
|
85
|
+
touchAction: 'none',
|
|
86
|
+
transform: 'translateX(4px)',
|
|
87
|
+
userSelect: 'none'
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
]
|
|
60
92
|
});
|
|
61
93
|
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "TableToolbar", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return TableToolbar;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _material = require("@mui/material");
|
|
25
|
+
const _react = require("react");
|
|
26
|
+
const _Magnify = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Magnify"));
|
|
27
|
+
const _Close = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Close"));
|
|
28
|
+
const _ViewColumn = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/ViewColumn"));
|
|
29
|
+
const _UnfoldMoreHorizontal = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/UnfoldMoreHorizontal"));
|
|
30
|
+
const _UnfoldLessHorizontal = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/UnfoldLessHorizontal"));
|
|
31
|
+
const _controls = require("../controls");
|
|
32
|
+
function _interop_require_default(obj) {
|
|
33
|
+
return obj && obj.__esModule ? obj : {
|
|
34
|
+
default: obj
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function TableToolbar({ isSearchEnabled, globalFilter, onGlobalFilterChange, isColumnFilterEnabled, columns, width, columnFilterMenuMaxHeight = 400, isExpandAllEnabled, isAllExpanded, onExpandAllChange }) {
|
|
38
|
+
const [colMenuAnchor, setColMenuAnchor] = (0, _react.useState)(null);
|
|
39
|
+
const colMenuOpen = Boolean(colMenuAnchor);
|
|
40
|
+
const [searchResetKey, setSearchResetKey] = (0, _react.useState)(0);
|
|
41
|
+
const handleSearchClear = (0, _react.useCallback)(()=>{
|
|
42
|
+
onGlobalFilterChange('');
|
|
43
|
+
setSearchResetKey((prev)=>prev + 1);
|
|
44
|
+
}, [
|
|
45
|
+
onGlobalFilterChange
|
|
46
|
+
]);
|
|
47
|
+
if (!isSearchEnabled && !isColumnFilterEnabled && !isExpandAllEnabled) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
51
|
+
direction: "row",
|
|
52
|
+
gap: 1,
|
|
53
|
+
alignItems: "center",
|
|
54
|
+
justifyContent: "flex-end",
|
|
55
|
+
width: width,
|
|
56
|
+
padding: "0.5rem",
|
|
57
|
+
sx: {
|
|
58
|
+
backgroundColor: (theme)=>theme.palette.background.default
|
|
59
|
+
},
|
|
60
|
+
children: [
|
|
61
|
+
isSearchEnabled && /*#__PURE__*/ (0, _jsxruntime.jsx)(_controls.TextField, {
|
|
62
|
+
placeholder: "Search...",
|
|
63
|
+
value: globalFilter,
|
|
64
|
+
onChange: onGlobalFilterChange,
|
|
65
|
+
variant: "standard",
|
|
66
|
+
slotProps: {
|
|
67
|
+
htmlInput: {
|
|
68
|
+
'aria-label': 'search table'
|
|
69
|
+
},
|
|
70
|
+
input: {
|
|
71
|
+
startAdornment: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.InputAdornment, {
|
|
72
|
+
position: "start",
|
|
73
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Magnify.default, {
|
|
74
|
+
fontSize: "small"
|
|
75
|
+
})
|
|
76
|
+
}),
|
|
77
|
+
endAdornment: globalFilter !== '' && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.InputAdornment, {
|
|
78
|
+
position: "end",
|
|
79
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
80
|
+
onClick: handleSearchClear,
|
|
81
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Close.default, {
|
|
82
|
+
fontSize: "small"
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
sx: {
|
|
89
|
+
flexGrow: 1
|
|
90
|
+
}
|
|
91
|
+
}, searchResetKey),
|
|
92
|
+
isExpandAllEnabled && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Tooltip, {
|
|
93
|
+
title: isAllExpanded ? 'Collapse all' : 'Expand all',
|
|
94
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
95
|
+
onClick: onExpandAllChange,
|
|
96
|
+
color: "info",
|
|
97
|
+
"aria-label": isAllExpanded ? 'collapse all rows' : 'expand all rows',
|
|
98
|
+
children: isAllExpanded ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_UnfoldLessHorizontal.default, {}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_UnfoldMoreHorizontal.default, {})
|
|
99
|
+
})
|
|
100
|
+
}),
|
|
101
|
+
isColumnFilterEnabled && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
102
|
+
children: [
|
|
103
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
104
|
+
onClick: (e)=>setColMenuAnchor(e.currentTarget),
|
|
105
|
+
"aria-haspopup": "listbox",
|
|
106
|
+
"aria-expanded": colMenuOpen,
|
|
107
|
+
color: "info",
|
|
108
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_ViewColumn.default, {})
|
|
109
|
+
}),
|
|
110
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Menu, {
|
|
111
|
+
anchorEl: colMenuAnchor,
|
|
112
|
+
open: colMenuOpen,
|
|
113
|
+
onClose: ()=>setColMenuAnchor(null),
|
|
114
|
+
slotProps: {
|
|
115
|
+
list: {
|
|
116
|
+
dense: true
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
sx: {
|
|
120
|
+
maxHeight: columnFilterMenuMaxHeight
|
|
121
|
+
},
|
|
122
|
+
children: columns.map((column)=>{
|
|
123
|
+
const header = column.columnDef.header;
|
|
124
|
+
const label = typeof header === 'string' ? header : column.id;
|
|
125
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.MenuItem, {
|
|
126
|
+
disabled: !column.getCanHide(),
|
|
127
|
+
onClick: column.getCanHide() ? column.getToggleVisibilityHandler() : undefined,
|
|
128
|
+
dense: true,
|
|
129
|
+
children: [
|
|
130
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Checkbox, {
|
|
131
|
+
checked: column.getIsVisible(),
|
|
132
|
+
disabled: !column.getCanHide(),
|
|
133
|
+
size: "small",
|
|
134
|
+
disableRipple: true,
|
|
135
|
+
sx: {
|
|
136
|
+
p: 0,
|
|
137
|
+
mr: 1
|
|
138
|
+
}
|
|
139
|
+
}),
|
|
140
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.ListItemText, {
|
|
141
|
+
primary: label
|
|
142
|
+
})
|
|
143
|
+
]
|
|
144
|
+
}, column.id);
|
|
145
|
+
})
|
|
146
|
+
})
|
|
147
|
+
]
|
|
148
|
+
})
|
|
149
|
+
]
|
|
150
|
+
});
|
|
151
|
+
}
|