@perses-dev/plugin-system 0.55.0-beta.1 → 0.55.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts +3 -3
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts.map +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +11 -11
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js.map +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts +3 -3
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts.map +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +6 -6
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js.map +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/index.js +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/index.js.map +1 -1
- package/dist/components/Annotations/index.js +2 -2
- package/dist/components/Annotations/index.js.map +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.d.ts +2 -2
- package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.js +2 -2
- package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
- package/dist/components/CalculationSelector/index.js +1 -1
- package/dist/components/CalculationSelector/index.js.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +3 -2
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +10 -9
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
- package/dist/components/DatasourceEditorForm/index.js +1 -1
- package/dist/components/DatasourceEditorForm/index.js.map +1 -1
- package/dist/components/DatasourceSelect/DatasourceSelect.d.ts +4 -4
- package/dist/components/DatasourceSelect/DatasourceSelect.d.ts.map +1 -1
- package/dist/components/DatasourceSelect/DatasourceSelect.js +7 -7
- package/dist/components/DatasourceSelect/DatasourceSelect.js.map +1 -1
- package/dist/components/DatasourceSelect/index.js +1 -1
- package/dist/components/DatasourceSelect/index.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/{cjs/model/alerts-queries.js → components/DatasourceTestConnectionButton/index.js} +3 -4
- package/dist/components/DatasourceTestConnectionButton/index.js.map +1 -0
- package/dist/components/HTTPSettingsEditor/HTTPHeaderPolicyEditor.d.ts +10 -0
- package/dist/components/HTTPSettingsEditor/HTTPHeaderPolicyEditor.d.ts.map +1 -0
- package/dist/components/HTTPSettingsEditor/HTTPHeaderPolicyEditor.js +99 -0
- package/dist/components/HTTPSettingsEditor/HTTPHeaderPolicyEditor.js.map +1 -0
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +4 -2
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +91 -41
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -1
- package/dist/components/HTTPSettingsEditor/index.js +1 -1
- package/dist/components/HTTPSettingsEditor/index.js.map +1 -1
- package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.d.ts +1 -1
- package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.d.ts.map +1 -1
- package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js +28 -28
- package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js.map +1 -1
- package/dist/components/ItemSelectionActionsOptionsEditor/index.js +1 -1
- package/dist/components/ItemSelectionActionsOptionsEditor/index.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/{cjs/model/explore.js → components/LayoutEditor/index.js} +5 -4
- package/dist/components/LayoutEditor/index.js.map +1 -0
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts +2 -2
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +5 -5
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
- package/dist/components/LegendOptionsEditor/index.js +1 -1
- package/dist/components/LegendOptionsEditor/index.js.map +1 -1
- package/dist/components/LinksEditor/LinksEditor.d.ts +3 -3
- package/dist/components/LinksEditor/LinksEditor.d.ts.map +1 -1
- package/dist/components/LinksEditor/LinksEditor.js +6 -6
- package/dist/components/LinksEditor/LinksEditor.js.map +1 -1
- package/dist/components/LinksEditor/index.js +1 -1
- package/dist/components/LinksEditor/index.js.map +1 -1
- package/dist/components/MetricLabelInput/MetricLabelInput.d.ts +1 -1
- package/dist/components/MetricLabelInput/MetricLabelInput.d.ts.map +1 -1
- package/dist/components/MetricLabelInput/MetricLabelInput.js +2 -2
- package/dist/components/MetricLabelInput/MetricLabelInput.js.map +1 -1
- package/dist/components/MetricLabelInput/index.js +1 -1
- package/dist/components/MetricLabelInput/index.js.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +3 -4
- package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js +12 -9
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts +3 -4
- package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js +14 -14
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
- package/dist/components/MultiQueryEditor/index.js +2 -2
- package/dist/components/MultiQueryEditor/index.js.map +1 -1
- package/dist/components/MultiQueryEditor/utils.d.ts +1 -1
- package/dist/components/MultiQueryEditor/utils.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/utils.js.map +1 -1
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts +1 -1
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts.map +1 -1
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js +4 -4
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
- package/dist/components/OptionsEditorRadios/index.js +1 -1
- package/dist/components/OptionsEditorRadios/index.js.map +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts.map +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
- package/dist/components/OptionsEditorTabPanel/index.js +1 -1
- package/dist/components/OptionsEditorTabPanel/index.js.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +4 -4
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
- package/dist/components/OptionsEditorTabs/index.js +1 -1
- package/dist/components/OptionsEditorTabs/index.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelAnnotationsEditor.d.ts +2 -2
- package/dist/components/PanelSpecEditor/PanelAnnotationsEditor.d.ts.map +1 -1
- package/dist/components/PanelSpecEditor/PanelAnnotationsEditor.js +9 -9
- package/dist/components/PanelSpecEditor/PanelAnnotationsEditor.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +8 -5
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js +23 -11
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
- package/dist/components/PanelSpecEditor/index.js +1 -1
- package/dist/components/PanelSpecEditor/index.js.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.d.ts +2 -2
- package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js +10 -9
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginEditor/index.js +2 -2
- package/dist/components/PluginEditor/index.js.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.d.ts +4 -3
- package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js +4 -4
- package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +3 -4
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js +6 -6
- package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
- package/dist/components/PluginKindSelect/index.js +1 -1
- package/dist/components/PluginKindSelect/index.js.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.d.ts +2 -2
- package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js +5 -5
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
- package/dist/components/PluginRegistry/getPluginSearchHelper.d.ts +2 -2
- package/dist/components/PluginRegistry/getPluginSearchHelper.d.ts.map +1 -1
- package/dist/components/PluginRegistry/getPluginSearchHelper.js +2 -2
- package/dist/components/PluginRegistry/getPluginSearchHelper.js.map +1 -1
- package/dist/components/PluginRegistry/index.js +1 -1
- package/dist/components/PluginRegistry/index.js.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.d.ts +2 -1
- package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js +3 -3
- 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 +5 -4
- package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js +19 -5
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
- package/dist/components/PluginSpecEditor/index.js +1 -1
- package/dist/components/PluginSpecEditor/index.js.map +1 -1
- package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.d.ts +1 -1
- package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.d.ts.map +1 -1
- package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.js +3 -3
- package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.js.map +1 -1
- package/dist/components/SelectionOptionsEditor/index.js +1 -1
- package/dist/components/SelectionOptionsEditor/index.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +4 -4
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +18 -55
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/TimeRangeControls/index.js +1 -1
- package/dist/components/TimeRangeControls/index.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +3 -3
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +11 -11
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +2 -2
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +8 -7
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/index.js +3 -3
- package/dist/components/Variables/VariableEditorForm/index.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +2 -2
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +6 -6
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/index.js +2 -2
- package/dist/components/Variables/index.js.map +1 -1
- package/dist/components/Variables/variable-model.d.ts +8 -8
- package/dist/components/Variables/variable-model.d.ts.map +1 -1
- package/dist/components/Variables/variable-model.js +3 -3
- 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 +21 -19
- 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 +2 -1
- 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/{cjs/model/datasource.js → constants/repeat.js} +4 -4
- package/dist/constants/repeat.js.map +1 -0
- package/dist/constants/user-interface-text.d.ts.map +1 -1
- package/dist/context/ValidationProvider.d.ts +9 -9
- package/dist/context/ValidationProvider.d.ts.map +1 -1
- package/dist/context/ValidationProvider.js +6 -6
- package/dist/context/ValidationProvider.js.map +1 -1
- package/dist/context/index.js +1 -1
- package/dist/context/index.js.map +1 -1
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/model/alerts-queries.d.ts +4 -4
- 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 +3 -3
- package/dist/model/annotations.d.ts.map +1 -1
- package/dist/model/annotations.js.map +1 -1
- package/dist/model/calculations.d.ts +1 -1
- package/dist/model/calculations.d.ts.map +1 -1
- package/dist/model/calculations.js.map +1 -1
- package/dist/model/datasource.d.ts +10 -3
- 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 +2 -3
- 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 +17 -16
- 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/{cjs/model/annotations.js → model/json-queries.js} +5 -4
- package/dist/model/json-queries.js.map +1 -0
- package/dist/model/legend.d.ts +3 -3
- package/dist/model/legend.d.ts.map +1 -1
- package/dist/model/legend.js +2 -2
- package/dist/model/legend.js.map +1 -1
- package/dist/model/log-queries.d.ts +3 -3
- 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 +13 -4
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js.map +1 -1
- package/dist/model/plugin-base.d.ts +3 -3
- package/dist/model/plugin-base.d.ts.map +1 -1
- package/dist/model/plugin-base.js.map +1 -1
- package/dist/model/plugin-loading.d.ts +1 -1
- package/dist/model/plugin-loading.d.ts.map +1 -1
- package/dist/model/plugin-loading.js +1 -1
- package/dist/model/plugin-loading.js.map +1 -1
- package/dist/model/plugins.d.ts +15 -13
- package/dist/model/plugins.d.ts.map +1 -1
- package/dist/model/plugins.js.map +1 -1
- package/dist/model/profile-queries.d.ts +4 -4
- 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 +4 -4
- 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 +4 -4
- 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 +4 -4
- 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 +7 -3
- 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 +1 -2
- package/dist/remote/PluginLoaderComponent.d.ts.map +1 -1
- package/dist/remote/PluginLoaderComponent.js +2 -2
- package/dist/remote/PluginLoaderComponent.js.map +1 -1
- package/dist/remote/PluginRuntime.d.ts +11 -2
- package/dist/remote/PluginRuntime.d.ts.map +1 -1
- package/dist/remote/PluginRuntime.js +84 -79
- package/dist/remote/PluginRuntime.js.map +1 -1
- package/dist/remote/index.d.ts +1 -0
- package/dist/remote/index.d.ts.map +1 -1
- package/dist/remote/index.js +3 -2
- package/dist/remote/index.js.map +1 -1
- package/dist/remote/remotePluginLoader.d.ts +2 -2
- package/dist/remote/remotePluginLoader.d.ts.map +1 -1
- package/dist/remote/remotePluginLoader.js +3 -3
- package/dist/remote/remotePluginLoader.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +3 -3
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +20 -12
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/index.js +2 -2
- package/dist/runtime/DataQueriesProvider/index.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.d.ts +3 -3
- package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/RouterProvider.d.ts +2 -1
- package/dist/runtime/RouterProvider.d.ts.map +1 -1
- package/dist/runtime/RouterProvider.js +3 -3
- package/dist/runtime/RouterProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +3 -2
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +22 -8
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProviders.d.ts +3 -2
- package/dist/runtime/TimeRangeProvider/TimeRangeProviders.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProviders.js +5 -5
- package/dist/runtime/TimeRangeProvider/TimeRangeProviders.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts +13 -2
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +65 -4
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/index.js +4 -4
- package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.d.ts +3 -3
- package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.js +4 -4
- package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/refresh-interval.d.ts +1 -1
- package/dist/runtime/TimeRangeProvider/refresh-interval.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/refresh-interval.js +2 -2
- package/dist/runtime/TimeRangeProvider/refresh-interval.js.map +1 -1
- package/dist/runtime/UsageMetricsProvider.d.ts +3 -3
- package/dist/runtime/UsageMetricsProvider.d.ts.map +1 -1
- package/dist/runtime/UsageMetricsProvider.js +3 -3
- package/dist/runtime/UsageMetricsProvider.js.map +1 -1
- package/dist/runtime/alerts-queries.d.ts +2 -2
- package/dist/runtime/alerts-queries.d.ts.map +1 -1
- package/dist/runtime/alerts-queries.js +5 -5
- package/dist/runtime/alerts-queries.js.map +1 -1
- package/dist/runtime/annotations.d.ts +2 -2
- package/dist/runtime/annotations.d.ts.map +1 -1
- package/dist/runtime/annotations.js +6 -6
- package/dist/runtime/annotations.js.map +1 -1
- package/dist/runtime/builtin-variables.d.ts +2 -3
- package/dist/runtime/builtin-variables.d.ts.map +1 -1
- package/dist/runtime/builtin-variables.js +1 -1
- package/dist/runtime/builtin-variables.js.map +1 -1
- package/dist/runtime/datasources.d.ts +2 -3
- package/dist/runtime/datasources.d.ts.map +1 -1
- package/dist/runtime/datasources.js +2 -2
- 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 +16 -15
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/item-actions.d.ts +3 -3
- package/dist/runtime/item-actions.d.ts.map +1 -1
- package/dist/runtime/item-actions.js +2 -2
- 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 +3 -3
- package/dist/runtime/log-queries.d.ts.map +1 -1
- package/dist/runtime/log-queries.js +5 -5
- package/dist/runtime/log-queries.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts +3 -4
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js +2 -2
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/runtime/profile-queries.d.ts +2 -2
- package/dist/runtime/profile-queries.d.ts.map +1 -1
- package/dist/runtime/profile-queries.js +4 -4
- package/dist/runtime/profile-queries.js.map +1 -1
- package/dist/runtime/silences-queries.d.ts +2 -2
- package/dist/runtime/silences-queries.d.ts.map +1 -1
- package/dist/runtime/silences-queries.js +5 -5
- package/dist/runtime/silences-queries.js.map +1 -1
- package/dist/runtime/time-series-queries.d.ts +3 -3
- package/dist/runtime/time-series-queries.d.ts.map +1 -1
- package/dist/runtime/time-series-queries.js +6 -6
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/runtime/trace-queries.d.ts +2 -2
- package/dist/runtime/trace-queries.d.ts.map +1 -1
- package/dist/runtime/trace-queries.js +6 -6
- package/dist/runtime/trace-queries.js.map +1 -1
- package/dist/runtime/utils.d.ts +1 -1
- package/dist/runtime/utils.d.ts.map +1 -1
- package/dist/runtime/utils.js.map +1 -1
- package/dist/runtime/variables.d.ts +1 -2
- package/dist/runtime/variables.d.ts.map +1 -1
- package/dist/runtime/variables.js +4 -4
- package/dist/runtime/variables.js.map +1 -1
- package/dist/schema/index.js +1 -1
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/panel.d.ts +4 -4
- package/dist/schema/panel.d.ts.map +1 -1
- package/dist/schema/panel.js +18 -4
- package/dist/schema/panel.js.map +1 -1
- package/dist/test/index.js +2 -2
- package/dist/test/index.js.map +1 -1
- package/dist/test/mock-data.d.ts +14 -13
- 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 +2 -2
- package/dist/test/render-hook.d.ts.map +1 -1
- package/dist/test/render-hook.js +2 -2
- package/dist/test/render-hook.js.map +1 -1
- package/dist/test/render.d.ts +3 -3
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +3 -3
- 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 +3 -3
- 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/test-plugins/index.d.ts +1 -1
- package/dist/test/test-plugins/index.d.ts.map +1 -1
- package/dist/test/test-plugins/index.js +5 -5
- package/dist/test/test-plugins/index.js.map +1 -1
- package/dist/test/utils.d.ts +2 -2
- package/dist/test/utils.d.ts.map +1 -1
- package/dist/test/utils.js +5 -5
- package/dist/test/utils.js.map +1 -1
- package/dist/test-utils/index.js +1 -1
- package/dist/test-utils/index.js.map +1 -1
- package/dist/test-utils/mock-plugin-registry.d.ts +2 -2
- package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
- package/dist/test-utils/mock-plugin-registry.js +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 +2 -2
- package/dist/utils/csv-export.js.map +1 -1
- package/dist/utils/event.js +1 -1
- package/dist/utils/index.js +3 -3
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/variables.js +1 -1
- package/package.json +16 -16
- package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +0 -283
- package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +0 -197
- package/dist/cjs/components/Annotations/AnnotationEditorForm/index.js +0 -30
- package/dist/cjs/components/Annotations/constants.js +0 -23
- package/dist/cjs/components/Annotations/index.js +0 -31
- package/dist/cjs/components/CalculationSelector/CalculationSelector.js +0 -49
- package/dist/cjs/components/CalculationSelector/index.js +0 -30
- package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +0 -270
- package/dist/cjs/components/DatasourceEditorForm/index.js +0 -30
- package/dist/cjs/components/DatasourceSelect/DatasourceSelect.js +0 -266
- package/dist/cjs/components/DatasourceSelect/index.js +0 -30
- package/dist/cjs/components/HTTPSettingsEditor/HTTPSettingsEditor.js +0 -568
- package/dist/cjs/components/HTTPSettingsEditor/index.js +0 -30
- package/dist/cjs/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js +0 -1175
- package/dist/cjs/components/ItemSelectionActionsOptionsEditor/index.js +0 -30
- package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +0 -211
- package/dist/cjs/components/LegendOptionsEditor/index.js +0 -30
- package/dist/cjs/components/LinksEditor/LinksEditor.js +0 -162
- package/dist/cjs/components/LinksEditor/index.js +0 -30
- package/dist/cjs/components/MetricLabelInput/MetricLabelInput.js +0 -41
- package/dist/cjs/components/MetricLabelInput/index.js +0 -30
- package/dist/cjs/components/MultiQueryEditor/MultiQueryEditor.js +0 -159
- package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +0 -250
- package/dist/cjs/components/MultiQueryEditor/index.js +0 -31
- package/dist/cjs/components/MultiQueryEditor/utils.js +0 -36
- package/dist/cjs/components/OptionsEditorRadios/OptionsEditorRadios.js +0 -69
- package/dist/cjs/components/OptionsEditorRadios/index.js +0 -30
- package/dist/cjs/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +0 -39
- package/dist/cjs/components/OptionsEditorTabPanel/index.js +0 -30
- package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.js +0 -61
- package/dist/cjs/components/OptionsEditorTabs/index.js +0 -30
- package/dist/cjs/components/PanelSpecEditor/PanelAnnotationsEditor.js +0 -246
- package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +0 -132
- package/dist/cjs/components/PanelSpecEditor/index.js +0 -30
- package/dist/cjs/components/PluginEditor/PluginEditor.js +0 -98
- package/dist/cjs/components/PluginEditor/index.js +0 -31
- package/dist/cjs/components/PluginEditor/plugin-editor-api.js +0 -136
- package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +0 -109
- package/dist/cjs/components/PluginKindSelect/index.js +0 -30
- package/dist/cjs/components/PluginRegistry/PluginRegistry.js +0 -86
- package/dist/cjs/components/PluginRegistry/getPluginSearchHelper.js +0 -92
- package/dist/cjs/components/PluginRegistry/index.js +0 -30
- package/dist/cjs/components/PluginRegistry/plugin-indexes.js +0 -88
- package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +0 -55
- package/dist/cjs/components/PluginSpecEditor/index.js +0 -30
- package/dist/cjs/components/SelectionOptionsEditor/SelectionOptionsEditor.js +0 -43
- package/dist/cjs/components/SelectionOptionsEditor/index.js +0 -30
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +0 -236
- package/dist/cjs/components/TimeRangeControls/index.js +0 -30
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +0 -613
- package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +0 -193
- package/dist/cjs/components/Variables/VariableEditorForm/index.js +0 -32
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +0 -143
- package/dist/cjs/components/Variables/index.js +0 -31
- package/dist/cjs/components/Variables/variable-model.js +0 -211
- package/dist/cjs/components/index.js +0 -48
- package/dist/cjs/constants/index.js +0 -30
- package/dist/cjs/constants/user-interface-text.js +0 -32
- package/dist/cjs/context/ValidationProvider.js +0 -77
- package/dist/cjs/context/index.js +0 -30
- package/dist/cjs/index.js +0 -38
- package/dist/cjs/model/calculations.js +0 -178
- package/dist/cjs/model/index.js +0 -45
- package/dist/cjs/model/legend.js +0 -111
- package/dist/cjs/model/log-queries.js +0 -16
- package/dist/cjs/model/log-volume-utils.js +0 -124
- package/dist/cjs/model/panels.js +0 -16
- package/dist/cjs/model/plugin-base.js +0 -16
- package/dist/cjs/model/plugin-loading.js +0 -56
- package/dist/cjs/model/plugins.js +0 -26
- package/dist/cjs/model/profile-queries.js +0 -16
- package/dist/cjs/model/silences-queries.js +0 -16
- package/dist/cjs/model/time-series-queries.js +0 -26
- package/dist/cjs/model/trace-queries.js +0 -16
- package/dist/cjs/model/variables.js +0 -16
- package/dist/cjs/remote/PersesPlugin.types.js +0 -16
- package/dist/cjs/remote/PluginLoaderComponent.js +0 -87
- package/dist/cjs/remote/PluginRuntime.js +0 -331
- package/dist/cjs/remote/index.js +0 -31
- package/dist/cjs/remote/remotePluginLoader.js +0 -101
- package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +0 -154
- package/dist/cjs/runtime/DataQueriesProvider/index.js +0 -31
- package/dist/cjs/runtime/DataQueriesProvider/model.js +0 -34
- package/dist/cjs/runtime/RouterProvider.js +0 -114
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +0 -201
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProviders.js +0 -66
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +0 -113
- package/dist/cjs/runtime/TimeRangeProvider/index.js +0 -33
- package/dist/cjs/runtime/TimeRangeProvider/query-params.js +0 -250
- package/dist/cjs/runtime/TimeRangeProvider/refresh-interval.js +0 -30
- package/dist/cjs/runtime/UsageMetricsProvider.js +0 -102
- package/dist/cjs/runtime/alerts-queries.js +0 -101
- package/dist/cjs/runtime/annotations.js +0 -148
- package/dist/cjs/runtime/builtin-variables.js +0 -81
- package/dist/cjs/runtime/datasources.js +0 -80
- package/dist/cjs/runtime/index.js +0 -44
- package/dist/cjs/runtime/item-actions.js +0 -302
- package/dist/cjs/runtime/log-queries.js +0 -76
- package/dist/cjs/runtime/plugin-registry.js +0 -135
- package/dist/cjs/runtime/profile-queries.js +0 -73
- package/dist/cjs/runtime/silences-queries.js +0 -101
- package/dist/cjs/runtime/time-series-queries.js +0 -165
- package/dist/cjs/runtime/trace-queries.js +0 -106
- package/dist/cjs/runtime/utils.js +0 -39
- package/dist/cjs/runtime/variables.js +0 -160
- package/dist/cjs/schema/index.js +0 -30
- package/dist/cjs/schema/panel.js +0 -42
- package/dist/cjs/test/index.js +0 -31
- package/dist/cjs/test/mock-data.js +0 -357
- package/dist/cjs/test/render-hook.js +0 -31
- package/dist/cjs/test/render.js +0 -31
- package/dist/cjs/test/setup-tests.js +0 -20
- package/dist/cjs/test/test-plugins/bert/index.js +0 -99
- package/dist/cjs/test/test-plugins/ernie/index.js +0 -92
- package/dist/cjs/test/test-plugins/index.js +0 -81
- package/dist/cjs/test/utils.js +0 -58
- package/dist/cjs/test-utils/index.js +0 -30
- package/dist/cjs/test-utils/mock-plugin-registry.js +0 -81
- package/dist/cjs/utils/csv-export.js +0 -248
- package/dist/cjs/utils/event.js +0 -30
- package/dist/cjs/utils/index.js +0 -32
- package/dist/cjs/utils/variables.js +0 -44
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { Control } from 'react-hook-form';
|
|
3
|
+
import type { PanelEditorValues } from '../../model';
|
|
4
|
+
import type { VariableDefinitionGroup } from '../../model/variables';
|
|
5
|
+
export type { VariableDefinitionGroup };
|
|
6
|
+
export interface PanelGroup {
|
|
7
|
+
id: number;
|
|
8
|
+
title?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface LayoutEditorProps {
|
|
11
|
+
control: Control<PanelEditorValues>;
|
|
12
|
+
variableDefinitionGroups: VariableDefinitionGroup[];
|
|
13
|
+
panelGroups?: PanelGroup[];
|
|
14
|
+
}
|
|
15
|
+
export declare function LayoutEditor({ control, variableDefinitionGroups, panelGroups }: LayoutEditorProps): ReactElement;
|
|
16
|
+
//# sourceMappingURL=LayoutEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LayoutEditor.d.ts","sourceRoot":"","sources":["../../../src/components/LayoutEditor/LayoutEditor.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAI/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAOrE,YAAY,EAAE,uBAAuB,EAAE,CAAC;AAExC,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACpC,wBAAwB,EAAE,uBAAuB,EAAE,CAAC;IACpD,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;CAC5B;AAED,wBAAgB,YAAY,CAAC,EAAE,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,EAAE,iBAAiB,GAAG,YAAY,CAwEhH"}
|
|
@@ -0,0 +1,115 @@
|
|
|
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, MenuItem, TextField, Typography } from "@mui/material";
|
|
15
|
+
import { useMemo } from "react";
|
|
16
|
+
import { Controller, useFormContext, useWatch } from "react-hook-form";
|
|
17
|
+
import { DEFAULT_MAX_PER_ROW, DEFAULT_REPEAT_ALIGNMENT } from "../../constants/index.js";
|
|
18
|
+
import { useVariableValues } from "../../runtime/index.js";
|
|
19
|
+
import { RepeatLayoutPreview } from "./RepeatLayoutPreview.js";
|
|
20
|
+
import { RepeatVariableEditor } from "./RepeatVariableEditor.js";
|
|
21
|
+
const DEFAULT_LAYOUT_WIDTH = 24;
|
|
22
|
+
export function LayoutEditor({ control, variableDefinitionGroups, panelGroups }) {
|
|
23
|
+
const { formState, setValue } = useFormContext();
|
|
24
|
+
const variableValues = useVariableValues();
|
|
25
|
+
const watchedRepeatVariableValue = useWatch({
|
|
26
|
+
control,
|
|
27
|
+
name: 'layoutDefinition.repeatVariable.value'
|
|
28
|
+
});
|
|
29
|
+
const watchedAlignment = useWatch({
|
|
30
|
+
control,
|
|
31
|
+
name: 'layoutDefinition.repeatVariable.alignment'
|
|
32
|
+
});
|
|
33
|
+
const watchedMaxPer = useWatch({
|
|
34
|
+
control,
|
|
35
|
+
name: 'layoutDefinition.repeatVariable.maxPer'
|
|
36
|
+
});
|
|
37
|
+
const optionCount = useMemo(()=>{
|
|
38
|
+
if (!watchedRepeatVariableValue) return 0;
|
|
39
|
+
return variableValues[watchedRepeatVariableValue]?.options?.length ?? 0;
|
|
40
|
+
}, [
|
|
41
|
+
watchedRepeatVariableValue,
|
|
42
|
+
variableValues
|
|
43
|
+
]);
|
|
44
|
+
const isVertical = (watchedAlignment ?? DEFAULT_REPEAT_ALIGNMENT) === 'vertical';
|
|
45
|
+
const perRow = isVertical ? 1 : watchedMaxPer ?? DEFAULT_MAX_PER_ROW;
|
|
46
|
+
return /*#__PURE__*/ _jsxs(Grid, {
|
|
47
|
+
container: true,
|
|
48
|
+
spacing: 2,
|
|
49
|
+
width: "100%",
|
|
50
|
+
children: [
|
|
51
|
+
panelGroups && /*#__PURE__*/ _jsxs(_Fragment, {
|
|
52
|
+
children: [
|
|
53
|
+
/*#__PURE__*/ _jsx(Grid, {
|
|
54
|
+
size: 12,
|
|
55
|
+
children: /*#__PURE__*/ _jsx(Typography, {
|
|
56
|
+
variant: "h4",
|
|
57
|
+
children: "Panel Group"
|
|
58
|
+
})
|
|
59
|
+
}),
|
|
60
|
+
/*#__PURE__*/ _jsx(Grid, {
|
|
61
|
+
size: 4,
|
|
62
|
+
children: /*#__PURE__*/ _jsx(Controller, {
|
|
63
|
+
control: control,
|
|
64
|
+
name: "groupId",
|
|
65
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ _jsx(TextField, {
|
|
66
|
+
select: true,
|
|
67
|
+
...field,
|
|
68
|
+
required: true,
|
|
69
|
+
fullWidth: true,
|
|
70
|
+
label: "Group",
|
|
71
|
+
error: !!fieldState.error,
|
|
72
|
+
helperText: fieldState.error?.message,
|
|
73
|
+
children: panelGroups.map((panelGroup, index)=>/*#__PURE__*/ _jsx(MenuItem, {
|
|
74
|
+
value: panelGroup.id,
|
|
75
|
+
children: panelGroup.title ?? `Group ${index + 1}`
|
|
76
|
+
}, panelGroup.id))
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
}),
|
|
80
|
+
/*#__PURE__*/ _jsx(Grid, {
|
|
81
|
+
size: 8
|
|
82
|
+
})
|
|
83
|
+
]
|
|
84
|
+
}),
|
|
85
|
+
/*#__PURE__*/ _jsx(Grid, {
|
|
86
|
+
size: 12,
|
|
87
|
+
children: /*#__PURE__*/ _jsx(Typography, {
|
|
88
|
+
variant: "h4",
|
|
89
|
+
children: "Repeat Options"
|
|
90
|
+
})
|
|
91
|
+
}),
|
|
92
|
+
/*#__PURE__*/ _jsx(Controller, {
|
|
93
|
+
control: control,
|
|
94
|
+
name: "layoutDefinition.repeatVariable",
|
|
95
|
+
render: ({ field })=>/*#__PURE__*/ _jsx(RepeatVariableEditor, {
|
|
96
|
+
value: field.value,
|
|
97
|
+
onChange: field.onChange,
|
|
98
|
+
errors: formState.errors.layoutDefinition?.repeatVariable ?? {},
|
|
99
|
+
variableDefinitionGroups: variableDefinitionGroups,
|
|
100
|
+
isVertical: isVertical,
|
|
101
|
+
onRepeatVariableSet: ()=>setValue('layoutDefinition.width', DEFAULT_LAYOUT_WIDTH)
|
|
102
|
+
})
|
|
103
|
+
}),
|
|
104
|
+
watchedRepeatVariableValue && optionCount > 0 && /*#__PURE__*/ _jsx(Grid, {
|
|
105
|
+
size: 12,
|
|
106
|
+
children: /*#__PURE__*/ _jsx(RepeatLayoutPreview, {
|
|
107
|
+
optionCount: optionCount,
|
|
108
|
+
maxPer: perRow
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
]
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
//# sourceMappingURL=LayoutEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/LayoutEditor/LayoutEditor.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, MenuItem, TextField, Typography } from '@mui/material';\nimport type { ReactElement } from 'react';\nimport { useMemo } from 'react';\nimport type { Control } from 'react-hook-form';\nimport { Controller, useFormContext, useWatch } from 'react-hook-form';\n\nimport { DEFAULT_MAX_PER_ROW, DEFAULT_REPEAT_ALIGNMENT } from '../../constants';\nimport type { PanelEditorValues } from '../../model';\nimport type { VariableDefinitionGroup } from '../../model/variables';\nimport { useVariableValues } from '../../runtime';\nimport { RepeatLayoutPreview } from './RepeatLayoutPreview';\nimport { RepeatVariableEditor } from './RepeatVariableEditor';\n\nconst DEFAULT_LAYOUT_WIDTH = 24;\n\nexport type { VariableDefinitionGroup };\n\nexport interface PanelGroup {\n id: number;\n title?: string;\n}\n\nexport interface LayoutEditorProps {\n control: Control<PanelEditorValues>;\n variableDefinitionGroups: VariableDefinitionGroup[];\n panelGroups?: PanelGroup[];\n}\n\nexport function LayoutEditor({ control, variableDefinitionGroups, panelGroups }: LayoutEditorProps): ReactElement {\n const { formState, setValue } = useFormContext<PanelEditorValues>();\n const variableValues = useVariableValues();\n const watchedRepeatVariableValue = useWatch({ control, name: 'layoutDefinition.repeatVariable.value' });\n const watchedAlignment = useWatch({ control, name: 'layoutDefinition.repeatVariable.alignment' });\n const watchedMaxPer = useWatch({ control, name: 'layoutDefinition.repeatVariable.maxPer' });\n\n const optionCount = useMemo(() => {\n if (!watchedRepeatVariableValue) return 0;\n return variableValues[watchedRepeatVariableValue]?.options?.length ?? 0;\n }, [watchedRepeatVariableValue, variableValues]);\n\n const isVertical = (watchedAlignment ?? DEFAULT_REPEAT_ALIGNMENT) === 'vertical';\n const perRow = isVertical ? 1 : (watchedMaxPer ?? DEFAULT_MAX_PER_ROW);\n\n return (\n <Grid container spacing={2} width=\"100%\">\n {panelGroups && (\n <>\n <Grid size={12}>\n <Typography variant=\"h4\">Panel Group</Typography>\n </Grid>\n <Grid size={4}>\n <Controller\n control={control}\n name=\"groupId\"\n render={({ field, fieldState }) => (\n <TextField\n select\n {...field}\n required\n fullWidth\n label=\"Group\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n >\n {panelGroups.map((panelGroup, index) => (\n <MenuItem key={panelGroup.id} value={panelGroup.id}>\n {panelGroup.title ?? `Group ${index + 1}`}\n </MenuItem>\n ))}\n </TextField>\n )}\n />\n </Grid>\n <Grid size={8} />\n </>\n )}\n <Grid size={12}>\n <Typography variant=\"h4\">Repeat Options</Typography>\n </Grid>\n <Controller\n control={control}\n name=\"layoutDefinition.repeatVariable\"\n render={({ field }) => (\n <RepeatVariableEditor\n value={field.value}\n onChange={field.onChange}\n errors={formState.errors.layoutDefinition?.repeatVariable ?? {}}\n variableDefinitionGroups={variableDefinitionGroups}\n isVertical={isVertical}\n onRepeatVariableSet={() => setValue('layoutDefinition.width', DEFAULT_LAYOUT_WIDTH)}\n />\n )}\n />\n {watchedRepeatVariableValue && optionCount > 0 && (\n <Grid size={12}>\n <RepeatLayoutPreview optionCount={optionCount} maxPer={perRow} />\n </Grid>\n )}\n </Grid>\n );\n}\n"],"names":["Grid2","Grid","MenuItem","TextField","Typography","useMemo","Controller","useFormContext","useWatch","DEFAULT_MAX_PER_ROW","DEFAULT_REPEAT_ALIGNMENT","useVariableValues","RepeatLayoutPreview","RepeatVariableEditor","DEFAULT_LAYOUT_WIDTH","LayoutEditor","control","variableDefinitionGroups","panelGroups","formState","setValue","variableValues","watchedRepeatVariableValue","name","watchedAlignment","watchedMaxPer","optionCount","options","length","isVertical","perRow","container","spacing","width","size","variant","render","field","fieldState","select","required","fullWidth","label","error","helperText","message","map","panelGroup","index","value","id","title","onChange","errors","layoutDefinition","repeatVariable","onRepeatVariableSet","maxPer"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEA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B,KAAClC;wBAAKiC,MAAM;kCACV,cAAA,KAAC5B;4BACCU,SAASA;4BACTO,MAAK;4BACLa,QAAQ,CAAC,EAAEC,KAAK,EAAEC,UAAU,EAAE,iBAC5B,KAACnC;oCACCoC,MAAM;oCACL,GAAGF,KAAK;oCACTG,QAAQ;oCACRC,SAAS;oCACTC,OAAM;oCACNC,OAAO,CAAC,CAACL,WAAWK,KAAK;oCACzBC,YAAYN,WAAWK,KAAK,EAAEE;8CAE7B3B,YAAY4B,GAAG,CAAC,CAACC,YAAYC,sBAC5B,KAAC9C;4CAA6B+C,OAAOF,WAAWG,EAAE;sDAC/CH,WAAWI,KAAK,IAAI,CAAC,MAAM,EAAEH,QAAQ,GAAG;2CAD5BD,WAAWG,EAAE;;;;kCAQtC,KAACjD;wBAAKiC,MAAM;;;;0BAGhB,KAACjC;gBAAKiC,MAAM;0BACV,cAAA,KAAC9B;oBAAW+B,SAAQ;8BAAK;;;0BAE3B,KAAC7B;gBACCU,SAASA;gBACTO,MAAK;gBACLa,QAAQ,CAAC,EAAEC,KAAK,EAAE,iBAChB,KAACxB;wBACCoC,OAAOZ,MAAMY,KAAK;wBAClBG,UAAUf,MAAMe,QAAQ;wBACxBC,QAAQlC,UAAUkC,MAAM,CAACC,gBAAgB,EAAEC,kBAAkB,CAAC;wBAC9DtC,0BAA0BA;wBAC1BY,YAAYA;wBACZ2B,qBAAqB,IAAMpC,SAAS,0BAA0BN;;;YAInEQ,8BAA8BI,cAAc,mBAC3C,KAACzB;gBAAKiC,MAAM;0BACV,cAAA,KAACtB;oBAAoBc,aAAaA;oBAAa+B,QAAQ3B;;;;;AAKjE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
export interface RepeatLayoutPreviewProps {
|
|
3
|
+
optionCount: number;
|
|
4
|
+
maxPer: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function RepeatLayoutPreview({ optionCount, maxPer }: RepeatLayoutPreviewProps): ReactElement;
|
|
7
|
+
//# sourceMappingURL=RepeatLayoutPreview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RepeatLayoutPreview.d.ts","sourceRoot":"","sources":["../../../src/components/LayoutEditor/RepeatLayoutPreview.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAID,wBAAgB,mBAAmB,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,wBAAwB,GAAG,YAAY,CA4CnG"}
|
|
@@ -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 type { ReactElement } from 'react';\nimport { 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;AAExE,SAASC,OAAO,QAAQ,QAAQ;AAOhC,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 type { ReactElement } from 'react';
|
|
2
|
+
import type { ControllerRenderProps, FieldErrors } from 'react-hook-form';
|
|
3
|
+
import type { PanelEditorValues } from '../../model';
|
|
4
|
+
import type { 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,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAE9D,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/index.js";
|
|
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 type { ReactElement } from 'react';\nimport { useCallback } from 'react';\nimport type { ControllerRenderProps, FieldErrors } from 'react-hook-form';\n\nimport { DEFAULT_MAX_PER_ROW, DEFAULT_REPEAT_ALIGNMENT } from '../../constants';\nimport type { PanelEditorValues } from '../../model';\nimport type { 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;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,SAASC,IAAI,EAAEC,aAAa,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,UAAU,QAAQ,gBAAgB;AAE9F,SAASC,WAAW,QAAQ,QAAQ;AAGpC,SAASC,mBAAmB,EAAEC,wBAAwB,QAAQ,2BAAkB;AAmBhF,OAAO,SAASC,qBAAqB,EACnCC,OAAOC,OAAO,EACdC,QAAQ,EACRC,MAAM,EACNC,wBAAwB,EACxBC,UAAU,EACVC,mBAAmB,EACO;IAC1B,MAAMC,uBAAuBX,YAC3B,CAACY;QACC,IAAI,CAACA,UAAU;YACbN,SAASO;QACX,OAAO;YACLP,SAASD,UAAU;gBAAE,GAAGA,OAAO;gBAAED,OAAOQ;YAAS,IAAI;gBAAER,OAAOQ;gBAAUE,WAAWZ;YAAyB;YAC5G,IAAI,CAACG,SAAS;gBACZK;YACF;QACF;IACF,GACA;QAACL;QAASC;QAAUI;KAAoB;IAG1C,MAAMK,wBAAwBf,YAC5B,CAACY;QACC,IAAI,CAACP,SAAS;QACdC,SACEM,aA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ACK,OAAO,EAAED,QAAQN,IAAIE,IAAI,CAACI,IAAI;uCAD3B,GAAGV,UAAU,YAAY,CAAC,EAAEI,IAAIE,IAAI,CAACI,IAAI,EAAE;6BAI7D;wBACH;;;;0BAIJ,KAAClD;gBAAKwB,MAAM;0BACV,cAAA,MAACrB;oBACCsB,MAAM;oBACNC,SAAS;oBACTC,OAAM;oBACNlB,OAAOC,SAASS,aAAaZ;oBAC7B6C,UAAU,CAAC1C;oBACXkB,OAAO,CAAC,CAAChB,OAAOO,SAAS;oBACzBU,YAAYjB,OAAOO,SAAS,EAAEW;oBAC9BnB,UAAU,CAACoB,QAAUX,sBAAsBW,MAAMC,MAAM,CAACvB,KAAK;;sCAE7D,KAACP;4BAASO,OAAM;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"}
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
export * from "./LayoutEditor.js";
|
|
14
|
+
export * from "./RepeatLayoutPreview.js";
|
|
15
|
+
export * from "./RepeatVariableEditor.js";
|
|
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,oBAAiB;AAC/B,cAAc,2BAAwB;AACtC,cAAc,4BAAyB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { LegendSpecOptions } from '../../model';
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { LegendSpecOptions } from '../../model';
|
|
3
3
|
export interface LegendOptionsEditorProps {
|
|
4
4
|
value?: LegendSpecOptions;
|
|
5
5
|
onChange: (legend?: LegendSpecOptions) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LegendOptionsEditor.d.ts","sourceRoot":"","sources":["../../../src/components/LegendOptionsEditor/LegendOptionsEditor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LegendOptionsEditor.d.ts","sourceRoot":"","sources":["../../../src/components/LegendOptionsEditor/LegendOptionsEditor.tsx"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAAE,iBAAiB,EAA2D,MAAM,aAAa,CAAC;AA8B9G,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,4 +1,3 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
1
|
// Copyright The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,10 +10,11 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
import { Switch, ToggleButtonGroup, ToggleButton } from "@mui/material";
|
|
15
|
+
import { ErrorAlert, OptionsEditorControl, OptionsEditorGroup, SettingsAutocomplete, DEFAULT_LEGEND, getLegendSize, getLegendMode, getLegendPosition } from "@perses-dev/components";
|
|
16
|
+
import { useMemo } from "react";
|
|
17
|
+
import { LEGEND_MODE_CONFIG, LEGEND_POSITIONS_CONFIG, validateLegendSpec, LEGEND_VALUE_CONFIG, LEGEND_SIZE_CONFIG, comparisonLegends } from "../../model/index.js";
|
|
18
18
|
const POSITION_OPTIONS = Object.entries(LEGEND_POSITIONS_CONFIG).map(([id, config])=>{
|
|
19
19
|
return {
|
|
20
20
|
id: id,
|
|
@@ -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,sE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CAChBvC,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 type { SwitchProps } from '@mui/material';\nimport { Switch, 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 type { ReactElement } from 'react';\nimport { useMemo } from 'react';\n\nimport type { LegendSpecOptions, LegendSingleSelectConfig, LegendValue, ComparisonValues } from '../../model';\nimport {\n LEGEND_MODE_CONFIG,\n LEGEND_POSITIONS_CONFIG,\n validateLegendSpec,\n LEGEND_VALUE_CONFIG,\n LEGEND_SIZE_CONFIG,\n comparisonLegends,\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;;AAGjC,SAASA,MAAM,EAAEC,iBAAiB,EAAEC,YAAY,QAAQ,gBAAgB;AACxE,SACEC,UAAU,EACVC,oBAAoB,EACpBC,kBAAkB,EAClBC,oBAAoB,EACpBC,cAAc,EACdC,aAAa,EACbC,aAAa,EACbC,iBAAiB,QACZ,yBAAyB;AAEhC,SAASC,OAAO,QAAQ,QAAQ;AAGhC,SACEC,kBAAkB,EAClBC,uBAAuB,EACvBC,kBAAkB,EAClBC,mBAAmB,EACnBC,kBAAkB,EAClBC,iBAAiB,QACZ,uBAAc;AAIrB,MAAMC,mBAA2CC,OAAOC,OAAO,CAACP,yBA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