@grafana/scenes 5.15.0--canary.845.11012035874.0 → 5.15.1--canary.899.11016830015.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,6 +5,7 @@ import { SceneAppPage } from './SceneAppPage.js';
5
5
  import { useAppQueryParams, getUrlWithAppState, renderSceneComponentWithRouteProps } from './utils.js';
6
6
  import { useUrlSync } from '../../services/useUrlSync.js';
7
7
  import { SceneAppContext } from './SceneApp.js';
8
+ import { useLocationServiceSafe } from '../../utils/utils.js';
8
9
 
9
10
  function SceneAppPageView({ page, routeProps }) {
10
11
  const containerPage = getParentPageIfTab(page);
@@ -14,6 +15,7 @@ function SceneAppPageView({ page, routeProps }) {
14
15
  const appContext = useContext(SceneAppContext);
15
16
  const isInitialized = containerState.initializedScene === scene;
16
17
  const { layout } = page.state;
18
+ const locationService = useLocationServiceSafe();
17
19
  useLayoutEffect(() => {
18
20
  if (!isInitialized) {
19
21
  containerPage.initializeScene(scene);
@@ -30,10 +32,13 @@ function SceneAppPageView({ page, routeProps }) {
30
32
  text: containerState.title,
31
33
  img: containerState.titleImg,
32
34
  icon: containerState.titleIcon,
33
- url: getUrlWithAppState(containerState.url, containerState.preserveUrlKeys),
35
+ url: getUrlWithAppState(containerState.url, locationService.getSearchObject(), containerState.preserveUrlKeys),
34
36
  hideFromBreadcrumbs: containerState.hideFromBreadcrumbs,
35
37
  parentItem: getParentBreadcrumbs(
36
- containerState.getParentPage ? containerState.getParentPage() : containerPage.parent)
38
+ containerState.getParentPage ? containerState.getParentPage() : containerPage.parent,
39
+ params,
40
+ locationService.getSearchObject()
41
+ )
37
42
  };
38
43
  if (containerState.tabs) {
39
44
  pageNav.children = containerState.tabs.map((tab) => {
@@ -42,7 +47,7 @@ function SceneAppPageView({ page, routeProps }) {
42
47
  icon: tab.state.titleIcon,
43
48
  tabSuffix: tab.state.tabSuffix,
44
49
  active: page === tab,
45
- url: getUrlWithAppState(tab.state.url, tab.state.preserveUrlKeys),
50
+ url: getUrlWithAppState(tab.state.url, locationService.getSearchObject(), tab.state.preserveUrlKeys),
46
51
  parentItem: pageNav
47
52
  };
48
53
  });
@@ -76,14 +81,17 @@ function getParentPageIfTab(page) {
76
81
  }
77
82
  return page;
78
83
  }
79
- function getParentBreadcrumbs(parent, params) {
84
+ function getParentBreadcrumbs(parent, params, searchObject) {
80
85
  if (parent instanceof SceneAppPage) {
81
86
  return {
82
87
  text: parent.state.title,
83
- url: getUrlWithAppState(parent.state.url, parent.state.preserveUrlKeys),
88
+ url: getUrlWithAppState(parent.state.url, searchObject, parent.state.preserveUrlKeys),
84
89
  hideFromBreadcrumbs: parent.state.hideFromBreadcrumbs,
85
90
  parentItem: getParentBreadcrumbs(
86
- parent.state.getParentPage ? parent.state.getParentPage() : parent.parent)
91
+ parent.state.getParentPage ? parent.state.getParentPage() : parent.parent,
92
+ params,
93
+ searchObject
94
+ )
87
95
  };
88
96
  }
89
97
  return void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"SceneAppPageView.js","sources":["../../../../src/components/SceneApp/SceneAppPageView.tsx"],"sourcesContent":["import { NavModelItem, UrlQueryMap } from '@grafana/data';\nimport { PluginPage } from '@grafana/runtime';\nimport React, { useContext, useEffect, useLayoutEffect } from 'react';\n\nimport { RouteComponentProps } from 'react-router-dom';\nimport { SceneObject } from '../../core/types';\nimport { SceneDebugger } from '../SceneDebugger/SceneDebugger';\nimport { SceneAppPage } from './SceneAppPage';\nimport { SceneAppDrilldownView, SceneAppPageLike } from './types';\nimport { getUrlWithAppState, renderSceneComponentWithRouteProps, useAppQueryParams } from './utils';\nimport { useUrlSync } from '../../services/useUrlSync';\nimport { SceneAppContext } from './SceneApp';\n\nexport interface Props {\n page: SceneAppPageLike;\n routeProps: RouteComponentProps;\n}\n\nexport function SceneAppPageView({ page, routeProps }: Props) {\n const containerPage = getParentPageIfTab(page);\n const containerState = containerPage.useState();\n const params = useAppQueryParams();\n const scene = page.getScene(routeProps.match);\n const appContext = useContext(SceneAppContext);\n const isInitialized = containerState.initializedScene === scene;\n const { layout } = page.state;\n\n useLayoutEffect(() => {\n // Before rendering scene components, we are making sure the URL sync is enabled for.\n if (!isInitialized) {\n containerPage.initializeScene(scene);\n }\n }, [scene, containerPage, isInitialized]);\n\n useEffect(() => {\n // Clear initializedScene when unmounting\n return () => containerPage.setState({ initializedScene: undefined });\n }, [containerPage]);\n\n const urlSyncInitialized = useUrlSync(containerPage, appContext?.state.urlSyncOptions);\n\n if (!isInitialized && !urlSyncInitialized) {\n return null;\n }\n\n const pageNav: NavModelItem = {\n text: containerState.title,\n img: containerState.titleImg,\n icon: containerState.titleIcon,\n url: getUrlWithAppState(containerState.url, containerState.preserveUrlKeys),\n hideFromBreadcrumbs: containerState.hideFromBreadcrumbs,\n parentItem: getParentBreadcrumbs(\n containerState.getParentPage ? containerState.getParentPage() : containerPage.parent,\n params\n ),\n };\n\n if (containerState.tabs) {\n pageNav.children = containerState.tabs.map((tab) => {\n return {\n text: tab.state.title,\n icon: tab.state.titleIcon,\n tabSuffix: tab.state.tabSuffix,\n active: page === tab,\n url: getUrlWithAppState(tab.state.url, tab.state.preserveUrlKeys),\n parentItem: pageNav,\n };\n });\n }\n\n let pageActions: React.ReactNode[] = [];\n if (containerState.controls) {\n pageActions = containerState.controls.map((control) => (\n <control.Component model={control} key={control.state.key} />\n ));\n }\n\n if (params['scene-debugger']) {\n pageActions.push(<SceneDebugger scene={containerPage} key={'scene-debugger'} />);\n }\n\n return (\n <PluginPage\n layout={layout}\n pageNav={pageNav}\n actions={pageActions}\n renderTitle={containerState.renderTitle}\n subTitle={containerState.subTitle}\n >\n <scene.Component model={scene} />\n </PluginPage>\n );\n}\n\n/**\n * For pages that are \"tabs\" this will return the parent page\n */\nfunction getParentPageIfTab(page: SceneAppPageLike) {\n if (page.parent instanceof SceneAppPage) {\n return page.parent;\n }\n\n return page;\n}\n\nfunction getParentBreadcrumbs(parent: SceneObject | undefined, params: UrlQueryMap): NavModelItem | undefined {\n if (parent instanceof SceneAppPage) {\n return {\n text: parent.state.title,\n url: getUrlWithAppState(parent.state.url, parent.state.preserveUrlKeys),\n hideFromBreadcrumbs: parent.state.hideFromBreadcrumbs,\n parentItem: getParentBreadcrumbs(\n parent.state.getParentPage ? parent.state.getParentPage() : parent.parent,\n params\n ),\n };\n }\n\n return undefined;\n}\n\nexport interface SceneAppDrilldownViewRenderProps {\n drilldown: SceneAppDrilldownView;\n parent: SceneAppPageLike;\n routeProps: RouteComponentProps;\n}\n\nexport function SceneAppDrilldownViewRender({ drilldown, parent, routeProps }: SceneAppDrilldownViewRenderProps) {\n return renderSceneComponentWithRouteProps(parent.getDrilldownPage(drilldown, routeProps.match), routeProps);\n}\n"],"names":[],"mappings":";;;;;;;;AAkBO,SAAS,gBAAiB,CAAA,EAAE,IAAM,EAAA,UAAA,EAAqB,EAAA;AAC5D,EAAM,MAAA,aAAA,GAAgB,mBAAmB,IAAI,CAAA,CAAA;AAC7C,EAAM,MAAA,cAAA,GAAiB,cAAc,QAAS,EAAA,CAAA;AAC9C,EAAA,MAAM,SAAS,iBAAkB,EAAA,CAAA;AACjC,EAAA,MAAM,KAAQ,GAAA,IAAA,CAAK,QAAS,CAAA,UAAA,CAAW,KAAK,CAAA,CAAA;AAC5C,EAAM,MAAA,UAAA,GAAa,WAAW,eAAe,CAAA,CAAA;AAC7C,EAAM,MAAA,aAAA,GAAgB,eAAe,gBAAqB,KAAA,KAAA,CAAA;AAC1D,EAAM,MAAA,EAAE,MAAO,EAAA,GAAI,IAAK,CAAA,KAAA,CAAA;AAExB,EAAA,eAAA,CAAgB,MAAM;AAEpB,IAAA,IAAI,CAAC,aAAe,EAAA;AAClB,MAAA,aAAA,CAAc,gBAAgB,KAAK,CAAA,CAAA;AAAA,KACrC;AAAA,GACC,EAAA,CAAC,KAAO,EAAA,aAAA,EAAe,aAAa,CAAC,CAAA,CAAA;AAExC,EAAA,SAAA,CAAU,MAAM;AAEd,IAAA,OAAO,MAAM,aAAc,CAAA,QAAA,CAAS,EAAE,gBAAA,EAAkB,QAAW,CAAA,CA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AAA,MACtE,mBAAA,EAAqB,OAAO,KAAM,CAAA,mBAAA;AAAA,MAClC,UAAY,EAAA,oBAAA;AAAA,QACV,OAAO,KAAM,CAAA,aAAA,GAAgB,OAAO,KAAM,CAAA,aAAA,KAAkB,MAAO,CAAA,MAErE,CAAA;AAAA,KACF,CAAA;AAAA,GACF;AAEA,EAAO,OAAA,KAAA,CAAA,CAAA;AACT,CAAA;AAQO,SAAS,2BAA4B,CAAA,EAAE,SAAW,EAAA,MAAA,EAAQ,YAAgD,EAAA;AAC/G,EAAA,OAAO,mCAAmC,MAAO,CAAA,gBAAA,CAAiB,WAAW,UAAW,CAAA,KAAK,GAAG,UAAU,CAAA,CAAA;AAC5G;;;;"}
1
+ {"version":3,"file":"SceneAppPageView.js","sources":["../../../../src/components/SceneApp/SceneAppPageView.tsx"],"sourcesContent":["import { NavModelItem, UrlQueryMap } from '@grafana/data';\nimport { PluginPage } from '@grafana/runtime';\nimport React, { useContext, useEffect, useLayoutEffect } from 'react';\n\nimport { RouteComponentProps } from 'react-router-dom';\nimport { SceneObject } from '../../core/types';\nimport { SceneDebugger } from '../SceneDebugger/SceneDebugger';\nimport { SceneAppPage } from './SceneAppPage';\nimport { SceneAppDrilldownView, SceneAppPageLike } from './types';\nimport { getUrlWithAppState, renderSceneComponentWithRouteProps, useAppQueryParams } from './utils';\nimport { useUrlSync } from '../../services/useUrlSync';\nimport { SceneAppContext } from './SceneApp';\nimport { useLocationServiceSafe } from '../../utils/utils';\n\nexport interface Props {\n page: SceneAppPageLike;\n routeProps: RouteComponentProps;\n}\n\nexport function SceneAppPageView({ page, routeProps }: Props) {\n const containerPage = getParentPageIfTab(page);\n const containerState = containerPage.useState();\n const params = useAppQueryParams();\n const scene = page.getScene(routeProps.match);\n const appContext = useContext(SceneAppContext);\n const isInitialized = containerState.initializedScene === scene;\n const { layout } = page.state;\n const locationService = useLocationServiceSafe();\n\n useLayoutEffect(() => {\n // Before rendering scene components, we are making sure the URL sync is enabled for.\n if (!isInitialized) {\n containerPage.initializeScene(scene);\n }\n }, [scene, containerPage, isInitialized]);\n\n useEffect(() => {\n // Clear initializedScene when unmounting\n return () => containerPage.setState({ initializedScene: undefined });\n }, [containerPage]);\n\n const urlSyncInitialized = useUrlSync(containerPage, appContext?.state.urlSyncOptions);\n\n if (!isInitialized && !urlSyncInitialized) {\n return null;\n }\n\n const pageNav: NavModelItem = {\n text: containerState.title,\n img: containerState.titleImg,\n icon: containerState.titleIcon,\n url: getUrlWithAppState(containerState.url, locationService.getSearchObject(), containerState.preserveUrlKeys),\n hideFromBreadcrumbs: containerState.hideFromBreadcrumbs,\n parentItem: getParentBreadcrumbs(\n containerState.getParentPage ? containerState.getParentPage() : containerPage.parent,\n params,\n locationService.getSearchObject()\n ),\n };\n\n if (containerState.tabs) {\n pageNav.children = containerState.tabs.map((tab) => {\n return {\n text: tab.state.title,\n icon: tab.state.titleIcon,\n tabSuffix: tab.state.tabSuffix,\n active: page === tab,\n url: getUrlWithAppState(tab.state.url, locationService.getSearchObject(), tab.state.preserveUrlKeys),\n parentItem: pageNav,\n };\n });\n }\n\n let pageActions: React.ReactNode[] = [];\n if (containerState.controls) {\n pageActions = containerState.controls.map((control) => (\n <control.Component model={control} key={control.state.key} />\n ));\n }\n\n if (params['scene-debugger']) {\n pageActions.push(<SceneDebugger scene={containerPage} key={'scene-debugger'} />);\n }\n\n return (\n <PluginPage\n layout={layout}\n pageNav={pageNav}\n actions={pageActions}\n renderTitle={containerState.renderTitle}\n subTitle={containerState.subTitle}\n >\n <scene.Component model={scene} />\n </PluginPage>\n );\n}\n\n/**\n * For pages that are \"tabs\" this will return the parent page\n */\nfunction getParentPageIfTab(page: SceneAppPageLike) {\n if (page.parent instanceof SceneAppPage) {\n return page.parent;\n }\n\n return page;\n}\n\nfunction getParentBreadcrumbs(\n parent: SceneObject | undefined,\n params: UrlQueryMap,\n searchObject: UrlQueryMap\n): NavModelItem | undefined {\n if (parent instanceof SceneAppPage) {\n return {\n text: parent.state.title,\n url: getUrlWithAppState(parent.state.url, searchObject, parent.state.preserveUrlKeys),\n hideFromBreadcrumbs: parent.state.hideFromBreadcrumbs,\n parentItem: getParentBreadcrumbs(\n parent.state.getParentPage ? parent.state.getParentPage() : parent.parent,\n params,\n searchObject\n ),\n };\n }\n\n return undefined;\n}\n\nexport interface SceneAppDrilldownViewRenderProps {\n drilldown: SceneAppDrilldownView;\n parent: SceneAppPageLike;\n routeProps: RouteComponentProps;\n}\n\nexport function SceneAppDrilldownViewRender({ drilldown, parent, routeProps }: SceneAppDrilldownViewRenderProps) {\n return renderSceneComponentWithRouteProps(parent.getDrilldownPage(drilldown, routeProps.match), routeProps);\n}\n"],"names":[],"mappings":";;;;;;;;;AAmBO,SAAS,gBAAiB,CAAA,EAAE,IAAM,EAAA,UAAA,EAAqB,EAAA;AAC5D,EAAM,MAAA,aAAA,GAAgB,mBAAmB,IAAI,CAAA,CAAA;AAC7C,EAAM,MAAA,cAAA,GAAiB,cAAc,QAAS,EAAA,CAAA;AAC9C,EAAA,MAAM,SAAS,iBAAkB,EAAA,CAAA;AACjC,EAAA,MAAM,KAAQ,GAAA,IAAA,CAAK,QAAS,CAAA,UAAA,CAAW,KAAK,CAAA,CAAA;AAC5C,EAAM,MAAA,UAAA,GAAa,WAAW,eAAe,CAAA,CAAA;AAC7C,EAAM,MAAA,aAAA,GAAgB,eAAe,gBAAqB,KAAA,KAAA,CAAA;AAC1D,EAAM,MAAA,EAAE,MAAO,EAAA,GAAI,IAAK,CAAA,KAAA,CAAA;AACxB,EAAA,MAAM,kBAAkB,sBAAuB,EAAA,CAAA;AAE/C,EAAA,eAAA,CAAgB,MAAM;AAEpB,IAAA,IAAI,CAAC,aAAe,EAAA;AAClB,MAAA,aAAA,CAAc,gBAAgB,KAAK,CAAA,CAAA;AAAA,KACrC;AAAA,GACC,EAAA,CAAC,KAAO,EAAA,aAAA,EAAe,aAAa,CAAC,CAAA,CAAA;AAExC,EAAA,SAAA,CAAU,MAAM;AAEd,IAAA,OAAO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AA;AAC1B,EAAA,IAAI,kBAAkB,YAAc,EAAA;AAClC,IAAO,OAAA;AAAA,MACL,IAAA,EAAM,OAAO,KAAM,CAAA,KAAA;AAAA,MACnB,GAAA,EAAK,mBAAmB,MAAO,CAAA,KAAA,CAAM,KAAK,YAAc,EAAA,MAAA,CAAO,MAAM,eAAe,CAAA;AAAA,MACpF,mBAAA,EAAqB,OAAO,KAAM,CAAA,mBAAA;AAAA,MAClC,UAAY,EAAA,oBAAA;AAAA,QACV,OAAO,KAAM,CAAA,aAAA,GAAgB,OAAO,KAAM,CAAA,aAAA,KAAkB,MAAO,CAAA,MAAA;AAAA,QACnE,MAAA;AAAA,QACA,YAAA;AAAA,OACF;AAAA,KACF,CAAA;AAAA,GACF;AAEA,EAAO,OAAA,KAAA,CAAA,CAAA;AACT,CAAA;AAQO,SAAS,2BAA4B,CAAA,EAAE,SAAW,EAAA,MAAA,EAAQ,YAAgD,EAAA;AAC/G,EAAA,OAAO,mCAAmC,MAAO,CAAA,gBAAA,CAAiB,WAAW,UAAW,CAAA,KAAK,GAAG,UAAU,CAAA,CAAA;AAC5G;;;;"}
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { useLocation } from 'react-router-dom';
3
3
  import { urlUtil, locationUtil } from '@grafana/data';
4
- import { locationService, locationSearchToObject } from '@grafana/runtime';
4
+ import { locationSearchToObject } from '@grafana/runtime';
5
5
 
6
6
  var __defProp = Object.defineProperty;
7
7
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
@@ -23,8 +23,8 @@ function useAppQueryParams() {
23
23
  const location = useLocation();
24
24
  return locationSearchToObject(location.search || "");
25
25
  }
26
- function getUrlWithAppState(path, preserveParams) {
27
- const paramsCopy = __spreadValues({}, locationService.getSearchObject());
26
+ function getUrlWithAppState(path, searchObject, preserveParams) {
27
+ const paramsCopy = __spreadValues({}, searchObject);
28
28
  if (preserveParams) {
29
29
  for (const key of Object.keys(paramsCopy)) {
30
30
  if (!preserveParams.includes(key)) {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../src/components/SceneApp/utils.ts"],"sourcesContent":["import React from 'react';\nimport { RouteComponentProps, useLocation } from 'react-router-dom';\nimport { UrlQueryMap, locationUtil, urlUtil } from '@grafana/data';\nimport { locationSearchToObject, locationService } from '@grafana/runtime';\nimport { SceneObject } from '../../core/types';\n\nexport function useAppQueryParams(): UrlQueryMap {\n const location = useLocation();\n return locationSearchToObject(location.search || '');\n}\n\n/**\n *\n * @param path Url to append query params to\n * @param preserveParams Query params to preserve\n * @returns Url with query params\n */\nexport function getUrlWithAppState(path: string, preserveParams?: string[]): string {\n // make a copy of params as the renderUrl function mutates the object\n const paramsCopy = { ...locationService.getSearchObject() };\n\n if (preserveParams) {\n for (const key of Object.keys(paramsCopy)) {\n // if param is not in preserveParams, remove it\n if (!preserveParams.includes(key)) {\n delete paramsCopy[key];\n }\n }\n }\n\n return urlUtil.renderUrl(locationUtil.assureBaseUrl(path), paramsCopy);\n}\n\nexport function renderSceneComponentWithRouteProps(sceneObject: SceneObject, routeProps: RouteComponentProps) {\n // @ts-ignore\n return React.createElement(sceneObject.Component, { model: sceneObject, routeProps: routeProps });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAMO,SAAS,iBAAiC,GAAA;AAC/C,EAAA,MAAM,WAAW,WAAY,EAAA,CAAA;AAC7B,EAAO,OAAA,sBAAA,CAAuB,QAAS,CAAA,MAAA,IAAU,EAAE,CAAA,CAAA;AACrD,CAAA;AAQgB,SAAA,kBAAA,CAAmB,MAAc,cAAmC,EAAA;AAElF,EAAM,MAAA,UAAA,GAAa,cAAK,CAAA,EAAA,EAAA,eAAA,CAAgB,eAAgB,EAAA,CAAA,CAAA;AAExD,EAAA,IAAI,cAAgB,EAAA;AAClB,IAAA,KAAA,MAAW,GAAO,IAAA,MAAA,CAAO,IAAK,CAAA,UAAU,CAAG,EAAA;AAEzC,MAAA,IAAI,CAAC,cAAA,CAAe,QAAS,CAAA,GAAG,CAAG,EAAA;AACjC,QAAA,OAAO,UAAW,CAAA,GAAA,CAAA,CAAA;AAAA,OACpB;AAAA,KACF;AAAA,GACF;AAEA,EAAA,OAAO,QAAQ,SAAU,CAAA,YAAA,CAAa,aAAc,CAAA,IAAI,GAAG,UAAU,CAAA,CAAA;AACvE,CAAA;AAEgB,SAAA,kCAAA,CAAmC,aAA0B,UAAiC,EAAA;AAE5G,EAAO,OAAA,KAAA,CAAM,cAAc,WAAY,CAAA,SAAA,EAAW,EAAE,KAAO,EAAA,WAAA,EAAa,YAAwB,CAAA,CAAA;AAClG;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../src/components/SceneApp/utils.ts"],"sourcesContent":["import React from 'react';\nimport { RouteComponentProps, useLocation } from 'react-router-dom';\nimport { UrlQueryMap, locationUtil, urlUtil } from '@grafana/data';\nimport { locationSearchToObject } from '@grafana/runtime';\nimport { SceneObject } from '../../core/types';\n\nexport function useAppQueryParams(): UrlQueryMap {\n const location = useLocation();\n return locationSearchToObject(location.search || '');\n}\n\n/**\n *\n * @param path Url to append query params to\n * @param searchObject Query params of the URL\n * @param preserveParams Query params to preserve\n * @returns Url with query params\n */\nexport function getUrlWithAppState(path: string, searchObject: UrlQueryMap, preserveParams?: string[]): string {\n // make a copy of params as the renderUrl function mutates the object\n const paramsCopy = { ...searchObject };\n\n if (preserveParams) {\n for (const key of Object.keys(paramsCopy)) {\n // if param is not in preserveParams, remove it\n if (!preserveParams.includes(key)) {\n delete paramsCopy[key];\n }\n }\n }\n\n return urlUtil.renderUrl(locationUtil.assureBaseUrl(path), paramsCopy);\n}\n\nexport function renderSceneComponentWithRouteProps(sceneObject: SceneObject, routeProps: RouteComponentProps) {\n // @ts-ignore\n return React.createElement(sceneObject.Component, { model: sceneObject, routeProps: routeProps });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAMO,SAAS,iBAAiC,GAAA;AAC/C,EAAA,MAAM,WAAW,WAAY,EAAA,CAAA;AAC7B,EAAO,OAAA,sBAAA,CAAuB,QAAS,CAAA,MAAA,IAAU,EAAE,CAAA,CAAA;AACrD,CAAA;AASgB,SAAA,kBAAA,CAAmB,IAAc,EAAA,YAAA,EAA2B,cAAmC,EAAA;AAE7G,EAAA,MAAM,aAAa,cAAK,CAAA,EAAA,EAAA,YAAA,CAAA,CAAA;AAExB,EAAA,IAAI,cAAgB,EAAA;AAClB,IAAA,KAAA,MAAW,GAAO,IAAA,MAAA,CAAO,IAAK,CAAA,UAAU,CAAG,EAAA;AAEzC,MAAA,IAAI,CAAC,cAAA,CAAe,QAAS,CAAA,GAAG,CAAG,EAAA;AACjC,QAAA,OAAO,UAAW,CAAA,GAAA,CAAA,CAAA;AAAA,OACpB;AAAA,KACF;AAAA,GACF;AAEA,EAAA,OAAO,QAAQ,SAAU,CAAA,YAAA,CAAa,aAAc,CAAA,IAAI,GAAG,UAAU,CAAA,CAAA;AACvE,CAAA;AAEgB,SAAA,kCAAA,CAAmC,aAA0B,UAAiC,EAAA;AAE5G,EAAO,OAAA,KAAA,CAAM,cAAc,WAAY,CAAA,SAAA,EAAW,EAAE,KAAO,EAAA,WAAA,EAAa,YAAwB,CAAA,CAAA;AAClG;;;;"}
@@ -1,10 +1,9 @@
1
1
  import { SceneObjectBase } from '../../../core/SceneObjectBase.js';
2
- import { DEFAULT_PANEL_SPAN, GRID_COLUMN_COUNT } from './constants.js';
2
+ import { DEFAULT_PANEL_SPAN } from './constants.js';
3
3
  import { isSceneGridRow } from './SceneGridItem.js';
4
4
  import { SceneGridLayoutRenderer } from './SceneGridLayoutRenderer.js';
5
5
  import { SceneGridRow } from './SceneGridRow.js';
6
6
  import { fitPanelsInHeight } from './utils.js';
7
- import { interpolate } from '../../../core/sceneGraph/sceneGraph.js';
8
7
 
9
8
  var __defProp = Object.defineProperty;
10
9
  var __defProps = Object.defineProperties;
@@ -33,7 +32,6 @@ const _SceneGridLayout = class extends SceneObjectBase {
33
32
  this._skipOnLayoutChange = false;
34
33
  this._oldLayout = [];
35
34
  this._loadOldLayout = false;
36
- this.savedLayout = void 0;
37
35
  this.onLayoutChange = (layout) => {
38
36
  if (this._skipOnLayoutChange) {
39
37
  this._skipOnLayoutChange = false;
@@ -242,38 +240,7 @@ const _SceneGridLayout = class extends SceneObjectBase {
242
240
  }
243
241
  buildGridLayout(width, height) {
244
242
  let cells = [];
245
- const searchString = this.state.searchString;
246
- const panelsPerRow = this.state.panelsPerRow;
247
- let children = this.state.children;
248
- if (searchString && searchString !== "" || panelsPerRow && Number.isInteger(panelsPerRow)) {
249
- if (this.savedLayout === void 0) {
250
- this.savedLayout = this.state.children.map((v) => v.clone());
251
- }
252
- const panelFilterInterpolated = interpolate(this, searchString).toLowerCase();
253
- const filteredChildren = this.state.children.filter((v) => {
254
- var _a, _b, _c, _d;
255
- const panelTitleInterpolated = interpolate(v, (_b = (_a = v.state.body) == null ? void 0 : _a.state) == null ? void 0 : _b.title).toLowerCase();
256
- return typeof ((_d = (_c = v.state.body) == null ? void 0 : _c.state) == null ? void 0 : _d.title) === "string" && panelTitleInterpolated.includes(panelFilterInterpolated);
257
- });
258
- this._skipOnLayoutChange = true;
259
- const rowSize = typeof panelsPerRow === "number" && Number.isInteger(panelsPerRow) && panelsPerRow > 0 ? panelsPerRow : 2;
260
- const panelWidth = GRID_COLUMN_COUNT / rowSize;
261
- const panelHeight = 5;
262
- return filteredChildren.map((child, i) => __spreadProps(__spreadValues({}, this.toGridCell(child)), {
263
- x: i % rowSize * panelWidth,
264
- y: Math.floor(i / rowSize) * panelHeight,
265
- w: panelWidth,
266
- h: panelHeight,
267
- isResizable: false,
268
- isDraggable: false
269
- }));
270
- } else if ((!searchString || searchString === "") && !panelsPerRow) {
271
- if (this.savedLayout) {
272
- children = this.savedLayout;
273
- this.savedLayout = void 0;
274
- }
275
- }
276
- for (const child of children) {
243
+ for (const child of this.state.children) {
277
244
  cells.push(this.toGridCell(child));
278
245
  if (child instanceof SceneGridRow && !child.state.isCollapsed) {
279
246
  for (const rowChild of child.state.children) {
@@ -1 +1 @@
1
- {"version":3,"file":"SceneGridLayout.js","sources":["../../../../../src/components/layout/grid/SceneGridLayout.tsx"],"sourcesContent":["import ReactGridLayout from 'react-grid-layout';\n\nimport { SceneObjectBase } from '../../../core/SceneObjectBase';\nimport { SceneLayout, SceneObjectState } from '../../../core/types';\nimport { DEFAULT_PANEL_SPAN, GRID_COLUMN_COUNT } from './constants';\nimport { isSceneGridRow } from './SceneGridItem';\nimport { SceneGridLayoutRenderer } from './SceneGridLayoutRenderer';\n\nimport { SceneGridRow } from './SceneGridRow';\nimport { SceneGridItemLike, SceneGridItemPlacement } from './types';\nimport { fitPanelsInHeight } from './utils';\nimport { interpolate } from '../../../core/sceneGraph/sceneGraph';\n\ninterface SceneGridLayoutState extends SceneObjectState {\n /**\n * Turn on or off dragging for all items. Individual items can still disabled via isDraggable property\n **/\n isDraggable?: boolean;\n /** Enable or disable item resizing */\n isResizable?: boolean;\n isLazy?: boolean;\n\n /** Panel search */\n showPanelSearch?: boolean;\n searchString?: string;\n panelsPerRow?: number;\n\n /**\n * Fit panels to height of the grid. This will scale down the panels vertically to fit available height.\n * The row height is not changed, only the y position and height of the panels.\n * UNSAFE: This feature is experimental and it might change in the future.\n */\n UNSAFE_fitPanels?: boolean;\n children: SceneGridItemLike[];\n}\n\nexport class SceneGridLayout extends SceneObjectBase<SceneGridLayoutState> implements SceneLayout {\n public static Component = SceneGridLayoutRenderer;\n\n private _skipOnLayoutChange = false;\n private _oldLayout: ReactGridLayout.Layout[] = [];\n private _loadOldLayout = false;\n\n private savedLayout: SceneGridItemLike[] | undefined = undefined;\n\n public constructor(state: SceneGridLayoutState) {\n super({\n ...state,\n children: sortChildrenByPosition(state.children),\n });\n }\n\n /**\n * SceneLayout interface. Used for example by VizPanelRenderer\n */\n public isDraggable(): boolean {\n return this.state.isDraggable ?? false;\n }\n\n public getDragClass() {\n return `grid-drag-handle-${this.state.key}`;\n }\n\n public getDragClassCancel() {\n return `grid-drag-cancel`;\n }\n\n public toggleRow(row: SceneGridRow) {\n const isCollapsed = row.state.isCollapsed;\n\n if (!isCollapsed) {\n row.setState({ isCollapsed: true });\n // To force re-render\n this.setState({});\n return;\n }\n\n const rowChildren = row.state.children;\n\n if (rowChildren.length === 0) {\n row.setState({ isCollapsed: false });\n this.setState({});\n return;\n }\n\n // Ok we are expanding row. We need to update row children y pos (incase they are incorrect) and push items below down\n // Code copied from DashboardModel toggleRow()\n\n const rowY = row.state.y!;\n const firstPanelYPos = rowChildren[0].state.y ?? rowY;\n const yDiff = firstPanelYPos - (rowY + 1);\n\n // y max will represent the bottom y pos after all panels have been added\n // needed to know home much panels below should be pushed down\n let yMax = rowY;\n\n for (const panel of rowChildren) {\n // set the y gridPos if it wasn't already set\n const newSize = { ...panel.state };\n newSize.y = newSize.y ?? rowY;\n // make sure y is adjusted (in case row moved while collapsed)\n newSize.y -= yDiff;\n\n if (newSize.y! !== panel.state.y!) {\n panel.setState(newSize);\n }\n\n // update insert post and y max\n yMax = Math.max(yMax, Number(newSize.y!) + Number(newSize.height!));\n }\n\n const pushDownAmount = yMax - rowY - 1;\n\n // push panels below down\n for (const child of this.state.children) {\n if (child.state.y! > rowY) {\n this.pushChildDown(child, pushDownAmount);\n }\n\n if (isSceneGridRow(child) && child !== row) {\n for (const rowChild of child.state.children) {\n if (rowChild.state.y! > rowY) {\n this.pushChildDown(rowChild, pushDownAmount);\n }\n }\n }\n }\n\n row.setState({ isCollapsed: false });\n // Trigger re-render\n this.setState({});\n }\n\n public ignoreLayoutChange(shouldIgnore: boolean) {\n this._skipOnLayoutChange = shouldIgnore;\n }\n\n public onLayoutChange = (layout: ReactGridLayout.Layout[]) => {\n if (this._skipOnLayoutChange) {\n // Layout has been updated by other RTL handler already\n this._skipOnLayoutChange = false;\n return;\n }\n\n // We replace with the old layout only if the current state is invalid\n if (this._loadOldLayout) {\n layout = [...this._oldLayout];\n this._loadOldLayout = false;\n }\n\n for (const item of layout) {\n const child = this.getSceneLayoutChild(item.i);\n\n const nextSize: SceneGridItemPlacement = {\n x: item.x,\n y: item.y,\n width: item.w,\n height: item.h,\n };\n\n if (!isItemSizeEqual(child.state, nextSize)) {\n child.setState({\n ...nextSize,\n });\n }\n }\n\n this.setState({ children: sortChildrenByPosition(this.state.children) });\n };\n\n /**\n * Will also scan row children and return child of the row\n */\n public getSceneLayoutChild(key: string): SceneGridItemLike {\n for (const child of this.state.children) {\n if (child.state.key === key) {\n return child;\n }\n\n if (child instanceof SceneGridRow) {\n for (const rowChild of child.state.children) {\n if (rowChild.state.key === key) {\n return rowChild;\n }\n }\n }\n }\n\n throw new Error('Scene layout child not found for GridItem');\n }\n\n public onResizeStop: ReactGridLayout.ItemCallback = (_, o, n) => {\n const child = this.getSceneLayoutChild(n.i);\n child.setState({\n width: n.w,\n height: n.h,\n });\n };\n\n private pushChildDown(child: SceneGridItemLike, amount: number) {\n child.setState({\n y: child.state.y! + amount,\n });\n }\n\n /**\n * We assume the layout array is sorted according to y pos, and walk upwards until we find a row.\n * If it is collapsed there is no row to add it to. The default is then to return the SceneGridLayout itself\n */\n private findGridItemSceneParent(layout: ReactGridLayout.Layout[], startAt: number): SceneGridRow | SceneGridLayout {\n for (let i = startAt; i >= 0; i--) {\n const gridItem = layout[i];\n const sceneChild = this.getSceneLayoutChild(gridItem.i);\n\n if (sceneChild instanceof SceneGridRow) {\n // the closest row is collapsed return null\n if (sceneChild.state.isCollapsed) {\n return this;\n }\n\n return sceneChild;\n }\n }\n\n return this;\n }\n\n /**\n * Helper func to check if we are dropping a row in between panels of another row\n */\n private isRowDropValid(\n gridLayout: ReactGridLayout.Layout[],\n updatedItem: ReactGridLayout.Layout,\n indexOfUpdatedItem: number\n ): boolean {\n // if the row is dropped at the end of the dashboard grid layout, we accept this valid state\n if (gridLayout[gridLayout.length - 1].i === updatedItem.i) {\n return true;\n }\n\n // if the next child after the updated item is a scene grid row, then we are either at the top\n // of the dashboard, or between rows\n // if it's not a grid row, but it's parent is the layout, it means we are not in between a\n // rows children, so also valid state\n const nextSceneChild = this.getSceneLayoutChild(gridLayout[indexOfUpdatedItem + 1].i);\n if (nextSceneChild instanceof SceneGridRow) {\n return true;\n } else if (nextSceneChild.parent instanceof SceneGridLayout) {\n return true;\n }\n\n return false;\n }\n\n /**\n * This likely needs a slightly different approach. Where we clone or deactivate or and re-activate the moved child\n */\n public moveChildTo(child: SceneGridItemLike, target: SceneGridLayout | SceneGridRow) {\n const currentParent = child.parent!;\n let rootChildren = this.state.children;\n\n const newChild = child.clone({ key: child.state.key });\n\n // Remove from current parent row\n if (currentParent instanceof SceneGridRow) {\n const newRow = currentParent.clone();\n newRow.setState({\n children: newRow.state.children.filter((c) => c.state.key !== child.state.key),\n });\n\n // new children with new row\n rootChildren = rootChildren.map((c) => (c === currentParent ? newRow : c));\n\n // if target is also a row\n if (target instanceof SceneGridRow) {\n const targetRow = target.clone();\n targetRow.setState({ children: [...targetRow.state.children, newChild] });\n rootChildren = rootChildren.map((c) => (c === target ? targetRow : c));\n } else {\n // target is the main grid\n rootChildren = [...rootChildren, newChild];\n }\n } else {\n if (!(target instanceof SceneGridLayout)) {\n // current parent is the main grid remove it from there\n rootChildren = rootChildren.filter((c) => c.state.key !== child.state.key);\n // Clone the target row and add the child\n const targetRow = target.clone();\n targetRow.setState({ children: [...targetRow.state.children, newChild] });\n // Replace row with new row\n rootChildren = rootChildren.map((c) => (c === target ? targetRow : c));\n }\n }\n\n return rootChildren;\n }\n\n public onDragStart: ReactGridLayout.ItemCallback = (gridLayout) => {\n this._oldLayout = [...gridLayout];\n };\n\n public onDragStop: ReactGridLayout.ItemCallback = (gridLayout, o, updatedItem) => {\n const sceneChild = this.getSceneLayoutChild(updatedItem.i)!;\n\n // Need to resort the grid layout based on new position (needed to find the new parent)\n gridLayout = sortGridLayout(gridLayout);\n\n // Update children positions if they have changed\n for (let i = 0; i < gridLayout.length; i++) {\n const gridItem = gridLayout[i];\n const child = this.getSceneLayoutChild(gridItem.i)!;\n const childSize = child.state;\n\n if (childSize?.x !== gridItem.x || childSize?.y !== gridItem.y) {\n child.setState({\n x: gridItem.x,\n y: gridItem.y,\n });\n }\n }\n\n // Update the parent if the child if it has moved to a row or back to the grid\n const indexOfUpdatedItem = gridLayout.findIndex((item) => item.i === updatedItem.i);\n let newParent = this.findGridItemSceneParent(gridLayout, indexOfUpdatedItem - 1);\n let newChildren = this.state.children;\n\n // if the child is a row and we are moving it under an uncollapsed row, keep the scene grid layout as parent\n // and set the old layout flag if the state is invalid. We allow setting the children in an invalid state,\n // as the layout will be updated in onLayoutChange and avoid flickering\n if (sceneChild instanceof SceneGridRow && newParent instanceof SceneGridRow) {\n if (!this.isRowDropValid(gridLayout, updatedItem, indexOfUpdatedItem)) {\n this._loadOldLayout = true;\n }\n\n newParent = this;\n }\n\n if (newParent !== sceneChild.parent) {\n newChildren = this.moveChildTo(sceneChild, newParent);\n }\n\n this.setState({ children: sortChildrenByPosition(newChildren) });\n this._skipOnLayoutChange = true;\n };\n\n private toGridCell(child: SceneGridItemLike): ReactGridLayout.Layout {\n const size = child.state;\n\n let x = size.x ?? 0;\n let y = size.y ?? 0;\n const w = Number.isInteger(Number(size.width)) ? Number(size.width) : DEFAULT_PANEL_SPAN;\n const h = Number.isInteger(Number(size.height)) ? Number(size.height) : DEFAULT_PANEL_SPAN;\n\n let isDraggable = child.state.isDraggable;\n let isResizable = child.state.isResizable;\n\n if (child instanceof SceneGridRow) {\n isDraggable = child.state.isCollapsed ? true : false;\n isResizable = false;\n }\n\n return { i: child.state.key!, x, y, h, w, isResizable, isDraggable };\n }\n\n public buildGridLayout(width: number, height: number): ReactGridLayout.Layout[] {\n let cells: ReactGridLayout.Layout[] = [];\n const searchString = this.state.searchString;\n const panelsPerRow = this.state.panelsPerRow;\n\n let children = this.state.children;\n if ((searchString && searchString !== '') || (panelsPerRow && Number.isInteger(panelsPerRow))) {\n if (this.savedLayout === undefined) {\n this.savedLayout = this.state.children.map((v) => v.clone());\n }\n\n const panelFilterInterpolated = interpolate(this, searchString).toLowerCase();\n const filteredChildren = this.state.children.filter((v) => {\n const panelTitleInterpolated = interpolate(v, (v.state as any).body?.state?.title).toLowerCase();\n return (\n typeof (v.state as any).body?.state?.title === 'string' &&\n panelTitleInterpolated.includes(panelFilterInterpolated)\n );\n });\n this._skipOnLayoutChange = true;\n const rowSize =\n typeof panelsPerRow === 'number' && Number.isInteger(panelsPerRow) && panelsPerRow > 0 ? panelsPerRow : 2;\n const panelWidth = GRID_COLUMN_COUNT / rowSize;\n const panelHeight = 5;\n return filteredChildren.map((child, i) => ({\n ...this.toGridCell(child),\n x: (i % rowSize) * panelWidth,\n y: Math.floor(i / rowSize) * panelHeight,\n w: panelWidth,\n h: panelHeight,\n isResizable: false,\n isDraggable: false,\n }));\n } else if ((!searchString || searchString === '') && !panelsPerRow) {\n if (this.savedLayout) {\n children = this.savedLayout;\n this.savedLayout = undefined;\n }\n }\n\n for (const child of children) {\n cells.push(this.toGridCell(child));\n\n if (child instanceof SceneGridRow && !child.state.isCollapsed) {\n for (const rowChild of child.state.children) {\n cells.push(this.toGridCell(rowChild));\n }\n }\n }\n\n // Sort by position\n cells = sortGridLayout(cells);\n\n if (this.state.UNSAFE_fitPanels) {\n cells = fitPanelsInHeight(cells, height);\n }\n\n if (width < 768) {\n // We should not persist the mobile layout\n this._skipOnLayoutChange = true;\n return cells.map((cell) => ({ ...cell, w: 24 }));\n }\n\n this._skipOnLayoutChange = false;\n\n return cells;\n }\n}\n\nfunction isItemSizeEqual(a: SceneGridItemPlacement, b: SceneGridItemPlacement) {\n return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;\n}\n\nfunction sortChildrenByPosition(children: SceneGridItemLike[]) {\n children.forEach((child) => {\n if (child instanceof SceneGridRow) {\n child.setState({ children: sortChildrenByPosition(child.state.children) });\n }\n });\n\n return [...children].sort((a, b) => {\n return a.state.y! - b.state.y! || a.state.x! - b.state.x!;\n });\n}\n\nfunction sortGridLayout(layout: ReactGridLayout.Layout[]) {\n return [...layout].sort((a, b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E,KAAM,CAAA,CAAA,GAAK,CAAE,CAAA,KAAA,CAAM,KAAM,CAAE,CAAA,KAAA,CAAM,CAAK,GAAA,CAAA,CAAE,KAAM,CAAA,CAAA,CAAA;AAAA,GACxD,CAAA,CAAA;AACH,CAAA;AAEA,SAAS,eAAe,MAAkC,EAAA;AACxD,EAAA,OAAO,CAAC,GAAG,MAAM,CAAA,CAAE,KAAK,CAAC,CAAA,EAAG,CAAM,KAAA,CAAA,CAAE,IAAI,CAAE,CAAA,CAAA,IAAK,CAAE,CAAA,CAAA,GAAK,EAAE,CAAC,CAAA,CAAA;AAC3D;;;;"}
1
+ {"version":3,"file":"SceneGridLayout.js","sources":["../../../../../src/components/layout/grid/SceneGridLayout.tsx"],"sourcesContent":["import ReactGridLayout from 'react-grid-layout';\n\nimport { SceneObjectBase } from '../../../core/SceneObjectBase';\nimport { SceneLayout, SceneObjectState } from '../../../core/types';\nimport { DEFAULT_PANEL_SPAN } from './constants';\nimport { isSceneGridRow } from './SceneGridItem';\nimport { SceneGridLayoutRenderer } from './SceneGridLayoutRenderer';\n\nimport { SceneGridRow } from './SceneGridRow';\nimport { SceneGridItemLike, SceneGridItemPlacement } from './types';\nimport { fitPanelsInHeight } from './utils';\n\ninterface SceneGridLayoutState extends SceneObjectState {\n /**\n * Turn on or off dragging for all items. Individual items can still disabled via isDraggable property\n **/\n isDraggable?: boolean;\n /** Enable or disable item resizing */\n isResizable?: boolean;\n isLazy?: boolean;\n /**\n * Fit panels to height of the grid. This will scale down the panels vertically to fit available height.\n * The row height is not changed, only the y position and height of the panels.\n * UNSAFE: This feature is experimental and it might change in the future.\n */\n UNSAFE_fitPanels?: boolean;\n children: SceneGridItemLike[];\n}\n\nexport class SceneGridLayout extends SceneObjectBase<SceneGridLayoutState> implements SceneLayout {\n public static Component = SceneGridLayoutRenderer;\n\n private _skipOnLayoutChange = false;\n private _oldLayout: ReactGridLayout.Layout[] = [];\n private _loadOldLayout = false;\n\n public constructor(state: SceneGridLayoutState) {\n super({\n ...state,\n children: sortChildrenByPosition(state.children),\n });\n }\n\n /**\n * SceneLayout interface. Used for example by VizPanelRenderer\n */\n public isDraggable(): boolean {\n return this.state.isDraggable ?? false;\n }\n\n public getDragClass() {\n return `grid-drag-handle-${this.state.key}`;\n }\n\n public getDragClassCancel() {\n return `grid-drag-cancel`;\n }\n\n public toggleRow(row: SceneGridRow) {\n const isCollapsed = row.state.isCollapsed;\n\n if (!isCollapsed) {\n row.setState({ isCollapsed: true });\n // To force re-render\n this.setState({});\n return;\n }\n\n const rowChildren = row.state.children;\n\n if (rowChildren.length === 0) {\n row.setState({ isCollapsed: false });\n this.setState({});\n return;\n }\n\n // Ok we are expanding row. We need to update row children y pos (incase they are incorrect) and push items below down\n // Code copied from DashboardModel toggleRow()\n\n const rowY = row.state.y!;\n const firstPanelYPos = rowChildren[0].state.y ?? rowY;\n const yDiff = firstPanelYPos - (rowY + 1);\n\n // y max will represent the bottom y pos after all panels have been added\n // needed to know home much panels below should be pushed down\n let yMax = rowY;\n\n for (const panel of rowChildren) {\n // set the y gridPos if it wasn't already set\n const newSize = { ...panel.state };\n newSize.y = newSize.y ?? rowY;\n // make sure y is adjusted (in case row moved while collapsed)\n newSize.y -= yDiff;\n\n if (newSize.y! !== panel.state.y!) {\n panel.setState(newSize);\n }\n\n // update insert post and y max\n yMax = Math.max(yMax, Number(newSize.y!) + Number(newSize.height!));\n }\n\n const pushDownAmount = yMax - rowY - 1;\n\n // push panels below down\n for (const child of this.state.children) {\n if (child.state.y! > rowY) {\n this.pushChildDown(child, pushDownAmount);\n }\n\n if (isSceneGridRow(child) && child !== row) {\n for (const rowChild of child.state.children) {\n if (rowChild.state.y! > rowY) {\n this.pushChildDown(rowChild, pushDownAmount);\n }\n }\n }\n }\n\n row.setState({ isCollapsed: false });\n // Trigger re-render\n this.setState({});\n }\n\n public ignoreLayoutChange(shouldIgnore: boolean) {\n this._skipOnLayoutChange = shouldIgnore;\n }\n\n public onLayoutChange = (layout: ReactGridLayout.Layout[]) => {\n if (this._skipOnLayoutChange) {\n // Layout has been updated by other RTL handler already\n this._skipOnLayoutChange = false;\n return;\n }\n\n // We replace with the old layout only if the current state is invalid\n if (this._loadOldLayout) {\n layout = [...this._oldLayout];\n this._loadOldLayout = false;\n }\n\n for (const item of layout) {\n const child = this.getSceneLayoutChild(item.i);\n\n const nextSize: SceneGridItemPlacement = {\n x: item.x,\n y: item.y,\n width: item.w,\n height: item.h,\n };\n\n if (!isItemSizeEqual(child.state, nextSize)) {\n child.setState({\n ...nextSize,\n });\n }\n }\n\n this.setState({ children: sortChildrenByPosition(this.state.children) });\n };\n\n /**\n * Will also scan row children and return child of the row\n */\n public getSceneLayoutChild(key: string): SceneGridItemLike {\n for (const child of this.state.children) {\n if (child.state.key === key) {\n return child;\n }\n\n if (child instanceof SceneGridRow) {\n for (const rowChild of child.state.children) {\n if (rowChild.state.key === key) {\n return rowChild;\n }\n }\n }\n }\n\n throw new Error('Scene layout child not found for GridItem');\n }\n\n public onResizeStop: ReactGridLayout.ItemCallback = (_, o, n) => {\n const child = this.getSceneLayoutChild(n.i);\n child.setState({\n width: n.w,\n height: n.h,\n });\n };\n\n private pushChildDown(child: SceneGridItemLike, amount: number) {\n child.setState({\n y: child.state.y! + amount,\n });\n }\n\n /**\n * We assume the layout array is sorted according to y pos, and walk upwards until we find a row.\n * If it is collapsed there is no row to add it to. The default is then to return the SceneGridLayout itself\n */\n private findGridItemSceneParent(layout: ReactGridLayout.Layout[], startAt: number): SceneGridRow | SceneGridLayout {\n for (let i = startAt; i >= 0; i--) {\n const gridItem = layout[i];\n const sceneChild = this.getSceneLayoutChild(gridItem.i);\n\n if (sceneChild instanceof SceneGridRow) {\n // the closest row is collapsed return null\n if (sceneChild.state.isCollapsed) {\n return this;\n }\n\n return sceneChild;\n }\n }\n\n return this;\n }\n\n /**\n * Helper func to check if we are dropping a row in between panels of another row\n */\n private isRowDropValid(\n gridLayout: ReactGridLayout.Layout[],\n updatedItem: ReactGridLayout.Layout,\n indexOfUpdatedItem: number\n ): boolean {\n // if the row is dropped at the end of the dashboard grid layout, we accept this valid state\n if (gridLayout[gridLayout.length - 1].i === updatedItem.i) {\n return true;\n }\n\n // if the next child after the updated item is a scene grid row, then we are either at the top\n // of the dashboard, or between rows\n // if it's not a grid row, but it's parent is the layout, it means we are not in between a\n // rows children, so also valid state\n const nextSceneChild = this.getSceneLayoutChild(gridLayout[indexOfUpdatedItem + 1].i);\n if (nextSceneChild instanceof SceneGridRow) {\n return true;\n } else if (nextSceneChild.parent instanceof SceneGridLayout) {\n return true;\n }\n\n return false;\n }\n\n /**\n * This likely needs a slightly different approach. Where we clone or deactivate or and re-activate the moved child\n */\n public moveChildTo(child: SceneGridItemLike, target: SceneGridLayout | SceneGridRow) {\n const currentParent = child.parent!;\n let rootChildren = this.state.children;\n\n const newChild = child.clone({ key: child.state.key });\n\n // Remove from current parent row\n if (currentParent instanceof SceneGridRow) {\n const newRow = currentParent.clone();\n newRow.setState({\n children: newRow.state.children.filter((c) => c.state.key !== child.state.key),\n });\n\n // new children with new row\n rootChildren = rootChildren.map((c) => (c === currentParent ? newRow : c));\n\n // if target is also a row\n if (target instanceof SceneGridRow) {\n const targetRow = target.clone();\n targetRow.setState({ children: [...targetRow.state.children, newChild] });\n rootChildren = rootChildren.map((c) => (c === target ? targetRow : c));\n } else {\n // target is the main grid\n rootChildren = [...rootChildren, newChild];\n }\n } else {\n if (!(target instanceof SceneGridLayout)) {\n // current parent is the main grid remove it from there\n rootChildren = rootChildren.filter((c) => c.state.key !== child.state.key);\n // Clone the target row and add the child\n const targetRow = target.clone();\n targetRow.setState({ children: [...targetRow.state.children, newChild] });\n // Replace row with new row\n rootChildren = rootChildren.map((c) => (c === target ? targetRow : c));\n }\n }\n\n return rootChildren;\n }\n\n public onDragStart: ReactGridLayout.ItemCallback = (gridLayout) => {\n this._oldLayout = [...gridLayout];\n };\n\n public onDragStop: ReactGridLayout.ItemCallback = (gridLayout, o, updatedItem) => {\n const sceneChild = this.getSceneLayoutChild(updatedItem.i)!;\n\n // Need to resort the grid layout based on new position (needed to find the new parent)\n gridLayout = sortGridLayout(gridLayout);\n\n // Update children positions if they have changed\n for (let i = 0; i < gridLayout.length; i++) {\n const gridItem = gridLayout[i];\n const child = this.getSceneLayoutChild(gridItem.i)!;\n const childSize = child.state;\n\n if (childSize?.x !== gridItem.x || childSize?.y !== gridItem.y) {\n child.setState({\n x: gridItem.x,\n y: gridItem.y,\n });\n }\n }\n\n // Update the parent if the child if it has moved to a row or back to the grid\n const indexOfUpdatedItem = gridLayout.findIndex((item) => item.i === updatedItem.i);\n let newParent = this.findGridItemSceneParent(gridLayout, indexOfUpdatedItem - 1);\n let newChildren = this.state.children;\n\n // if the child is a row and we are moving it under an uncollapsed row, keep the scene grid layout as parent\n // and set the old layout flag if the state is invalid. We allow setting the children in an invalid state,\n // as the layout will be updated in onLayoutChange and avoid flickering\n if (sceneChild instanceof SceneGridRow && newParent instanceof SceneGridRow) {\n if (!this.isRowDropValid(gridLayout, updatedItem, indexOfUpdatedItem)) {\n this._loadOldLayout = true;\n }\n\n newParent = this;\n }\n\n if (newParent !== sceneChild.parent) {\n newChildren = this.moveChildTo(sceneChild, newParent);\n }\n\n this.setState({ children: sortChildrenByPosition(newChildren) });\n this._skipOnLayoutChange = true;\n };\n\n private toGridCell(child: SceneGridItemLike): ReactGridLayout.Layout {\n const size = child.state;\n\n let x = size.x ?? 0;\n let y = size.y ?? 0;\n const w = Number.isInteger(Number(size.width)) ? Number(size.width) : DEFAULT_PANEL_SPAN;\n const h = Number.isInteger(Number(size.height)) ? Number(size.height) : DEFAULT_PANEL_SPAN;\n\n let isDraggable = child.state.isDraggable;\n let isResizable = child.state.isResizable;\n\n if (child instanceof SceneGridRow) {\n isDraggable = child.state.isCollapsed ? true : false;\n isResizable = false;\n }\n\n return { i: child.state.key!, x, y, h, w, isResizable, isDraggable };\n }\n\n public buildGridLayout(width: number, height: number): ReactGridLayout.Layout[] {\n let cells: ReactGridLayout.Layout[] = [];\n\n for (const child of this.state.children) {\n cells.push(this.toGridCell(child));\n\n if (child instanceof SceneGridRow && !child.state.isCollapsed) {\n for (const rowChild of child.state.children) {\n cells.push(this.toGridCell(rowChild));\n }\n }\n }\n\n // Sort by position\n cells = sortGridLayout(cells);\n\n if (this.state.UNSAFE_fitPanels) {\n cells = fitPanelsInHeight(cells, height);\n }\n\n if (width < 768) {\n // We should not persist the mobile layout\n this._skipOnLayoutChange = true;\n return cells.map((cell) => ({ ...cell, w: 24 }));\n }\n\n this._skipOnLayoutChange = false;\n\n return cells;\n }\n}\n\nfunction isItemSizeEqual(a: SceneGridItemPlacement, b: SceneGridItemPlacement) {\n return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;\n}\n\nfunction sortChildrenByPosition(children: SceneGridItemLike[]) {\n children.forEach((child) => {\n if (child instanceof SceneGridRow) {\n child.setState({ children: sortChildrenByPosition(child.state.children) });\n }\n });\n\n return [...children].sort((a, b) => {\n return a.state.y! - b.state.y! || a.state.x! - b.state.x!;\n });\n}\n\nfunction sortGridLayout(layout: ReactGridLayout.Layout[]) {\n return [...layout].sort((a, b) => a.y - b.y || a.x! - b.x);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6BO,MAAM,gBAAA,GAAN,cAA8B,eAA6D,CAAA;AAAA,EAOzF,YAAY,KAA6B,EAAA;AAC9C,IAAA,KAAA,CAAM,iCACD,KADC,CAAA,EAAA;AAAA,MAEJ,QAAA,EAAU,sBAAuB,CAAA,KAAA,CAAM,QAAQ,CAAA;AAAA,KAChD,CAAA,CAAA,CAAA;AARH,IAAA,IAAA,CAAQ,mBAAsB,GAAA,KAAA,CAAA;AAC9B,IAAA,IAAA,CAAQ,aAAuC,EAAC,CAAA;AAChD,IAAA,IAAA,CAAQ,cAAiB,GAAA,KAAA,CAAA;AA8FzB,IAAO,IAAA,CAAA,cAAA,GAAiB,CAAC,MAAqC,KAAA;AAC5D,MAAA,IAAI,KAAK,mBAAqB,E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,CAAA;AAC3D;;;;"}
@@ -1,11 +1,10 @@
1
- import React, { useRef, useEffect, useCallback } from 'react';
1
+ import React, { useRef, useEffect } from 'react';
2
2
  import ReactGridLayout from 'react-grid-layout';
3
3
  import { GRID_CELL_VMARGIN, GRID_COLUMN_COUNT, GRID_CELL_HEIGHT } from './constants.js';
4
4
  import { LazyLoader } from '../LazyLoader.js';
5
- import { useStyles2, Input } from '@grafana/ui';
5
+ import { useStyles2 } from '@grafana/ui';
6
6
  import { cx, css } from '@emotion/css';
7
7
  import { useMeasure } from 'react-use';
8
- import { ControlsLabel } from '../../../utils/ControlsLabel.js';
9
8
 
10
9
  var __defProp = Object.defineProperty;
11
10
  var __defProps = Object.defineProperties;
@@ -39,7 +38,7 @@ var __objRest = (source, exclude) => {
39
38
  return target;
40
39
  };
41
40
  function SceneGridLayoutRenderer({ model }) {
42
- const { children, isLazy, isDraggable, isResizable, showPanelSearch } = model.useState();
41
+ const { children, isLazy, isDraggable, isResizable } = model.useState();
43
42
  const [outerDivRef, { width, height }] = useMeasure();
44
43
  const ref = useRef(null);
45
44
  useEffect(() => {
@@ -85,67 +84,7 @@ function SceneGridLayoutRenderer({ model }) {
85
84
  return /* @__PURE__ */ React.createElement("div", {
86
85
  ref: outerDivRef,
87
86
  style: { flex: "1 1 auto", position: "relative", zIndex: 1, width: "100%" }
88
- }, showPanelSearch && /* @__PURE__ */ React.createElement(PanelSearchControls, {
89
- model
90
- }), renderGrid(width, height));
91
- }
92
- function PanelSearchControls({ model }) {
93
- const { searchString, panelsPerRow } = model.useState();
94
- const styles = useStyles2(getPanelSearchStyles);
95
- const onSearchStringChange = useCallback(
96
- (e) => {
97
- model.setState({ searchString: e.currentTarget.value });
98
- },
99
- [model]
100
- );
101
- const onPanelsPerRowChange = useCallback(
102
- (e) => {
103
- model.setState({ panelsPerRow: Number.parseInt(e.currentTarget.value, 10) });
104
- },
105
- [model]
106
- );
107
- return /* @__PURE__ */ React.createElement("div", {
108
- className: styles.wrapper
109
- }, /* @__PURE__ */ React.createElement("div", {
110
- id: "panel-search",
111
- className: styles.input
112
- }, /* @__PURE__ */ React.createElement(ControlsLabel, {
113
- isLoading: false,
114
- label: "Panel search",
115
- htmlFor: "panel-search-input"
116
- }), /* @__PURE__ */ React.createElement(Input, {
117
- id: "panel-search-input",
118
- label: "Search",
119
- placeholder: "Enter value",
120
- value: searchString,
121
- onChange: onSearchStringChange
122
- })), /* @__PURE__ */ React.createElement("div", {
123
- id: "panels-per-row",
124
- className: styles.input
125
- }, /* @__PURE__ */ React.createElement(ControlsLabel, {
126
- isLoading: false,
127
- label: "Panels per row",
128
- htmlFor: "panels-per-row-input"
129
- }), /* @__PURE__ */ React.createElement(Input, {
130
- id: "panels-per-row-input",
131
- type: "number",
132
- placeholder: "Enter value",
133
- label: "Panels per row",
134
- value: panelsPerRow,
135
- onChange: onPanelsPerRowChange
136
- })));
137
- }
138
- function getPanelSearchStyles(theme) {
139
- return {
140
- wrapper: css({
141
- display: "flex",
142
- gap: theme.spacing(1),
143
- marginBottom: theme.spacing(1)
144
- }),
145
- input: css({
146
- display: "flex"
147
- })
148
- };
87
+ }, renderGrid(width, height));
149
88
  }
150
89
  const GridItemWrapper = React.forwardRef((props, ref) => {
151
90
  var _b;
@@ -1 +1 @@
1
- {"version":3,"file":"SceneGridLayoutRenderer.js","sources":["../../../../../src/components/layout/grid/SceneGridLayoutRenderer.tsx"],"sourcesContent":["import React, { RefCallback, useCallback, useEffect, useRef } from 'react';\nimport ReactGridLayout from 'react-grid-layout';\nimport { SceneComponentProps } from '../../../core/types';\nimport { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN, GRID_COLUMN_COUNT } from './constants';\nimport { LazyLoader } from '../LazyLoader';\nimport { SceneGridLayout } from './SceneGridLayout';\nimport { SceneGridItemLike } from './types';\nimport { Input, useStyles2 } from '@grafana/ui';\nimport { css, cx } from '@emotion/css';\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { useMeasure } from 'react-use';\nimport { ControlsLabel } from '../../../utils/ControlsLabel';\n\nexport function SceneGridLayoutRenderer({ model }: SceneComponentProps<SceneGridLayout>) {\n const { children, isLazy, isDraggable, isResizable, showPanelSearch } = model.useState();\n const [outerDivRef, { width, height }] = useMeasure();\n const ref = useRef<HTMLDivElement | null>(null);\n\n /**\n * The class that enables drag animations needs to be added after mount otherwise panels move on mount to their set positions which is annoying\n */\n useEffect(() => {\n updateAnimationClass(ref, !!isDraggable);\n }, [isDraggable]);\n\n validateChildrenSize(children);\n\n const renderGrid = (width: number, height: number) => {\n if (!width || !height) {\n return null;\n }\n\n const layout = model.buildGridLayout(width, height);\n\n return (\n /**\n * The children is using a width of 100% so we need to guarantee that it is wrapped\n * in an element that has the calculated size given by the AutoSizer. The AutoSizer\n * has a width of 0 and will let its content overflow its div.\n */\n <div ref={ref} style={{ width: `${width}px`, height: '100%' }} className=\"react-grid-layout\">\n <ReactGridLayout\n width={width}\n /**\n Disable draggable if mobile device, solving an issue with unintentionally\n moving panels. https://github.com/grafana/grafana/issues/18497\n theme.breakpoints.md = 769\n */\n isDraggable={isDraggable && width > 768}\n isResizable={isResizable ?? false}\n containerPadding={[0, 0]}\n useCSSTransforms={true}\n margin={[GRID_CELL_VMARGIN, GRID_CELL_VMARGIN]}\n cols={GRID_COLUMN_COUNT}\n rowHeight={GRID_CELL_HEIGHT}\n draggableHandle={`.grid-drag-handle-${model.state.key}`}\n draggableCancel=\".grid-drag-cancel\"\n layout={layout}\n onDragStart={model.onDragStart}\n onDragStop={model.onDragStop}\n onResizeStop={model.onResizeStop}\n onLayoutChange={model.onLayoutChange}\n isBounded={false}\n resizeHandle={<ResizeHandle />}\n >\n {layout.map((gridItem, index) => (\n <GridItemWrapper\n key={gridItem.i}\n grid={model}\n layoutItem={gridItem}\n index={index}\n isLazy={isLazy}\n totalCount={layout.length}\n />\n ))}\n </ReactGridLayout>\n </div>\n );\n };\n\n return (\n <div\n ref={outerDivRef as RefCallback<HTMLDivElement>}\n style={{ flex: '1 1 auto', position: 'relative', zIndex: 1, width: '100%' }}\n >\n {showPanelSearch && <PanelSearchControls model={model} />}\n {renderGrid(width, height)}\n </div>\n );\n}\n\ninterface PanelSearchProps {\n model: SceneGridLayout;\n}\n\nfunction PanelSearchControls({ model }: PanelSearchProps) {\n const { searchString, panelsPerRow } = model.useState();\n const styles = useStyles2(getPanelSearchStyles);\n\n const onSearchStringChange = useCallback(\n (e: React.FormEvent<HTMLInputElement>) => {\n model.setState({ searchString: e.currentTarget.value });\n },\n [model]\n );\n\n const onPanelsPerRowChange = useCallback(\n (e: React.FormEvent<HTMLInputElement>) => {\n model.setState({ panelsPerRow: Number.parseInt(e.currentTarget.value, 10) });\n },\n [model]\n );\n\n return (\n <div className={styles.wrapper}>\n <div id=\"panel-search\" className={styles.input}>\n <ControlsLabel isLoading={false} label=\"Panel search\" htmlFor=\"panel-search-input\" />\n <Input\n id=\"panel-search-input\"\n label=\"Search\"\n placeholder=\"Enter value\"\n value={searchString}\n onChange={onSearchStringChange}\n />\n </div>\n <div id=\"panels-per-row\" className={styles.input}>\n <ControlsLabel isLoading={false} label=\"Panels per row\" htmlFor=\"panels-per-row-input\" />\n <Input\n id=\"panels-per-row-input\"\n type=\"number\"\n placeholder=\"Enter value\"\n label=\"Panels per row\"\n value={panelsPerRow}\n onChange={onPanelsPerRowChange}\n />\n </div>\n </div>\n );\n}\n\nfunction getPanelSearchStyles(theme: GrafanaTheme2) {\n return {\n wrapper: css({\n display: 'flex',\n gap: theme.spacing(1),\n marginBottom: theme.spacing(1),\n }),\n input: css({\n display: 'flex',\n })\n }\n}\n\ninterface GridItemWrapperProps extends React.HTMLAttributes<HTMLDivElement> {\n grid: SceneGridLayout;\n layoutItem: ReactGridLayout.Layout;\n index: number;\n totalCount: number;\n isLazy?: boolean;\n}\n\nconst GridItemWrapper = React.forwardRef<HTMLDivElement, GridItemWrapperProps>((props, ref) => {\n const { grid, layoutItem, index, totalCount, isLazy, style, onLoad, onChange, children, ...divProps } = props;\n const sceneChild = grid.getSceneLayoutChild(layoutItem.i)!;\n const className = sceneChild.getClassName?.();\n\n const innerContent = <sceneChild.Component model={sceneChild} key={sceneChild.state.key} />;\n\n if (isLazy) {\n return (\n <LazyLoader\n {...divProps}\n key={sceneChild.state.key!}\n data-griditem-key={sceneChild.state.key}\n className={cx(className, props.className)}\n style={style}\n ref={ref}\n >\n {innerContent}\n {children}\n </LazyLoader>\n );\n }\n\n return (\n <div\n {...divProps}\n ref={ref}\n key={sceneChild.state.key}\n data-griditem-key={sceneChild.state.key}\n className={cx(className, props.className)}\n style={style}\n >\n {innerContent}\n {children}\n </div>\n );\n});\n\nGridItemWrapper.displayName = 'GridItemWrapper';\n\nfunction validateChildrenSize(children: SceneGridItemLike[]) {\n if (\n children.some(\n (c) =>\n c.state.height === undefined ||\n c.state.width === undefined ||\n c.state.x === undefined ||\n c.state.y === undefined\n )\n ) {\n throw new Error('All children must have a size specified');\n }\n}\n\nfunction updateAnimationClass(\n ref: React.MutableRefObject<HTMLDivElement | null>,\n isDraggable: boolean,\n retry?: boolean\n) {\n if (ref.current) {\n if (isDraggable) {\n ref.current.classList.add('react-grid-layout--enable-move-animations');\n } else {\n ref.current.classList.remove('react-grid-layout--enable-move-animations');\n }\n } else if (!retry) {\n setTimeout(() => updateAnimationClass(ref, isDraggable, true), 50);\n }\n}\n\ninterface ResizeHandleProps extends React.HTMLAttributes<HTMLDivElement> {\n handleAxis?: string;\n}\n\nconst ResizeHandle = React.forwardRef<HTMLDivElement, ResizeHandleProps>(({ handleAxis, ...divProps }, ref) => {\n const customCssClass = useStyles2(getResizeHandleStyles);\n\n return (\n <div ref={ref} {...divProps} className={`${customCssClass} scene-resize-handle`}>\n <svg width=\"16px\" height=\"16px\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M21 15L15 21M21 8L8 21\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n </div>\n );\n});\n\nResizeHandle.displayName = 'ResizeHandle';\n\nfunction getResizeHandleStyles(theme: GrafanaTheme2) {\n return css({\n position: 'absolute',\n bottom: 0,\n right: 0,\n zIndex: 999,\n padding: theme.spacing(1.5, 0, 0, 1.5),\n color: theme.colors.border.strong,\n cursor: 'se-resize',\n '&:hover': {\n color: theme.colors.text.link,\n },\n svg: {\n display: 'block',\n },\n '.react-resizable-hide &': {\n display: 'none',\n },\n });\n}\n"],"names":["width","height"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAagB,SAAA,uBAAA,CAAwB,EAAE,KAAA,EAA+C,EAAA;AACvF,EAAM,MAAA,EAAE,UAAU,MAAQ,EAAA,WAAA,EAAa,aAAa,eAAgB,EAAA,GAAI,MAAM,QAAS,EAAA,CAAA;AACvF,EAAA,MAAM,CAAC,WAAa,EAAA,EAAE,OAAO,MAAO,EAAC,IAAI,UAAW,EAAA,CAAA;AACpD,EAAM,MAAA,GAAA,GAAM,OAA8B,IAAI,CAAA,CAAA;AAK9C,EAAA,SAAA,CAAU,MAAM;AACd,IAAqB,oBAAA,CAAA,GAAA,EAAK,CAAC,CAAC,WAAW,CAAA,CAAA;AAAA,GACzC,EAAG,CAAC,WAAW,CAAC,CAAA,CAAA;AAEhB,EAAA,oBAAA,CAAqB,QAAQ,CAAA,CAAA;AAE7B,EAAM,MAAA,UAAA,GAAa,CAACA,MAAAA,EAAeC,OAAmB,KAAA;AACpD,IAAI,IAAA,CAACD,MAAS,IAAA,CAACC,OAAQ,EAAA;AACrB,MAAO,OAAA,IAAA,CAAA;AAAA,KACT;AAEA,IAAA,MAAM,MAAS,GAAA,KAAA,CAAM,eAAgBD,CAAAA,MAAAA,EAAOC,OAAM,CAAA,CAAA;AAElD,IAAA,uBAMG,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,MAAI,GAAA;AAAA,MAAU,OAAO,EAAE,KAAA,EAAO,CAAGD,EAAAA,MAAAA,CAAA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AAA,MAAA;AAAA,IAC3B,MAAQ,EAAA,WAAA;AAAA,IACR,SAAW,EAAA;AAAA,MACT,KAAA,EAAO,KAAM,CAAA,MAAA,CAAO,IAAK,CAAA,IAAA;AAAA,KAC3B;AAAA,IACA,GAAK,EAAA;AAAA,MACH,OAAS,EAAA,OAAA;AAAA,KACX;AAAA,IACA,yBAA2B,EAAA;AAAA,MACzB,OAAS,EAAA,MAAA;AAAA,KACX;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"SceneGridLayoutRenderer.js","sources":["../../../../../src/components/layout/grid/SceneGridLayoutRenderer.tsx"],"sourcesContent":["import React, { RefCallback, useEffect, useRef } from 'react';\nimport ReactGridLayout from 'react-grid-layout';\nimport { SceneComponentProps } from '../../../core/types';\nimport { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN, GRID_COLUMN_COUNT } from './constants';\nimport { LazyLoader } from '../LazyLoader';\nimport { SceneGridLayout } from './SceneGridLayout';\nimport { SceneGridItemLike } from './types';\nimport { useStyles2 } from '@grafana/ui';\nimport { css, cx } from '@emotion/css';\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { useMeasure } from 'react-use';\n\nexport function SceneGridLayoutRenderer({ model }: SceneComponentProps<SceneGridLayout>) {\n const { children, isLazy, isDraggable, isResizable } = model.useState();\n const [outerDivRef, { width, height }] = useMeasure();\n const ref = useRef<HTMLDivElement | null>(null);\n\n /**\n * The class that enables drag animations needs to be added after mount otherwise panels move on mount to their set positions which is annoying\n */\n useEffect(() => {\n updateAnimationClass(ref, !!isDraggable);\n }, [isDraggable]);\n\n validateChildrenSize(children);\n\n const renderGrid = (width: number, height: number) => {\n if (!width || !height) {\n return null;\n }\n\n const layout = model.buildGridLayout(width, height);\n\n return (\n /**\n * The children is using a width of 100% so we need to guarantee that it is wrapped\n * in an element that has the calculated size given by the AutoSizer. The AutoSizer\n * has a width of 0 and will let its content overflow its div.\n */\n <div ref={ref} style={{ width: `${width}px`, height: '100%' }} className=\"react-grid-layout\">\n <ReactGridLayout\n width={width}\n /**\n Disable draggable if mobile device, solving an issue with unintentionally\n moving panels. https://github.com/grafana/grafana/issues/18497\n theme.breakpoints.md = 769\n */\n isDraggable={isDraggable && width > 768}\n isResizable={isResizable ?? false}\n containerPadding={[0, 0]}\n useCSSTransforms={true}\n margin={[GRID_CELL_VMARGIN, GRID_CELL_VMARGIN]}\n cols={GRID_COLUMN_COUNT}\n rowHeight={GRID_CELL_HEIGHT}\n draggableHandle={`.grid-drag-handle-${model.state.key}`}\n draggableCancel=\".grid-drag-cancel\"\n layout={layout}\n onDragStart={model.onDragStart}\n onDragStop={model.onDragStop}\n onResizeStop={model.onResizeStop}\n onLayoutChange={model.onLayoutChange}\n isBounded={false}\n resizeHandle={<ResizeHandle />}\n >\n {layout.map((gridItem, index) => (\n <GridItemWrapper\n key={gridItem.i}\n grid={model}\n layoutItem={gridItem}\n index={index}\n isLazy={isLazy}\n totalCount={layout.length}\n />\n ))}\n </ReactGridLayout>\n </div>\n );\n };\n\n return (\n <div\n ref={outerDivRef as RefCallback<HTMLDivElement>}\n style={{ flex: '1 1 auto', position: 'relative', zIndex: 1, width: '100%' }}\n >\n {renderGrid(width, height)}\n </div>\n );\n}\n\ninterface GridItemWrapperProps extends React.HTMLAttributes<HTMLDivElement> {\n grid: SceneGridLayout;\n layoutItem: ReactGridLayout.Layout;\n index: number;\n totalCount: number;\n isLazy?: boolean;\n}\n\nconst GridItemWrapper = React.forwardRef<HTMLDivElement, GridItemWrapperProps>((props, ref) => {\n const { grid, layoutItem, index, totalCount, isLazy, style, onLoad, onChange, children, ...divProps } = props;\n const sceneChild = grid.getSceneLayoutChild(layoutItem.i)!;\n const className = sceneChild.getClassName?.();\n\n const innerContent = <sceneChild.Component model={sceneChild} key={sceneChild.state.key} />;\n\n if (isLazy) {\n return (\n <LazyLoader\n {...divProps}\n key={sceneChild.state.key!}\n data-griditem-key={sceneChild.state.key}\n className={cx(className, props.className)}\n style={style}\n ref={ref}\n >\n {innerContent}\n {children}\n </LazyLoader>\n );\n }\n\n return (\n <div\n {...divProps}\n ref={ref}\n key={sceneChild.state.key}\n data-griditem-key={sceneChild.state.key}\n className={cx(className, props.className)}\n style={style}\n >\n {innerContent}\n {children}\n </div>\n );\n});\n\nGridItemWrapper.displayName = 'GridItemWrapper';\n\nfunction validateChildrenSize(children: SceneGridItemLike[]) {\n if (\n children.some(\n (c) =>\n c.state.height === undefined ||\n c.state.width === undefined ||\n c.state.x === undefined ||\n c.state.y === undefined\n )\n ) {\n throw new Error('All children must have a size specified');\n }\n}\n\nfunction updateAnimationClass(\n ref: React.MutableRefObject<HTMLDivElement | null>,\n isDraggable: boolean,\n retry?: boolean\n) {\n if (ref.current) {\n if (isDraggable) {\n ref.current.classList.add('react-grid-layout--enable-move-animations');\n } else {\n ref.current.classList.remove('react-grid-layout--enable-move-animations');\n }\n } else if (!retry) {\n setTimeout(() => updateAnimationClass(ref, isDraggable, true), 50);\n }\n}\n\ninterface ResizeHandleProps extends React.HTMLAttributes<HTMLDivElement> {\n handleAxis?: string;\n}\n\nconst ResizeHandle = React.forwardRef<HTMLDivElement, ResizeHandleProps>(({ handleAxis, ...divProps }, ref) => {\n const customCssClass = useStyles2(getResizeHandleStyles);\n\n return (\n <div ref={ref} {...divProps} className={`${customCssClass} scene-resize-handle`}>\n <svg width=\"16px\" height=\"16px\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M21 15L15 21M21 8L8 21\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n </div>\n );\n});\n\nResizeHandle.displayName = 'ResizeHandle';\n\nfunction getResizeHandleStyles(theme: GrafanaTheme2) {\n return css({\n position: 'absolute',\n bottom: 0,\n right: 0,\n zIndex: 999,\n padding: theme.spacing(1.5, 0, 0, 1.5),\n color: theme.colors.border.strong,\n cursor: 'se-resize',\n '&:hover': {\n color: the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AO,CAAA,MAAA;AAAA,IAC3B,MAAQ,EAAA,WAAA;AAAA,IACR,SAAW,EAAA;AAAA,MACT,KAAA,EAAO,KAAM,CAAA,MAAA,CAAO,IAAK,CAAA,IAAA;AAAA,KAC3B;AAAA,IACA,GAAK,EAAA;AAAA,MACH,OAAS,EAAA,OAAA;AAAA,KACX;AAAA,IACA,yBAA2B,EAAA;AAAA,MACzB,OAAS,EAAA,MAAA;AAAA,KACX;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
@@ -30,10 +30,11 @@ class NewSceneObjectAddedEvent extends BusEventWithPayload {
30
30
  }
31
31
  NewSceneObjectAddedEvent.type = "new-scene-object-added";
32
32
  class UrlSyncManager {
33
- constructor(_options = {}) {
33
+ constructor(_options = {}, locationService$1 = locationService) {
34
34
  this._urlKeyMapper = new UniqueUrlKeyMapper();
35
- this._paramsCache = new UrlParamsCache();
36
35
  this._options = _options;
36
+ this._locationService = locationService$1;
37
+ this._paramsCache = new UrlParamsCache(locationService$1);
37
38
  }
38
39
  initSync(root) {
39
40
  var _a;
@@ -55,12 +56,12 @@ class UrlSyncManager {
55
56
  })
56
57
  );
57
58
  this._urlKeyMapper.clear();
58
- this._lastLocation = locationService.getLocation();
59
+ this._lastLocation = this._locationService.getLocation();
59
60
  this.handleNewObject(this._sceneRoot);
60
61
  if (this._options.updateUrlOnInit) {
61
62
  const urlState = getUrlState(root);
62
63
  if (isUrlStateDifferent(urlState, this._paramsCache.getParams())) {
63
- locationService.partial(urlState, true);
64
+ this._locationService.partial(urlState, true);
64
65
  }
65
66
  }
66
67
  }
@@ -102,7 +103,7 @@ class UrlSyncManager {
102
103
  return;
103
104
  }
104
105
  const newUrlState = changedObject.urlSync.getUrlState();
105
- const searchParams = locationService.getSearch();
106
+ const searchParams = this._locationService.getSearch();
106
107
  const mappedUpdated = {};
107
108
  for (const [key, newUrlValue] of Object.entries(newUrlState)) {
108
109
  const uniqueKey = this._urlKeyMapper.getUniqueKey(key, changedObject);
@@ -115,8 +116,8 @@ class UrlSyncManager {
115
116
  const shouldCreateHistoryEntry = (_b = (_a = changedObject.urlSync).shouldCreateHistoryStep) == null ? void 0 : _b.call(_a, newUrlState);
116
117
  const shouldReplace = shouldCreateHistoryEntry !== true;
117
118
  writeSceneLog("UrlSyncManager", "onStateChange updating URL");
118
- locationService.partial(mappedUpdated, shouldReplace);
119
- this._lastLocation = locationService.getLocation();
119
+ this._locationService.partial(mappedUpdated, shouldReplace);
120
+ this._lastLocation = this._locationService.getLocation();
120
121
  }
121
122
  }
122
123
  getUrlState(root) {
@@ -124,12 +125,13 @@ class UrlSyncManager {
124
125
  }
125
126
  }
126
127
  class UrlParamsCache {
127
- constructor() {
128
+ constructor(locationService) {
129
+ this.locationService = locationService;
128
130
  __privateAdd(this, _cache, void 0);
129
131
  __privateAdd(this, _location, void 0);
130
132
  }
131
133
  getParams() {
132
- const location = locationService.getLocation();
134
+ const location = this.locationService.getLocation();
133
135
  if (__privateGet(this, _location) === location) {
134
136
  return __privateGet(this, _cache);
135
137
  }
@@ -148,13 +150,16 @@ function isUrlStateDifferent(sceneUrlState, currentParams) {
148
150
  }
149
151
  return false;
150
152
  }
151
- function useUrlSyncManager(options) {
153
+ function useUrlSyncManager(options, locationService) {
152
154
  return useMemo(
153
- () => new UrlSyncManager({
154
- updateUrlOnInit: options.updateUrlOnInit,
155
- createBrowserHistorySteps: options.createBrowserHistorySteps
156
- }),
157
- [options.updateUrlOnInit, options.createBrowserHistorySteps]
155
+ () => new UrlSyncManager(
156
+ {
157
+ updateUrlOnInit: options.updateUrlOnInit,
158
+ createBrowserHistorySteps: options.createBrowserHistorySteps
159
+ },
160
+ locationService
161
+ ),
162
+ [options.updateUrlOnInit, options.createBrowserHistorySteps, locationService]
158
163
  );
159
164
  }
160
165