@grafana/scenes 6.12.0--canary.1121.15045230319.0 → 6.12.0--canary.1121.15070832166.0
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/CHANGELOG.md +12 -0
- package/README.md +10 -0
- package/dist/esm/components/VizPanel/VizPanel.js +2 -2
- package/dist/esm/components/VizPanel/VizPanel.js.map +1 -1
- package/dist/esm/variables/VariableDependencyConfig.js.map +1 -1
- package/dist/esm/variables/components/VariableValueSelectors.js +2 -2
- package/dist/esm/variables/components/VariableValueSelectors.js.map +1 -1
- package/dist/esm/variables/sets/SceneVariableSet.js.map +1 -1
- package/dist/esm/variables/types.js.map +1 -1
- package/dist/esm/variables/variants/ScopesVariable.js +19 -12
- package/dist/esm/variables/variants/ScopesVariable.js.map +1 -1
- package/dist/index.d.ts +11 -12
- package/dist/index.js +20 -13
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import * as _grafana_data from '@grafana/data';
|
2
2
|
import { BusEventWithPayload, EventBus, BusEvent, BusEventType, BusEventHandler, PanelMenuItem, FieldConfigSource, PanelPlugin, AbsoluteTimeRange, PanelData, InterpolateFunction, PanelModel, TimeRange, DataTransformContext, DataFrame, DataQueryRequest, DataSourceGetTagKeysOptions, DataSourceGetTagValuesOptions, IconName, PageLayoutType, UrlQueryMap, DataQuery as DataQuery$1, DataSourceApi, Registry, RegistryItem, ScopedVars, AdHocVariableFilter, GetTagResponse, MetricFindValue, SelectableValue, VariableRefresh as VariableRefresh$1, VariableSort, Scope, EventFilterOptions, AnnotationEvent, AnnotationQuery, DataTransformerConfig, TimeOption, FieldConfig, FieldType, FieldValueMatcherConfig, ScopedVar, RawTimeRange } from '@grafana/data';
|
3
3
|
import * as React$1 from 'react';
|
4
|
-
import React__default, { ComponentType,
|
4
|
+
import React__default, { ComponentType, CSSProperties, PointerEvent, ForwardRefExoticComponent } from 'react';
|
5
5
|
import * as rxjs from 'rxjs';
|
6
6
|
import { Observable, Subscription, Unsubscribable, MonoTypeOperatorFunction, ReplaySubject } from 'rxjs';
|
7
7
|
import * as _grafana_schema from '@grafana/schema';
|
@@ -64,9 +64,9 @@ interface SceneVariable<TState extends SceneVariableState = SceneVariableState>
|
|
64
64
|
*/
|
65
65
|
onCancel?(): void;
|
66
66
|
/**
|
67
|
-
* Edge case for variables that
|
67
|
+
* Edge case for variables that are hidden but wants to be render to access react contexts (ScopesVariable)
|
68
68
|
*/
|
69
|
-
|
69
|
+
UNSAFE_renderAsHidden?: boolean;
|
70
70
|
/**
|
71
71
|
* @experimental
|
72
72
|
* Indicates that a variable loads values lazily when user interacts with the variable dropdown.
|
@@ -280,7 +280,7 @@ interface VariableDependencyConfigOptions<TState extends SceneObjectState> {
|
|
280
280
|
*/
|
281
281
|
handleTimeMacros?: boolean;
|
282
282
|
/**
|
283
|
-
*
|
283
|
+
* Will add ScopesVariable as a dependency which will cause updates when the scopes change.
|
284
284
|
*/
|
285
285
|
dependsOnScopes?: boolean;
|
286
286
|
}
|
@@ -374,7 +374,7 @@ interface VizPanelState<TOptions = {}, TFieldConfig = {}> extends SceneObjectSta
|
|
374
374
|
}
|
375
375
|
declare class VizPanel<TOptions = {}, TFieldConfig extends {} = {}> extends SceneObjectBase<VizPanelState<TOptions, TFieldConfig>> {
|
376
376
|
static Component: typeof VizPanelRenderer;
|
377
|
-
protected _variableDependency: VariableDependencyConfig<VizPanelState<
|
377
|
+
protected _variableDependency: VariableDependencyConfig<VizPanelState<{}, {}>>;
|
378
378
|
protected _panelContext?: PanelContext;
|
379
379
|
private _plugin?;
|
380
380
|
private _prevData?;
|
@@ -414,7 +414,7 @@ declare class VizPanel<TOptions = {}, TFieldConfig extends {} = {}> extends Scen
|
|
414
414
|
private _onSeriesVisibilityChange;
|
415
415
|
private _onInstanceStateChange;
|
416
416
|
private _onToggleLegendSort;
|
417
|
-
clone(): this;
|
417
|
+
clone(withState?: Partial<VizPanelState>): this;
|
418
418
|
private buildPanelContext;
|
419
419
|
}
|
420
420
|
|
@@ -1857,7 +1857,7 @@ interface VariableSelectProps {
|
|
1857
1857
|
/** To provide an option to hide the label in the variable value selector */
|
1858
1858
|
hideLabel?: boolean;
|
1859
1859
|
}
|
1860
|
-
declare function VariableValueSelectWrapper({ variable, layout, showAlways, hideLabel }: VariableSelectProps):
|
1860
|
+
declare function VariableValueSelectWrapper({ variable, layout, showAlways, hideLabel }: VariableSelectProps): React__default.JSX.Element | null;
|
1861
1861
|
|
1862
1862
|
interface VariableValueControlState extends SceneObjectState {
|
1863
1863
|
layout?: ControlsLayout;
|
@@ -1987,11 +1987,13 @@ interface ScopesVariableState extends SceneVariableState {
|
|
1987
1987
|
declare class ScopesVariable extends SceneObjectBase<ScopesVariableState> implements SceneVariable<ScopesVariableState> {
|
1988
1988
|
protected _renderBeforeActivation: boolean;
|
1989
1989
|
protected _context: ScopesContextValue | undefined;
|
1990
|
+
UNSAFE_renderAsHidden: boolean;
|
1991
|
+
static Component: typeof ScopesVariableRenderer;
|
1990
1992
|
constructor(state: Partial<ScopesVariableState>);
|
1991
1993
|
/**
|
1992
1994
|
* Temporary simple implementation to stringify the scopes.
|
1993
1995
|
*/
|
1994
|
-
getValue(
|
1996
|
+
getValue(): VariableValue;
|
1995
1997
|
getScopes(): Scope[] | undefined;
|
1996
1998
|
/**
|
1997
1999
|
* This method is used to keep the context up to date with the scopes context received from React
|
@@ -2003,11 +2005,8 @@ declare class ScopesVariable extends SceneObjectBase<ScopesVariableState> implem
|
|
2003
2005
|
loading: boolean;
|
2004
2006
|
value: Scope[];
|
2005
2007
|
}): void;
|
2006
|
-
/**
|
2007
|
-
* Special function that enables variables to be hidden but still render to access react contexts
|
2008
|
-
*/
|
2009
|
-
hiddenRender(): ReactNode;
|
2010
2008
|
}
|
2009
|
+
declare function ScopesVariableRenderer({ model }: SceneComponentProps<ScopesVariable>): null;
|
2011
2010
|
|
2012
2011
|
interface LocalValueVariableState extends SceneVariableState {
|
2013
2012
|
value: VariableValue;
|
package/dist/index.js
CHANGED
@@ -7087,15 +7087,16 @@ class ScopesVariable extends SceneObjectBase {
|
|
7087
7087
|
hide: schema.VariableHide.hideVariable
|
7088
7088
|
});
|
7089
7089
|
this._renderBeforeActivation = true;
|
7090
|
+
// Special options that enables variables to be hidden but still render to access react contexts
|
7091
|
+
this.UNSAFE_renderAsHidden = true;
|
7090
7092
|
}
|
7091
7093
|
/**
|
7092
7094
|
* Temporary simple implementation to stringify the scopes.
|
7093
7095
|
*/
|
7094
|
-
getValue(
|
7096
|
+
getValue() {
|
7095
7097
|
var _a;
|
7096
7098
|
const scopes = (_a = this.state.scopes) != null ? _a : [];
|
7097
|
-
|
7098
|
-
return scopeNames.join(", ");
|
7099
|
+
return new ScopesVariableFormatter(scopes.map((scope) => scope.metadata.name));
|
7099
7100
|
}
|
7100
7101
|
getScopes() {
|
7101
7102
|
return this.state.scopes;
|
@@ -7131,13 +7132,8 @@ class ScopesVariable extends SceneObjectBase {
|
|
7131
7132
|
this.publishEvent(new SceneVariableValueChangedEvent(this), true);
|
7132
7133
|
}
|
7133
7134
|
}
|
7134
|
-
/**
|
7135
|
-
* Special function that enables variables to be hidden but still render to access react contexts
|
7136
|
-
*/
|
7137
|
-
hiddenRender() {
|
7138
|
-
return /* @__PURE__ */ React__default.default.createElement(ScopesVariableRenderer, { model: this });
|
7139
|
-
}
|
7140
7135
|
}
|
7136
|
+
ScopesVariable.Component = ScopesVariableRenderer;
|
7141
7137
|
function ScopesVariableRenderer({ model }) {
|
7142
7138
|
const context = React.useContext(runtime.ScopesContext);
|
7143
7139
|
React.useEffect(() => {
|
@@ -7145,6 +7141,17 @@ function ScopesVariableRenderer({ model }) {
|
|
7145
7141
|
}, [context, model]);
|
7146
7142
|
return null;
|
7147
7143
|
}
|
7144
|
+
class ScopesVariableFormatter {
|
7145
|
+
constructor(_value) {
|
7146
|
+
this._value = _value;
|
7147
|
+
}
|
7148
|
+
formatter(formatNameOrFn) {
|
7149
|
+
if (formatNameOrFn === schema.VariableFormatID.QueryParam) {
|
7150
|
+
return this._value.map((scope) => `scope=${encodeURIComponent(scope)}`).join("&");
|
7151
|
+
}
|
7152
|
+
return this._value.join(", ");
|
7153
|
+
}
|
7154
|
+
}
|
7148
7155
|
|
7149
7156
|
function getVariables(sceneObject) {
|
7150
7157
|
var _a;
|
@@ -8351,8 +8358,8 @@ class VizPanel extends SceneObjectBase {
|
|
8351
8358
|
this._prevData = rawData;
|
8352
8359
|
return this._dataWithFieldConfig;
|
8353
8360
|
}
|
8354
|
-
clone() {
|
8355
|
-
return super.clone({ _pluginInstanceState: void 0, _pluginLoadError: void 0 });
|
8361
|
+
clone(withState) {
|
8362
|
+
return super.clone({ _pluginInstanceState: void 0, _pluginLoadError: void 0, ...withState });
|
8356
8363
|
}
|
8357
8364
|
buildPanelContext() {
|
8358
8365
|
const sync = getCursorSyncScope(this);
|
@@ -9407,8 +9414,8 @@ function VariableValueSelectorsRenderer({ model }) {
|
|
9407
9414
|
function VariableValueSelectWrapper({ variable, layout, showAlways, hideLabel }) {
|
9408
9415
|
const state = useSceneObjectState(variable, { shouldActivateOrKeepAlive: true });
|
9409
9416
|
if (state.hide === data.VariableHide.hideVariable && !showAlways) {
|
9410
|
-
if (variable.
|
9411
|
-
return variable.
|
9417
|
+
if (variable.UNSAFE_renderAsHidden) {
|
9418
|
+
return /* @__PURE__ */ React__default.default.createElement(variable.Component, { model: variable });
|
9412
9419
|
}
|
9413
9420
|
return null;
|
9414
9421
|
}
|