@grafana/scenes 6.39.2--canary.1256.18205384867.0 → 6.39.2--canary.1258.18314715919.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/dist/esm/components/VizPanel/VizPanel.js +3 -22
- package/dist/esm/components/VizPanel/VizPanel.js.map +1 -1
- package/dist/esm/components/VizPanel/seriesVisibilityConfigFactory.js +9 -16
- package/dist/esm/components/VizPanel/seriesVisibilityConfigFactory.js.map +1 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/variables/variants/SwitchVariable.js +108 -0
- package/dist/esm/variables/variants/SwitchVariable.js.map +1 -0
- package/dist/esm/variables/variants/guards.js +4 -1
- package/dist/esm/variables/variants/guards.js.map +1 -1
- package/dist/index.d.ts +27 -2
- package/dist/index.js +137 -60
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
@@ -420,7 +420,6 @@ declare class VizPanel<TOptions = {}, TFieldConfig extends {} = {}> extends Scen
|
|
420
420
|
*/
|
421
421
|
private _onSeriesColorChange;
|
422
422
|
private _onSeriesVisibilityChange;
|
423
|
-
private _onAnnotationVisibilityChange;
|
424
423
|
private _onInstanceStateChange;
|
425
424
|
private _onToggleLegendSort;
|
426
425
|
clone(withState?: Partial<VizPanelState>): this;
|
@@ -1286,6 +1285,30 @@ declare class GroupByVariable extends MultiValueVariable<GroupByVariableState> {
|
|
1286
1285
|
}
|
1287
1286
|
declare function GroupByVariableRenderer({ model }: SceneComponentProps<GroupByVariable>): React__default.JSX.Element;
|
1288
1287
|
|
1288
|
+
interface SwitchVariableState extends SceneVariableState {
|
1289
|
+
value: string;
|
1290
|
+
enabledValue: string;
|
1291
|
+
disabledValue: string;
|
1292
|
+
}
|
1293
|
+
declare class SwitchVariable extends SceneObjectBase<SwitchVariableState> implements SceneVariable<SwitchVariableState> {
|
1294
|
+
static Component: typeof SwitchVariableRenderer;
|
1295
|
+
private _prevValue;
|
1296
|
+
constructor(initialState: Partial<SwitchVariableState>);
|
1297
|
+
/**
|
1298
|
+
* This function is called on when SceneVariableSet is activated or when a dependency changes.
|
1299
|
+
*/
|
1300
|
+
validateAndUpdate(): Observable<ValidateAndUpdateResult>;
|
1301
|
+
setValue(newValue: string): void;
|
1302
|
+
getValue(): VariableValue;
|
1303
|
+
isEnabled(): boolean;
|
1304
|
+
isDisabled(): boolean;
|
1305
|
+
private getKey;
|
1306
|
+
getKeys(): string[];
|
1307
|
+
getUrlState(): SceneObjectUrlValues;
|
1308
|
+
updateFromUrl(values: SceneObjectUrlValues): void;
|
1309
|
+
}
|
1310
|
+
declare function SwitchVariableRenderer({ model }: SceneComponentProps<SwitchVariable>): React__default.JSX.Element;
|
1311
|
+
|
1289
1312
|
declare function isAdHocVariable(variable: SceneVariable): variable is AdHocFiltersVariable;
|
1290
1313
|
declare function isConstantVariable(variable: SceneVariable): variable is ConstantVariable;
|
1291
1314
|
declare function isCustomVariable(variable: SceneVariable): variable is CustomVariable;
|
@@ -1294,6 +1317,7 @@ declare function isIntervalVariable(variable: SceneVariable): variable is Interv
|
|
1294
1317
|
declare function isQueryVariable(variable: SceneVariable): variable is QueryVariable;
|
1295
1318
|
declare function isTextBoxVariable(variable: SceneVariable): variable is TextBoxVariable;
|
1296
1319
|
declare function isGroupByVariable(variable: SceneVariable): variable is GroupByVariable;
|
1320
|
+
declare function isSwitchVariable(variable: SceneVariable): variable is SwitchVariable;
|
1297
1321
|
|
1298
1322
|
interface SceneObjectStateChangedPayload<TState extends SceneObjectState = SceneObjectState> {
|
1299
1323
|
prevState: TState;
|
@@ -3202,9 +3226,10 @@ declare const sceneUtils: {
|
|
3202
3226
|
isQueryVariable: typeof isQueryVariable;
|
3203
3227
|
isTextBoxVariable: typeof isTextBoxVariable;
|
3204
3228
|
isGroupByVariable: typeof isGroupByVariable;
|
3229
|
+
isSwitchVariable: typeof isSwitchVariable;
|
3205
3230
|
isRepeatCloneOrChildOf: typeof isRepeatCloneOrChildOf;
|
3206
3231
|
buildPathIdFor: typeof buildPathIdFor;
|
3207
3232
|
};
|
3208
3233
|
|
3209
|
-
export { AdHocFiltersVariable, ConstantVariable, ControlsLabel, CustomVariable, DataProviderProxy, DataSourceVariable, EmbeddedScene, FieldConfigBuilder, FieldConfigBuilders, FieldConfigOverridesBuilder, GroupByVariable, IntervalVariable, LazyLoader, LocalValueVariable, MultiOrSingleValueSelect, MultiValueVariable, NestedScene, NewSceneObjectAddedEvent, PATH_ID_SEPARATOR, PanelBuilders, PanelOptionsBuilders, QueryVariable, RuntimeDataSource, SafeSerializableSceneObject, SceneApp, SceneAppPage, SceneByFrameRepeater, SceneByVariableRepeater, SceneCSSGridItem, SceneCSSGridLayout, SceneCanvasText, SceneControlsSpacer, SceneDataLayerBase, SceneDataLayerControls, SceneDataLayerSet, SceneDataLayerSetBase, SceneDataNode, SceneDataTransformer, SceneDebugger, SceneFlexItem, SceneFlexLayout, SceneGridItem, SceneGridLayout, SceneGridLayoutDragStartEvent, SceneGridRow, SceneObjectBase, SceneObjectRef, SceneObjectStateChangedEvent, SceneObjectUrlSyncConfig, SceneQueryRunner, SceneReactObject, SceneRefreshPicker, SceneRenderProfiler, SceneTimePicker, SceneTimeRange, SceneTimeRangeCompare, SceneTimeRangeTransformerBase, SceneTimeZoneOverride, SceneToolbarButton, SceneToolbarInput, SceneVariableSet, SceneVariableValueChangedEvent, ScopesVariable, SplitLayout, TestVariable, TextBoxVariable, UrlSyncContextProvider, UrlSyncManager, UserActionEvent, VariableDependencyConfig, VariableValueControl, VariableValueSelectWrapper, VariableValueSelectors, VizConfigBuilder, VizConfigBuilders, VizPanel, VizPanelBuilder, VizPanelExploreButton, VizPanelMenu, index$1 as behaviors, index as dataLayers, escapeUrlPipeDelimiters, formatRegistry, getExploreURL, isCustomVariableValue, isDataLayer, isDataRequestEnricher, isFiltersRequestEnricher, isSceneObject, loadResources, registerQueryWithController, registerRuntimeDataSource, sceneGraph, sceneUtils, useSceneApp, useSceneObjectState, useUrlSync };
|
3234
|
+
export { AdHocFiltersVariable, ConstantVariable, ControlsLabel, CustomVariable, DataProviderProxy, DataSourceVariable, EmbeddedScene, FieldConfigBuilder, FieldConfigBuilders, FieldConfigOverridesBuilder, GroupByVariable, IntervalVariable, LazyLoader, LocalValueVariable, MultiOrSingleValueSelect, MultiValueVariable, NestedScene, NewSceneObjectAddedEvent, PATH_ID_SEPARATOR, PanelBuilders, PanelOptionsBuilders, QueryVariable, RuntimeDataSource, SafeSerializableSceneObject, SceneApp, SceneAppPage, SceneByFrameRepeater, SceneByVariableRepeater, SceneCSSGridItem, SceneCSSGridLayout, SceneCanvasText, SceneControlsSpacer, SceneDataLayerBase, SceneDataLayerControls, SceneDataLayerSet, SceneDataLayerSetBase, SceneDataNode, SceneDataTransformer, SceneDebugger, SceneFlexItem, SceneFlexLayout, SceneGridItem, SceneGridLayout, SceneGridLayoutDragStartEvent, SceneGridRow, SceneObjectBase, SceneObjectRef, SceneObjectStateChangedEvent, SceneObjectUrlSyncConfig, SceneQueryRunner, SceneReactObject, SceneRefreshPicker, SceneRenderProfiler, SceneTimePicker, SceneTimeRange, SceneTimeRangeCompare, SceneTimeRangeTransformerBase, SceneTimeZoneOverride, SceneToolbarButton, SceneToolbarInput, SceneVariableSet, SceneVariableValueChangedEvent, ScopesVariable, SplitLayout, SwitchVariable, TestVariable, TextBoxVariable, UrlSyncContextProvider, UrlSyncManager, UserActionEvent, VariableDependencyConfig, VariableValueControl, VariableValueSelectWrapper, VariableValueSelectors, VizConfigBuilder, VizConfigBuilders, VizPanel, VizPanelBuilder, VizPanelExploreButton, VizPanelMenu, index$1 as behaviors, index as dataLayers, escapeUrlPipeDelimiters, formatRegistry, getExploreURL, isCustomVariableValue, isDataLayer, isDataRequestEnricher, isFiltersRequestEnricher, isSceneObject, loadResources, registerQueryWithController, registerRuntimeDataSource, sceneGraph, sceneUtils, useSceneApp, useSceneObjectState, useUrlSync };
|
3210
3235
|
export type { AdHocFilterWithLabels, CancelActivationHandler, ControlsLayout, CustomFormatterVariable, CustomTransformOperator, CustomTransformerDefinition, CustomVariableValue, DataLayerFilter, DataRequestEnricher, DeepPartial, EmbeddedSceneState, ExtraQueryDataProcessor, ExtraQueryDescriptor, ExtraQueryProvider, FiltersRequestEnricher, FormatVariable, InterpolationFormatParameter, MacroVariableConstructor, MultiValueVariableState, QueryRunnerState, SceneActivationHandler, SceneAppDrilldownView, SceneAppPageLike, SceneAppPageState, SceneAppRoute, SceneComponent, SceneComponentProps, SceneDataLayerProvider, SceneDataLayerProviderState, SceneDataProvider, SceneDataProviderResult, SceneDataQuery, SceneDataState, SceneDataTransformerState, SceneDeactivationHandler, SceneFlexItemLike, SceneFlexItemState, SceneGridItemLike, SceneGridItemStateLike, SceneInteractionProfileEvent, SceneLayout, SceneLayoutChildOptions, SceneLayoutState, SceneObject, SceneObjectState, SceneObjectStateChangedPayload, SceneObjectUrlSyncHandler, SceneObjectUrlValue, SceneObjectUrlValues, SceneObjectWithUrlSync, SceneQueryControllerEntry, SceneQueryControllerEntryType, SceneQueryControllerLike, SceneRefreshPickerState, SceneRouteMatch, SceneStateChangedHandler, SceneStatelessBehavior, SceneTimeRangeLike, SceneTimeRangeState, SceneUrlSyncOptions, SceneVariable, SceneVariableDependencyConfigLike, SceneVariableSetState, SceneVariableState, SceneVariables, UrlSyncManagerLike, UseStateHookOptions, ValidateAndUpdateResult, VariableCustomFormatterFn, VariableGetOptionsArgs, VariableValue, VariableValueOption, VariableValueSingle, VizConfig, VizPanelState };
|
package/dist/index.js
CHANGED
@@ -3603,7 +3603,7 @@ function wrapInSafeSerializableSceneObject(sceneObject) {
|
|
3603
3603
|
function DefaultGroupByCustomIndicatorContainer(props) {
|
3604
3604
|
const { model } = props;
|
3605
3605
|
const theme = ui.useTheme2();
|
3606
|
-
const styles = getStyles$
|
3606
|
+
const styles = getStyles$i(theme);
|
3607
3607
|
const inputStyles = ui.getInputStyles({ theme, invalid: false });
|
3608
3608
|
const value = lodash.isArray(model.state.value) ? model.state.value : model.state.value ? [model.state.value] : [];
|
3609
3609
|
let buttons = [];
|
@@ -3685,7 +3685,7 @@ function DefaultGroupByCustomIndicatorContainer(props) {
|
|
3685
3685
|
buttons
|
3686
3686
|
);
|
3687
3687
|
}
|
3688
|
-
const getStyles$
|
3688
|
+
const getStyles$i = (theme) => ({
|
3689
3689
|
clearIcon: css.css({
|
3690
3690
|
color: theme.colors.action.disabledText,
|
3691
3691
|
cursor: "pointer",
|
@@ -4206,7 +4206,7 @@ function LoadingIndicator(props) {
|
|
4206
4206
|
}
|
4207
4207
|
|
4208
4208
|
function ControlsLabel(props) {
|
4209
|
-
const styles = ui.useStyles2(getStyles$
|
4209
|
+
const styles = ui.useStyles2(getStyles$h);
|
4210
4210
|
const theme = ui.useTheme2();
|
4211
4211
|
const isVertical = props.layout === "vertical";
|
4212
4212
|
const loadingIndicator = Boolean(props.isLoading) ? /* @__PURE__ */ React__default.default.createElement(
|
@@ -4253,7 +4253,7 @@ function ControlsLabel(props) {
|
|
4253
4253
|
}
|
4254
4254
|
return labelElement;
|
4255
4255
|
}
|
4256
|
-
const getStyles$
|
4256
|
+
const getStyles$h = (theme) => ({
|
4257
4257
|
horizontalLabel: css.css({
|
4258
4258
|
background: theme.isDark ? theme.colors.background.primary : theme.colors.background.secondary,
|
4259
4259
|
display: `flex`,
|
@@ -4306,7 +4306,7 @@ function keyLabelToOption(key, label) {
|
|
4306
4306
|
const filterNoOp = () => true;
|
4307
4307
|
function AdHocFilterRenderer({ filter, model }) {
|
4308
4308
|
var _a, _b, _c, _d, _e;
|
4309
|
-
const styles = ui.useStyles2(getStyles$
|
4309
|
+
const styles = ui.useStyles2(getStyles$g);
|
4310
4310
|
const [keys, setKeys] = React.useState([]);
|
4311
4311
|
const [values, setValues] = React.useState([]);
|
4312
4312
|
const [isKeysLoading, setIsKeysLoading] = React.useState(false);
|
@@ -4533,7 +4533,7 @@ function AdHocFilterRenderer({ filter, model }) {
|
|
4533
4533
|
}
|
4534
4534
|
));
|
4535
4535
|
}
|
4536
|
-
const getStyles$
|
4536
|
+
const getStyles$g = (theme) => ({
|
4537
4537
|
field: css.css({
|
4538
4538
|
marginBottom: 0
|
4539
4539
|
}),
|
@@ -4733,7 +4733,7 @@ function isFilter(filter) {
|
|
4733
4733
|
|
4734
4734
|
const DropdownItem = React.forwardRef(
|
4735
4735
|
function DropdownItem2({ children, active, addGroupBottomBorder, isMultiValueEdit, checked, ...rest }, ref) {
|
4736
|
-
const styles = ui.useStyles2(getStyles$
|
4736
|
+
const styles = ui.useStyles2(getStyles$f);
|
4737
4737
|
const id = React.useId();
|
4738
4738
|
return /* @__PURE__ */ React__default.default.createElement(
|
4739
4739
|
"div",
|
@@ -4749,7 +4749,7 @@ const DropdownItem = React.forwardRef(
|
|
4749
4749
|
);
|
4750
4750
|
}
|
4751
4751
|
);
|
4752
|
-
const getStyles$
|
4752
|
+
const getStyles$f = (theme) => ({
|
4753
4753
|
option: css.css({
|
4754
4754
|
label: "grafana-select-option",
|
4755
4755
|
top: 0,
|
@@ -4819,7 +4819,7 @@ const MultiValueApplyButton = ({
|
|
4819
4819
|
maxOptionWidth,
|
4820
4820
|
menuHeight
|
4821
4821
|
}) => {
|
4822
|
-
const styles = ui.useStyles2(getStyles$
|
4822
|
+
const styles = ui.useStyles2(getStyles$f);
|
4823
4823
|
const floatingElementRect = floatingElement == null ? void 0 : floatingElement.getBoundingClientRect();
|
4824
4824
|
return /* @__PURE__ */ React__default.default.createElement(
|
4825
4825
|
"div",
|
@@ -5040,7 +5040,7 @@ const MultiValuePill = ({
|
|
5040
5040
|
handleEditMultiValuePill
|
5041
5041
|
}) => {
|
5042
5042
|
var _a, _b;
|
5043
|
-
const styles = ui.useStyles2(getStyles$
|
5043
|
+
const styles = ui.useStyles2(getStyles$e);
|
5044
5044
|
const editMultiValuePill = React.useCallback(
|
5045
5045
|
(e) => {
|
5046
5046
|
e.stopPropagation();
|
@@ -5104,7 +5104,7 @@ const MultiValuePill = ({
|
|
5104
5104
|
)
|
5105
5105
|
);
|
5106
5106
|
};
|
5107
|
-
const getStyles$
|
5107
|
+
const getStyles$e = (theme) => ({
|
5108
5108
|
basePill: css.css({
|
5109
5109
|
display: "flex",
|
5110
5110
|
alignItems: "center",
|
@@ -5143,7 +5143,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
5143
5143
|
const [activeIndex, setActiveIndex] = React.useState(null);
|
5144
5144
|
const [filterInputType, setInputType] = React.useState(!isAlwaysWip ? "value" : "key");
|
5145
5145
|
const [preventFiltering, setPreventFiltering] = React.useState(!isAlwaysWip && filterInputType === "value");
|
5146
|
-
const styles = ui.useStyles2(getStyles$
|
5146
|
+
const styles = ui.useStyles2(getStyles$d);
|
5147
5147
|
const [filterMultiValues, setFilterMultiValues] = React.useState([]);
|
5148
5148
|
const [_, setForceRefresh] = React.useState({});
|
5149
5149
|
const allowCustomValue = (_a = model.state.allowCustomValue) != null ? _a : true;
|
@@ -5752,7 +5752,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
5752
5752
|
}
|
5753
5753
|
) : null))));
|
5754
5754
|
});
|
5755
|
-
const getStyles$
|
5755
|
+
const getStyles$d = (theme) => ({
|
5756
5756
|
comboboxWrapper: css.css({
|
5757
5757
|
display: "flex",
|
5758
5758
|
flexWrap: "wrap"
|
@@ -5826,7 +5826,7 @@ const getStyles$c = (theme) => ({
|
|
5826
5826
|
const LABEL_MAX_VISIBLE_LENGTH = 20;
|
5827
5827
|
function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
|
5828
5828
|
var _a, _b, _c, _d;
|
5829
|
-
const styles = ui.useStyles2(getStyles$
|
5829
|
+
const styles = ui.useStyles2(getStyles$c);
|
5830
5830
|
const [viewMode, setViewMode] = React.useState(true);
|
5831
5831
|
const [shouldFocusOnPillWrapper, setShouldFocusOnPillWrapper] = React.useState(false);
|
5832
5832
|
const pillWrapperRef = React.useRef(null);
|
@@ -6004,7 +6004,7 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
|
|
6004
6004
|
}
|
6005
6005
|
);
|
6006
6006
|
}
|
6007
|
-
const getStyles$
|
6007
|
+
const getStyles$c = (theme) => ({
|
6008
6008
|
combinedFilterPill: css.css({
|
6009
6009
|
display: "flex",
|
6010
6010
|
alignItems: "center",
|
@@ -6088,7 +6088,7 @@ const AdHocFiltersAlwaysWipCombobox = React.forwardRef(function AdHocFiltersAlwa
|
|
6088
6088
|
|
6089
6089
|
const AdHocFiltersComboboxRenderer = React.memo(function AdHocFiltersComboboxRenderer2({ model }) {
|
6090
6090
|
const { originFilters, filters, readOnly } = model.useState();
|
6091
|
-
const styles = ui.useStyles2(getStyles$
|
6091
|
+
const styles = ui.useStyles2(getStyles$b);
|
6092
6092
|
const focusOnWipInputRef = React.useRef();
|
6093
6093
|
return /* @__PURE__ */ React__default.default.createElement(
|
6094
6094
|
"div",
|
@@ -6124,7 +6124,7 @@ const AdHocFiltersComboboxRenderer = React.memo(function AdHocFiltersComboboxRen
|
|
6124
6124
|
!readOnly ? /* @__PURE__ */ React__default.default.createElement(AdHocFiltersAlwaysWipCombobox, { model, ref: focusOnWipInputRef }) : null
|
6125
6125
|
);
|
6126
6126
|
});
|
6127
|
-
const getStyles$
|
6127
|
+
const getStyles$b = (theme) => ({
|
6128
6128
|
comboboxWrapper: css.css({
|
6129
6129
|
display: "flex",
|
6130
6130
|
flexWrap: "wrap",
|
@@ -6717,13 +6717,13 @@ function renderExpression(builder, filters) {
|
|
6717
6717
|
}
|
6718
6718
|
function AdHocFiltersVariableRenderer({ model }) {
|
6719
6719
|
const { filters, readOnly, addFilterButtonText } = model.useState();
|
6720
|
-
const styles = ui.useStyles2(getStyles$
|
6720
|
+
const styles = ui.useStyles2(getStyles$a);
|
6721
6721
|
if (model.state.layout === "combobox") {
|
6722
6722
|
return /* @__PURE__ */ React__default.default.createElement(AdHocFiltersComboboxRenderer, { model });
|
6723
6723
|
}
|
6724
6724
|
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.wrapper }, filters.filter((filter) => !filter.hidden).map((filter, index) => /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, { key: index }, /* @__PURE__ */ React__default.default.createElement(AdHocFilterRenderer, { filter, model }))), !readOnly && /* @__PURE__ */ React__default.default.createElement(AdHocFilterBuilder, { model, key: "'builder", addFilterButtonText }));
|
6725
6725
|
}
|
6726
|
-
const getStyles$
|
6726
|
+
const getStyles$a = (theme) => ({
|
6727
6727
|
wrapper: css.css({
|
6728
6728
|
display: "flex",
|
6729
6729
|
flexWrap: "wrap",
|
@@ -8615,6 +8615,9 @@ function isTextBoxVariable(variable) {
|
|
8615
8615
|
function isGroupByVariable(variable) {
|
8616
8616
|
return variable.state.type === "groupby";
|
8617
8617
|
}
|
8618
|
+
function isSwitchVariable(variable) {
|
8619
|
+
return variable.state.type === "switch";
|
8620
|
+
}
|
8618
8621
|
|
8619
8622
|
class ActWhenVariableChanged extends SceneObjectBase {
|
8620
8623
|
constructor() {
|
@@ -8690,7 +8693,7 @@ function getCursorSyncScope(sceneObject) {
|
|
8690
8693
|
}
|
8691
8694
|
|
8692
8695
|
function VizPanelSeriesLimit({ data, showAll, seriesLimit, onShowAllSeries }) {
|
8693
|
-
const styles = ui.useStyles2(getStyles$
|
8696
|
+
const styles = ui.useStyles2(getStyles$9);
|
8694
8697
|
const seriesCount = data == null ? void 0 : data.series.length;
|
8695
8698
|
if (seriesCount === void 0 || seriesCount < seriesLimit) {
|
8696
8699
|
return null;
|
@@ -8720,7 +8723,7 @@ function VizPanelSeriesLimit({ data, showAll, seriesLimit, onShowAllSeries }) {
|
|
8720
8723
|
/* @__PURE__ */ React__default.default.createElement(ui.Button, { variant: "secondary", size: "sm", onClick: onShowAllSeries }, buttonText)
|
8721
8724
|
));
|
8722
8725
|
}
|
8723
|
-
const getStyles$
|
8726
|
+
const getStyles$9 = (theme) => ({
|
8724
8727
|
timeSeriesDisclaimer: css.css({
|
8725
8728
|
label: "time-series-disclaimer",
|
8726
8729
|
display: "flex",
|
@@ -8745,7 +8748,7 @@ function useUniqueId() {
|
|
8745
8748
|
const LazyLoader = React__default.default.forwardRef(
|
8746
8749
|
({ children, onLoad, onChange, className, ...rest }, ref) => {
|
8747
8750
|
const id = useUniqueId();
|
8748
|
-
const { hideEmpty } = ui.useStyles2(getStyles$
|
8751
|
+
const { hideEmpty } = ui.useStyles2(getStyles$8);
|
8749
8752
|
const [loaded, setLoaded] = React.useState(false);
|
8750
8753
|
const [isInView, setIsInView] = React.useState(false);
|
8751
8754
|
const innerRef = React.useRef(null);
|
@@ -8774,7 +8777,7 @@ const LazyLoader = React__default.default.forwardRef(
|
|
8774
8777
|
return /* @__PURE__ */ React__default.default.createElement("div", { id, ref: innerRef, className: `${hideEmpty} ${className}`, ...rest }, !loaded ? i18n.t("grafana-scenes.components.lazy-loader.placeholder", "\xA0") : /* @__PURE__ */ React__default.default.createElement(LazyLoaderInViewContext.Provider, { value: isInView }, children));
|
8775
8778
|
}
|
8776
8779
|
);
|
8777
|
-
function getStyles$
|
8780
|
+
function getStyles$8() {
|
8778
8781
|
return {
|
8779
8782
|
hideEmpty: css.css({
|
8780
8783
|
"&:empty": {
|
@@ -9065,25 +9068,20 @@ const getAlertStateStyles = (theme) => {
|
|
9065
9068
|
|
9066
9069
|
const displayOverrideRef = "hideSeriesFrom";
|
9067
9070
|
const isHideSeriesOverride = data.isSystemOverrideWithRef(displayOverrideRef);
|
9068
|
-
function seriesVisibilityConfigFactory(label, mode, fieldConfig, data
|
9071
|
+
function seriesVisibilityConfigFactory(label, mode, fieldConfig, data) {
|
9069
9072
|
const { overrides } = fieldConfig;
|
9070
9073
|
const displayName = label;
|
9071
9074
|
const currentIndex = overrides.findIndex(isHideSeriesOverride);
|
9072
9075
|
if (currentIndex < 0) {
|
9073
9076
|
if (mode === ui.SeriesVisibilityChangeMode.ToggleSelection) {
|
9074
|
-
const override3 = createOverride$1(
|
9075
|
-
[displayName, ...getNamesOfHiddenFields(overrides, data)],
|
9076
|
-
void 0,
|
9077
|
-
void 0,
|
9078
|
-
dataTopic
|
9079
|
-
);
|
9077
|
+
const override3 = createOverride$1([displayName, ...getNamesOfHiddenFields(overrides, data)]);
|
9080
9078
|
return {
|
9081
9079
|
...fieldConfig,
|
9082
9080
|
overrides: [...fieldConfig.overrides, override3]
|
9083
9081
|
};
|
9084
9082
|
}
|
9085
9083
|
const displayNames = getDisplayNames(data, displayName);
|
9086
|
-
const override2 = createOverride$1(displayNames
|
9084
|
+
const override2 = createOverride$1(displayNames);
|
9087
9085
|
return {
|
9088
9086
|
...fieldConfig,
|
9089
9087
|
overrides: [...fieldConfig.overrides, override2]
|
@@ -9103,13 +9101,13 @@ function seriesVisibilityConfigFactory(label, mode, fieldConfig, data, dataTopic
|
|
9103
9101
|
overrides: overridesCopy
|
9104
9102
|
};
|
9105
9103
|
}
|
9106
|
-
const override2 = createOverride$1([displayName, ...nameOfHiddenFields]
|
9104
|
+
const override2 = createOverride$1([displayName, ...nameOfHiddenFields]);
|
9107
9105
|
return {
|
9108
9106
|
...fieldConfig,
|
9109
9107
|
overrides: [...overridesCopy, override2]
|
9110
9108
|
};
|
9111
9109
|
}
|
9112
|
-
const override = createExtendedOverride(current, displayName
|
9110
|
+
const override = createExtendedOverride(current, displayName);
|
9113
9111
|
if (allFieldsAreExcluded(override, data)) {
|
9114
9112
|
return {
|
9115
9113
|
...fieldConfig,
|
@@ -9121,7 +9119,7 @@ function seriesVisibilityConfigFactory(label, mode, fieldConfig, data, dataTopic
|
|
9121
9119
|
overrides: [...overridesCopy, override]
|
9122
9120
|
};
|
9123
9121
|
}
|
9124
|
-
function createOverride$1(names, mode = data.ByNamesMatcherMode.exclude, property
|
9122
|
+
function createOverride$1(names, mode = data.ByNamesMatcherMode.exclude, property) {
|
9125
9123
|
property = property != null ? property : {
|
9126
9124
|
id: "custom.hideFrom",
|
9127
9125
|
value: {
|
@@ -9150,12 +9148,10 @@ function createOverride$1(names, mode = data.ByNamesMatcherMode.exclude, propert
|
|
9150
9148
|
tooltip: true
|
9151
9149
|
}
|
9152
9150
|
}
|
9153
|
-
]
|
9154
|
-
// @ts-ignore
|
9155
|
-
dataTopic
|
9151
|
+
]
|
9156
9152
|
};
|
9157
9153
|
}
|
9158
|
-
const createExtendedOverride = (current, displayName, mode = data.ByNamesMatcherMode.exclude
|
9154
|
+
const createExtendedOverride = (current, displayName, mode = data.ByNamesMatcherMode.exclude) => {
|
9159
9155
|
const property = current.properties.find((p) => p.id === "custom.hideFrom");
|
9160
9156
|
const existing = getExistingDisplayNames(current);
|
9161
9157
|
const index = existing.findIndex((name) => name === displayName);
|
@@ -9164,7 +9160,7 @@ const createExtendedOverride = (current, displayName, mode = data.ByNamesMatcher
|
|
9164
9160
|
} else {
|
9165
9161
|
existing.splice(index, 1);
|
9166
9162
|
}
|
9167
|
-
return createOverride$1(existing, mode, property
|
9163
|
+
return createOverride$1(existing, mode, property);
|
9168
9164
|
};
|
9169
9165
|
const getExistingDisplayNames = (rule) => {
|
9170
9166
|
var _a;
|
@@ -9663,22 +9659,6 @@ class VizPanel extends SceneObjectBase {
|
|
9663
9659
|
true
|
9664
9660
|
);
|
9665
9661
|
};
|
9666
|
-
this._onAnnotationVisibilityChange = (label, mode) => {
|
9667
|
-
var _a;
|
9668
|
-
if (!this._dataWithFieldConfig) {
|
9669
|
-
return;
|
9670
|
-
}
|
9671
|
-
this.onFieldConfigChange(
|
9672
|
-
seriesVisibilityConfigFactory(
|
9673
|
-
label,
|
9674
|
-
mode,
|
9675
|
-
this.state.fieldConfig,
|
9676
|
-
(_a = this._dataWithFieldConfig.annotations) != null ? _a : [],
|
9677
|
-
data.DataTopic.Annotations
|
9678
|
-
),
|
9679
|
-
true
|
9680
|
-
);
|
9681
|
-
};
|
9682
9662
|
this._onInstanceStateChange = (state) => {
|
9683
9663
|
if (this._panelContext) {
|
9684
9664
|
this._panelContext = {
|
@@ -9893,14 +9873,12 @@ class VizPanel extends SceneObjectBase {
|
|
9893
9873
|
data: this._dataWithFieldConfig.annotations,
|
9894
9874
|
fieldConfig: {
|
9895
9875
|
defaults: {},
|
9896
|
-
overrides: [
|
9876
|
+
overrides: []
|
9897
9877
|
},
|
9898
9878
|
fieldConfigRegistry,
|
9899
9879
|
replaceVariables: this.interpolate,
|
9900
9880
|
theme: runtime.config.theme2,
|
9901
|
-
timeZone: (_d = rawData.request) == null ? void 0 : _d.timezone
|
9902
|
-
// @ts-ignore
|
9903
|
-
dataTopic: data.DataTopic.Annotations
|
9881
|
+
timeZone: (_d = rawData.request) == null ? void 0 : _d.timezone
|
9904
9882
|
});
|
9905
9883
|
}
|
9906
9884
|
if (!pluginDataSupport.alertStates) {
|
@@ -9929,7 +9907,6 @@ class VizPanel extends SceneObjectBase {
|
|
9929
9907
|
},
|
9930
9908
|
onSeriesColorChange: this._onSeriesColorChange,
|
9931
9909
|
onToggleSeriesVisibility: this._onSeriesVisibilityChange,
|
9932
|
-
onAnnotationVisibilityChange: this._onAnnotationVisibilityChange,
|
9933
9910
|
onToggleLegendSort: this._onToggleLegendSort,
|
9934
9911
|
onInstanceStateChange: this._onInstanceStateChange
|
9935
9912
|
};
|
@@ -11149,6 +11126,104 @@ CustomVariable.Component = ({ model }) => {
|
|
11149
11126
|
return /* @__PURE__ */ React__default.default.createElement(MultiOrSingleValueSelect, { model });
|
11150
11127
|
};
|
11151
11128
|
|
11129
|
+
class SwitchVariable extends SceneObjectBase {
|
11130
|
+
constructor(initialState) {
|
11131
|
+
super({
|
11132
|
+
// TODO: remove this once switch is in the schema @leventebalogh
|
11133
|
+
// @ts-expect-error - switch is a valid variable type, but not in the schema yet
|
11134
|
+
type: "switch",
|
11135
|
+
value: "false",
|
11136
|
+
enabledValue: "true",
|
11137
|
+
disabledValue: "false",
|
11138
|
+
name: "",
|
11139
|
+
...initialState
|
11140
|
+
});
|
11141
|
+
this._prevValue = "";
|
11142
|
+
this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: () => this.getKeys() });
|
11143
|
+
}
|
11144
|
+
/**
|
11145
|
+
* This function is called on when SceneVariableSet is activated or when a dependency changes.
|
11146
|
+
*/
|
11147
|
+
validateAndUpdate() {
|
11148
|
+
const newValue = this.getValue();
|
11149
|
+
if (this._prevValue !== newValue) {
|
11150
|
+
this._prevValue = newValue;
|
11151
|
+
this.publishEvent(new SceneVariableValueChangedEvent(this), true);
|
11152
|
+
}
|
11153
|
+
return rxjs.of({});
|
11154
|
+
}
|
11155
|
+
setValue(newValue) {
|
11156
|
+
if (this.getValue() === newValue) {
|
11157
|
+
return;
|
11158
|
+
}
|
11159
|
+
if ([this.state.enabledValue, this.state.disabledValue].includes(newValue)) {
|
11160
|
+
this.setState({ value: newValue });
|
11161
|
+
this.publishEvent(new SceneVariableValueChangedEvent(this), true);
|
11162
|
+
} else {
|
11163
|
+
console.error(
|
11164
|
+
`Invalid value for switch variable: "${newValue}". Valid values are: "${this.state.enabledValue}" and "${this.state.disabledValue}".`
|
11165
|
+
);
|
11166
|
+
}
|
11167
|
+
}
|
11168
|
+
getValue() {
|
11169
|
+
return this.state.value;
|
11170
|
+
}
|
11171
|
+
isEnabled() {
|
11172
|
+
return this.state.value === this.state.enabledValue;
|
11173
|
+
}
|
11174
|
+
isDisabled() {
|
11175
|
+
return this.state.value === this.state.disabledValue;
|
11176
|
+
}
|
11177
|
+
getKey() {
|
11178
|
+
return `var-${this.state.name}`;
|
11179
|
+
}
|
11180
|
+
getKeys() {
|
11181
|
+
if (this.state.skipUrlSync) {
|
11182
|
+
return [];
|
11183
|
+
}
|
11184
|
+
return [this.getKey()];
|
11185
|
+
}
|
11186
|
+
getUrlState() {
|
11187
|
+
if (this.state.skipUrlSync) {
|
11188
|
+
return {};
|
11189
|
+
}
|
11190
|
+
return { [this.getKey()]: this.state.value };
|
11191
|
+
}
|
11192
|
+
updateFromUrl(values) {
|
11193
|
+
const val = values[this.getKey()];
|
11194
|
+
if (typeof val === "string") {
|
11195
|
+
this.setValue(val);
|
11196
|
+
}
|
11197
|
+
}
|
11198
|
+
}
|
11199
|
+
SwitchVariable.Component = SwitchVariableRenderer;
|
11200
|
+
function SwitchVariableRenderer({ model }) {
|
11201
|
+
const state = model.useState();
|
11202
|
+
const styles = ui.useStyles2(getStyles$7);
|
11203
|
+
return /* @__PURE__ */ React__default.default.createElement("div", { className: styles.container }, /* @__PURE__ */ React__default.default.createElement(
|
11204
|
+
ui.Switch,
|
11205
|
+
{
|
11206
|
+
value: state.value === state.enabledValue,
|
11207
|
+
onChange: (event) => {
|
11208
|
+
model.setValue(event.currentTarget.checked ? state.enabledValue : state.disabledValue);
|
11209
|
+
}
|
11210
|
+
}
|
11211
|
+
));
|
11212
|
+
}
|
11213
|
+
function getStyles$7(theme) {
|
11214
|
+
return {
|
11215
|
+
container: css.css({
|
11216
|
+
display: "flex",
|
11217
|
+
alignItems: "center",
|
11218
|
+
padding: theme.spacing(0, 1),
|
11219
|
+
height: theme.spacing(theme.components.height.md),
|
11220
|
+
borderRadius: theme.shape.radius.default,
|
11221
|
+
border: `1px solid ${theme.components.input.borderColor}`,
|
11222
|
+
background: theme.colors.background.primary
|
11223
|
+
})
|
11224
|
+
};
|
11225
|
+
}
|
11226
|
+
|
11152
11227
|
class DataSourceVariable extends MultiValueVariable {
|
11153
11228
|
constructor(initialState) {
|
11154
11229
|
super({
|
@@ -15331,6 +15406,7 @@ const sceneUtils = {
|
|
15331
15406
|
isQueryVariable,
|
15332
15407
|
isTextBoxVariable,
|
15333
15408
|
isGroupByVariable,
|
15409
|
+
isSwitchVariable,
|
15334
15410
|
isRepeatCloneOrChildOf,
|
15335
15411
|
buildPathIdFor
|
15336
15412
|
};
|
@@ -15399,6 +15475,7 @@ exports.SceneVariableSet = SceneVariableSet;
|
|
15399
15475
|
exports.SceneVariableValueChangedEvent = SceneVariableValueChangedEvent;
|
15400
15476
|
exports.ScopesVariable = ScopesVariable;
|
15401
15477
|
exports.SplitLayout = SplitLayout;
|
15478
|
+
exports.SwitchVariable = SwitchVariable;
|
15402
15479
|
exports.TestVariable = TestVariable;
|
15403
15480
|
exports.TextBoxVariable = TextBoxVariable;
|
15404
15481
|
exports.UrlSyncContextProvider = UrlSyncContextProvider;
|