@grafana/scenes 5.26.0 → 5.27.0--canary.912.12014950388.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -3110,7 +3110,7 @@ function LoadingIndicator(props) {
3110
3110
  }
3111
3111
 
3112
3112
  function ControlsLabel(props) {
3113
- const styles = ui.useStyles2(getStyles$f);
3113
+ const styles = ui.useStyles2(getStyles$g);
3114
3114
  const theme = ui.useTheme2();
3115
3115
  const isVertical = props.layout === "vertical";
3116
3116
  const loadingIndicator = Boolean(props.isLoading) ? /* @__PURE__ */ React__default["default"].createElement("div", {
@@ -3173,7 +3173,7 @@ function ControlsLabel(props) {
3173
3173
  }
3174
3174
  return labelElement;
3175
3175
  }
3176
- const getStyles$f = (theme) => ({
3176
+ const getStyles$g = (theme) => ({
3177
3177
  horizontalLabel: css.css({
3178
3178
  background: theme.isDark ? theme.colors.background.primary : theme.colors.background.secondary,
3179
3179
  display: `flex`,
@@ -3242,7 +3242,7 @@ function keyLabelToOption(key, label) {
3242
3242
  const filterNoOp = () => true;
3243
3243
  function AdHocFilterRenderer({ filter, model }) {
3244
3244
  var _a, _b, _c, _d, _e;
3245
- const styles = ui.useStyles2(getStyles$e);
3245
+ const styles = ui.useStyles2(getStyles$f);
3246
3246
  const [keys, setKeys] = React.useState([]);
3247
3247
  const [values, setValues] = React.useState([]);
3248
3248
  const [isKeysLoading, setIsKeysLoading] = React.useState(false);
@@ -3445,7 +3445,7 @@ function AdHocFilterRenderer({ filter, model }) {
3445
3445
  onClick: () => model._removeFilter(filter)
3446
3446
  }));
3447
3447
  }
3448
- const getStyles$e = (theme) => ({
3448
+ const getStyles$f = (theme) => ({
3449
3449
  field: css.css({
3450
3450
  marginBottom: 0
3451
3451
  }),
@@ -3628,7 +3628,7 @@ var __objRest$3 = (source, exclude) => {
3628
3628
  const DropdownItem = React.forwardRef(
3629
3629
  function DropdownItem2(_a, ref) {
3630
3630
  var _b = _a, { children, active, addGroupBottomBorder, isMultiValueEdit, checked } = _b, rest = __objRest$3(_b, ["children", "active", "addGroupBottomBorder", "isMultiValueEdit", "checked"]);
3631
- const styles = ui.useStyles2(getStyles$d);
3631
+ const styles = ui.useStyles2(getStyles$e);
3632
3632
  const id = React.useId();
3633
3633
  return /* @__PURE__ */ React__default["default"].createElement("div", __spreadValues$C({
3634
3634
  ref,
@@ -3646,7 +3646,7 @@ const DropdownItem = React.forwardRef(
3646
3646
  }) : null, children)));
3647
3647
  }
3648
3648
  );
3649
- const getStyles$d = (theme) => ({
3649
+ const getStyles$e = (theme) => ({
3650
3650
  option: css.css({
3651
3651
  label: "grafana-select-option",
3652
3652
  top: 0,
@@ -3717,7 +3717,7 @@ const OptionsErrorPlaceholder = ({ handleFetchOptions }) => {
3717
3717
  }, "An error has occurred fetching labels. Click to retry");
3718
3718
  };
3719
3719
  const MultiValueApplyButton = ({ onApply, floatingElement, maxOptionWidth, menuHeight }) => {
3720
- const styles = ui.useStyles2(getStyles$d);
3720
+ const styles = ui.useStyles2(getStyles$e);
3721
3721
  const floatingElementRect = floatingElement == null ? void 0 : floatingElement.getBoundingClientRect();
3722
3722
  return /* @__PURE__ */ React__default["default"].createElement("div", {
3723
3723
  className: styles.multiValueApplyWrapper,
@@ -3963,7 +3963,7 @@ const MultiValuePill = ({
3963
3963
  handleEditMultiValuePill
3964
3964
  }) => {
3965
3965
  var _a, _b;
3966
- const styles = ui.useStyles2(getStyles$c);
3966
+ const styles = ui.useStyles2(getStyles$d);
3967
3967
  const editMultiValuePill = React.useCallback(
3968
3968
  (e) => {
3969
3969
  e.stopPropagation();
@@ -4016,7 +4016,7 @@ const MultiValuePill = ({
4016
4016
  id: `${item.value}-${index}-close-icon`
4017
4017
  })));
4018
4018
  };
4019
- const getStyles$c = (theme) => ({
4019
+ const getStyles$d = (theme) => ({
4020
4020
  basePill: css.css(__spreadProps$p(__spreadValues$B({
4021
4021
  display: "flex",
4022
4022
  alignItems: "center",
@@ -4073,7 +4073,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4073
4073
  const [inputValue, setInputValue] = React.useState("");
4074
4074
  const [activeIndex, setActiveIndex] = React.useState(null);
4075
4075
  const [filterInputType, setInputType] = React.useState(!isAlwaysWip ? "value" : "key");
4076
- const styles = ui.useStyles2(getStyles$b);
4076
+ const styles = ui.useStyles2(getStyles$c);
4077
4077
  const [filterMultiValues, setFilterMultiValues] = React.useState([]);
4078
4078
  const [_, setForceRefresh] = React.useState({});
4079
4079
  const allowCustomValue = (_a = model.state.allowCustomValue) != null ? _a : true;
@@ -4577,7 +4577,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4577
4577
  menuHeight: Math.min(rowVirtualizer.getTotalSize(), MAX_MENU_HEIGHT)
4578
4578
  }) : null))));
4579
4579
  });
4580
- const getStyles$b = (theme) => ({
4580
+ const getStyles$c = (theme) => ({
4581
4581
  comboboxWrapper: css.css({
4582
4582
  display: "flex",
4583
4583
  flexWrap: "wrap"
@@ -4668,7 +4668,7 @@ var __spreadValues$z = (a, b) => {
4668
4668
  var __spreadProps$n = (a, b) => __defProps$n(a, __getOwnPropDescs$n(b));
4669
4669
  function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
4670
4670
  var _a, _b, _c;
4671
- const styles = ui.useStyles2(getStyles$a);
4671
+ const styles = ui.useStyles2(getStyles$b);
4672
4672
  const [viewMode, setViewMode] = React.useState(true);
4673
4673
  const [shouldFocusOnPillWrapper, setShouldFocusOnPillWrapper] = React.useState(false);
4674
4674
  const pillWrapperRef = React.useRef(null);
@@ -4758,7 +4758,7 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnWipInputRef }) {
4758
4758
  populateInputOnEdit
4759
4759
  });
4760
4760
  }
4761
- const getStyles$a = (theme) => ({
4761
+ const getStyles$b = (theme) => ({
4762
4762
  combinedFilterPill: css.css(__spreadProps$n(__spreadValues$z({
4763
4763
  display: "flex",
4764
4764
  alignItems: "center",
@@ -4819,7 +4819,7 @@ const AdHocFiltersAlwaysWipCombobox = React.forwardRef(function AdHocFiltersAlwa
4819
4819
 
4820
4820
  const AdHocFiltersComboboxRenderer = React.memo(function AdHocFiltersComboboxRenderer2({ model }) {
4821
4821
  const { filters, readOnly } = model.useState();
4822
- const styles = ui.useStyles2(getStyles$9);
4822
+ const styles = ui.useStyles2(getStyles$a);
4823
4823
  const focusOnWipInputRef = React.useRef();
4824
4824
  return /* @__PURE__ */ React__default["default"].createElement("div", {
4825
4825
  className: css.cx(styles.comboboxWrapper, { [styles.comboboxFocusOutline]: !readOnly }),
@@ -4842,7 +4842,7 @@ const AdHocFiltersComboboxRenderer = React.memo(function AdHocFiltersComboboxRen
4842
4842
  ref: focusOnWipInputRef
4843
4843
  }) : null);
4844
4844
  });
4845
- const getStyles$9 = (theme) => ({
4845
+ const getStyles$a = (theme) => ({
4846
4846
  comboboxWrapper: css.css({
4847
4847
  display: "flex",
4848
4848
  flexWrap: "wrap",
@@ -5095,7 +5095,7 @@ function renderExpression(builder, filters) {
5095
5095
  }
5096
5096
  function AdHocFiltersVariableRenderer({ model }) {
5097
5097
  const { filters, readOnly, addFilterButtonText } = model.useState();
5098
- const styles = ui.useStyles2(getStyles$8);
5098
+ const styles = ui.useStyles2(getStyles$9);
5099
5099
  if (model.state.layout === "combobox") {
5100
5100
  return /* @__PURE__ */ React__default["default"].createElement(AdHocFiltersComboboxRenderer, {
5101
5101
  model
@@ -5114,7 +5114,7 @@ function AdHocFiltersVariableRenderer({ model }) {
5114
5114
  addFilterButtonText
5115
5115
  }));
5116
5116
  }
5117
- const getStyles$8 = (theme) => ({
5117
+ const getStyles$9 = (theme) => ({
5118
5118
  wrapper: css.css({
5119
5119
  display: "flex",
5120
5120
  flexWrap: "wrap",
@@ -6545,6 +6545,13 @@ function findAllObjects(scene, check) {
6545
6545
  });
6546
6546
  return found;
6547
6547
  }
6548
+ function findDescendent(scene, descendentType) {
6549
+ function isDescendentType(scene2) {
6550
+ return scene2 instanceof descendentType;
6551
+ }
6552
+ const targetScenes = findAllObjects(scene, isDescendentType);
6553
+ return targetScenes.find(isDescendentType);
6554
+ }
6548
6555
  function getDataLayers(sceneObject, localOnly = false) {
6549
6556
  let currentLevel = sceneObject;
6550
6557
  let collected = [];
@@ -6629,7 +6636,8 @@ const sceneGraph = {
6629
6636
  getAncestor,
6630
6637
  findDescendents,
6631
6638
  getQueryController,
6632
- getUrlSyncManager
6639
+ getUrlSyncManager,
6640
+ findDescendent
6633
6641
  };
6634
6642
 
6635
6643
  class UniqueUrlKeyMapper {
@@ -9843,7 +9851,7 @@ class EmbeddedScene extends SceneObjectBase {
9843
9851
  EmbeddedScene.Component = EmbeddedSceneRenderer;
9844
9852
  function EmbeddedSceneRenderer({ model }) {
9845
9853
  const { body, controls } = model.useState();
9846
- const styles = ui.useStyles2(getStyles$7);
9854
+ const styles = ui.useStyles2(getStyles$8);
9847
9855
  return /* @__PURE__ */ React__default["default"].createElement("div", {
9848
9856
  className: styles.container
9849
9857
  }, controls && /* @__PURE__ */ React__default["default"].createElement("div", {
@@ -9857,7 +9865,7 @@ function EmbeddedSceneRenderer({ model }) {
9857
9865
  model: body
9858
9866
  })));
9859
9867
  }
9860
- const getStyles$7 = (theme) => {
9868
+ const getStyles$8 = (theme) => {
9861
9869
  return {
9862
9870
  container: css.css({
9863
9871
  flexGrow: 1,
@@ -10074,7 +10082,7 @@ const LazyLoader = React__default["default"].forwardRef(
10074
10082
  (_a, ref) => {
10075
10083
  var _b = _a, { children, onLoad, onChange, className } = _b, rest = __objRest$1(_b, ["children", "onLoad", "onChange", "className"]);
10076
10084
  const id = useUniqueId();
10077
- const { hideEmpty } = ui.useStyles2(getStyles$6);
10085
+ const { hideEmpty } = ui.useStyles2(getStyles$7);
10078
10086
  const [loaded, setLoaded] = React.useState(false);
10079
10087
  const [isInView, setIsInView] = React.useState(false);
10080
10088
  const innerRef = React.useRef(null);
@@ -10108,7 +10116,7 @@ const LazyLoader = React__default["default"].forwardRef(
10108
10116
  }, rest), loaded && (typeof children === "function" ? children({ isInView }) : children));
10109
10117
  }
10110
10118
  );
10111
- function getStyles$6() {
10119
+ function getStyles$7() {
10112
10120
  return {
10113
10121
  hideEmpty: css.css({
10114
10122
  "&:empty": {
@@ -10805,7 +10813,7 @@ NestedScene.Component = NestedSceneRenderer;
10805
10813
  function NestedSceneRenderer({ model }) {
10806
10814
  const { title, isCollapsed, canCollapse, canRemove, body, controls } = model.useState();
10807
10815
  const gridRow = ui.useStyles2(getSceneGridRowStyles);
10808
- const styles = ui.useStyles2(getStyles$5);
10816
+ const styles = ui.useStyles2(getStyles$6);
10809
10817
  const toolbarControls = (controls != null ? controls : []).map((action) => /* @__PURE__ */ React__default["default"].createElement(action.Component, {
10810
10818
  key: action.state.key,
10811
10819
  model: action
@@ -10840,7 +10848,7 @@ function NestedSceneRenderer({ model }) {
10840
10848
  model: body
10841
10849
  }));
10842
10850
  }
10843
- const getStyles$5 = (theme) => ({
10851
+ const getStyles$6 = (theme) => ({
10844
10852
  wrapper: css.css({
10845
10853
  display: "flex",
10846
10854
  flexDirection: "column",
@@ -11418,7 +11426,7 @@ const timeShiftAlignmentProcessor = (primary, secondary) => {
11418
11426
  };
11419
11427
  function SceneTimeRangeCompareRenderer({ model }) {
11420
11428
  var _a;
11421
- const styles = ui.useStyles2(getStyles$4);
11429
+ const styles = ui.useStyles2(getStyles$5);
11422
11430
  const { compareWith, compareOptions } = model.useState();
11423
11431
  const [previousCompare, setPreviousCompare] = React__default["default"].useState(compareWith);
11424
11432
  const previousValue = (_a = compareOptions.find(({ value: value2 }) => value2 === previousCompare)) != null ? _a : PREVIOUS_PERIOD_COMPARE_OPTION;
@@ -11458,7 +11466,7 @@ function SceneTimeRangeCompareRenderer({ model }) {
11458
11466
  isOpen: false
11459
11467
  }, previousValue.label));
11460
11468
  }
11461
- function getStyles$4(theme) {
11469
+ function getStyles$5(theme) {
11462
11470
  return {
11463
11471
  previewButton: css.css({
11464
11472
  "&:disabled": {
@@ -11566,6 +11574,92 @@ SceneControlsSpacer.Component = (_props) => {
11566
11574
  });
11567
11575
  };
11568
11576
 
11577
+ const LIMIT_FRAMES_TITLE_ITEM_TRANSFORMATION_KEY = "limit_frames_title_item_transformation";
11578
+ class LimitFramesTitleItemScene extends SceneObjectBase {
11579
+ constructor(state) {
11580
+ super(state);
11581
+ this.addActivationHandler(this.onActivate.bind(this));
11582
+ }
11583
+ onActivate() {
11584
+ var _a;
11585
+ const panel = sceneGraph.getAncestor(this, VizPanel);
11586
+ const $transformedDataArray = sceneGraph.findAllObjects(panel, (scene) => scene.state.key === LIMIT_FRAMES_TITLE_ITEM_TRANSFORMATION_KEY);
11587
+ const $transformedData = $transformedDataArray[0];
11588
+ if ($transformedData) {
11589
+ const $untransformedDataProvider = (_a = sceneGraph.findDescendent($transformedData, SceneDataTransformer)) != null ? _a : sceneGraph.findDescendent(panel, SceneQueryRunner);
11590
+ this._subs.add(
11591
+ $transformedData.subscribeToState((transformedDataState) => {
11592
+ var _a2, _b, _c;
11593
+ if ($untransformedDataProvider && ((_a2 = $untransformedDataProvider.state.data) == null ? void 0 : _a2.series.length) !== this.state.currentFrameCount) {
11594
+ this.setState({
11595
+ currentFrameCount: (_b = transformedDataState.data) == null ? void 0 : _b.series.length,
11596
+ totalFrameCount: (_c = $untransformedDataProvider.state.data) == null ? void 0 : _c.series.length
11597
+ });
11598
+ }
11599
+ })
11600
+ );
11601
+ }
11602
+ }
11603
+ showAllSeries() {
11604
+ const $data = sceneGraph.getData(this);
11605
+ if ($data instanceof SceneDataTransformer) {
11606
+ $data.setState({
11607
+ transformations: []
11608
+ });
11609
+ this.setState({
11610
+ showAllFrames: true
11611
+ });
11612
+ $data.reprocessTransformations();
11613
+ }
11614
+ }
11615
+ }
11616
+ LimitFramesTitleItemScene.Component = ({ model }) => {
11617
+ const { showAllFrames, currentFrameCount, frameLimit, totalFrameCount } = model.useState();
11618
+ const styles = ui.useStyles2(getStyles$4);
11619
+ if (totalFrameCount === void 0 || showAllFrames || !currentFrameCount || totalFrameCount < frameLimit) {
11620
+ return null;
11621
+ }
11622
+ return /* @__PURE__ */ React__default["default"].createElement("div", {
11623
+ className: styles.timeSeriesDisclaimer
11624
+ }, /* @__PURE__ */ React__default["default"].createElement("span", {
11625
+ className: styles.warningMessage
11626
+ }, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement(ui.Icon, {
11627
+ title: `Showing only ${model.state.frameLimit} series`,
11628
+ name: "exclamation-triangle",
11629
+ "aria-hidden": "true"
11630
+ }))), /* @__PURE__ */ React__default["default"].createElement(ui.Tooltip, {
11631
+ content: "Rendering too many series in a single panel may impact performance and make data harder to read."
11632
+ }, /* @__PURE__ */ React__default["default"].createElement(ui.Button, {
11633
+ variant: "secondary",
11634
+ size: "sm",
11635
+ onClick: () => model.showAllSeries()
11636
+ }, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, "Show all ", totalFrameCount))));
11637
+ };
11638
+ function limitFramesTransformation(limit) {
11639
+ return (source) => {
11640
+ return source.pipe(
11641
+ rxjs.map((frames) => {
11642
+ return frames.slice(0, limit);
11643
+ })
11644
+ );
11645
+ };
11646
+ }
11647
+ const getStyles$4 = (theme) => ({
11648
+ timeSeriesDisclaimer: css.css({
11649
+ label: "time-series-disclaimer",
11650
+ display: "flex",
11651
+ alignItems: "center",
11652
+ gap: theme.spacing(1)
11653
+ }),
11654
+ warningMessage: css.css({
11655
+ display: "flex",
11656
+ alignItems: "center",
11657
+ gap: theme.spacing(0.5),
11658
+ color: theme.colors.warning.main,
11659
+ fontSize: theme.typography.bodySmall.fontSize
11660
+ })
11661
+ });
11662
+
11569
11663
  class SceneFlexLayout extends SceneObjectBase {
11570
11664
  toggleDirection() {
11571
11665
  this.setState({
@@ -13016,6 +13110,10 @@ class VizPanelBuilder {
13016
13110
  this._state.title = title;
13017
13111
  return this;
13018
13112
  }
13113
+ setTitleItems(titleItems) {
13114
+ this._state.titleItems = titleItems;
13115
+ return this;
13116
+ }
13019
13117
  setDescription(description) {
13020
13118
  this._state.description = description;
13021
13119
  return this;
@@ -13113,12 +13211,39 @@ class VizPanelBuilder {
13113
13211
  return this;
13114
13212
  }
13115
13213
  build() {
13214
+ this.limitFrames();
13116
13215
  const panel = new VizPanel(__spreadProps(__spreadValues({}, this._state), {
13117
13216
  options: this._panelOptionsBuilder.build(),
13118
13217
  fieldConfig: this._fieldConfigBuilder.build()
13119
13218
  }));
13120
13219
  return panel;
13121
13220
  }
13221
+ limitFrames() {
13222
+ if (this._state.$data) {
13223
+ const limitSeriesTitleItem = this.getLimitSeriesTitleItem();
13224
+ if (limitSeriesTitleItem && limitSeriesTitleItem.state.frameLimit) {
13225
+ this.setData(new SceneDataTransformer({
13226
+ key: LIMIT_FRAMES_TITLE_ITEM_TRANSFORMATION_KEY,
13227
+ $data: this._state.$data,
13228
+ transformations: [() => limitFramesTransformation(limitSeriesTitleItem.state.frameLimit)]
13229
+ }));
13230
+ }
13231
+ }
13232
+ }
13233
+ getLimitSeriesTitleItem() {
13234
+ if (this._state.titleItems) {
13235
+ if (Array.isArray(this._state.titleItems)) {
13236
+ for (const titleItem of this._state.titleItems) {
13237
+ if (titleItem instanceof LimitFramesTitleItemScene) {
13238
+ return titleItem;
13239
+ }
13240
+ }
13241
+ } else if (this._state.titleItems instanceof LimitFramesTitleItemScene) {
13242
+ return this._state.titleItems;
13243
+ }
13244
+ }
13245
+ return void 0;
13246
+ }
13122
13247
  }
13123
13248
 
13124
13249
  const PanelOptionsBuilders = {
@@ -13547,6 +13672,7 @@ exports.FieldConfigBuilders = FieldConfigBuilders;
13547
13672
  exports.FieldConfigOverridesBuilder = FieldConfigOverridesBuilder;
13548
13673
  exports.GroupByVariable = GroupByVariable;
13549
13674
  exports.IntervalVariable = IntervalVariable;
13675
+ exports.LimitFramesTitleItemScene = LimitFramesTitleItemScene;
13550
13676
  exports.LocalValueVariable = LocalValueVariable;
13551
13677
  exports.MultiValueVariable = MultiValueVariable;
13552
13678
  exports.NestedScene = NestedScene;