@perses-dev/plugin-system 0.55.0-beta.2 → 0.55.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +4 -4
- package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +1 -1
- package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +3 -2
- package/dist/cjs/components/DatasourceSelect/DatasourceSelect.js +1 -1
- package/dist/cjs/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.js +53 -0
- package/dist/cjs/components/DatasourceTestConnectionButton/index.js +30 -0
- package/dist/cjs/components/HTTPSettingsEditor/HTTPSettingsEditor.js +49 -24
- package/dist/cjs/components/LayoutEditor/LayoutEditor.js +123 -0
- package/dist/cjs/components/LayoutEditor/RepeatLayoutPreview.js +105 -0
- package/dist/cjs/components/LayoutEditor/RepeatVariableEditor.js +176 -0
- package/dist/cjs/components/LayoutEditor/index.js +32 -0
- package/dist/cjs/components/LinksEditor/LinksEditor.js +4 -4
- package/dist/cjs/components/MultiQueryEditor/MultiQueryEditor.js +8 -5
- package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +7 -7
- package/dist/cjs/components/PanelSpecEditor/PanelAnnotationsEditor.js +4 -4
- package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +14 -5
- package/dist/cjs/components/PluginEditor/PluginEditor.js +4 -3
- package/dist/cjs/components/PluginEditor/plugin-editor-api.js +1 -1
- package/dist/cjs/components/PluginRegistry/PluginRegistry.js +1 -1
- package/dist/cjs/components/PluginSpecEditor/DatasourceSpecEditor.js +70 -0
- package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +17 -3
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +6 -7
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +5 -5
- package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +1 -1
- package/dist/cjs/components/index.js +2 -0
- package/dist/cjs/constants/index.js +1 -0
- package/dist/cjs/constants/repeat.js +32 -0
- package/dist/cjs/context/ValidationProvider.js +2 -2
- package/dist/cjs/model/index.js +1 -0
- package/dist/cjs/model/json-queries.js +16 -0
- package/dist/cjs/remote/PluginRuntime.js +12 -20
- package/dist/cjs/remote/remotePluginLoader.js +1 -1
- package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +14 -6
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +18 -4
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProviders.js +2 -2
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +14 -1
- package/dist/cjs/runtime/TimeRangeProvider/query-params.js +2 -2
- package/dist/cjs/runtime/alerts-queries.js +1 -1
- package/dist/cjs/runtime/annotations.js +2 -2
- package/dist/cjs/runtime/index.js +1 -0
- package/dist/cjs/runtime/item-actions.js +1 -1
- package/dist/cjs/runtime/json-queries.js +70 -0
- package/dist/cjs/runtime/silences-queries.js +1 -1
- package/dist/cjs/runtime/time-series-queries.js +1 -1
- package/dist/cjs/runtime/trace-queries.js +1 -1
- package/dist/cjs/schema/panel.js +17 -3
- package/dist/cjs/test/mock-data.js +9 -0
- package/dist/cjs/test/setup-tests.js +9 -3
- package/dist/cjs/test/test-plugins/ernie/index.js +58 -1
- package/dist/cjs/utils/csv-export.js +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts +2 -2
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts.map +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +4 -4
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js.map +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts +2 -2
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts.map +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js.map +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +2 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +3 -2
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
- package/dist/components/DatasourceSelect/DatasourceSelect.d.ts.map +1 -1
- package/dist/components/DatasourceSelect/DatasourceSelect.js +1 -1
- package/dist/components/DatasourceSelect/DatasourceSelect.js.map +1 -1
- package/dist/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.d.ts +8 -0
- package/dist/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.d.ts.map +1 -0
- package/dist/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.js +45 -0
- package/dist/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.js.map +1 -0
- package/dist/components/DatasourceTestConnectionButton/index.d.ts +2 -0
- package/dist/components/DatasourceTestConnectionButton/index.d.ts.map +1 -0
- package/dist/components/DatasourceTestConnectionButton/index.js +15 -0
- package/dist/components/DatasourceTestConnectionButton/index.js.map +1 -0
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +2 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +50 -25
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -1
- package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js.map +1 -1
- package/dist/components/LayoutEditor/LayoutEditor.d.ts +16 -0
- package/dist/components/LayoutEditor/LayoutEditor.d.ts.map +1 -0
- package/dist/components/LayoutEditor/LayoutEditor.js +115 -0
- package/dist/components/LayoutEditor/LayoutEditor.js.map +1 -0
- package/dist/components/LayoutEditor/RepeatLayoutPreview.d.ts +7 -0
- package/dist/components/LayoutEditor/RepeatLayoutPreview.d.ts.map +1 -0
- package/dist/components/LayoutEditor/RepeatLayoutPreview.js +92 -0
- package/dist/components/LayoutEditor/RepeatLayoutPreview.js.map +1 -0
- package/dist/components/LayoutEditor/RepeatVariableEditor.d.ts +18 -0
- package/dist/components/LayoutEditor/RepeatVariableEditor.d.ts.map +1 -0
- package/dist/components/LayoutEditor/RepeatVariableEditor.js +168 -0
- package/dist/components/LayoutEditor/RepeatVariableEditor.js.map +1 -0
- package/dist/components/LayoutEditor/index.d.ts +4 -0
- package/dist/components/LayoutEditor/index.d.ts.map +1 -0
- package/dist/components/LayoutEditor/index.js +17 -0
- package/dist/components/LayoutEditor/index.js.map +1 -0
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
- package/dist/components/LinksEditor/LinksEditor.d.ts.map +1 -1
- package/dist/components/LinksEditor/LinksEditor.js +4 -4
- package/dist/components/LinksEditor/LinksEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +0 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js +8 -5
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts +0 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js +7 -7
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts.map +1 -1
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelAnnotationsEditor.d.ts +1 -1
- package/dist/components/PanelSpecEditor/PanelAnnotationsEditor.d.ts.map +1 -1
- package/dist/components/PanelSpecEditor/PanelAnnotationsEditor.js +4 -4
- package/dist/components/PanelSpecEditor/PanelAnnotationsEditor.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +3 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js +14 -5
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js +4 -3
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.d.ts +2 -1
- package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +0 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
- package/dist/components/PluginRegistry/getPluginSearchHelper.d.ts.map +1 -1
- package/dist/components/PluginRegistry/getPluginSearchHelper.js.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
- package/dist/components/PluginSpecEditor/DatasourceSpecEditor.d.ts +10 -0
- package/dist/components/PluginSpecEditor/DatasourceSpecEditor.d.ts.map +1 -0
- package/dist/components/PluginSpecEditor/DatasourceSpecEditor.js +62 -0
- package/dist/components/PluginSpecEditor/DatasourceSpecEditor.js.map +1 -0
- package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts +2 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js +17 -3
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +9 -10
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +2 -2
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +5 -5
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/variable-model.d.ts.map +1 -1
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -1
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +1 -0
- package/dist/constants/index.js.map +1 -1
- package/dist/constants/repeat.d.ts +3 -0
- package/dist/constants/repeat.d.ts.map +1 -0
- package/dist/constants/repeat.js +16 -0
- package/dist/constants/repeat.js.map +1 -0
- package/dist/context/ValidationProvider.d.ts +2 -2
- package/dist/context/ValidationProvider.d.ts.map +1 -1
- package/dist/context/ValidationProvider.js +2 -2
- package/dist/context/ValidationProvider.js.map +1 -1
- package/dist/model/alerts-queries.d.ts +1 -1
- package/dist/model/alerts-queries.d.ts.map +1 -1
- package/dist/model/alerts-queries.js.map +1 -1
- package/dist/model/annotations.d.ts.map +1 -1
- package/dist/model/annotations.js.map +1 -1
- package/dist/model/calculations.js.map +1 -1
- package/dist/model/datasource.d.ts +9 -2
- package/dist/model/datasource.d.ts.map +1 -1
- package/dist/model/datasource.js +1 -1
- package/dist/model/datasource.js.map +1 -1
- package/dist/model/explore.d.ts +0 -1
- package/dist/model/explore.d.ts.map +1 -1
- package/dist/model/explore.js.map +1 -1
- package/dist/model/index.d.ts +1 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +1 -0
- package/dist/model/index.js.map +1 -1
- package/dist/model/json-queries.d.ts +29 -0
- package/dist/model/json-queries.d.ts.map +1 -0
- package/dist/model/json-queries.js +17 -0
- package/dist/model/json-queries.js.map +1 -0
- package/dist/model/legend.d.ts.map +1 -1
- package/dist/model/legend.js.map +1 -1
- package/dist/model/log-queries.d.ts.map +1 -1
- package/dist/model/log-queries.js.map +1 -1
- package/dist/model/panels.d.ts +10 -1
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js.map +1 -1
- package/dist/model/plugin-base.d.ts +2 -2
- package/dist/model/plugin-base.d.ts.map +1 -1
- package/dist/model/plugin-base.js.map +1 -1
- package/dist/model/plugins.d.ts +8 -6
- package/dist/model/plugins.d.ts.map +1 -1
- package/dist/model/plugins.js.map +1 -1
- package/dist/model/profile-queries.d.ts +1 -1
- package/dist/model/profile-queries.d.ts.map +1 -1
- package/dist/model/profile-queries.js.map +1 -1
- package/dist/model/silences-queries.d.ts +1 -1
- package/dist/model/silences-queries.d.ts.map +1 -1
- package/dist/model/silences-queries.js.map +1 -1
- package/dist/model/time-series-queries.d.ts +1 -1
- package/dist/model/time-series-queries.d.ts.map +1 -1
- package/dist/model/time-series-queries.js.map +1 -1
- package/dist/model/trace-queries.d.ts +1 -1
- package/dist/model/trace-queries.d.ts.map +1 -1
- package/dist/model/trace-queries.js.map +1 -1
- package/dist/model/variables.d.ts +5 -1
- package/dist/model/variables.d.ts.map +1 -1
- package/dist/model/variables.js +1 -3
- package/dist/model/variables.js.map +1 -1
- package/dist/remote/PluginLoaderComponent.d.ts +0 -1
- package/dist/remote/PluginLoaderComponent.d.ts.map +1 -1
- package/dist/remote/PluginLoaderComponent.js.map +1 -1
- package/dist/remote/PluginRuntime.d.ts.map +1 -1
- package/dist/remote/PluginRuntime.js +12 -20
- package/dist/remote/PluginRuntime.js.map +1 -1
- package/dist/remote/remotePluginLoader.d.ts +1 -1
- package/dist/remote/remotePluginLoader.d.ts.map +1 -1
- package/dist/remote/remotePluginLoader.js +1 -1
- package/dist/remote/remotePluginLoader.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +2 -2
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +15 -7
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +18 -4
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProviders.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProviders.js +3 -3
- package/dist/runtime/TimeRangeProvider/TimeRangeProviders.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts +8 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +14 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.d.ts +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.js +2 -2
- package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
- package/dist/runtime/UsageMetricsProvider.d.ts.map +1 -1
- package/dist/runtime/alerts-queries.d.ts.map +1 -1
- package/dist/runtime/alerts-queries.js +1 -1
- package/dist/runtime/alerts-queries.js.map +1 -1
- package/dist/runtime/annotations.d.ts.map +1 -1
- package/dist/runtime/annotations.js +2 -2
- package/dist/runtime/annotations.js.map +1 -1
- package/dist/runtime/builtin-variables.d.ts +0 -1
- package/dist/runtime/builtin-variables.d.ts.map +1 -1
- package/dist/runtime/builtin-variables.js.map +1 -1
- package/dist/runtime/datasources.d.ts +0 -1
- package/dist/runtime/datasources.d.ts.map +1 -1
- package/dist/runtime/datasources.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/item-actions.d.ts +1 -1
- package/dist/runtime/item-actions.d.ts.map +1 -1
- package/dist/runtime/item-actions.js +1 -1
- package/dist/runtime/item-actions.js.map +1 -1
- package/dist/runtime/json-queries.d.ts +11 -0
- package/dist/runtime/json-queries.d.ts.map +1 -0
- package/dist/runtime/json-queries.js +58 -0
- package/dist/runtime/json-queries.js.map +1 -0
- package/dist/runtime/log-queries.d.ts.map +1 -1
- package/dist/runtime/log-queries.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts +0 -1
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/runtime/profile-queries.d.ts.map +1 -1
- package/dist/runtime/profile-queries.js.map +1 -1
- package/dist/runtime/silences-queries.d.ts.map +1 -1
- package/dist/runtime/silences-queries.js +1 -1
- package/dist/runtime/silences-queries.js.map +1 -1
- package/dist/runtime/time-series-queries.d.ts.map +1 -1
- package/dist/runtime/time-series-queries.js +1 -1
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/runtime/trace-queries.d.ts.map +1 -1
- package/dist/runtime/trace-queries.js +1 -1
- package/dist/runtime/trace-queries.js.map +1 -1
- package/dist/runtime/variables.d.ts +0 -1
- package/dist/runtime/variables.d.ts.map +1 -1
- package/dist/runtime/variables.js.map +1 -1
- package/dist/schema/panel.d.ts +1 -1
- package/dist/schema/panel.d.ts.map +1 -1
- package/dist/schema/panel.js +17 -3
- package/dist/schema/panel.js.map +1 -1
- package/dist/test/mock-data.d.ts +2 -1
- package/dist/test/mock-data.d.ts.map +1 -1
- package/dist/test/mock-data.js +6 -0
- package/dist/test/mock-data.js.map +1 -1
- package/dist/test/render-hook.d.ts.map +1 -1
- package/dist/test/render-hook.js.map +1 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js.map +1 -1
- package/dist/test/setup-tests.d.ts +1 -1
- package/dist/test/setup-tests.d.ts.map +1 -1
- package/dist/test/setup-tests.js +3 -2
- package/dist/test/setup-tests.js.map +1 -1
- package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
- package/dist/test/test-plugins/bert/index.js.map +1 -1
- package/dist/test/test-plugins/ernie/index.d.ts +7 -1
- package/dist/test/test-plugins/ernie/index.d.ts.map +1 -1
- package/dist/test/test-plugins/ernie/index.js +58 -1
- package/dist/test/test-plugins/ernie/index.js.map +1 -1
- package/dist/test/utils.d.ts.map +1 -1
- package/dist/test/utils.js +1 -1
- package/dist/test/utils.js.map +1 -1
- package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
- package/dist/test-utils/mock-plugin-registry.js.map +1 -1
- package/dist/utils/csv-export.d.ts.map +1 -1
- package/dist/utils/csv-export.js +1 -1
- package/dist/utils/csv-export.js.map +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Copyright The Perses Authors
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import { Box, IconButton, Typography } from '@mui/material';
|
|
15
|
+
import { InfoTooltip, RepeatGrid } from '@perses-dev/components';
|
|
16
|
+
import InformationOutlineIcon from 'mdi-material-ui/InformationOutline';
|
|
17
|
+
import { useMemo } from 'react';
|
|
18
|
+
const PREVIEW_GAP = 4;
|
|
19
|
+
export function RepeatLayoutPreview({ optionCount, maxPer }) {
|
|
20
|
+
const repeatItems = useMemo(()=>Array.from({
|
|
21
|
+
length: optionCount
|
|
22
|
+
}, (_, i)=>i), [
|
|
23
|
+
optionCount
|
|
24
|
+
]);
|
|
25
|
+
return /*#__PURE__*/ _jsxs(Box, {
|
|
26
|
+
children: [
|
|
27
|
+
/*#__PURE__*/ _jsxs(Box, {
|
|
28
|
+
sx: {
|
|
29
|
+
display: 'flex',
|
|
30
|
+
alignItems: 'center',
|
|
31
|
+
gap: 0.5,
|
|
32
|
+
mb: 0.5
|
|
33
|
+
},
|
|
34
|
+
children: [
|
|
35
|
+
/*#__PURE__*/ _jsxs(Typography, {
|
|
36
|
+
variant: "subtitle2",
|
|
37
|
+
color: "text.secondary",
|
|
38
|
+
children: [
|
|
39
|
+
"Layout preview (",
|
|
40
|
+
optionCount,
|
|
41
|
+
" panel",
|
|
42
|
+
optionCount !== 1 ? 's' : '',
|
|
43
|
+
")"
|
|
44
|
+
]
|
|
45
|
+
}),
|
|
46
|
+
/*#__PURE__*/ _jsx(InfoTooltip, {
|
|
47
|
+
description: "Preview of the layout when all available options of the selected variable are selected.",
|
|
48
|
+
enterDelay: 100,
|
|
49
|
+
children: /*#__PURE__*/ _jsx(IconButton, {
|
|
50
|
+
size: "small",
|
|
51
|
+
sx: (theme)=>({
|
|
52
|
+
borderRadius: theme.shape.borderRadius,
|
|
53
|
+
padding: '2px'
|
|
54
|
+
}),
|
|
55
|
+
children: /*#__PURE__*/ _jsx(InformationOutlineIcon, {
|
|
56
|
+
"aria-hidden": false,
|
|
57
|
+
"aria-label": "Show layout preview information",
|
|
58
|
+
fontSize: "inherit",
|
|
59
|
+
sx: {
|
|
60
|
+
color: (theme)=>theme.palette.grey[700]
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
]
|
|
66
|
+
}),
|
|
67
|
+
/*#__PURE__*/ _jsx(Box, {
|
|
68
|
+
sx: {
|
|
69
|
+
height: 315,
|
|
70
|
+
overflow: 'auto'
|
|
71
|
+
},
|
|
72
|
+
children: /*#__PURE__*/ _jsx(RepeatGrid, {
|
|
73
|
+
repeatItems: repeatItems,
|
|
74
|
+
maxPer: maxPer,
|
|
75
|
+
gap: PREVIEW_GAP,
|
|
76
|
+
renderItem: ()=>/*#__PURE__*/ _jsx(Box, {
|
|
77
|
+
sx: {
|
|
78
|
+
width: `100%`,
|
|
79
|
+
height: 150,
|
|
80
|
+
borderRadius: 1,
|
|
81
|
+
bgcolor: 'action.selected',
|
|
82
|
+
border: '1px solid',
|
|
83
|
+
borderColor: 'divider'
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
})
|
|
88
|
+
]
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=RepeatLayoutPreview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/LayoutEditor/RepeatLayoutPreview.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, IconButton, Typography } from '@mui/material';\nimport { InfoTooltip, RepeatGrid } from '@perses-dev/components';\nimport InformationOutlineIcon from 'mdi-material-ui/InformationOutline';\nimport { ReactElement, useMemo } from 'react';\n\nexport interface RepeatLayoutPreviewProps {\n optionCount: number;\n maxPer: number;\n}\n\nconst PREVIEW_GAP = 4;\n\nexport function RepeatLayoutPreview({ optionCount, maxPer }: RepeatLayoutPreviewProps): ReactElement {\n const repeatItems = useMemo(() => Array.from({ length: optionCount }, (_, i) => i), [optionCount]);\n\n return (\n <Box>\n <Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5, mb: 0.5 }}>\n <Typography variant=\"subtitle2\" color=\"text.secondary\">\n Layout preview ({optionCount} panel{optionCount !== 1 ? 's' : ''})\n </Typography>\n <InfoTooltip\n description=\"Preview of the layout when all available options of the selected variable are selected.\"\n enterDelay={100}\n >\n <IconButton size=\"small\" sx={(theme) => ({ borderRadius: theme.shape.borderRadius, padding: '2px' })}>\n <InformationOutlineIcon\n aria-hidden={false}\n aria-label=\"Show layout preview information\"\n fontSize=\"inherit\"\n sx={{ color: (theme) => theme.palette.grey[700] }}\n />\n </IconButton>\n </InfoTooltip>\n </Box>\n <Box sx={{ height: 315, overflow: 'auto' }}>\n <RepeatGrid\n repeatItems={repeatItems}\n maxPer={maxPer}\n gap={PREVIEW_GAP}\n renderItem={() => (\n <Box\n sx={{\n width: `100%`,\n height: 150,\n borderRadius: 1,\n bgcolor: 'action.selected',\n border: '1px solid',\n borderColor: 'divider',\n }}\n />\n )}\n />\n </Box>\n </Box>\n );\n}\n"],"names":["Box","IconButton","Typography","InfoTooltip","RepeatGrid","InformationOutlineIcon","useMemo","PREVIEW_GAP","RepeatLayoutPreview","optionCount","maxPer","repeatItems","Array","from","length","_","i","sx","display","alignItems","gap","mb","variant","color","description","enterDelay","size","theme","borderRadius","shape","padding","aria-hidden","aria-label","fontSize","palette","grey","height","overflow","renderItem","width","bgcolor","border","borderColor"],"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,EAAEC,UAAU,QAAQ,gBAAgB;AAC5D,SAASC,WAAW,EAAEC,UAAU,QAAQ,yBAAyB;AACjE,OAAOC,4BAA4B,qCAAqC;AACxE,SAAuBC,OAAO,QAAQ,QAAQ;AAO9C,MAAMC,cAAc;AAEpB,OAAO,SAASC,oBAAoB,EAAEC,WAAW,EAAEC,MAAM,EAA4B;IACnF,MAAMC,cAAcL,QAAQ,IAAMM,MAAMC,IAAI,CAAC;YAAEC,QAAQL;QAAY,GAAG,CAACM,GAAGC,IAAMA,IAAI;QAACP;KAAY;IAEjG,qBACE,MAACT;;0BACC,MAACA;gBAAIiB,IAAI;oBAAEC,SAAS;oBAAQC,YAAY;oBAAUC,KAAK;oBAAKC,IAAI;gBAAI;;kCAClE,MAACnB;wBAAWoB,SAAQ;wBAAYC,OAAM;;4BAAiB;4BACpCd;4BAAY;4BAAOA,gBAAgB,IAAI,MAAM;4BAAG;;;kCAEnE,KAACN;wBACCqB,aAAY;wBACZC,YAAY;kCAEZ,cAAA,KAACxB;4BAAWyB,MAAK;4BAAQT,IAAI,CAACU,QAAW,CAAA;oCAAEC,cAAcD,MAAME,KAAK,CAACD,YAAY;oCAAEE,SAAS;gCAAM,CAAA;sCAChG,cAAA,KAACzB;gCACC0B,eAAa;gCACbC,cAAW;gCACXC,UAAS;gCACThB,IAAI;oCAAEM,OAAO,CAACI,QAAUA,MAAMO,OAAO,CAACC,IAAI,CAAC,IAAI;gCAAC;;;;;;0BAKxD,KAACnC;gBAAIiB,IAAI;oBAAEmB,QAAQ;oBAAKC,UAAU;gBAAO;0BACvC,cAAA,KAACjC;oBACCO,aAAaA;oBACbD,QAAQA;oBACRU,KAAKb;oBACL+B,YAAY,kBACV,KAACtC;4BACCiB,IAAI;gCACFsB,OAAO,CAAC,IAAI,CAAC;gCACbH,QAAQ;gCACRR,cAAc;gCACdY,SAAS;gCACTC,QAAQ;gCACRC,aAAa;4BACf;;;;;;AAOd"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { ControllerRenderProps, FieldErrors } from 'react-hook-form';
|
|
3
|
+
import { PanelEditorValues } from '../../model';
|
|
4
|
+
import { VariableDefinitionGroup } from './LayoutEditor';
|
|
5
|
+
type RepeatVariableValue = ControllerRenderProps<PanelEditorValues, 'layoutDefinition.repeatVariable'>['value'];
|
|
6
|
+
type RepeatVariableOnChange = ControllerRenderProps<PanelEditorValues, 'layoutDefinition.repeatVariable'>['onChange'];
|
|
7
|
+
type RepeatVariableErrors = FieldErrors<NonNullable<NonNullable<PanelEditorValues['layoutDefinition']>['repeatVariable']>>;
|
|
8
|
+
export interface RepeatVariableEditorProps {
|
|
9
|
+
value: RepeatVariableValue;
|
|
10
|
+
onChange: RepeatVariableOnChange;
|
|
11
|
+
errors: RepeatVariableErrors;
|
|
12
|
+
variableDefinitionGroups: VariableDefinitionGroup[];
|
|
13
|
+
isVertical: boolean;
|
|
14
|
+
onRepeatVariableSet: () => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function RepeatVariableEditor({ value: current, onChange, errors, variableDefinitionGroups, isVertical, onRepeatVariableSet, }: RepeatVariableEditorProps): ReactElement;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=RepeatVariableEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RepeatVariableEditor.d.ts","sourceRoot":"","sources":["../../../src/components/LayoutEditor/RepeatVariableEditor.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,YAAY,EAAe,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,KAAK,mBAAmB,GAAG,qBAAqB,CAAC,iBAAiB,EAAE,iCAAiC,CAAC,CAAC,OAAO,CAAC,CAAC;AAChH,KAAK,sBAAsB,GAAG,qBAAqB,CAAC,iBAAiB,EAAE,iCAAiC,CAAC,CAAC,UAAU,CAAC,CAAC;AACtH,KAAK,oBAAoB,GAAG,WAAW,CACrC,WAAW,CAAC,WAAW,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAClF,CAAC;AAEF,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,mBAAmB,CAAC;IAC3B,QAAQ,EAAE,sBAAsB,CAAC;IACjC,MAAM,EAAE,oBAAoB,CAAC;IAC7B,wBAAwB,EAAE,uBAAuB,EAAE,CAAC;IACpD,UAAU,EAAE,OAAO,CAAC;IACpB,mBAAmB,EAAE,MAAM,IAAI,CAAC;CACjC;AAED,wBAAgB,oBAAoB,CAAC,EACnC,KAAK,EAAE,OAAO,EACd,QAAQ,EACR,MAAM,EACN,wBAAwB,EACxB,UAAU,EACV,mBAAmB,GACpB,EAAE,yBAAyB,GAAG,YAAY,CAuG1C"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// Copyright The Perses Authors
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import { Grid2 as Grid, ListSubheader, MenuItem, TextField, Typography } from '@mui/material';
|
|
15
|
+
import { useCallback } from 'react';
|
|
16
|
+
import { DEFAULT_MAX_PER_ROW, DEFAULT_REPEAT_ALIGNMENT } from '../../constants';
|
|
17
|
+
export function RepeatVariableEditor({ value: current, onChange, errors, variableDefinitionGroups, isVertical, onRepeatVariableSet }) {
|
|
18
|
+
const handleVariableChange = useCallback((selected)=>{
|
|
19
|
+
if (!selected) {
|
|
20
|
+
onChange(undefined);
|
|
21
|
+
} else {
|
|
22
|
+
onChange(current ? {
|
|
23
|
+
...current,
|
|
24
|
+
value: selected
|
|
25
|
+
} : {
|
|
26
|
+
value: selected,
|
|
27
|
+
alignment: DEFAULT_REPEAT_ALIGNMENT
|
|
28
|
+
});
|
|
29
|
+
if (!current) {
|
|
30
|
+
onRepeatVariableSet();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}, [
|
|
34
|
+
current,
|
|
35
|
+
onChange,
|
|
36
|
+
onRepeatVariableSet
|
|
37
|
+
]);
|
|
38
|
+
const handleAlignmentChange = useCallback((selected)=>{
|
|
39
|
+
if (!current) return;
|
|
40
|
+
onChange(selected === 'vertical' ? {
|
|
41
|
+
...current,
|
|
42
|
+
alignment: selected,
|
|
43
|
+
maxPer: undefined
|
|
44
|
+
} : {
|
|
45
|
+
...current,
|
|
46
|
+
alignment: selected
|
|
47
|
+
});
|
|
48
|
+
}, [
|
|
49
|
+
current,
|
|
50
|
+
onChange
|
|
51
|
+
]);
|
|
52
|
+
const handleMaxPerChange = useCallback((value)=>{
|
|
53
|
+
if (!current) return;
|
|
54
|
+
onChange({
|
|
55
|
+
...current,
|
|
56
|
+
maxPer: value === '' ? undefined : Number(value)
|
|
57
|
+
});
|
|
58
|
+
}, [
|
|
59
|
+
current,
|
|
60
|
+
onChange
|
|
61
|
+
]);
|
|
62
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
63
|
+
children: [
|
|
64
|
+
/*#__PURE__*/ _jsx(Grid, {
|
|
65
|
+
size: 4,
|
|
66
|
+
children: /*#__PURE__*/ _jsxs(TextField, {
|
|
67
|
+
select: true,
|
|
68
|
+
fullWidth: true,
|
|
69
|
+
label: "Repeat Variable",
|
|
70
|
+
value: current?.value ?? '',
|
|
71
|
+
error: !!errors.value,
|
|
72
|
+
helperText: errors.value?.message,
|
|
73
|
+
onChange: (event)=>handleVariableChange(event.target.value),
|
|
74
|
+
slotProps: {
|
|
75
|
+
select: {
|
|
76
|
+
MenuProps: {
|
|
77
|
+
PaperProps: {
|
|
78
|
+
sx: {
|
|
79
|
+
maxHeight: 240
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
children: [
|
|
86
|
+
/*#__PURE__*/ _jsx(MenuItem, {
|
|
87
|
+
value: "",
|
|
88
|
+
children: /*#__PURE__*/ _jsx(Typography, {
|
|
89
|
+
sx: {
|
|
90
|
+
fontStyle: 'italic'
|
|
91
|
+
},
|
|
92
|
+
children: "None"
|
|
93
|
+
})
|
|
94
|
+
}),
|
|
95
|
+
variableDefinitionGroups.flatMap(({ source, definitions })=>{
|
|
96
|
+
const listDefs = definitions.filter((def)=>def.kind === 'ListVariable' && def.spec.allowMultiple);
|
|
97
|
+
if (listDefs.length === 0) return [];
|
|
98
|
+
return [
|
|
99
|
+
source && /*#__PURE__*/ _jsx(ListSubheader, {
|
|
100
|
+
children: source
|
|
101
|
+
}, `group-${source}`),
|
|
102
|
+
...listDefs.map((def)=>/*#__PURE__*/ _jsx(MenuItem, {
|
|
103
|
+
value: def.spec.name,
|
|
104
|
+
children: def.spec.display?.name ?? def.spec.name
|
|
105
|
+
}, `${source ?? 'dashboard'}-${def.spec.name}`))
|
|
106
|
+
];
|
|
107
|
+
})
|
|
108
|
+
]
|
|
109
|
+
})
|
|
110
|
+
}),
|
|
111
|
+
/*#__PURE__*/ _jsx(Grid, {
|
|
112
|
+
size: 4,
|
|
113
|
+
children: /*#__PURE__*/ _jsxs(TextField, {
|
|
114
|
+
select: true,
|
|
115
|
+
fullWidth: true,
|
|
116
|
+
label: "Alignment",
|
|
117
|
+
value: current?.alignment ?? DEFAULT_REPEAT_ALIGNMENT,
|
|
118
|
+
disabled: !current,
|
|
119
|
+
error: !!errors.alignment,
|
|
120
|
+
helperText: errors.alignment?.message,
|
|
121
|
+
onChange: (event)=>handleAlignmentChange(event.target.value),
|
|
122
|
+
children: [
|
|
123
|
+
/*#__PURE__*/ _jsx(MenuItem, {
|
|
124
|
+
value: "horizontal",
|
|
125
|
+
children: "Horizontal"
|
|
126
|
+
}),
|
|
127
|
+
/*#__PURE__*/ _jsx(MenuItem, {
|
|
128
|
+
value: "vertical",
|
|
129
|
+
children: "Vertical"
|
|
130
|
+
})
|
|
131
|
+
]
|
|
132
|
+
})
|
|
133
|
+
}),
|
|
134
|
+
/*#__PURE__*/ _jsx(Grid, {
|
|
135
|
+
size: 4,
|
|
136
|
+
children: /*#__PURE__*/ _jsx(TextField, {
|
|
137
|
+
select: true,
|
|
138
|
+
fullWidth: true,
|
|
139
|
+
label: "Max Per Row",
|
|
140
|
+
value: current?.maxPer ?? DEFAULT_MAX_PER_ROW,
|
|
141
|
+
disabled: !current || isVertical,
|
|
142
|
+
error: !!errors.maxPer,
|
|
143
|
+
helperText: errors.maxPer?.message,
|
|
144
|
+
onChange: (event)=>handleMaxPerChange(event.target.value),
|
|
145
|
+
slotProps: {
|
|
146
|
+
select: {
|
|
147
|
+
MenuProps: {
|
|
148
|
+
PaperProps: {
|
|
149
|
+
sx: {
|
|
150
|
+
maxHeight: 240
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
children: Array.from({
|
|
157
|
+
length: 12
|
|
158
|
+
}, (_, i)=>i + 1).map((n)=>/*#__PURE__*/ _jsx(MenuItem, {
|
|
159
|
+
value: n,
|
|
160
|
+
children: n
|
|
161
|
+
}, n))
|
|
162
|
+
})
|
|
163
|
+
})
|
|
164
|
+
]
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
//# sourceMappingURL=RepeatVariableEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/LayoutEditor/RepeatVariableEditor.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 { Grid2 as Grid, ListSubheader, MenuItem, TextField, Typography } from '@mui/material';\nimport { ReactElement, useCallback } from 'react';\nimport { ControllerRenderProps, FieldErrors } from 'react-hook-form';\n\nimport { DEFAULT_MAX_PER_ROW, DEFAULT_REPEAT_ALIGNMENT } from '../../constants';\nimport { PanelEditorValues } from '../../model';\nimport { VariableDefinitionGroup } from './LayoutEditor';\n\ntype RepeatVariableValue = ControllerRenderProps<PanelEditorValues, 'layoutDefinition.repeatVariable'>['value'];\ntype RepeatVariableOnChange = ControllerRenderProps<PanelEditorValues, 'layoutDefinition.repeatVariable'>['onChange'];\ntype RepeatVariableErrors = FieldErrors<\n NonNullable<NonNullable<PanelEditorValues['layoutDefinition']>['repeatVariable']>\n>;\n\nexport interface RepeatVariableEditorProps {\n value: RepeatVariableValue;\n onChange: RepeatVariableOnChange;\n errors: RepeatVariableErrors;\n variableDefinitionGroups: VariableDefinitionGroup[];\n isVertical: boolean;\n onRepeatVariableSet: () => void;\n}\n\nexport function RepeatVariableEditor({\n value: current,\n onChange,\n errors,\n variableDefinitionGroups,\n isVertical,\n onRepeatVariableSet,\n}: RepeatVariableEditorProps): ReactElement {\n const handleVariableChange = useCallback(\n (selected: string): void => {\n if (!selected) {\n onChange(undefined);\n } else {\n onChange(current ? { ...current, value: selected } : { value: selected, alignment: DEFAULT_REPEAT_ALIGNMENT });\n if (!current) {\n onRepeatVariableSet();\n }\n }\n },\n [current, onChange, onRepeatVariableSet],\n );\n\n const handleAlignmentChange = useCallback(\n (selected: string): void => {\n if (!current) return;\n onChange(\n selected === 'vertical'\n ? { ...current, alignment: selected, maxPer: undefined }\n : { ...current, alignment: selected },\n );\n },\n [current, onChange],\n );\n\n const handleMaxPerChange = useCallback(\n (value: string): void => {\n if (!current) return;\n onChange({ ...current, maxPer: value === '' ? undefined : Number(value) });\n },\n [current, onChange],\n );\n\n return (\n <>\n <Grid size={4}>\n <TextField\n select\n fullWidth\n label=\"Repeat Variable\"\n value={current?.value ?? ''}\n error={!!errors.value}\n helperText={errors.value?.message}\n onChange={(event) => handleVariableChange(event.target.value)}\n slotProps={{ select: { MenuProps: { PaperProps: { sx: { maxHeight: 240 } } } } }}\n >\n <MenuItem value=\"\">\n <Typography sx={{ fontStyle: 'italic' }}>None</Typography>\n </MenuItem>\n {variableDefinitionGroups.flatMap(({ source, definitions }) => {\n const listDefs = definitions.filter((def) => def.kind === 'ListVariable' && def.spec.allowMultiple);\n if (listDefs.length === 0) return [];\n return [\n source && <ListSubheader key={`group-${source}`}>{source}</ListSubheader>,\n ...listDefs.map((def) => (\n <MenuItem key={`${source ?? 'dashboard'}-${def.spec.name}`} value={def.spec.name}>\n {def.spec.display?.name ?? def.spec.name}\n </MenuItem>\n )),\n ];\n })}\n </TextField>\n </Grid>\n\n <Grid size={4}>\n <TextField\n select\n fullWidth\n label=\"Alignment\"\n value={current?.alignment ?? DEFAULT_REPEAT_ALIGNMENT}\n disabled={!current}\n error={!!errors.alignment}\n helperText={errors.alignment?.message}\n onChange={(event) => handleAlignmentChange(event.target.value)}\n >\n <MenuItem value=\"horizontal\">Horizontal</MenuItem>\n <MenuItem value=\"vertical\">Vertical</MenuItem>\n </TextField>\n </Grid>\n\n <Grid size={4}>\n <TextField\n select\n fullWidth\n label=\"Max Per Row\"\n value={current?.maxPer ?? DEFAULT_MAX_PER_ROW}\n disabled={!current || isVertical}\n error={!!errors.maxPer}\n helperText={errors.maxPer?.message}\n onChange={(event) => handleMaxPerChange(event.target.value)}\n slotProps={{ select: { MenuProps: { PaperProps: { sx: { maxHeight: 240 } } } } }}\n >\n {Array.from({ length: 12 }, (_, i) => i + 1).map((n) => (\n <MenuItem key={n} value={n}>\n {n}\n </MenuItem>\n ))}\n </TextField>\n </Grid>\n </>\n );\n}\n"],"names":["Grid2","Grid","ListSubheader","MenuItem","TextField","Typography","useCallback","DEFAULT_MAX_PER_ROW","DEFAULT_REPEAT_ALIGNMENT","RepeatVariableEditor","value","current","onChange","errors","variableDefinitionGroups","isVertical","onRepeatVariableSet","handleVariableChange","selected","undefined","alignment","handleAlignmentChange","maxPer","handleMaxPerChange","Number","size","select","fullWidth","label","error","helperText","message","event","target","slotProps","MenuProps","PaperProps","sx","maxHeight","fontStyle","flatMap","source","definitions","listDefs","filter","def","kind","spec","allowMultiple","length","map","name","display","disabled","Array","from","_","i","n"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;A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sCAAa;;sCAC7B,KAACP;4BAASO,OAAM;sCAAW;;;;;0BAI/B,KAACT;gBAAKwB,MAAM;0BACV,cAAA,KAACrB;oBACCsB,MAAM;oBACNC,SAAS;oBACTC,OAAM;oBACNlB,OAAOC,SAASW,UAAUf;oBAC1B8C,UAAU,CAAC1C,WAAWI;oBACtBc,OAAO,CAAC,CAAChB,OAAOS,MAAM;oBACtBQ,YAAYjB,OAAOS,MAAM,EAAES;oBAC3BnB,UAAU,CAACoB,QAAUT,mBAAmBS,MAAMC,MAAM,CAACvB,KAAK;oBAC1DwB,WAAW;wBAAER,QAAQ;4BAAES,WAAW;gCAAEC,YAAY;oCAAEC,IAAI;wCAAEC,WAAW;oCAAI;gCAAE;4BAAE;wBAAE;oBAAE;8BAE9EgB,MAAMC,IAAI,CAAC;wBAAEN,QAAQ;oBAAG,GAAG,CAACO,GAAGC,IAAMA,IAAI,GAAGP,GAAG,CAAC,CAACQ,kBAChD,KAACvD;4BAAiBO,OAAOgD;sCACtBA;2BADYA;;;;;AAQ3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/LayoutEditor/index.ts"],"names":[],"mappings":"AAaA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
export * from './LayoutEditor';
|
|
14
|
+
export * from './RepeatLayoutPreview';
|
|
15
|
+
export * from './RepeatVariableEditor';
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/LayoutEditor/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './LayoutEditor';\nexport * from './RepeatLayoutPreview';\nexport * from './RepeatVariableEditor';\n"],"names":[],"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,cAAc,iBAAiB;AAC/B,cAAc,wBAAwB;AACtC,cAAc,yBAAyB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LegendOptionsEditor.d.ts","sourceRoot":"","sources":["../../../src/components/LegendOptionsEditor/LegendOptionsEditor.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAAE,YAAY,EAAW,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"LegendOptionsEditor.d.ts","sourceRoot":"","sources":["../../../src/components/LegendOptionsEditor/LegendOptionsEditor.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAAE,YAAY,EAAW,MAAM,OAAO,CAAC;AAE9C,OAAO,EAGL,iBAAiB,EAQlB,MAAM,aAAa,CAAC;AAsBrB,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC/C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,WAAW,CAAC,EAAE,aAAa,GAAG,YAAY,CAAC;CAC5C;AAED,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,QAAQ,EACR,gBAAuB,EACvB,WAA2B,GAC5B,EAAE,wBAAwB,GAAG,YAAY,CAgLzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/LegendOptionsEditor/LegendOptionsEditor.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 { Switch, SwitchProps, ToggleButtonGroup, ToggleButton } from '@mui/material';\nimport {\n ErrorAlert,\n OptionsEditorControl,\n OptionsEditorGroup,\n SettingsAutocomplete,\n DEFAULT_LEGEND,\n getLegendSize,\n getLegendMode,\n getLegendPosition,\n} from '@perses-dev/components';\nimport { ReactElement, useMemo } from 'react';\nimport {\n LEGEND_MODE_CONFIG,\n LEGEND_POSITIONS_CONFIG,\n LegendSpecOptions,\n LegendSingleSelectConfig,\n validateLegendSpec,\n LEGEND_VALUE_CONFIG,\n LegendValue,\n LEGEND_SIZE_CONFIG,\n comparisonLegends,\n ComparisonValues,\n} from '../../model';\n\ntype LegendPositionOption = LegendSingleSelectConfig & { id: LegendSpecOptions['position'] };\n\nconst POSITION_OPTIONS: LegendPositionOption[] = Object.entries(LEGEND_POSITIONS_CONFIG).map(([id, config]) => {\n return {\n id: id as LegendSpecOptions['position'],\n ...config,\n };\n});\n\ntype LegendSizeOption = LegendSingleSelectConfig & { id: Required<LegendSpecOptions>['size'] };\n\nconst SIZE_OPTIONS: LegendSizeOption[] = Object.entries(LEGEND_SIZE_CONFIG).map(([id, config]) => {\n return {\n id: id as Required<LegendSpecOptions>['size'],\n ...config,\n };\n});\n\ntype LegendValueOption = LegendSingleSelectConfig & { id: LegendValue | ComparisonValues };\n\nexport interface LegendOptionsEditorProps {\n value?: LegendSpecOptions;\n onChange: (legend?: LegendSpecOptions) => void;\n showValuesEditor?: boolean;\n calculation?: 'aggregation' | 'comparison';\n}\n\nexport function LegendOptionsEditor({\n value,\n onChange,\n showValuesEditor = true,\n calculation = 'aggregation',\n}: LegendOptionsEditorProps): ReactElement {\n const handleLegendShowChange: SwitchProps['onChange'] = (_: unknown, checked: boolean) => {\n // legend is hidden when legend obj is undefined\n const legendValue = checked === true ? { position: DEFAULT_LEGEND.position } : undefined;\n onChange(legendValue);\n };\n\n const handleLegendPositionChange = (_: unknown, newValue: LegendPositionOption): void => {\n onChange({\n ...value,\n position: newValue.id,\n });\n };\n\n const handleLegendSizeChange = (_: unknown, newValue: LegendSizeOption): void => {\n onChange({\n ...value,\n position: currentPosition,\n size: newValue.id,\n });\n };\n\n const handleLegendValueChange = (_: unknown, newValue: LegendValueOption[]): void => {\n onChange({\n ...value,\n position: currentPosition,\n values: newValue.map((value) => {\n return value.id;\n }),\n });\n };\n\n const isValidLegend = validateLegendSpec(value);\n const currentPosition = getLegendPosition(value?.position);\n const legendPositionConfig = LEGEND_POSITIONS_CONFIG[currentPosition];\n\n const currentMode = getLegendMode(value?.mode);\n\n const currentSize = getLegendSize(value?.size);\n const legendSizeConfig = LEGEND_SIZE_CONFIG[currentSize];\n\n const legendValuesConfig = useMemo(() => {\n const currentValues = value?.values;\n if (!currentValues?.length) return [];\n\n if (calculation === 'aggregation') {\n return currentValues.reduce((result, item) => {\n const config = LEGEND_VALUE_CONFIG[item as LegendValue];\n if (config) {\n result.push({ ...config, id: item });\n }\n return result;\n }, [] as LegendValueOption[]);\n }\n\n return currentValues.map((id) => {\n const { label, description } = comparisonLegends[id as ComparisonValues];\n return {\n id,\n label,\n description,\n };\n });\n }, [calculation, value?.values]);\n\n const valueOptions = useMemo(() => {\n if (calculation === 'aggregation') {\n return Object.entries(LEGEND_VALUE_CONFIG || {}).map(([id, config]) => {\n return {\n id: id as LegendValue,\n ...config,\n };\n });\n }\n\n return Object.entries(comparisonLegends).map(([id, config]) => ({\n id: id as ComparisonValues,\n ...config,\n }));\n }, [calculation]);\n\n return (\n <OptionsEditorGroup title=\"Legend\">\n {!isValidLegend && <ErrorAlert error={{ name: 'invalid-legend', message: 'Invalid legend spec' }} />}\n <OptionsEditorControl label=\"Show\" control={<Switch checked={!!value} onChange={handleLegendShowChange} />} />\n {value && (\n <>\n <OptionsEditorControl\n label=\"Position\"\n control={\n <SettingsAutocomplete\n value={{\n ...legendPositionConfig,\n id: currentPosition,\n }}\n options={POSITION_OPTIONS}\n onChange={handleLegendPositionChange}\n disableClearable\n />\n }\n />\n <OptionsEditorControl\n label=\"Mode\"\n control={\n <ToggleButtonGroup\n color=\"primary\"\n exclusive\n value={currentMode}\n aria-label=\"Mode\"\n onChange={(__, newValue) => {\n onChange({\n ...value,\n position: currentPosition,\n mode: newValue,\n });\n }}\n >\n {Object.entries(LEGEND_MODE_CONFIG).map(([modeId, config]) => (\n <ToggleButton\n key={modeId}\n value={modeId}\n selected={currentMode === modeId}\n aria-label={`display ${modeId} mode`}\n >\n {config.label}\n </ToggleButton>\n ))}\n </ToggleButtonGroup>\n }\n />\n {currentMode === 'table' && (\n <>\n <OptionsEditorControl\n label=\"Size\"\n control={\n <SettingsAutocomplete\n value={{\n ...legendSizeConfig,\n id: currentSize,\n }}\n options={SIZE_OPTIONS}\n onChange={handleLegendSizeChange}\n // TODO: enable sizes for list mode when we normalize the layout of\n // lists to more closely match tables.\n disableClearable\n />\n }\n />\n {showValuesEditor && (\n <OptionsEditorControl\n label=\"Values\"\n control={\n // For some reason, the inferred option type doesn't always seem to work\n // quite right when `multiple` is true. Explicitly setting the generics\n // to work around this.\n <SettingsAutocomplete<LegendValueOption, true, true>\n multiple={true}\n disableCloseOnSelect\n disableClearable\n value={legendValuesConfig}\n options={valueOptions}\n onChange={handleLegendValueChange}\n limitTags={1}\n ChipProps={{\n size: 'small',\n }}\n />\n }\n />\n )}\n </>\n )}\n </>\n )}\n </OptionsEditorGroup>\n );\n}\n"],"names":["Switch","ToggleButtonGroup","ToggleButton","ErrorAlert","OptionsEditorControl","OptionsEditorGroup","SettingsAutocomplete","DEFAULT_LEGEND","getLegendSize","getLegendMode","getLegendPosition","useMemo","LEGEND_MODE_CONFIG","LEGEND_POSITIONS_CONFIG","validateLegendSpec","LEGEND_VALUE_CONFIG","LEGEND_SIZE_CONFIG","comparisonLegends","POSITION_OPTIONS","Object","entries","map","id","config","SIZE_OPTIONS","LegendOptionsEditor","value","onChange","showValuesEditor","calculation","handleLegendShowChange","_","checked","legendValue","position","undefined","handleLegendPositionChange","newValue","handleLegendSizeChange","currentPosition","size","handleLegendValueChange","values","isValidLegend","legendPositionConfig","currentMode","mode","currentSize","legendSizeConfig","legendValuesConfig","currentValues","length","reduce","result","item","push","label","description","valueOptions","title","error","name","message","control","options","disableClearable","color","exclusive","aria-label","__","modeId","selected","multiple","disableCloseOnSelect","limitTags","ChipProps"],"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,iBAAiB,EAAEC,YAAY,QAAQ,gBAAgB;AACrF,SACEC,UAAU,EACVC,oBAAoB,EACpBC,kBAAkB,EAClBC,oBAAoB,EACpBC,cAAc,EACdC,aAAa,EACb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gBAAOO,uBAAS,KAAC/D;oBAAOgC,SAAS,CAAC,CAACN;oBAAOC,UAAUG;;;YAC/EJ,uBACC;;kCACE,KAACtB;wBACCoD,OAAM;wBACNO,uBACE,KAACzD;4BACCoB,OAAO;gCACL,GAAGkB,oBAAoB;gCACvBtB,IAAIiB;4BACN;4BACAyB,SAAS9C;4BACTS,UAAUS;4BACV6B,gBAAgB;;;kCAItB,KAAC7D;wBACCoD,OAAM;wBACNO,uBACE,KAAC9D;4BACCiE,OAAM;4BACNC,SAAS;4BACTzC,OAAOmB;4BACPuB,cAAW;4BACXzC,UAAU,CAAC0C,IAAIhC;gCACbV,SAAS;oCACP,GAAGD,KAAK;oCACRQ,UAAUK;oCACVO,MAAMT;gCACR;4BACF;sCAEClB,OAAOC,OAAO,CAACR,oBAAoBS,GAAG,CAAC,CAAC,CAACiD,QAAQ/C,OAAO,iBACvD,KAACrB;oCAECwB,OAAO4C;oCACPC,UAAU1B,gBAAgByB;oCAC1BF,cAAY,CAAC,QAAQ,EAAEE,OAAO,KAAK,CAAC;8CAEnC/C,OAAOiC,KAAK;mCALRc;;;oBAWdzB,gBAAgB,yBACf;;0CACE,KAACzC;gCACCoD,OAAM;gCACNO,uBACE,KAACzD;oCACCoB,OAAO;wCACL,GAAGsB,gBAAgB;wCACnB1B,IAAIyB;oCACN;oCACAiB,SAASxC;oCACTG,UAAUW;oCACV,mEAAmE;oCACnE,sCAAsC;oCACtC2B,gBAAgB;;;4BAIrBrC,kCACC,KAACxB;gCACCoD,OAAM;gCACNO,SACE,wEAAwE;gCACxE,uEAAuE;gCACvE,uBAAuB;8CACvB,KAACzD;oCACCkE,UAAU;oCACVC,oBAAoB;oCACpBR,gBAAgB;oCAChBvC,OAAOuB;oCACPe,SAASN;oCACT/B,UAAUc;oCACViC,WAAW;oCACXC,WAAW;wCACTnC,MAAM;oCACR;;;;;;;;;AAWtB"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/LegendOptionsEditor/LegendOptionsEditor.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 { Switch, SwitchProps, ToggleButtonGroup, ToggleButton } from '@mui/material';\nimport {\n ErrorAlert,\n OptionsEditorControl,\n OptionsEditorGroup,\n SettingsAutocomplete,\n DEFAULT_LEGEND,\n getLegendSize,\n getLegendMode,\n getLegendPosition,\n} from '@perses-dev/components';\nimport { ReactElement, useMemo } from 'react';\n\nimport {\n LEGEND_MODE_CONFIG,\n LEGEND_POSITIONS_CONFIG,\n LegendSpecOptions,\n LegendSingleSelectConfig,\n validateLegendSpec,\n LEGEND_VALUE_CONFIG,\n LegendValue,\n LEGEND_SIZE_CONFIG,\n comparisonLegends,\n ComparisonValues,\n} from '../../model';\n\ntype LegendPositionOption = LegendSingleSelectConfig & { id: LegendSpecOptions['position'] };\n\nconst POSITION_OPTIONS: LegendPositionOption[] = Object.entries(LEGEND_POSITIONS_CONFIG).map(([id, config]) => {\n return {\n id: id as LegendSpecOptions['position'],\n ...config,\n };\n});\n\ntype LegendSizeOption = LegendSingleSelectConfig & { id: Required<LegendSpecOptions>['size'] };\n\nconst SIZE_OPTIONS: LegendSizeOption[] = Object.entries(LEGEND_SIZE_CONFIG).map(([id, config]) => {\n return {\n id: id as Required<LegendSpecOptions>['size'],\n ...config,\n };\n});\n\ntype LegendValueOption = LegendSingleSelectConfig & { id: LegendValue | ComparisonValues };\n\nexport interface LegendOptionsEditorProps {\n value?: LegendSpecOptions;\n onChange: (legend?: LegendSpecOptions) => void;\n showValuesEditor?: boolean;\n calculation?: 'aggregation' | 'comparison';\n}\n\nexport function LegendOptionsEditor({\n value,\n onChange,\n showValuesEditor = true,\n calculation = 'aggregation',\n}: LegendOptionsEditorProps): ReactElement {\n const handleLegendShowChange: SwitchProps['onChange'] = (_: unknown, checked: boolean) => {\n // legend is hidden when legend obj is undefined\n const legendValue = checked === true ? { position: DEFAULT_LEGEND.position } : undefined;\n onChange(legendValue);\n };\n\n const handleLegendPositionChange = (_: unknown, newValue: LegendPositionOption): void => {\n onChange({\n ...value,\n position: newValue.id,\n });\n };\n\n const handleLegendSizeChange = (_: unknown, newValue: LegendSizeOption): void => {\n onChange({\n ...value,\n position: currentPosition,\n size: newValue.id,\n });\n };\n\n const handleLegendValueChange = (_: unknown, newValue: LegendValueOption[]): void => {\n onChange({\n ...value,\n position: currentPosition,\n values: newValue.map((value) => {\n return value.id;\n }),\n });\n };\n\n const isValidLegend = validateLegendSpec(value);\n const currentPosition = getLegendPosition(value?.position);\n const legendPositionConfig = LEGEND_POSITIONS_CONFIG[currentPosition];\n\n const currentMode = getLegendMode(value?.mode);\n\n const currentSize = getLegendSize(value?.size);\n const legendSizeConfig = LEGEND_SIZE_CONFIG[currentSize];\n\n const legendValuesConfig = useMemo(() => {\n const currentValues = value?.values;\n if (!currentValues?.length) return [];\n\n if (calculation === 'aggregation') {\n return currentValues.reduce((result, item) => {\n const config = LEGEND_VALUE_CONFIG[item as LegendValue];\n if (config) {\n result.push({ ...config, id: item });\n }\n return result;\n }, [] as LegendValueOption[]);\n }\n\n return currentValues.map((id) => {\n const { label, description } = comparisonLegends[id as ComparisonValues];\n return {\n id,\n label,\n description,\n };\n });\n }, [calculation, value?.values]);\n\n const valueOptions = useMemo(() => {\n if (calculation === 'aggregation') {\n return Object.entries(LEGEND_VALUE_CONFIG || {}).map(([id, config]) => {\n return {\n id: id as LegendValue,\n ...config,\n };\n });\n }\n\n return Object.entries(comparisonLegends).map(([id, config]) => ({\n id: id as ComparisonValues,\n ...config,\n }));\n }, [calculation]);\n\n return (\n <OptionsEditorGroup title=\"Legend\">\n {!isValidLegend && <ErrorAlert error={{ name: 'invalid-legend', message: 'Invalid legend spec' }} />}\n <OptionsEditorControl label=\"Show\" control={<Switch checked={!!value} onChange={handleLegendShowChange} />} />\n {value && (\n <>\n <OptionsEditorControl\n label=\"Position\"\n control={\n <SettingsAutocomplete\n value={{\n ...legendPositionConfig,\n id: currentPosition,\n }}\n options={POSITION_OPTIONS}\n onChange={handleLegendPositionChange}\n disableClearable\n />\n }\n />\n <OptionsEditorControl\n label=\"Mode\"\n control={\n <ToggleButtonGroup\n color=\"primary\"\n exclusive\n value={currentMode}\n aria-label=\"Mode\"\n onChange={(__, newValue) => {\n onChange({\n ...value,\n position: currentPosition,\n mode: newValue,\n });\n }}\n >\n {Object.entries(LEGEND_MODE_CONFIG).map(([modeId, config]) => (\n <ToggleButton\n key={modeId}\n value={modeId}\n selected={currentMode === modeId}\n aria-label={`display ${modeId} mode`}\n >\n {config.label}\n </ToggleButton>\n ))}\n </ToggleButtonGroup>\n }\n />\n {currentMode === 'table' && (\n <>\n <OptionsEditorControl\n label=\"Size\"\n control={\n <SettingsAutocomplete\n value={{\n ...legendSizeConfig,\n id: currentSize,\n }}\n options={SIZE_OPTIONS}\n onChange={handleLegendSizeChange}\n // TODO: enable sizes for list mode when we normalize the layout of\n // lists to more closely match tables.\n disableClearable\n />\n }\n />\n {showValuesEditor && (\n <OptionsEditorControl\n label=\"Values\"\n control={\n // For some reason, the inferred option type doesn't always seem to work\n // quite right when `multiple` is true. Explicitly setting the generics\n // to work around this.\n <SettingsAutocomplete<LegendValueOption, true, true>\n multiple={true}\n disableCloseOnSelect\n disableClearable\n value={legendValuesConfig}\n options={valueOptions}\n onChange={handleLegendValueChange}\n limitTags={1}\n ChipProps={{\n size: 'small',\n }}\n />\n }\n />\n )}\n </>\n )}\n </>\n )}\n </OptionsEditorGroup>\n );\n}\n"],"names":["Switch","ToggleButtonGroup","ToggleButton","ErrorAlert","OptionsEditorControl","OptionsEditorGroup","SettingsAutocomplete","DEFAULT_LEGEND","getLegendSize","getLegendMode","getLegendPosition","useMemo","LEGEND_MODE_CONFIG","LEGEND_POSITIONS_CONFIG","validateLegendSpec","LEGEND_VALUE_CONFIG","LEGEND_SIZE_CONFIG","comparisonLegends","POSITION_OPTIONS","Object","entries","map","id","config","SIZE_OPTIONS","LegendOptionsEditor","value","onChange","showValuesEditor","calculation","handleLegendShowChange","_","checked","legendValue","position","undefined","handleLegendPositionChange","newValue","handleLegendSizeChange","currentPosition","size","handleLegendValueChange","values","isValidLegend","legendPositionConfig","currentMode","mode","currentSize","legendSizeConfig","legendValuesConfig","currentValues","length","reduce","result","item","push","label","description","valueOptions","title","error","name","message","control","options","disableClearable","color","exclusive","aria-label","__","modeId","selected","multiple","disableCloseOnSelect","limitTags","ChipProps"],"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,iBAAiB,EAAEC,YAAY,QAAQ,gBAAgB;AACrF,SACEC,UAAU,EACVC,oBAAoB,EACpBC,kBAAkB,EAClBC,oBAAoB,EACpBC,cAAc,EACdC,aAAa,EACbC,aAAa,EACbC,iBAAiB,QACZ,yBAAyB;AAChC,SAAuBC,OAAO,QAAQ,QAAQ;AAE9C,SACEC,kBAAkB,EAClBC,uBAAuB,EAGvBC,kBAAkB,EAClBC,mBAAmB,EAEnBC,kBAAkB,EAClBC,iBAAiB,QAEZ,cAAc;AAIrB,MAAMC,mBAA2CC,OAAOC,OAAO,CAACP,yBAAyBQ,GAAG,CAAC,CAAC,CAACC,IAAIC,OAAO;IACxG,OAAO;QACLD,IAAIA;QACJ,GAAGC,MAAM;IACX;AACF;AAIA,MAAMC,eAAmCL,OAAOC,OAAO,CAACJ,oBAAoBK,GAAG,CAAC,CAAC,CAACC,IAAIC,OAAO;IAC3F,OAAO;QACLD,IA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MAAMT;gCACR;4BACF;sCAEClB,OAAOC,OAAO,CAACR,oBAAoBS,GAAG,CAAC,CAAC,CAACiD,QAAQ/C,OAAO,iBACvD,KAACrB;oCAECwB,OAAO4C;oCACPC,UAAU1B,gBAAgByB;oCAC1BF,cAAY,CAAC,QAAQ,EAAEE,OAAO,KAAK,CAAC;8CAEnC/C,OAAOiC,KAAK;mCALRc;;;oBAWdzB,gBAAgB,yBACf;;0CACE,KAACzC;gCACCoD,OAAM;gCACNO,uBACE,KAACzD;oCACCoB,OAAO;wCACL,GAAGsB,gBAAgB;wCACnB1B,IAAIyB;oCACN;oCACAiB,SAASxC;oCACTG,UAAUW;oCACV,mEAAmE;oCACnE,sCAAsC;oCACtC2B,gBAAgB;;;4BAIrBrC,kCACC,KAACxB;gCACCoD,OAAM;gCACNO,SACE,wEAAwE;gCACxE,uEAAuE;gCACvE,uBAAuB;8CACvB,KAACzD;oCACCkE,UAAU;oCACVC,oBAAoB;oCACpBR,gBAAgB;oCAChBvC,OAAOuB;oCACPe,SAASN;oCACT/B,UAAUc;oCACViC,WAAW;oCACXC,WAAW;wCACTnC,MAAM;oCACR;;;;;;;;;AAWtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinksEditor.d.ts","sourceRoot":"","sources":["../../../src/components/LinksEditor/LinksEditor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LinksEditor.d.ts","sourceRoot":"","sources":["../../../src/components/LinksEditor/LinksEditor.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAY,cAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EAA6B,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAErE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,WAAW,gBAAiB,SAAQ,cAAc,CAAC,cAAc,CAAC;IACtE,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACrC;AAED,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,EAAE,gBAAgB,GAAG,YAAY,CAiCjF"}
|
|
@@ -11,12 +11,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import { Fragment } from 'react';
|
|
15
14
|
import { Divider, IconButton, Stack, Typography } from '@mui/material';
|
|
16
|
-
import { Controller, useFieldArray } from 'react-hook-form';
|
|
17
|
-
import PlusIcon from 'mdi-material-ui/Plus';
|
|
18
|
-
import MinusIcon from 'mdi-material-ui/Minus';
|
|
19
15
|
import { LinkEditorForm } from '@perses-dev/components';
|
|
16
|
+
import MinusIcon from 'mdi-material-ui/Minus';
|
|
17
|
+
import PlusIcon from 'mdi-material-ui/Plus';
|
|
18
|
+
import { Fragment } from 'react';
|
|
19
|
+
import { Controller, useFieldArray } from 'react-hook-form';
|
|
20
20
|
export function LinksEditor({ control, ...props }) {
|
|
21
21
|
const { fields, append, remove } = useFieldArray({
|
|
22
22
|
control: control,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/LinksEditor/LinksEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/components/LinksEditor/LinksEditor.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 { Divider, IconButton, Stack, Typography } from '@mui/material';\nimport { LinkEditorForm } from '@perses-dev/components';\nimport MinusIcon from 'mdi-material-ui/Minus';\nimport PlusIcon from 'mdi-material-ui/Plus';\nimport { Fragment, HTMLAttributes, ReactElement } from 'react';\nimport { Controller, useFieldArray, Control } from 'react-hook-form';\n\nimport { PanelEditorValues } from '../../model';\n\nexport interface LinksEditorProps extends HTMLAttributes<HTMLDivElement> {\n control: Control<PanelEditorValues>;\n}\n\nexport function LinksEditor({ control, ...props }: LinksEditorProps): ReactElement {\n const { fields, append, remove } = useFieldArray({\n control: control,\n name: 'panelDefinition.spec.links',\n });\n\n return (\n <Stack {...props} gap={3}>\n {fields && fields.length > 0 ? (\n fields.map((field, index) => (\n <Fragment key={field.id}>\n <Stack direction=\"row\" gap={1} alignItems=\"center\">\n <LinkControl control={control} index={index} />\n <IconButton style={{ width: 'fit-content', height: 'fit-content' }} onClick={() => remove(index)}>\n <MinusIcon />\n </IconButton>\n </Stack>\n <Divider />\n </Fragment>\n ))\n ) : (\n <Typography variant=\"subtitle1\" mb={2} fontStyle=\"italic\">\n No links defined\n </Typography>\n )}\n <IconButton\n style={{ width: 'fit-content', height: 'fit-content' }}\n onClick={() => append({ url: '', name: '', tooltip: '', renderVariables: false, targetBlank: false })}\n >\n <PlusIcon />\n </IconButton>\n </Stack>\n );\n}\n\nfunction LinkControl({ control, index }: { control: Control<PanelEditorValues>; index: number }): ReactElement {\n const defaultLink = { url: '', name: '', tooltip: '', renderVariables: false, targetBlank: false };\n return (\n <Controller\n control={control}\n name={`panelDefinition.spec.links.${index}`}\n render={({ field, field: { value: link }, fieldState }) => {\n const safeLink = link ?? defaultLink;\n return (\n <LinkEditorForm\n mode=\"inline\"\n url={{\n value: safeLink.url,\n label: 'URL',\n error: { hasError: !!fieldState.error, helperText: fieldState.error?.message },\n onChange: (url) => {\n field.onChange({ ...link, url });\n },\n }}\n newTabOpen={{\n value: !!safeLink.targetBlank,\n onChange: (targetBlank) => {\n field.onChange({ ...link, targetBlank });\n },\n label: 'Open in new tab',\n }}\n name={{\n value: safeLink.name ?? '',\n label: 'Name',\n onChange: (name) => {\n field.onChange({ ...link, name });\n },\n }}\n renderVariables={{\n value: !!safeLink.renderVariables,\n label: 'Render variables',\n onChange: (renderVariables) => {\n field.onChange({ ...link, renderVariables });\n },\n }}\n tooltip={{\n value: safeLink.tooltip ?? '',\n label: 'Tooltip',\n onChange: (tooltip) => {\n field.onChange({ ...link, tooltip });\n },\n }}\n />\n );\n }}\n />\n );\n}\n"],"names":["Divider","IconButton","Stack","Typography","LinkEditorForm","MinusIcon","PlusIcon","Fragment","Controller","useFieldArray","LinksEditor","control","props","fields","append","remove","name","gap","length","map","field","index","direction","alignItems","LinkControl","style","width","height","onClick","id","variant","mb","fontStyle","url","tooltip","renderVariables","targetBlank","defaultLink","render","value","link","fieldState","safeLink","mode","label","error","hasError","helperText","message","onChange","newTabOpen"],"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,OAAO,EAAEC,UAAU,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAgB;AACvE,SAASC,cAAc,QAAQ,yBAAyB;AACxD,OAAOC,eAAe,wBAAwB;AAC9C,OAAOC,cAAc,uBAAuB;AAC5C,SAASC,QAAQ,QAAsC,QAAQ;AAC/D,SAASC,UAAU,EAAEC,aAAa,QAAiB,kBAAkB;AAQrE,OAAO,SAASC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AOG,SAAST,GAAG;oBACnBW,OAAO;oBACPC,OAAO;wBAAEC,UAAU,CAAC,CAACL,WAAWI,KAAK;wBAAEE,YAAYN,WAAWI,KAAK,EAAEG;oBAAQ;oBAC7EC,UAAU,CAAChB;wBACTb,MAAM6B,QAAQ,CAAC;4BAAE,GAAGT,IAAI;4BAAEP;wBAAI;oBAChC;gBACF;gBACAiB,YAAY;oBACVX,OAAO,CAAC,CAACG,SAASN,WAAW;oBAC7Ba,UAAU,CAACb;wBACThB,MAAM6B,QAAQ,CAAC;4BAAE,GAAGT,IAAI;4BAAEJ;wBAAY;oBACxC;oBACAQ,OAAO;gBACT;gBACA5B,MAAM;oBACJuB,OAAOG,SAAS1B,IAAI,IAAI;oBACxB4B,OAAO;oBACPK,UAAU,CAACjC;wBACTI,MAAM6B,QAAQ,CAAC;4BAAE,GAAGT,IAAI;4BAAExB;wBAAK;oBACjC;gBACF;gBACAmB,iBAAiB;oBACfI,OAAO,CAAC,CAACG,SAASP,eAAe;oBACjCS,OAAO;oBACPK,UAAU,CAACd;wBACTf,MAAM6B,QAAQ,CAAC;4BAAE,GAAGT,IAAI;4BAAEL;wBAAgB;oBAC5C;gBACF;gBACAD,SAAS;oBACPK,OAAOG,SAASR,OAAO,IAAI;oBAC3BU,OAAO;oBACPK,UAAU,CAACf;wBACTd,MAAM6B,QAAQ,CAAC;4BAAE,GAAGT,IAAI;4BAAEN;wBAAQ;oBACpC;gBACF;;QAGN;;AAGN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiQueryEditor.d.ts","sourceRoot":"","sources":["../../../src/components/MultiQueryEditor/MultiQueryEditor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MultiQueryEditor.d.ts","sourceRoot":"","sources":["../../../src/components/MultiQueryEditor/MultiQueryEditor.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKpE,OAAO,EAAE,SAAS,EAAuD,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlD,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAC5B,YAAY,CAAC,EAAE,SAAS,EAAE,CAAC;IAC3B,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;IAC/C,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;CAC7D;AA4CD;;;;;;;GAOG;AAEH,eAAO,MAAM,gBAAgB,mHAyF3B,CAAC"}
|
|
@@ -11,10 +11,10 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import { forwardRef, useState } from 'react';
|
|
15
|
-
import { produce } from 'immer';
|
|
16
14
|
import { Button, Stack } from '@mui/material';
|
|
15
|
+
import { produce } from 'immer';
|
|
17
16
|
import AddIcon from 'mdi-material-ui/Plus';
|
|
17
|
+
import { forwardRef, useState } from 'react';
|
|
18
18
|
import { useListPluginMetadata, usePlugin, usePluginRegistry } from '../../runtime';
|
|
19
19
|
import { QueryEditorContainer } from './QueryEditorContainer';
|
|
20
20
|
function useDefaultQueryDefinition(queryTypes, filteredQueryPlugins) {
|
|
@@ -115,9 +115,12 @@ function useDefaultQueryDefinition(queryTypes, filteredQueryPlugins) {
|
|
|
115
115
|
});
|
|
116
116
|
};
|
|
117
117
|
// show one query input if queries is empty
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
let queryDefinitions = queries;
|
|
119
|
+
if (queries.length === 0 && !isLoading) {
|
|
120
|
+
queryDefinitions = [
|
|
121
|
+
defaultInitialQueryDefinition
|
|
122
|
+
];
|
|
123
|
+
}
|
|
121
124
|
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
122
125
|
children: [
|
|
123
126
|
/*#__PURE__*/ _jsx(Stack, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/MultiQueryEditor/MultiQueryEditor.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 { forwardRef, ReactElement, useState } from 'react';\nimport { produce } from 'immer';\nimport { Button, Stack } from '@mui/material';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport { QueryDefinition, QueryPluginType } from '@perses-dev/spec';\nimport { QueryData, useListPluginMetadata, usePlugin, usePluginRegistry } from '../../runtime';\nimport { PluginEditorRef } from '../PluginEditor';\nimport { QueryEditorContainer } from './QueryEditorContainer';\n\nexport interface MultiQueryEditorProps {\n queryTypes: QueryPluginType[];\n filteredQueryPlugins?: string[];\n queries?: QueryDefinition[];\n queryResults?: QueryData[];\n onChange: (queries: QueryDefinition[]) => void;\n onQueryRun: (index: number, query: QueryDefinition) => void;\n}\n\nfunction useDefaultQueryDefinition(\n queryTypes: QueryPluginType[],\n filteredQueryPlugins?: string[]\n): {\n defaultInitialQueryDefinition: QueryDefinition;\n isLoading: boolean;\n} {\n // Build the default query plugin\n // This will be used only if the queries are empty, to open a starting query\n\n // Firs the default query type\n const defaultQueryType = queryTypes[0]!;\n // Then the default plugin kind\n // Use as default the plugin kind explicitly set as default or the first in the list\n const { data: queryPlugins, isLoading } = useListPluginMetadata(queryTypes);\n const { defaultPluginKinds } = usePluginRegistry();\n\n let defaultQueryKind: string = '';\n\n if (filteredQueryPlugins?.length) {\n defaultQueryKind = queryPlugins?.find((i) => filteredQueryPlugins.includes(i.spec.name))!.spec.name ?? '';\n } else {\n defaultQueryKind = defaultPluginKinds?.[defaultQueryType] ?? queryPlugins?.[0]?.spec.name ?? '';\n }\n\n const { data: defaultQueryPlugin, isLoading: isPluginLoading } = usePlugin(defaultQueryType, defaultQueryKind, {\n useErrorBoundary: true,\n enabled: true,\n });\n\n // This default query definition is used if no query is provided initially or when we add a new query\n return {\n defaultInitialQueryDefinition: {\n kind: defaultQueryType,\n spec: {\n plugin: { kind: defaultQueryKind, spec: defaultQueryPlugin?.createInitialOptions() || {} },\n },\n },\n isLoading: isLoading || isPluginLoading,\n };\n}\n\n/**\n * A component render a list of {@link QueryEditorContainer} for the given query definitions.\n * It allows adding, removing and editing queries.\n * @param queryTypes The list of query types that the underlying editor will propose\n * @param queries The list of query definitions to render\n * @param onChange The callback to call when the queries are modified\n * @constructor\n */\n\nexport const MultiQueryEditor = forwardRef<PluginEditorRef, MultiQueryEditorProps>((props, ref): ReactElement => {\n const { queryTypes, queries = [], queryResults, filteredQueryPlugins, onChange, onQueryRun } = props;\n const { defaultInitialQueryDefinition, isLoading } = useDefaultQueryDefinition(queryTypes, filteredQueryPlugins);\n // State for which queries are collapsed\n const [queriesCollapsed, setQueriesCollapsed] = useState(queries.map(() => false));\n\n // Query handlers\n const handleQueryChange = (index: number, queryDef: QueryDefinition): void => {\n onChange(\n produce(queries, (draft) => {\n if (draft) {\n draft[index] = queryDef;\n } else {\n draft = [queryDef];\n }\n })\n );\n };\n\n const handleQueryRun = (index: number, queryDef: QueryDefinition): void => {\n onQueryRun(index, queryDef);\n };\n\n const handleQueryAdd = (): void => {\n onChange(\n produce(queries, (draft) => {\n if (draft) {\n draft.push(defaultInitialQueryDefinition);\n } else {\n draft = [...queries, defaultInitialQueryDefinition];\n }\n })\n );\n setQueriesCollapsed((queriesCollapsed) => {\n queriesCollapsed.push(false);\n return [...queriesCollapsed];\n });\n };\n\n const handleQueryDelete = (index: number): void => {\n onChange(\n produce(queries, (draft) => {\n draft.splice(index, 1);\n })\n );\n setQueriesCollapsed((queriesCollapsed) => {\n queriesCollapsed.splice(index, 1);\n return [...queriesCollapsed];\n });\n };\n\n const handleQueryCollapseExpand = (index: number): void => {\n setQueriesCollapsed((queriesCollapsed) => {\n queriesCollapsed[index] = !queriesCollapsed[index];\n return [...queriesCollapsed];\n });\n };\n\n // show one query input if queries is empty\n const queryDefinitions: QueryDefinition[] = queries.length\n ? queries\n : !isLoading\n ? [defaultInitialQueryDefinition]\n : [];\n\n return (\n <>\n <Stack spacing={1}>\n {queryDefinitions.map((query: QueryDefinition, i: number) => (\n <QueryEditorContainer\n ref={ref}\n queryTypes={queryTypes}\n key={i}\n index={i}\n query={query}\n queryResult={queryResults?.[i]}\n filteredQueryPlugins={filteredQueryPlugins}\n isCollapsed={!!queriesCollapsed[i]}\n onChange={handleQueryChange}\n onQueryRun={handleQueryRun}\n onDelete={queries.length > 1 ? handleQueryDelete : undefined}\n onCollapseExpand={handleQueryCollapseExpand}\n />\n ))}\n </Stack>\n <Button variant=\"contained\" startIcon={<AddIcon />} sx={{ marginTop: 1 }} onClick={handleQueryAdd}>\n Add Query\n </Button>\n </>\n );\n});\n\nMultiQueryEditor.displayName = 'MultiQueryEditor';\n"],"names":["forwardRef","useState","produce","Button","Stack","AddIcon","useListPluginMetadata","usePlugin","usePluginRegistry","QueryEditorContainer","useDefaultQueryDefinition","queryTypes","filteredQueryPlugins","defaultQueryType","data","queryPlugins","isLoading","defaultPluginKinds","defaultQueryKind","length","find","i","includes","spec","name","defaultQueryPlugin","isPluginLoading","useErrorBoundary","enabled","defaultInitialQueryDefinition","kind","plugin","createInitialOptions","MultiQueryEditor","props","ref","queries","queryResults","onChange","onQueryRun","queriesCollapsed","setQueriesCollapsed","map","handleQueryChange","index","queryDef","draft","handleQueryRun","handleQueryAdd","push","handleQueryDelete","splice","handleQueryCollapseExpand","queryDefinitions","spacing","query","queryResult","isCollapsed","onDelete","undefined","onCollapseExpand","variant","startIcon","sx","marginTop","onClick","displayName"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,UAAU,EAAgBC,QAAQ,QAAQ,QAAQ;AAC3D,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAASC,MAAM,EAAEC,KAAK,QAAQ,gBAAgB;AAC9C,OAAOC,aAAa,uBAAuB;AAE3C,SAAoBC,qBAAqB,EAAEC,SAAS,EAAEC,iBAAiB,QAAQ,gBAAgB;AAE/F,SAASC,oBAAoB,QAAQ,yBAAyB;AAW9D,SAASC,0BACPC,UAA6B,EAC7BC,oBAA+B;IAK/B,iCAAiC;IACjC,4EAA4E;IAE5E,8BAA8B;IAC9B,MAAMC,mBAAmBF,UAAU,CAAC,EAAE;IACtC,+BAA+B;IAC/B,oFAAoF;IACpF,MAAM,EAAEG,MAAMC,YAAY,EAAEC,SAAS,EAAE,GAAGV,sBAAsBK;IAChE,MAAM,EAAEM,kBAAkB,EAAE,GAAGT;IAE/B,IAAIU,mBAA2B;IAE/B,IAAIN,sBAAsBO,QAAQ;QAChCD,mBAAmBH,cAAcK,KAAK,CAACC,IAAMT,qBAAqBU,QAAQ,CAACD,EAAEE,IAAI,CAACC,IAAI,GAAID,KAAKC,QAAQ;IACzG,OAAO;QACLN,mBAAmBD,oBAAoB,CAACJ,iBAAiB,IAAIE,cAAc,CAAC,EAAE,EAAEQ,KAAKC,QAAQ;IAC/F;IAEA,MAAM,EAAEV,MAAMW,kBAAkB,EAAET,WAAWU,eAAe,EAAE,GAAGnB,UAAUM,kBAAkBK,kBAAk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AiBW,MAAM,CAACP,OAAO;YAC/B,OAAO;mBAAIJ;aAAiB;QAC9B;IACF;IAEA,MAAMY,4BAA4B,CAACR;QACjCH,oBAAoB,CAACD;YACnBA,gBAAgB,CAACI,MAAM,GAAG,CAACJ,gBAAgB,CAACI,MAAM;YAClD,OAAO;mBAAIJ;aAAiB;QAC9B;IACF;IAEA,2CAA2C;IAC3C,MAAMa,mBAAsCjB,QAAQjB,MAAM,GACtDiB,UACA,CAACpB,YACC;QAACa;KAA8B,GAC/B,EAAE;IAER,qBACE;;0BACE,KAACzB;gBAAMkD,SAAS;0BACbD,iBAAiBX,GAAG,CAAC,CAACa,OAAwBlC,kBAC7C,KAACZ;wBACC0B,KAAKA;wBACLxB,YAAYA;wBAEZiC,OAAOvB;wBACPkC,OAAOA;wBACPC,aAAanB,cAAc,CAAChB,EAAE;wBAC9BT,sBAAsBA;wBACtB6C,aAAa,CAAC,CAACjB,gBAAgB,CAACnB,EAAE;wBAClCiB,UAAUK;wBACVJ,YAAYQ;wBACZW,UAAUtB,QAAQjB,MAAM,GAAG,IAAI+B,oBAAoBS;wBACnDC,kBAAkBR;uBATb/B;;0BAaX,KAAClB;gBAAO0D,SAAQ;gBAAYC,yBAAW,KAACzD;gBAAY0D,IAAI;oBAAEC,WAAW;gBAAE;gBAAGC,SAASjB;0BAAgB;;;;AAKzG,GAAG;AAEHf,iBAAiBiC,WAAW,GAAG"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/MultiQueryEditor/MultiQueryEditor.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, Stack } from '@mui/material';\nimport { QueryDefinition, QueryPluginType } from '@perses-dev/spec';\nimport { produce } from 'immer';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport { forwardRef, ReactElement, useState } from 'react';\n\nimport { QueryData, useListPluginMetadata, usePlugin, usePluginRegistry } from '../../runtime';\nimport { PluginEditorRef } from '../PluginEditor';\nimport { QueryEditorContainer } from './QueryEditorContainer';\n\nexport interface MultiQueryEditorProps {\n queryTypes: QueryPluginType[];\n filteredQueryPlugins?: string[];\n queries?: QueryDefinition[];\n queryResults?: QueryData[];\n onChange: (queries: QueryDefinition[]) => void;\n onQueryRun: (index: number, query: QueryDefinition) => void;\n}\n\nfunction useDefaultQueryDefinition(\n queryTypes: QueryPluginType[],\n filteredQueryPlugins?: string[],\n): {\n defaultInitialQueryDefinition: QueryDefinition;\n isLoading: boolean;\n} {\n // Build the default query plugin\n // This will be used only if the queries are empty, to open a starting query\n\n // Firs the default query type\n const defaultQueryType = queryTypes[0]!;\n // Then the default plugin kind\n // Use as default the plugin kind explicitly set as default or the first in the list\n const { data: queryPlugins, isLoading } = useListPluginMetadata(queryTypes);\n const { defaultPluginKinds } = usePluginRegistry();\n\n let defaultQueryKind: string = '';\n\n if (filteredQueryPlugins?.length) {\n defaultQueryKind = queryPlugins?.find((i) => filteredQueryPlugins.includes(i.spec.name))!.spec.name ?? '';\n } else {\n defaultQueryKind = defaultPluginKinds?.[defaultQueryType] ?? queryPlugins?.[0]?.spec.name ?? '';\n }\n\n const { data: defaultQueryPlugin, isLoading: isPluginLoading } = usePlugin(defaultQueryType, defaultQueryKind, {\n useErrorBoundary: true,\n enabled: true,\n });\n\n // This default query definition is used if no query is provided initially or when we add a new query\n return {\n defaultInitialQueryDefinition: {\n kind: defaultQueryType,\n spec: {\n plugin: { kind: defaultQueryKind, spec: defaultQueryPlugin?.createInitialOptions() || {} },\n },\n },\n isLoading: isLoading || isPluginLoading,\n };\n}\n\n/**\n * A component render a list of {@link QueryEditorContainer} for the given query definitions.\n * It allows adding, removing and editing queries.\n * @param queryTypes The list of query types that the underlying editor will propose\n * @param queries The list of query definitions to render\n * @param onChange The callback to call when the queries are modified\n * @constructor\n */\n\nexport const MultiQueryEditor = forwardRef<PluginEditorRef, MultiQueryEditorProps>((props, ref): ReactElement => {\n const { queryTypes, queries = [], queryResults, filteredQueryPlugins, onChange, onQueryRun } = props;\n const { defaultInitialQueryDefinition, isLoading } = useDefaultQueryDefinition(queryTypes, filteredQueryPlugins);\n // State for which queries are collapsed\n const [queriesCollapsed, setQueriesCollapsed] = useState(queries.map(() => false));\n\n // Query handlers\n const handleQueryChange = (index: number, queryDef: QueryDefinition): void => {\n onChange(\n produce(queries, (draft) => {\n if (draft) {\n draft[index] = queryDef;\n } else {\n draft = [queryDef];\n }\n }),\n );\n };\n\n const handleQueryRun = (index: number, queryDef: QueryDefinition): void => {\n onQueryRun(index, queryDef);\n };\n\n const handleQueryAdd = (): void => {\n onChange(\n produce(queries, (draft) => {\n if (draft) {\n draft.push(defaultInitialQueryDefinition);\n } else {\n draft = [...queries, defaultInitialQueryDefinition];\n }\n }),\n );\n setQueriesCollapsed((queriesCollapsed) => {\n queriesCollapsed.push(false);\n return [...queriesCollapsed];\n });\n };\n\n const handleQueryDelete = (index: number): void => {\n onChange(\n produce(queries, (draft) => {\n draft.splice(index, 1);\n }),\n );\n setQueriesCollapsed((queriesCollapsed) => {\n queriesCollapsed.splice(index, 1);\n return [...queriesCollapsed];\n });\n };\n\n const handleQueryCollapseExpand = (index: number): void => {\n setQueriesCollapsed((queriesCollapsed) => {\n queriesCollapsed[index] = !queriesCollapsed[index];\n return [...queriesCollapsed];\n });\n };\n\n // show one query input if queries is empty\n let queryDefinitions: QueryDefinition[] = queries;\n if (queries.length === 0 && !isLoading) {\n queryDefinitions = [defaultInitialQueryDefinition];\n }\n\n return (\n <>\n <Stack spacing={1}>\n {queryDefinitions.map((query: QueryDefinition, i: number) => (\n <QueryEditorContainer\n ref={ref}\n queryTypes={queryTypes}\n key={i}\n index={i}\n query={query}\n queryResult={queryResults?.[i]}\n filteredQueryPlugins={filteredQueryPlugins}\n isCollapsed={!!queriesCollapsed[i]}\n onChange={handleQueryChange}\n onQueryRun={handleQueryRun}\n onDelete={queries.length > 1 ? handleQueryDelete : undefined}\n onCollapseExpand={handleQueryCollapseExpand}\n />\n ))}\n </Stack>\n <Button variant=\"contained\" startIcon={<AddIcon />} sx={{ marginTop: 1 }} onClick={handleQueryAdd}>\n Add Query\n </Button>\n </>\n );\n});\n\nMultiQueryEditor.displayName = 'MultiQueryEditor';\n"],"names":["Button","Stack","produce","AddIcon","forwardRef","useState","useListPluginMetadata","usePlugin","usePluginRegistry","QueryEditorContainer","useDefaultQueryDefinition","queryTypes","filteredQueryPlugins","defaultQueryType","data","queryPlugins","isLoading","defaultPluginKinds","defaultQueryKind","length","find","i","includes","spec","name","defaultQueryPlugin","isPluginLoading","useErrorBoundary","enabled","defaultInitialQueryDefinition","kind","plugin","createInitialOptions","MultiQueryEditor","props","ref","queries","queryResults","onChange","onQueryRun","queriesCollapsed","setQueriesCollapsed","map","handleQueryChange","index","queryDef","draft","handleQueryRun","handleQueryAdd","push","handleQueryDelete","splice","handleQueryCollapseExpand","queryDefinitions","spacing","query","queryResult","isCollapsed","onDelete","undefined","onCollapseExpand","variant","startIcon","sx","marginTop","onClick","displayName"],"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,KAAK,QAAQ,gBAAgB;AAE9C,SAASC,OAAO,QAAQ,QAAQ;AAChC,OAAOC,aAAa,uBAAuB;AAC3C,SAASC,UAAU,EAAgBC,QAAQ,QAAQ,QAAQ;AAE3D,SAAoBC,qBAAqB,EAAEC,SAAS,EAAEC,iBAAiB,QAAQ,gBAAgB;AAE/F,SA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BA;wBACtB6C,aAAa,CAAC,CAACjB,gBAAgB,CAACnB,EAAE;wBAClCiB,UAAUK;wBACVJ,YAAYQ;wBACZW,UAAUtB,QAAQjB,MAAM,GAAG,IAAI+B,oBAAoBS;wBACnDC,kBAAkBR;uBATb/B;;0BAaX,KAACrB;gBAAO6D,SAAQ;gBAAYC,yBAAW,KAAC3D;gBAAY4D,IAAI;oBAAEC,WAAW;gBAAE;gBAAGC,SAASjB;0BAAgB;;;;AAKzG,GAAG;AAEHf,iBAAiBiC,WAAW,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryEditorContainer.d.ts","sourceRoot":"","sources":["../../../src/components/MultiQueryEditor/QueryEditorContainer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"QueryEditorContainer.d.ts","sourceRoot":"","sources":["../../../src/components/MultiQueryEditor/QueryEditorContainer.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAWpE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAmC,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGnF;;GAEG;AACH,UAAU,yBAAyB;IACjC,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,eAAe,CAAC;IACvB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAC1D,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAC5D,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,oBAAoB,uHAyIhC,CAAC"}
|