@grafana/scenes 5.4.0--canary.816.9794480649.0 → 5.4.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +40 -0
- package/dist/esm/components/VizPanel/VizPanelRenderer.js +1 -0
- package/dist/esm/components/VizPanel/VizPanelRenderer.js.map +1 -1
- package/dist/esm/components/layout/CSSGrid/SceneCSSGridLayout.js.map +1 -1
- package/dist/esm/components/layout/LazyLoader.js +16 -2
- package/dist/esm/components/layout/LazyLoader.js.map +1 -1
- package/dist/esm/components/layout/grid/SceneGridRow.js +4 -0
- package/dist/esm/components/layout/grid/SceneGridRow.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +26 -10
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,43 @@
|
|
1
|
+
# v5.4.0 (Tue Jul 16 2024)
|
2
|
+
|
3
|
+
#### 🚀 Enhancement
|
4
|
+
|
5
|
+
- Adhoc filters/Group by: Support groups [#816](https://github.com/grafana/scenes/pull/816) ([@ashharrison90](https://github.com/ashharrison90))
|
6
|
+
|
7
|
+
#### Authors: 1
|
8
|
+
|
9
|
+
- Ashley Harrison ([@ashharrison90](https://github.com/ashharrison90))
|
10
|
+
|
11
|
+
---
|
12
|
+
|
13
|
+
# v5.3.9 (Tue Jul 16 2024)
|
14
|
+
|
15
|
+
#### 🐛 Bug Fix
|
16
|
+
|
17
|
+
- Add variable dependency config to SceneGridRow [#832](https://github.com/grafana/scenes/pull/832) ([@kaydelaney](https://github.com/kaydelaney))
|
18
|
+
- VizPanelRenderer: Set attention with onMouseEnter [#831](https://github.com/grafana/scenes/pull/831) ([@tskarhed](https://github.com/tskarhed))
|
19
|
+
- LazyLoader: add use of `useStyles2` and improve name [#825](https://github.com/grafana/scenes/pull/825) ([@svennergr](https://github.com/svennergr))
|
20
|
+
|
21
|
+
#### Authors: 3
|
22
|
+
|
23
|
+
- kay delaney ([@kaydelaney](https://github.com/kaydelaney))
|
24
|
+
- Sven Grossmann ([@svennergr](https://github.com/svennergr))
|
25
|
+
- Tobias Skarhed ([@tskarhed](https://github.com/tskarhed))
|
26
|
+
|
27
|
+
---
|
28
|
+
|
29
|
+
# v5.3.8 (Wed Jul 10 2024)
|
30
|
+
|
31
|
+
#### 🐛 Bug Fix
|
32
|
+
|
33
|
+
- LazyLoader: Hide wrapper if child is hidden [#823](https://github.com/grafana/scenes/pull/823) ([@svennergr](https://github.com/svennergr))
|
34
|
+
|
35
|
+
#### Authors: 1
|
36
|
+
|
37
|
+
- Sven Grossmann ([@svennergr](https://github.com/svennergr))
|
38
|
+
|
39
|
+
---
|
40
|
+
|
1
41
|
# v5.3.7 (Thu Jul 04 2024)
|
2
42
|
|
3
43
|
#### 🐛 Bug Fix
|
@@ -145,6 +145,7 @@ function VizPanelRenderer({ model }) {
|
|
145
145
|
menu: panelMenu,
|
146
146
|
onCancelQuery: model.onCancelQuery,
|
147
147
|
onFocus: setPanelAttention,
|
148
|
+
onMouseEnter: setPanelAttention,
|
148
149
|
onMouseMove: debouncedMouseMove
|
149
150
|
}, (innerWidth, innerHeight) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ErrorBoundaryAlert, {
|
150
151
|
dependencies: [plugin, data]
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"VizPanelRenderer.js","sources":["../../../../src/components/VizPanel/VizPanelRenderer.tsx"],"sourcesContent":["import React, { RefCallback, useCallback, useMemo } from 'react';\nimport { useMeasure } from 'react-use';\n\n// @ts-ignore\nimport { AlertState, GrafanaTheme2, PanelData, PluginContextProvider, SetPanelAttentionEvent } from '@grafana/data';\n\nimport { getAppEvents } from '@grafana/runtime';\nimport { PanelChrome, ErrorBoundaryAlert, PanelContextProvider, Tooltip, useStyles2, Icon } from '@grafana/ui';\n\nimport { sceneGraph } from '../../core/sceneGraph';\nimport { isSceneObject, SceneComponentProps, SceneLayout, SceneObject } from '../../core/types';\n\nimport { VizPanel } from './VizPanel';\nimport { css, cx } from '@emotion/css';\nimport { debounce } from 'lodash';\n\nexport function VizPanelRenderer({ model }: SceneComponentProps<VizPanel>) {\n const {\n title,\n options,\n fieldConfig,\n _pluginLoadError,\n displayMode,\n hoverHeader,\n hoverHeaderOffset,\n menu,\n headerActions,\n titleItems,\n description,\n } = model.useState();\n const [ref, { width, height }] = useMeasure();\n const appEvents = useMemo(() => getAppEvents(), []);\n\n const setPanelAttention = useCallback(\n () => appEvents.publish(new SetPanelAttentionEvent({ panelId: model.state.key })),\n [model.state.key, appEvents]\n );\n const debouncedMouseMove = useMemo(() => debounce(setPanelAttention, 100), [setPanelAttention]);\n\n const plugin = model.getPlugin();\n\n const { dragClass, dragClassCancel } = getDragClasses(model);\n const dataObject = sceneGraph.getData(model);\n\n const rawData = dataObject.useState();\n const dataWithFieldConfig = model.applyFieldConfig(rawData.data!);\n const sceneTimeRange = sceneGraph.getTimeRange(model);\n const timeZone = sceneTimeRange.getTimeZone();\n const timeRange = model.getTimeRange(dataWithFieldConfig);\n\n // Interpolate title\n const titleInterpolated = model.interpolate(title, undefined, 'text');\n\n const alertStateStyles = useStyles2(getAlertStateStyles);\n\n if (!plugin) {\n return <div>Loading plugin panel...</div>;\n }\n\n if (!plugin.panel) {\n return <div>Panel plugin has no panel component</div>;\n }\n\n const PanelComponent = plugin.panel;\n\n // If we have a query runner on our level inform it of the container width (used to set auto max data points)\n if (dataObject && dataObject.setContainerWidth) {\n dataObject.setContainerWidth(Math.round(width));\n }\n\n let titleItemsElement: React.ReactNode[] = [];\n\n if (titleItems) {\n if (Array.isArray(titleItems)) {\n titleItemsElement = titleItemsElement.concat(\n titleItems.map((titleItem) => {\n return <titleItem.Component model={titleItem} key={`${titleItem.state.key}`} />;\n })\n );\n } else if (isSceneObject(titleItems)) {\n titleItemsElement.push(<titleItems.Component model={titleItems} />);\n } else {\n titleItemsElement.push(titleItems);\n }\n }\n\n // If we have local time range show that in panel header\n if (model.state.$timeRange) {\n titleItemsElement.push(<model.state.$timeRange.Component model={model.state.$timeRange} key={model.state.key} />);\n }\n\n if (dataWithFieldConfig.alertState) {\n titleItemsElement.push(\n <Tooltip content={dataWithFieldConfig.alertState.state ?? 'unknown'} key={`alert-states-icon-${model.state.key}`}>\n <PanelChrome.TitleItem\n className={cx({\n [alertStateStyles.ok]: dataWithFieldConfig.alertState.state === AlertState.OK,\n [alertStateStyles.pending]: dataWithFieldConfig.alertState.state === AlertState.Pending,\n [alertStateStyles.alerting]: dataWithFieldConfig.alertState.state === AlertState.Alerting,\n })}\n >\n <Icon\n name={dataWithFieldConfig.alertState.state === 'alerting' ? 'heart-break' : 'heart'}\n className=\"panel-alert-icon\"\n size=\"md\"\n />\n </PanelChrome.TitleItem>\n </Tooltip>\n );\n }\n\n let panelMenu;\n if (menu) {\n panelMenu = <menu.Component model={menu} />;\n }\n\n let actionsElement: React.ReactNode | undefined;\n\n if (headerActions) {\n if (Array.isArray(headerActions)) {\n actionsElement = (\n <>\n {headerActions.map((action) => {\n return <action.Component model={action} key={`${action.state.key}`} />;\n })}\n </>\n );\n } else if (isSceneObject(headerActions)) {\n actionsElement = <headerActions.Component model={headerActions} />;\n } else {\n actionsElement = headerActions;\n }\n }\n\n // Data is always returned. For non-data panels, empty PanelData is returned.\n const data = dataWithFieldConfig!;\n\n const isReadyToRender = dataObject.isDataReadyToDisplay ? dataObject.isDataReadyToDisplay() : true;\n\n const context = model.getPanelContext();\n const panelId = model.getLegacyPanelId();\n\n return (\n <div className={relativeWrapper}>\n <div ref={ref as RefCallback<HTMLDivElement>} className={absoluteWrapper} data-viz-panel-key={model.state.key}>\n {width > 0 && height > 0 && (\n <PanelChrome\n title={titleInterpolated}\n description={description?.trim() ? model.getDescription : undefined}\n loadingState={data.state}\n statusMessage={getChromeStatusMessage(data, _pluginLoadError)}\n statusMessageOnClick={model.onStatusMessageClick}\n width={width}\n height={height}\n displayMode={displayMode}\n hoverHeader={hoverHeader}\n hoverHeaderOffset={hoverHeaderOffset}\n titleItems={titleItemsElement}\n dragClass={dragClass}\n actions={actionsElement}\n dragClassCancel={dragClassCancel}\n padding={plugin.noPadding ? 'none' : 'md'}\n menu={panelMenu}\n onCancelQuery={model.onCancelQuery}\n // @ts-ignore\n onFocus={setPanelAttention}\n onMouseMove={debouncedMouseMove}\n >\n {(innerWidth, innerHeight) => (\n <>\n <ErrorBoundaryAlert dependencies={[plugin, data]}>\n <PluginContextProvider meta={plugin.meta}>\n <PanelContextProvider value={context}>\n {isReadyToRender && (\n <PanelComponent\n id={panelId}\n data={data}\n title={title}\n timeRange={timeRange}\n timeZone={timeZone}\n options={options}\n fieldConfig={fieldConfig}\n transparent={false}\n width={innerWidth}\n height={innerHeight}\n renderCounter={0}\n replaceVariables={model.interpolate}\n onOptionsChange={model.onOptionsChange}\n onFieldConfigChange={model.onFieldConfigChange}\n onChangeTimeRange={model.onTimeRangeChange}\n eventBus={appEvents}\n />\n )}\n </PanelContextProvider>\n </PluginContextProvider>\n </ErrorBoundaryAlert>\n </>\n )}\n </PanelChrome>\n )}\n </div>\n </div>\n );\n}\n\nfunction getDragClasses(panel: VizPanel) {\n const parentLayout = sceneGraph.getLayout(panel);\n const isDraggable = parentLayout?.isDraggable();\n\n if (!parentLayout || !isDraggable || itemDraggingDisabled(panel, parentLayout)) {\n return { dragClass: '', dragClassCancel: '' };\n }\n\n return { dragClass: parentLayout.getDragClass?.(), dragClassCancel: parentLayout?.getDragClassCancel?.() };\n}\n\n/**\n * Walks up the parent chain until it hits the layout object, trying to find the closest SceneGridItemLike ancestor.\n * It is not always the direct parent, because the VizPanel can be wrapped in other objects.\n */\nfunction itemDraggingDisabled(item: SceneObject, layout: SceneLayout) {\n let ancestor = item.parent;\n\n while (ancestor && ancestor !== layout) {\n if ('isDraggable' in ancestor.state && ancestor.state.isDraggable === false) {\n return true;\n }\n\n ancestor = ancestor.parent;\n }\n\n return false;\n}\n\nfunction getChromeStatusMessage(data: PanelData, pluginLoadingError: string | undefined) {\n if (pluginLoadingError) {\n return pluginLoadingError;\n }\n\n let message = data.error ? data.error.message : undefined;\n\n // Handling multiple errors with a single string until we integrate VizPanel with inspector\n if (data.errors) {\n message = data.errors.map((e) => e.message).join(', ');\n }\n return message;\n}\n\nconst relativeWrapper = css({\n position: 'relative',\n width: '100%',\n height: '100%',\n});\n\n/**\n * Sadly this this absolute wrapper is needed for the panel to adopt smaller sizes.\n * The combo of useMeasure and PanelChrome makes the panel take up the width it get's but that makes it impossible to\n * Then adapt to smaller space (say resizing the browser window or undocking menu).\n */\nconst absoluteWrapper = css({\n position: 'absolute',\n width: '100%',\n height: '100%',\n});\n\nconst getAlertStateStyles = (theme: GrafanaTheme2) => {\n return {\n ok: css({\n color: theme.colors.success.text,\n }),\n pending: css({\n color: theme.colors.warning.text,\n }),\n alerting: css({\n color: theme.colors.error.text,\n }),\n };\n};\n"],"names":[],"mappings":";;;;;;;;;;AAgBgB,SAAA,gBAAA,CAAiB,EAAE,KAAA,EAAwC,EAAA;AAhB3E,EAAA,IAAA,EAAA,CAAA;AAiBE,EAAM,MAAA;AAAA,IACJ,KAAA;AAAA,IACA,OAAA;AAAA,IACA,WAAA;AAAA,IACA,gBAAA;AAAA,IACA,WAAA;AAAA,IACA,WAAA;AAAA,IACA,iBAAA;AAAA,IACA,IAAA;AAAA,IACA,aAAA;AAAA,IACA,UAAA;AAAA,IACA,WAAA;AAAA,GACF,GAAI,MAAM,QAAS,EAAA,CAAA;AACnB,EAAA,MAAM,CAAC,GAAK,EAAA,EAAE,OAAO,MAAO,EAAC,IAAI,UAAW,EAAA,CAAA;AAC5C,EAAA,MAAM,YAAY,OAAQ,CAAA,MAAM,YAAa,EAAA,EAAG,EAAE,CAAA,CAAA;AAElD,EAAA,MAAM,iBAAoB,GAAA,WAAA;AAAA,IACxB,MAAM,SAAU,CAAA,OAAA,CAAQ,IAAI,sBAAA,CAAuB,EAAE,OAAA,EAAS,KAAM,CAAA,KAAA,CAAM,GAAI,EAAC,CAAC,CAAA;AAAA,IAChF,CAAC,KAAA,CAAM,KAAM,CAAA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,IACD,UAAU,GAAI,CAAA;AAAA,MACZ,KAAA,EAAO,KAAM,CAAA,MAAA,CAAO,KAAM,CAAA,IAAA;AAAA,KAC3B,CAAA;AAAA,GACH,CAAA;AACF,CAAA;;;;"}
|
1
|
+
{"version":3,"file":"VizPanelRenderer.js","sources":["../../../../src/components/VizPanel/VizPanelRenderer.tsx"],"sourcesContent":["import React, { RefCallback, useCallback, useMemo } from 'react';\nimport { useMeasure } from 'react-use';\n\n// @ts-ignore\nimport { AlertState, GrafanaTheme2, PanelData, PluginContextProvider, SetPanelAttentionEvent } from '@grafana/data';\n\nimport { getAppEvents } from '@grafana/runtime';\nimport { PanelChrome, ErrorBoundaryAlert, PanelContextProvider, Tooltip, useStyles2, Icon } from '@grafana/ui';\n\nimport { sceneGraph } from '../../core/sceneGraph';\nimport { isSceneObject, SceneComponentProps, SceneLayout, SceneObject } from '../../core/types';\n\nimport { VizPanel } from './VizPanel';\nimport { css, cx } from '@emotion/css';\nimport { debounce } from 'lodash';\n\nexport function VizPanelRenderer({ model }: SceneComponentProps<VizPanel>) {\n const {\n title,\n options,\n fieldConfig,\n _pluginLoadError,\n displayMode,\n hoverHeader,\n hoverHeaderOffset,\n menu,\n headerActions,\n titleItems,\n description,\n } = model.useState();\n const [ref, { width, height }] = useMeasure();\n const appEvents = useMemo(() => getAppEvents(), []);\n\n const setPanelAttention = useCallback(\n () => appEvents.publish(new SetPanelAttentionEvent({ panelId: model.state.key })),\n [model.state.key, appEvents]\n );\n const debouncedMouseMove = useMemo(() => debounce(setPanelAttention, 100), [setPanelAttention]);\n\n const plugin = model.getPlugin();\n\n const { dragClass, dragClassCancel } = getDragClasses(model);\n const dataObject = sceneGraph.getData(model);\n\n const rawData = dataObject.useState();\n const dataWithFieldConfig = model.applyFieldConfig(rawData.data!);\n const sceneTimeRange = sceneGraph.getTimeRange(model);\n const timeZone = sceneTimeRange.getTimeZone();\n const timeRange = model.getTimeRange(dataWithFieldConfig);\n\n // Interpolate title\n const titleInterpolated = model.interpolate(title, undefined, 'text');\n\n const alertStateStyles = useStyles2(getAlertStateStyles);\n\n if (!plugin) {\n return <div>Loading plugin panel...</div>;\n }\n\n if (!plugin.panel) {\n return <div>Panel plugin has no panel component</div>;\n }\n\n const PanelComponent = plugin.panel;\n\n // If we have a query runner on our level inform it of the container width (used to set auto max data points)\n if (dataObject && dataObject.setContainerWidth) {\n dataObject.setContainerWidth(Math.round(width));\n }\n\n let titleItemsElement: React.ReactNode[] = [];\n\n if (titleItems) {\n if (Array.isArray(titleItems)) {\n titleItemsElement = titleItemsElement.concat(\n titleItems.map((titleItem) => {\n return <titleItem.Component model={titleItem} key={`${titleItem.state.key}`} />;\n })\n );\n } else if (isSceneObject(titleItems)) {\n titleItemsElement.push(<titleItems.Component model={titleItems} />);\n } else {\n titleItemsElement.push(titleItems);\n }\n }\n\n // If we have local time range show that in panel header\n if (model.state.$timeRange) {\n titleItemsElement.push(<model.state.$timeRange.Component model={model.state.$timeRange} key={model.state.key} />);\n }\n\n if (dataWithFieldConfig.alertState) {\n titleItemsElement.push(\n <Tooltip content={dataWithFieldConfig.alertState.state ?? 'unknown'} key={`alert-states-icon-${model.state.key}`}>\n <PanelChrome.TitleItem\n className={cx({\n [alertStateStyles.ok]: dataWithFieldConfig.alertState.state === AlertState.OK,\n [alertStateStyles.pending]: dataWithFieldConfig.alertState.state === AlertState.Pending,\n [alertStateStyles.alerting]: dataWithFieldConfig.alertState.state === AlertState.Alerting,\n })}\n >\n <Icon\n name={dataWithFieldConfig.alertState.state === 'alerting' ? 'heart-break' : 'heart'}\n className=\"panel-alert-icon\"\n size=\"md\"\n />\n </PanelChrome.TitleItem>\n </Tooltip>\n );\n }\n\n let panelMenu;\n if (menu) {\n panelMenu = <menu.Component model={menu} />;\n }\n\n let actionsElement: React.ReactNode | undefined;\n\n if (headerActions) {\n if (Array.isArray(headerActions)) {\n actionsElement = (\n <>\n {headerActions.map((action) => {\n return <action.Component model={action} key={`${action.state.key}`} />;\n })}\n </>\n );\n } else if (isSceneObject(headerActions)) {\n actionsElement = <headerActions.Component model={headerActions} />;\n } else {\n actionsElement = headerActions;\n }\n }\n\n // Data is always returned. For non-data panels, empty PanelData is returned.\n const data = dataWithFieldConfig!;\n\n const isReadyToRender = dataObject.isDataReadyToDisplay ? dataObject.isDataReadyToDisplay() : true;\n\n const context = model.getPanelContext();\n const panelId = model.getLegacyPanelId();\n\n return (\n <div className={relativeWrapper}>\n <div ref={ref as RefCallback<HTMLDivElement>} className={absoluteWrapper} data-viz-panel-key={model.state.key}>\n {width > 0 && height > 0 && (\n <PanelChrome\n title={titleInterpolated}\n description={description?.trim() ? model.getDescription : undefined}\n loadingState={data.state}\n statusMessage={getChromeStatusMessage(data, _pluginLoadError)}\n statusMessageOnClick={model.onStatusMessageClick}\n width={width}\n height={height}\n displayMode={displayMode}\n hoverHeader={hoverHeader}\n hoverHeaderOffset={hoverHeaderOffset}\n titleItems={titleItemsElement}\n dragClass={dragClass}\n actions={actionsElement}\n dragClassCancel={dragClassCancel}\n padding={plugin.noPadding ? 'none' : 'md'}\n menu={panelMenu}\n onCancelQuery={model.onCancelQuery}\n // @ts-ignore\n onFocus={setPanelAttention}\n onMouseEnter={setPanelAttention}\n onMouseMove={debouncedMouseMove}\n >\n {(innerWidth, innerHeight) => (\n <>\n <ErrorBoundaryAlert dependencies={[plugin, data]}>\n <PluginContextProvider meta={plugin.meta}>\n <PanelContextProvider value={context}>\n {isReadyToRender && (\n <PanelComponent\n id={panelId}\n data={data}\n title={title}\n timeRange={timeRange}\n timeZone={timeZone}\n options={options}\n fieldConfig={fieldConfig}\n transparent={false}\n width={innerWidth}\n height={innerHeight}\n renderCounter={0}\n replaceVariables={model.interpolate}\n onOptionsChange={model.onOptionsChange}\n onFieldConfigChange={model.onFieldConfigChange}\n onChangeTimeRange={model.onTimeRangeChange}\n eventBus={appEvents}\n />\n )}\n </PanelContextProvider>\n </PluginContextProvider>\n </ErrorBoundaryAlert>\n </>\n )}\n </PanelChrome>\n )}\n </div>\n </div>\n );\n}\n\nfunction getDragClasses(panel: VizPanel) {\n const parentLayout = sceneGraph.getLayout(panel);\n const isDraggable = parentLayout?.isDraggable();\n\n if (!parentLayout || !isDraggable || itemDraggingDisabled(panel, parentLayout)) {\n return { dragClass: '', dragClassCancel: '' };\n }\n\n return { dragClass: parentLayout.getDragClass?.(), dragClassCancel: parentLayout?.getDragClassCancel?.() };\n}\n\n/**\n * Walks up the parent chain until it hits the layout object, trying to find the closest SceneGridItemLike ancestor.\n * It is not always the direct parent, because the VizPanel can be wrapped in other objects.\n */\nfunction itemDraggingDisabled(item: SceneObject, layout: SceneLayout) {\n let ancestor = item.parent;\n\n while (ancestor && ancestor !== layout) {\n if ('isDraggable' in ancestor.state && ancestor.state.isDraggable === false) {\n return true;\n }\n\n ancestor = ancestor.parent;\n }\n\n return false;\n}\n\nfunction getChromeStatusMessage(data: PanelData, pluginLoadingError: string | undefined) {\n if (pluginLoadingError) {\n return pluginLoadingError;\n }\n\n let message = data.error ? data.error.message : undefined;\n\n // Handling multiple errors with a single string until we integrate VizPanel with inspector\n if (data.errors) {\n message = data.errors.map((e) => e.message).join(', ');\n }\n return message;\n}\n\nconst relativeWrapper = css({\n position: 'relative',\n width: '100%',\n height: '100%',\n});\n\n/**\n * Sadly this this absolute wrapper is needed for the panel to adopt smaller sizes.\n * The combo of useMeasure and PanelChrome makes the panel take up the width it get's but that makes it impossible to\n * Then adapt to smaller space (say resizing the browser window or undocking menu).\n */\nconst absoluteWrapper = css({\n position: 'absolute',\n width: '100%',\n height: '100%',\n});\n\nconst getAlertStateStyles = (theme: GrafanaTheme2) => {\n return {\n ok: css({\n color: theme.colors.success.text,\n }),\n pending: css({\n color: theme.colors.warning.text,\n }),\n alerting: css({\n color: theme.colors.error.text,\n }),\n };\n};\n"],"names":[],"mappings":";;;;;;;;;;AAgBgB,SAAA,gBAAA,CAAiB,EAAE,KAAA,EAAwC,EAAA;AAhB3E,EAAA,IAAA,EAAA,CAAA;AAiBE,EAAM,MA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AAA,GACvD;AACA,EAAO,OAAA,OAAA,CAAA;AACT,CAAA;AAEA,MAAM,kBAAkB,GAAI,CAAA;AAAA,EAC1B,QAAU,EAAA,UAAA;AAAA,EACV,KAAO,EAAA,MAAA;AAAA,EACP,MAAQ,EAAA,MAAA;AACV,CAAC,CAAA,CAAA;AAOD,MAAM,kBAAkB,GAAI,CAAA;AAAA,EAC1B,QAAU,EAAA,UAAA;AAAA,EACV,KAAO,EAAA,MAAA;AAAA,EACP,MAAQ,EAAA,MAAA;AACV,CAAC,CAAA,CAAA;AAED,MAAM,mBAAA,GAAsB,CAAC,KAAyB,KAAA;AACpD,EAAO,OAAA;AAAA,IACL,IAAI,GAAI,CAAA;AAAA,MACN,KAAA,EAAO,KAAM,CAAA,MAAA,CAAO,OAAQ,CAAA,IAAA;AAAA,KAC7B,CAAA;AAAA,IACD,SAAS,GAAI,CAAA;AAAA,MACX,KAAA,EAAO,KAAM,CAAA,MAAA,CAAO,OAAQ,CAAA,IAAA;AAAA,KAC7B,CAAA;AAAA,IACD,UAAU,GAAI,CAAA;AAAA,MACZ,KAAA,EAAO,KAAM,CAAA,MAAA,CAAO,KAAM,CAAA,IAAA;AAAA,KAC3B,CAAA;AAAA,GACH,CAAA;AACF,CAAA;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SceneCSSGridLayout.js","sources":["../../../../../src/components/layout/CSSGrid/SceneCSSGridLayout.tsx"],"sourcesContent":["import { css, CSSObject } from '@emotion/css';\nimport React, { ComponentType, CSSProperties, useMemo } from 'react';\n\nimport { SceneObjectBase } from '../../../core/SceneObjectBase';\nimport { SceneComponentProps, SceneLayout, SceneObjectState, SceneObject } from '../../../core/types';\nimport { config } from '@grafana/runtime';\nimport { LazyLoader } from '../LazyLoader';\n\nexport interface SceneCSSGridLayoutState extends SceneObjectState, SceneCSSGridLayoutOptions {\n children: Array<SceneCSSGridItem | SceneObject>;\n /**\n * True when the item should rendered but not visible.\n * Useful for conditional display of layout items\n */\n isHidden?: boolean;\n /**\n * For media query for sceens smaller than md breakpoint\n */\n md?: SceneCSSGridLayoutOptions;\n /** True when the items should be lazy loaded */\n isLazy?: boolean;\n}\n\nexport interface SceneCSSGridLayoutOptions {\n /**\n * Useful for setting a height on items without specifying how many rows there will be.\n * Defaults to 320px\n */\n autoRows?: CSSProperties['gridAutoRows'];\n /**\n * This overrides the autoRows with a specific row template.\n */\n templateRows?: CSSProperties['gridTemplateRows'];\n /**\n * Defaults to repeat(auto-fit, minmax(400px, 1fr)). This pattern us useful for equally sized items with a min width of 400px\n * and dynamic max width split equally among columns.\n */\n templateColumns: CSSProperties['gridTemplateColumns'];\n /** In Grafana design system grid units (8px) */\n rowGap: number;\n /** In Grafana design system grid units (8px) */\n columnGap: number;\n justifyItems?: CSSProperties['justifyItems'];\n alignItems?: CSSProperties['alignItems'];\n justifyContent?: CSSProperties['justifyContent'];\n}\n\nexport class SceneCSSGridLayout extends SceneObjectBase<SceneCSSGridLayoutState> implements SceneLayout {\n public static Component = SceneCSSGridLayoutRenderer;\n\n public constructor(state: Partial<SceneCSSGridLayoutState>) {\n super({\n rowGap: 1,\n columnGap: 1,\n templateColumns: 'repeat(auto-fit, minmax(400px, 1fr))',\n autoRows: state.autoRows ?? `320px`,\n children: state.children ?? [],\n ...state,\n });\n }\n\n public isDraggable(): boolean {\n return false;\n }\n}\n\nfunction SceneCSSGridLayoutRenderer({ model }: SceneCSSGridItemRenderProps<SceneCSSGridLayout>) {\n const { children, isHidden, isLazy } = model.useState();\n const style = useLayoutStyle(model.state);\n\n if (isHidden) {\n return null;\n }\n\n return (\n <div className={style}>\n {children.map((item) => {\n const Component = item.Component as ComponentType<SceneCSSGridItemRenderProps<SceneObject>>;\n if (isLazy) {\n return (\n <LazyLoader key={item.state.key!} className={style}>\n <Component key={item.state.key} model={item} parentState={model.state} />\n </LazyLoader>\n );\n }\n return <Component key={item.state.key} model={item} parentState={model.state} />;\n })}\n </div>\n );\n}\n\nexport interface SceneCSSGridItemPlacement {\n /**\n * True when the item should rendered but not visible.\n * Useful for conditional display of layout items\n */\n isHidden?: boolean;\n /**\n * Useful for making content span across multiple rows or columns\n */\n gridColumn?: CSSProperties['gridColumn'];\n gridRow?: CSSProperties['gridRow'];\n}\n\nexport interface SceneCSSGridItemState extends SceneCSSGridItemPlacement, SceneObjectState {\n body: SceneObject | undefined;\n}\n\ninterface SceneCSSGridItemRenderProps<T> extends SceneComponentProps<T> {\n parentState?: SceneCSSGridItemPlacement;\n}\n\nexport class SceneCSSGridItem extends SceneObjectBase<SceneCSSGridItemState> {\n public static Component = SceneCSSGridItemRenderer;\n}\n\nfunction SceneCSSGridItemRenderer({ model, parentState }: SceneCSSGridItemRenderProps<SceneCSSGridItem>) {\n if (!parentState) {\n throw new Error('SceneCSSGridItem must be a child of SceneCSSGridLayout');\n }\n\n const { body, isHidden } = model.useState();\n const style = useItemStyle(model.state);\n\n if (!body || isHidden) {\n return null;\n }\n\n return (\n <div className={style}>\n <body.Component model={body} />\n </div>\n );\n}\n\nfunction useLayoutStyle(state: SceneCSSGridLayoutState) {\n return useMemo(() => {\n const {} = state;\n // only need breakpoints so accessing theme from config instead of context is ok\n const style: CSSObject = {};\n const theme = config.theme2;\n\n style.display = 'grid';\n style.gridTemplateColumns = state.templateColumns;\n style.gridTemplateRows = state.templateRows || 'unset';\n style.gridAutoRows = state.autoRows || 'unset';\n style.rowGap = theme.spacing(state.rowGap ?? 1);\n style.columnGap = theme.spacing(state.columnGap ?? 1);\n style.justifyItems = state.justifyItems || 'unset';\n style.alignItems = state.alignItems || 'unset';\n style.justifyContent = state.justifyContent || 'unset';\n style.flexGrow = 1;\n\n if (state.md) {\n style[theme.breakpoints.down('md')] = {\n gridTemplateRows: state.md?.templateRows,\n gridTemplateColumns: state.md?.templateColumns,\n rowGap: state.md.rowGap ? theme.spacing(state.md?.rowGap ?? 1) : undefined,\n columnGap: state.md.columnGap ? theme.spacing(state.md?.rowGap ?? 1) : undefined,\n justifyItems: state.md?.justifyItems,\n alignItems: state.md?.alignItems,\n justifyContent: state.md?.justifyContent,\n };\n }\n\n return css(style);\n }, [state]);\n}\n\nfunction useItemStyle(state: SceneCSSGridItemState) {\n return useMemo(() => {\n const style: CSSObject = {};\n\n style.gridColumn = state.gridColumn || 'unset';\n style.gridRow = state.gridRow || 'unset';\n // Needed for VizPanel\n style.position = 'relative';\n\n return css(style);\n }, [state]);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA+CO,MAAM,2BAA2B,eAAgE,CAAA;AAAA,EAG/F,YAAY,KAAyC,EAAA;AAlD9D,IAAA,IAAA,EAAA,EAAA,EAAA,CAAA;AAmDI,IAAM,KAAA,CAAA,cAAA,CAAA;AAAA,MACJ,MAAQ,EAAA,CAAA;AAAA,MACR,SAAW,EAAA,CAAA;AAAA,MACX,eAAiB,EAAA,sCAAA;AAAA,MACjB,QAAA,EAAA,CAAU,EAAM,GAAA,KAAA,CAAA,QAAA,KAAN,IAAkB,GAAA,EAAA,GAAA,CAAA,KAAA,CAAA;AAAA,MAC5B,QAAU,EAAA,CAAA,EAAA,GAAA,KAAA,CAAM,QAAN,KAAA,IAAA,GAAA,EAAA,GAAkB,EAAC;AAAA,KAAA,EAC1B,KACJ,CAAA,CAAA,CAAA;AAAA,GACH;AAAA,EAEO,WAAuB,GAAA;AAC5B,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AACF,CAAA;AAjBa,kBAAA,CACG,SAAY,GAAA,0BAAA,CAAA;AAkB5B,SAAS,0BAAA,CAA2B,EAAE,KAAA,EAA0D,EAAA;AAC9F,EAAA,MAAM,EAAE,QAAU,EAAA,QAAA,EAAU,MAAO,EAAA,GAAI,MAAM,QAAS,EAAA,CAAA;AACtD,EAAM,MAAA,KAAA,GAAQ,cAAe,CAAA,KAAA,CAAM,KAAK,CAAA,CAAA;AAExC,EAAA,IAAI,QAAU,EAAA;AACZ,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAA,uBACG,KAAA,CAAA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N,IAAU,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,cAAA;AAAA,OAC5B,CAAA;AAAA,KACF;AAEA,IAAA,OAAO,IAAI,KAAK,CAAA,CAAA;AAAA,GAClB,EAAG,CAAC,KAAK,CAAC,CAAA,CAAA;AACZ,CAAA;AAEA,SAAS,aAAa,KAA8B,EAAA;AAClD,EAAA,OAAO,QAAQ,MAAM;AACnB,IAAA,MAAM,QAAmB,EAAC,CAAA;AAE1B,IAAM,KAAA,CAAA,UAAA,GAAa,MAAM,UAAc,IAAA,OAAA,CAAA;AACvC,IAAM,KAAA,CAAA,OAAA,GAAU,MAAM,OAAW,IAAA,OAAA,CAAA;AAEjC,IAAA,KAAA,CAAM,QAAW,GAAA,UAAA,CAAA;AAEjB,IAAA,OAAO,IAAI,KAAK,CAAA,CAAA;AAAA,GAClB,EAAG,CAAC,KAAK,CAAC,CAAA,CAAA;AACZ;;;;"}
|
1
|
+
{"version":3,"file":"SceneCSSGridLayout.js","sources":["../../../../../src/components/layout/CSSGrid/SceneCSSGridLayout.tsx"],"sourcesContent":["import { css, CSSObject } from '@emotion/css';\nimport React, { ComponentType, CSSProperties, useMemo } from 'react';\n\nimport { SceneObjectBase } from '../../../core/SceneObjectBase';\nimport { SceneComponentProps, SceneLayout, SceneObjectState, SceneObject } from '../../../core/types';\nimport { config } from '@grafana/runtime';\nimport { LazyLoader } from '../LazyLoader';\n\nexport interface SceneCSSGridLayoutState extends SceneObjectState, SceneCSSGridLayoutOptions {\n children: Array<SceneCSSGridItem | SceneObject>;\n /**\n * True when the item should rendered but not visible.\n * Useful for conditional display of layout items\n */\n isHidden?: boolean;\n /**\n * For media query for sceens smaller than md breakpoint\n */\n md?: SceneCSSGridLayoutOptions;\n /** True when the items should be lazy loaded */\n isLazy?: boolean;\n}\n\nexport interface SceneCSSGridLayoutOptions {\n /**\n * Useful for setting a height on items without specifying how many rows there will be.\n * Defaults to 320px\n */\n autoRows?: CSSProperties['gridAutoRows'];\n /**\n * This overrides the autoRows with a specific row template.\n */\n templateRows?: CSSProperties['gridTemplateRows'];\n /**\n * Defaults to repeat(auto-fit, minmax(400px, 1fr)). This pattern us useful for equally sized items with a min width of 400px\n * and dynamic max width split equally among columns.\n */\n templateColumns: CSSProperties['gridTemplateColumns'];\n /** In Grafana design system grid units (8px) */\n rowGap: number;\n /** In Grafana design system grid units (8px) */\n columnGap: number;\n justifyItems?: CSSProperties['justifyItems'];\n alignItems?: CSSProperties['alignItems'];\n justifyContent?: CSSProperties['justifyContent'];\n}\n\nexport class SceneCSSGridLayout extends SceneObjectBase<SceneCSSGridLayoutState> implements SceneLayout {\n public static Component = SceneCSSGridLayoutRenderer;\n\n public constructor(state: Partial<SceneCSSGridLayoutState>) {\n super({\n rowGap: 1,\n columnGap: 1,\n templateColumns: 'repeat(auto-fit, minmax(400px, 1fr))',\n autoRows: state.autoRows ?? `320px`,\n children: state.children ?? [],\n ...state,\n });\n }\n\n public isDraggable(): boolean {\n return false;\n }\n}\n\nfunction SceneCSSGridLayoutRenderer({ model }: SceneCSSGridItemRenderProps<SceneCSSGridLayout>) {\n const { children, isHidden, isLazy } = model.useState();\n const style = useLayoutStyle(model.state);\n\n if (isHidden) {\n return null;\n }\n\n return (\n <div className={style}>\n {children.map((item) => {\n const Component = item.Component as ComponentType<SceneCSSGridItemRenderProps<SceneObject>>;\n \n if (isLazy) {\n return (\n <LazyLoader key={item.state.key!} className={style}>\n <Component key={item.state.key} model={item} parentState={model.state} />\n </LazyLoader>\n );\n }\n return <Component key={item.state.key} model={item} parentState={model.state} />;\n })}\n </div>\n );\n}\n\nexport interface SceneCSSGridItemPlacement {\n /**\n * True when the item should rendered but not visible.\n * Useful for conditional display of layout items\n */\n isHidden?: boolean;\n /**\n * Useful for making content span across multiple rows or columns\n */\n gridColumn?: CSSProperties['gridColumn'];\n gridRow?: CSSProperties['gridRow'];\n}\n\nexport interface SceneCSSGridItemState extends SceneCSSGridItemPlacement, SceneObjectState {\n body: SceneObject | undefined;\n}\n\ninterface SceneCSSGridItemRenderProps<T> extends SceneComponentProps<T> {\n parentState?: SceneCSSGridItemPlacement;\n}\n\nexport class SceneCSSGridItem extends SceneObjectBase<SceneCSSGridItemState> {\n public static Component = SceneCSSGridItemRenderer;\n}\n\nfunction SceneCSSGridItemRenderer({ model, parentState }: SceneCSSGridItemRenderProps<SceneCSSGridItem>) {\n if (!parentState) {\n throw new Error('SceneCSSGridItem must be a child of SceneCSSGridLayout');\n }\n\n const { body, isHidden } = model.useState();\n const style = useItemStyle(model.state);\n\n if (!body || isHidden) {\n return null;\n }\n\n return (\n <div className={style}>\n <body.Component model={body} />\n </div>\n );\n}\n\nfunction useLayoutStyle(state: SceneCSSGridLayoutState) {\n return useMemo(() => {\n const {} = state;\n // only need breakpoints so accessing theme from config instead of context is ok\n const style: CSSObject = {};\n const theme = config.theme2;\n\n style.display = 'grid';\n style.gridTemplateColumns = state.templateColumns;\n style.gridTemplateRows = state.templateRows || 'unset';\n style.gridAutoRows = state.autoRows || 'unset';\n style.rowGap = theme.spacing(state.rowGap ?? 1);\n style.columnGap = theme.spacing(state.columnGap ?? 1);\n style.justifyItems = state.justifyItems || 'unset';\n style.alignItems = state.alignItems || 'unset';\n style.justifyContent = state.justifyContent || 'unset';\n style.flexGrow = 1;\n\n if (state.md) {\n style[theme.breakpoints.down('md')] = {\n gridTemplateRows: state.md?.templateRows,\n gridTemplateColumns: state.md?.templateColumns,\n rowGap: state.md.rowGap ? theme.spacing(state.md?.rowGap ?? 1) : undefined,\n columnGap: state.md.columnGap ? theme.spacing(state.md?.rowGap ?? 1) : undefined,\n justifyItems: state.md?.justifyItems,\n alignItems: state.md?.alignItems,\n justifyContent: state.md?.justifyContent,\n };\n }\n\n return css(style);\n }, [state]);\n}\n\nfunction useItemStyle(state: SceneCSSGridItemState) {\n return useMemo(() => {\n const style: CSSObject = {};\n\n style.gridColumn = state.gridColumn || 'unset';\n style.gridRow = state.gridRow || 'unset';\n // Needed for VizPanel\n style.position = 'relative';\n\n return css(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AAO,QAAQ,MAAM;AACnB,IAAA,MAAM,QAAmB,EAAC,CAAA;AAE1B,IAAM,KAAA,CAAA,UAAA,GAAa,MAAM,UAAc,IAAA,OAAA,CAAA;AACvC,IAAM,KAAA,CAAA,OAAA,GAAU,MAAM,OAAW,IAAA,OAAA,CAAA;AAEjC,IAAA,KAAA,CAAM,QAAW,GAAA,UAAA,CAAA;AAEjB,IAAA,OAAO,IAAI,KAAK,CAAA,CAAA;AAAA,GAClB,EAAG,CAAC,KAAK,CAAC,CAAA,CAAA;AACZ;;;;"}
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import React, { useState, useRef, useImperativeHandle } from 'react';
|
2
2
|
import { useEffectOnce } from 'react-use';
|
3
3
|
import { uniqueId } from 'lodash';
|
4
|
+
import { css } from '@emotion/css';
|
5
|
+
import { useStyles2 } from '@grafana/ui';
|
4
6
|
|
5
7
|
var __defProp = Object.defineProperty;
|
6
8
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
@@ -38,8 +40,9 @@ function useUniqueId() {
|
|
38
40
|
}
|
39
41
|
const LazyLoader = React.forwardRef(
|
40
42
|
(_a, ref) => {
|
41
|
-
var _b = _a, { children, onLoad, onChange } = _b, rest = __objRest(_b, ["children", "onLoad", "onChange"]);
|
43
|
+
var _b = _a, { children, onLoad, onChange, className } = _b, rest = __objRest(_b, ["children", "onLoad", "onChange", "className"]);
|
42
44
|
const id = useUniqueId();
|
45
|
+
const { hideEmpty } = useStyles2(getStyles);
|
43
46
|
const [loaded, setLoaded] = useState(false);
|
44
47
|
const [isInView, setIsInView] = useState(false);
|
45
48
|
const innerRef = useRef(null);
|
@@ -65,12 +68,23 @@ const LazyLoader = React.forwardRef(
|
|
65
68
|
}
|
66
69
|
};
|
67
70
|
});
|
71
|
+
const classes = `${loaded ? hideEmpty : ""} ${className}`;
|
68
72
|
return /* @__PURE__ */ React.createElement("div", __spreadValues({
|
69
73
|
id,
|
70
|
-
ref: innerRef
|
74
|
+
ref: innerRef,
|
75
|
+
className: classes
|
71
76
|
}, rest), loaded && (typeof children === "function" ? children({ isInView }) : children));
|
72
77
|
}
|
73
78
|
);
|
79
|
+
function getStyles() {
|
80
|
+
return {
|
81
|
+
hideEmpty: css({
|
82
|
+
"&:empty": {
|
83
|
+
display: "none"
|
84
|
+
}
|
85
|
+
})
|
86
|
+
};
|
87
|
+
}
|
74
88
|
LazyLoader.displayName = "LazyLoader";
|
75
89
|
LazyLoader.callbacks = {};
|
76
90
|
LazyLoader.addCallback = (id, c) => LazyLoader.callbacks[id] = c;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"LazyLoader.js","sources":["../../../../src/components/layout/LazyLoader.tsx"],"sourcesContent":["import React, { ForwardRefExoticComponent, useImperativeHandle, useRef, useState } from 'react';\nimport { useEffectOnce } from 'react-use';\n\nimport { uniqueId } from 'lodash';\n\nexport function useUniqueId(): string {\n const idRefLazy = useRef<string | undefined>(undefined);\n idRefLazy.current ??= uniqueId();\n return idRefLazy.current;\n}\n\nexport interface Props extends Omit<React.HTMLProps<HTMLDivElement>, 'onChange' | 'children'> {\n children: React.ReactNode | (({ isInView }: { isInView: boolean }) => React.ReactNode);\n key: string;\n onLoad?: () => void;\n onChange?: (isInView: boolean) => void;\n}\n\nexport interface LazyLoaderType extends ForwardRefExoticComponent<Props> {\n addCallback: (id: string, c: (e: IntersectionObserverEntry) => void) => void;\n callbacks: Record<string, (e: IntersectionObserverEntry) => void>;\n observer: IntersectionObserver;\n}\n\nexport const LazyLoader: LazyLoaderType = React.forwardRef<HTMLDivElement, Props>(\n ({ children, onLoad, onChange, ...rest }, ref) => {\n const id = useUniqueId();\n const [loaded, setLoaded] = useState(false);\n const [isInView, setIsInView] = useState(false);\n const innerRef = useRef<HTMLDivElement>(null);\n\n useImperativeHandle(ref, () => innerRef.current!);\n\n useEffectOnce(() => {\n LazyLoader.addCallback(id, (entry) => {\n if (!loaded && entry.isIntersecting) {\n setLoaded(true);\n onLoad?.();\n }\n\n setIsInView(entry.isIntersecting);\n onChange?.(entry.isIntersecting);\n });\n\n const wrapperEl = innerRef.current;\n\n if (wrapperEl) {\n LazyLoader.observer.observe(wrapperEl);\n }\n\n return () => {\n delete LazyLoader.callbacks[id];\n wrapperEl && LazyLoader.observer.unobserve(wrapperEl);\n if (Object.keys(LazyLoader.callbacks).length === 0) {\n LazyLoader.observer.disconnect();\n }\n };\n });\n\n return (\n <div id={id} ref={innerRef} {...rest}>\n {loaded && (typeof children === 'function' ? children({ isInView }) : children)}\n </div>\n );\n }\n) as LazyLoaderType;\n\nLazyLoader.displayName = 'LazyLoader';\nLazyLoader.callbacks = {} as Record<string, (e: IntersectionObserverEntry) => void>;\nLazyLoader.addCallback = (id: string, c: (e: IntersectionObserverEntry) => void) => (LazyLoader.callbacks[id] = c);\nLazyLoader.observer = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n LazyLoader.callbacks[entry.target.id](entry);\n }\n },\n { rootMargin: '100px' }\n);\n"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"LazyLoader.js","sources":["../../../../src/components/layout/LazyLoader.tsx"],"sourcesContent":["import React, { ForwardRefExoticComponent, useImperativeHandle, useRef, useState } from 'react';\nimport { useEffectOnce } from 'react-use';\n\nimport { uniqueId } from 'lodash';\nimport { css } from '@emotion/css';\nimport { useStyles2 } from '@grafana/ui';\n\nexport function useUniqueId(): string {\n const idRefLazy = useRef<string | undefined>(undefined);\n idRefLazy.current ??= uniqueId();\n return idRefLazy.current;\n}\n\nexport interface Props extends Omit<React.HTMLProps<HTMLDivElement>, 'onChange' | 'children'> {\n children: React.ReactNode | (({ isInView }: { isInView: boolean }) => React.ReactNode);\n key: string;\n onLoad?: () => void;\n onChange?: (isInView: boolean) => void;\n}\n\nexport interface LazyLoaderType extends ForwardRefExoticComponent<Props> {\n addCallback: (id: string, c: (e: IntersectionObserverEntry) => void) => void;\n callbacks: Record<string, (e: IntersectionObserverEntry) => void>;\n observer: IntersectionObserver;\n}\n\nexport const LazyLoader: LazyLoaderType = React.forwardRef<HTMLDivElement, Props>(\n ({ children, onLoad, onChange, className, ...rest }, ref) => {\n const id = useUniqueId();\n const { hideEmpty } = useStyles2(getStyles);\n const [loaded, setLoaded] = useState(false);\n const [isInView, setIsInView] = useState(false);\n const innerRef = useRef<HTMLDivElement>(null);\n\n useImperativeHandle(ref, () => innerRef.current!);\n\n useEffectOnce(() => {\n LazyLoader.addCallback(id, (entry) => {\n if (!loaded && entry.isIntersecting) {\n setLoaded(true);\n onLoad?.();\n }\n\n setIsInView(entry.isIntersecting);\n onChange?.(entry.isIntersecting);\n });\n\n const wrapperEl = innerRef.current;\n\n if (wrapperEl) {\n LazyLoader.observer.observe(wrapperEl);\n }\n\n return () => {\n delete LazyLoader.callbacks[id];\n wrapperEl && LazyLoader.observer.unobserve(wrapperEl);\n if (Object.keys(LazyLoader.callbacks).length === 0) {\n LazyLoader.observer.disconnect();\n }\n };\n });\n\n // If the element was loaded, we add the `hideEmpty` class to potentially\n // hide the LazyLoader if it does not have any children. This is the case\n // when children have the `isHidden` property set. \n // We always include the `className` class, as this is coming from the \n // caller of the `LazyLoader` component.\n const classes = `${loaded ? hideEmpty : ''} ${className}`;\n return (\n <div id={id} ref={innerRef} className={classes} {...rest}>\n {loaded && (typeof children === 'function' ? children({ isInView }) : children)}\n </div>\n );\n }\n) as LazyLoaderType;\n\nfunction getStyles() {\n return {\n hideEmpty: css({\n '&:empty': {\n display: 'none',\n },\n }),\n };\n}\n\nLazyLoader.displayName = 'LazyLoader';\nLazyLoader.callbacks = {} as Record<string, (e: IntersectionObserverEntry) => void>;\nLazyLoader.addCallback = (id: string, c: (e: IntersectionObserverEntry) => void) => (LazyLoader.callbacks[id] = c);\nLazyLoader.observer = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n LazyLoader.callbacks[entry.target.id](entry);\n }\n },\n { rootMargin: '100px' }\n);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOO,SAAS,WAAs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AS,EAAA,MAAA;AAAA,OACX;AAAA,KACD,CAAA;AAAA,GACH,CAAA;AACF,CAAA;AAEA,UAAA,CAAW,WAAc,GAAA,YAAA,CAAA;AACzB,UAAA,CAAW,YAAY,EAAC,CAAA;AACxB,UAAA,CAAW,cAAc,CAAC,EAAA,EAAY,CAA+C,KAAA,UAAA,CAAW,UAAU,EAAM,CAAA,GAAA,CAAA,CAAA;AAChH,UAAA,CAAW,WAAW,IAAI,oBAAA;AAAA,EACxB,CAAC,OAAY,KAAA;AACX,IAAA,KAAA,MAAW,SAAS,OAAS,EAAA;AAC3B,MAAA,UAAA,CAAW,SAAU,CAAA,KAAA,CAAM,MAAO,CAAA,EAAA,CAAA,CAAI,KAAK,CAAA,CAAA;AAAA,KAC7C;AAAA,GACF;AAAA,EACA,EAAE,YAAY,OAAQ,EAAA;AACxB,CAAA;;;;"}
|
@@ -6,6 +6,7 @@ import { SceneGridLayout } from './SceneGridLayout.js';
|
|
6
6
|
import { GRID_COLUMN_COUNT } from './constants.js';
|
7
7
|
import { sceneGraph } from '../../../core/sceneGraph/index.js';
|
8
8
|
import { selectors } from '@grafana/e2e-selectors';
|
9
|
+
import { VariableDependencyConfig } from '../../../variables/VariableDependencyConfig.js';
|
9
10
|
|
10
11
|
var __defProp = Object.defineProperty;
|
11
12
|
var __defProps = Object.defineProperties;
|
@@ -37,6 +38,9 @@ class SceneGridRow extends SceneObjectBase {
|
|
37
38
|
height: 1,
|
38
39
|
width: GRID_COLUMN_COUNT
|
39
40
|
}));
|
41
|
+
this._variableDependency = new VariableDependencyConfig(this, {
|
42
|
+
statePaths: ["title"]
|
43
|
+
});
|
40
44
|
this.onCollapseToggle = () => {
|
41
45
|
if (!this.state.isCollapsible) {
|
42
46
|
return;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SceneGridRow.js","sources":["../../../../../src/components/layout/grid/SceneGridRow.tsx"],"sourcesContent":["import { css, cx } from '@emotion/css';\nimport React from 'react';\n\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { Icon, useStyles2 } from '@grafana/ui';\n\nimport { SceneObjectBase } from '../../../core/SceneObjectBase';\nimport { SceneComponentProps, SceneObject, SceneObjectUrlValues } from '../../../core/types';\n\nimport { SceneGridLayout } from './SceneGridLayout';\nimport { GRID_COLUMN_COUNT } from './constants';\nimport { SceneGridItemLike, SceneGridItemStateLike } from './types';\nimport { sceneGraph } from '../../../core/sceneGraph';\nimport { selectors } from '@grafana/e2e-selectors';\n\nexport interface SceneGridRowState extends SceneGridItemStateLike {\n title: string;\n isCollapsible?: boolean;\n isCollapsed?: boolean;\n actions?: SceneObject;\n children: SceneGridItemLike[];\n}\n\nexport class SceneGridRow extends SceneObjectBase<SceneGridRowState> {\n public static Component = SceneGridRowRenderer;\n\n public constructor(state: Partial<SceneGridRowState>) {\n super({\n children: state.children || [],\n isCollapsible: state.isCollapsible || true,\n title: state.title || '',\n ...state,\n x: 0,\n height: 1,\n width: GRID_COLUMN_COUNT,\n });\n }\n\n public getGridLayout(): SceneGridLayout {\n const layout = this.parent;\n\n if (!layout || !(layout instanceof SceneGridLayout)) {\n throw new Error('SceneGridRow must be a child of SceneGridLayout');\n }\n\n return layout;\n }\n\n public onCollapseToggle = () => {\n if (!this.state.isCollapsible) {\n return;\n }\n\n this.getGridLayout().toggleRow(this);\n };\n\n public getUrlState() {\n return { rowc: this.state.isCollapsed ? '1' : '0' };\n }\n\n public updateFromUrl(values: SceneObjectUrlValues) {\n if (values.rowc == null) {\n return;\n }\n\n if (values.rowc !== this.getUrlState().rowc) {\n this.onCollapseToggle();\n }\n }\n}\n\nexport function SceneGridRowRenderer({ model }: SceneComponentProps<SceneGridRow>) {\n const styles = useStyles2(getSceneGridRowStyles);\n const { isCollapsible, isCollapsed, title, actions, children } = model.useState();\n const layout = model.getGridLayout();\n const layoutDragClass = layout.getDragClass();\n const isDraggable = layout.isDraggable();\n\n const count = children ? children.length : 0;\n const panels = count === 1 ? 'panel' : 'panels';\n\n return (\n <div className={cx(styles.row, isCollapsed && styles.rowCollapsed)}>\n <div className={styles.rowTitleAndActionsGroup}>\n <button\n onClick={model.onCollapseToggle}\n className={styles.rowTitleButton}\n aria-label={isCollapsed ? 'Expand row' : 'Collapse row'}\n data-testid={selectors.components.DashboardRow.title(sceneGraph.interpolate(model, title, undefined, 'text'))}\n >\n {isCollapsible && <Icon name={isCollapsed ? 'angle-right' : 'angle-down'} />}\n <span className={styles.rowTitle} role=\"heading\">\n {sceneGraph.interpolate(model, title, undefined, 'text')}\n </span>\n </button>\n <span className={cx(styles.panelCount, isCollapsed && styles.panelCountCollapsed)}>\n ({count} {panels})\n </span>\n {actions && (\n <div className={styles.rowActions}>\n <actions.Component model={actions} />\n </div>\n )}\n </div>\n {isDraggable && isCollapsed && (\n <div className={cx(styles.dragHandle, layoutDragClass)}>\n <Icon name=\"draggabledots\" />\n </div>\n )}\n </div>\n );\n}\n\nexport const getSceneGridRowStyles = (theme: GrafanaTheme2) => {\n return {\n row: css({\n width: '100%',\n height: '30px',\n display: 'flex',\n justifyContent: 'space-between',\n gap: theme.spacing(1),\n }),\n rowTitleButton: css({\n display: 'flex',\n alignItems: 'center',\n cursor: 'pointer',\n background: 'transparent',\n border: 'none',\n gap: theme.spacing(1),\n }),\n rowCollapsed: css({\n borderBottom: `1px solid ${theme.colors.border.weak}`,\n }),\n rowTitle: css({\n fontSize: theme.typography.h5.fontSize,\n fontWeight: theme.typography.fontWeightMedium,\n }),\n collapsedInfo: css({\n fontSize: theme.typography.bodySmall.fontSize,\n color: theme.colors.text.secondary,\n display: 'flex',\n alignItems: 'center',\n flexGrow: 1,\n }),\n rowTitleAndActionsGroup: css({\n display: 'flex',\n\n '&:hover, &:focus-within': {\n '& > div': {\n opacity: 1,\n },\n },\n }),\n rowActions: css({\n display: 'flex',\n opacity: 0,\n transition: '200ms opacity ease-in 200ms',\n\n '&:hover, &:focus-within': {\n opacity: 1,\n },\n }),\n dragHandle: css({\n display: 'flex',\n padding: theme.spacing(0, 1),\n alignItems: 'center',\n justifyContent: 'flex-end',\n cursor: 'move',\n color: theme.colors.text.secondary,\n '&:hover': {\n color: theme.colors.text.primary,\n },\n }),\n panelCount: css({\n paddingLeft: theme.spacing(2),\n color: theme.colors.text.secondary,\n fontStyle: 'italic',\n fontSize: theme.typography.size.sm,\n fontWeight: 'normal',\n display: 'none',\n lineHeight: '30px',\n }),\n panelCountCollapsed: css({\n display: 'inline-block',\n }),\n };\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBO,MAAM,qBAAqB,eAAmC,CAAA;AAAA,EAG5D,YAAY,KAAmC,EAAA;AACpD,IAAM,KAAA,CAAA,aAAA,CAAA,cAAA,CAAA;AAAA,MACJ,QAAA,EAAU,KAAM,CAAA,QAAA,IAAY,EAAC;AAAA,MAC7B,aAAA,EAAe,MAAM,aAAiB,IAAA,IAAA;AAAA,MACtC,KAAA,EAAO,MAAM,KAAS,IAAA,EAAA;AAAA,KAAA,EACnB,KAJC,CAAA,EAAA;AAAA,MAKJ,CAAG,EAAA,CAAA;AAAA,MACH,MAAQ,EAAA,CAAA;AAAA,MACR,KAAO,EAAA,iBAAA;AAAA,KACR,CAAA,CAAA,CAAA;AAaH,IAAA,IAAA,CAAO,mBAAmB,MAAM;AAC9B,MAAI,IAAA,CAAC,IAAK,CAAA,KAAA,CAAM,aAAe,EAAA;AAC7B,QAAA,OAAA;AAAA,OACF;AAEA,MAAK,IAAA,CAAA,aAAA,EAAgB,CAAA,SAAA,CAAU,IAAI,CAAA,CAAA;AAAA,KACrC,CAAA;AAAA,GAlBA;AAAA,EAEO,aAAiC,GAAA;AACtC,IAAA,MAAM,SAAS,IAAK,CAAA,MAAA,CAAA;AAEpB,IAAA,IAAI,CAAC,MAAA,IAAU,EAAE,MAAA,YAAkB,eAAkB,CAAA,EAAA;AACnD,MAAM,MAAA,IAAI,MAAM,iDAAiD,CAAA,CAAA;AAAA,KACnE;AAEA,IAAO,OAAA,MAAA,CAAA;AAAA,GACT;A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|
+
{"version":3,"file":"SceneGridRow.js","sources":["../../../../../src/components/layout/grid/SceneGridRow.tsx"],"sourcesContent":["import { css, cx } from '@emotion/css';\nimport React from 'react';\n\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { Icon, useStyles2 } from '@grafana/ui';\n\nimport { SceneObjectBase } from '../../../core/SceneObjectBase';\nimport { SceneComponentProps, SceneObject, SceneObjectUrlValues } from '../../../core/types';\n\nimport { SceneGridLayout } from './SceneGridLayout';\nimport { GRID_COLUMN_COUNT } from './constants';\nimport { SceneGridItemLike, SceneGridItemStateLike } from './types';\nimport { sceneGraph } from '../../../core/sceneGraph';\nimport { selectors } from '@grafana/e2e-selectors';\nimport { VariableDependencyConfig } from '../../../variables/VariableDependencyConfig';\n\nexport interface SceneGridRowState extends SceneGridItemStateLike {\n title: string;\n isCollapsible?: boolean;\n isCollapsed?: boolean;\n actions?: SceneObject;\n children: SceneGridItemLike[];\n}\n\nexport class SceneGridRow extends SceneObjectBase<SceneGridRowState> {\n public static Component = SceneGridRowRenderer;\n\n protected _variableDependency = new VariableDependencyConfig(this, {\n statePaths: ['title'],\n });\n\n public constructor(state: Partial<SceneGridRowState>) {\n super({\n children: state.children || [],\n isCollapsible: state.isCollapsible || true,\n title: state.title || '',\n ...state,\n x: 0,\n height: 1,\n width: GRID_COLUMN_COUNT,\n });\n }\n\n public getGridLayout(): SceneGridLayout {\n const layout = this.parent;\n\n if (!layout || !(layout instanceof SceneGridLayout)) {\n throw new Error('SceneGridRow must be a child of SceneGridLayout');\n }\n\n return layout;\n }\n\n public onCollapseToggle = () => {\n if (!this.state.isCollapsible) {\n return;\n }\n\n this.getGridLayout().toggleRow(this);\n };\n\n public getUrlState() {\n return { rowc: this.state.isCollapsed ? '1' : '0' };\n }\n\n public updateFromUrl(values: SceneObjectUrlValues) {\n if (values.rowc == null) {\n return;\n }\n\n if (values.rowc !== this.getUrlState().rowc) {\n this.onCollapseToggle();\n }\n }\n}\n\nexport function SceneGridRowRenderer({ model }: SceneComponentProps<SceneGridRow>) {\n const styles = useStyles2(getSceneGridRowStyles);\n const { isCollapsible, isCollapsed, title, actions, children } = model.useState();\n const layout = model.getGridLayout();\n const layoutDragClass = layout.getDragClass();\n const isDraggable = layout.isDraggable();\n\n const count = children ? children.length : 0;\n const panels = count === 1 ? 'panel' : 'panels';\n\n return (\n <div className={cx(styles.row, isCollapsed && styles.rowCollapsed)}>\n <div className={styles.rowTitleAndActionsGroup}>\n <button\n onClick={model.onCollapseToggle}\n className={styles.rowTitleButton}\n aria-label={isCollapsed ? 'Expand row' : 'Collapse row'}\n data-testid={selectors.components.DashboardRow.title(sceneGraph.interpolate(model, title, undefined, 'text'))}\n >\n {isCollapsible && <Icon name={isCollapsed ? 'angle-right' : 'angle-down'} />}\n <span className={styles.rowTitle} role=\"heading\">\n {sceneGraph.interpolate(model, title, undefined, 'text')}\n </span>\n </button>\n <span className={cx(styles.panelCount, isCollapsed && styles.panelCountCollapsed)}>\n ({count} {panels})\n </span>\n {actions && (\n <div className={styles.rowActions}>\n <actions.Component model={actions} />\n </div>\n )}\n </div>\n {isDraggable && isCollapsed && (\n <div className={cx(styles.dragHandle, layoutDragClass)}>\n <Icon name=\"draggabledots\" />\n </div>\n )}\n </div>\n );\n}\n\nexport const getSceneGridRowStyles = (theme: GrafanaTheme2) => {\n return {\n row: css({\n width: '100%',\n height: '30px',\n display: 'flex',\n justifyContent: 'space-between',\n gap: theme.spacing(1),\n }),\n rowTitleButton: css({\n display: 'flex',\n alignItems: 'center',\n cursor: 'pointer',\n background: 'transparent',\n border: 'none',\n gap: theme.spacing(1),\n }),\n rowCollapsed: css({\n borderBottom: `1px solid ${theme.colors.border.weak}`,\n }),\n rowTitle: css({\n fontSize: theme.typography.h5.fontSize,\n fontWeight: theme.typography.fontWeightMedium,\n }),\n collapsedInfo: css({\n fontSize: theme.typography.bodySmall.fontSize,\n color: theme.colors.text.secondary,\n display: 'flex',\n alignItems: 'center',\n flexGrow: 1,\n }),\n rowTitleAndActionsGroup: css({\n display: 'flex',\n\n '&:hover, &:focus-within': {\n '& > div': {\n opacity: 1,\n },\n },\n }),\n rowActions: css({\n display: 'flex',\n opacity: 0,\n transition: '200ms opacity ease-in 200ms',\n\n '&:hover, &:focus-within': {\n opacity: 1,\n },\n }),\n dragHandle: css({\n display: 'flex',\n padding: theme.spacing(0, 1),\n alignItems: 'center',\n justifyContent: 'flex-end',\n cursor: 'move',\n color: theme.colors.text.secondary,\n '&:hover': {\n color: theme.colors.text.primary,\n },\n }),\n panelCount: css({\n paddingLeft: theme.spacing(2),\n color: theme.colors.text.secondary,\n fontStyle: 'italic',\n fontSize: theme.typography.size.sm,\n fontWeight: 'normal',\n display: 'none',\n lineHeight: '30px',\n }),\n panelCountCollapsed: css({\n display: 'inline-block',\n }),\n };\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBO,MAAM,qBAAqB,eAAmC,CAAA;AAAA,EAO5D,YAAY,KAAmC,EAAA;AACpD,IAAM,KAAA,CAAA,aAAA,CAAA,cAAA,CAAA;AAAA,MACJ,QAAA,EAAU,KAAM,CAAA,QAAA,IAAY,EAAC;AAAA,MAC7B,aAAA,EAAe,MAAM,aAAiB,IAAA,IAAA;AAAA,MACtC,KAAA,EAAO,MAAM,KAAS,IAAA,EAAA;AAAA,KAAA,EACnB,KAJC,CAAA,EAAA;AAAA,MAKJ,CAAG,EAAA,CAAA;AAAA,MACH,MAAQ,EAAA,CAAA;AAAA,MACR,KAAO,EAAA,iBAAA;AAAA,KACR,CAAA,CAAA,CAAA;AAbH,IAAU,IAAA,CAAA,mBAAA,GAAsB,IAAI,wBAAA,CAAyB,IAAM,EAAA;AAAA,MACjE,UAAA,EAAY,CAAC,OAAO,CAAA;AAAA,KACrB,CAAA,CAAA;AAwBD,IAAA,IAAA,CAAO,mBAAmB,MAAM;AAC9B,MAAI,IAAA,CAAC,IAAK,CAAA,KAAA,CAAM,aAAe,EAAA;AAC7B,QAAA,OAAA;AAAA,OACF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AO,KAAM,CAAA,MAAA,CAAO,IAAK,CAAA,SAAA;AAAA,MACzB,SAAW,EAAA,QAAA;AAAA,MACX,QAAA,EAAU,KAAM,CAAA,UAAA,CAAW,IAAK,CAAA,EAAA;AAAA,MAChC,UAAY,EAAA,QAAA;AAAA,MACZ,OAAS,EAAA,MAAA;AAAA,MACT,UAAY,EAAA,MAAA;AAAA,KACb,CAAA;AAAA,IACD,qBAAqB,GAAI,CAAA;AAAA,MACvB,OAAS,EAAA,cAAA;AAAA,KACV,CAAA;AAAA,GACH,CAAA;AACF;;;;"}
|
package/dist/index.d.ts
CHANGED
@@ -2009,6 +2009,7 @@ interface SceneGridRowState extends SceneGridItemStateLike {
|
|
2009
2009
|
}
|
2010
2010
|
declare class SceneGridRow extends SceneObjectBase<SceneGridRowState> {
|
2011
2011
|
static Component: typeof SceneGridRowRenderer;
|
2012
|
+
protected _variableDependency: VariableDependencyConfig<SceneGridRowState>;
|
2012
2013
|
constructor(state: Partial<SceneGridRowState>);
|
2013
2014
|
getGridLayout(): SceneGridLayout;
|
2014
2015
|
onCollapseToggle: () => void;
|
package/dist/index.js
CHANGED
@@ -3327,7 +3327,7 @@ function LoadingIndicator(props) {
|
|
3327
3327
|
}
|
3328
3328
|
|
3329
3329
|
function ControlsLabel(props) {
|
3330
|
-
const styles = ui.useStyles2(getStyles$
|
3330
|
+
const styles = ui.useStyles2(getStyles$a);
|
3331
3331
|
const theme = ui.useTheme2();
|
3332
3332
|
const isVertical = props.layout === "vertical";
|
3333
3333
|
const loadingIndicator = Boolean(props.isLoading) ? /* @__PURE__ */ React__default["default"].createElement("div", {
|
@@ -3390,7 +3390,7 @@ function ControlsLabel(props) {
|
|
3390
3390
|
}
|
3391
3391
|
return labelElement;
|
3392
3392
|
}
|
3393
|
-
const getStyles$
|
3393
|
+
const getStyles$a = (theme) => ({
|
3394
3394
|
horizontalLabel: css.css({
|
3395
3395
|
background: theme.isDark ? theme.colors.background.primary : theme.colors.background.secondary,
|
3396
3396
|
display: `flex`,
|
@@ -3470,7 +3470,7 @@ function keyLabelToOption(key, label) {
|
|
3470
3470
|
const filterNoOp = () => true;
|
3471
3471
|
function AdHocFilterRenderer({ filter, model }) {
|
3472
3472
|
var _a, _b;
|
3473
|
-
const styles = ui.useStyles2(getStyles$
|
3473
|
+
const styles = ui.useStyles2(getStyles$9);
|
3474
3474
|
const [keys, setKeys] = React.useState([]);
|
3475
3475
|
const [values, setValues] = React.useState([]);
|
3476
3476
|
const [isKeysLoading, setIsKeysLoading] = React.useState(false);
|
@@ -3614,7 +3614,7 @@ function AdHocFilterRenderer({ filter, model }) {
|
|
3614
3614
|
onClick: () => model._removeFilter(filter)
|
3615
3615
|
}));
|
3616
3616
|
}
|
3617
|
-
const getStyles$
|
3617
|
+
const getStyles$9 = (theme) => ({
|
3618
3618
|
field: css.css({
|
3619
3619
|
marginBottom: 0
|
3620
3620
|
}),
|
@@ -3913,7 +3913,7 @@ function renderExpression(builder, filters) {
|
|
3913
3913
|
}
|
3914
3914
|
function AdHocFiltersVariableRenderer({ model }) {
|
3915
3915
|
const { filters, readOnly, addFilterButtonText } = model.useState();
|
3916
|
-
const styles = ui.useStyles2(getStyles$
|
3916
|
+
const styles = ui.useStyles2(getStyles$8);
|
3917
3917
|
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
3918
3918
|
className: styles.wrapper
|
3919
3919
|
}, filters.map((filter, index) => /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, {
|
@@ -3927,7 +3927,7 @@ function AdHocFiltersVariableRenderer({ model }) {
|
|
3927
3927
|
addFilterButtonText
|
3928
3928
|
}));
|
3929
3929
|
}
|
3930
|
-
const getStyles$
|
3930
|
+
const getStyles$8 = (theme) => ({
|
3931
3931
|
wrapper: css.css({
|
3932
3932
|
display: "flex",
|
3933
3933
|
flexWrap: "wrap",
|
@@ -4816,6 +4816,7 @@ function VizPanelRenderer({ model }) {
|
|
4816
4816
|
menu: panelMenu,
|
4817
4817
|
onCancelQuery: model.onCancelQuery,
|
4818
4818
|
onFocus: setPanelAttention,
|
4819
|
+
onMouseEnter: setPanelAttention,
|
4819
4820
|
onMouseMove: debouncedMouseMove
|
4820
4821
|
}, (innerWidth, innerHeight) => /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement(ui.ErrorBoundaryAlert, {
|
4821
4822
|
dependencies: [plugin, data$1]
|
@@ -8048,7 +8049,7 @@ class EmbeddedScene extends SceneObjectBase {
|
|
8048
8049
|
EmbeddedScene.Component = EmbeddedSceneRenderer;
|
8049
8050
|
function EmbeddedSceneRenderer({ model }) {
|
8050
8051
|
const { body, controls } = model.useState();
|
8051
|
-
const styles = ui.useStyles2(getStyles$
|
8052
|
+
const styles = ui.useStyles2(getStyles$7);
|
8052
8053
|
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
8053
8054
|
className: styles.container
|
8054
8055
|
}, controls && /* @__PURE__ */ React__default["default"].createElement("div", {
|
@@ -8062,7 +8063,7 @@ function EmbeddedSceneRenderer({ model }) {
|
|
8062
8063
|
model: body
|
8063
8064
|
})));
|
8064
8065
|
}
|
8065
|
-
const getStyles$
|
8066
|
+
const getStyles$7 = (theme) => {
|
8066
8067
|
return {
|
8067
8068
|
container: css.css({
|
8068
8069
|
flexGrow: 1,
|
@@ -8201,8 +8202,9 @@ function useUniqueId() {
|
|
8201
8202
|
}
|
8202
8203
|
const LazyLoader = React__default["default"].forwardRef(
|
8203
8204
|
(_a, ref) => {
|
8204
|
-
var _b = _a, { children, onLoad, onChange } = _b, rest = __objRest$1(_b, ["children", "onLoad", "onChange"]);
|
8205
|
+
var _b = _a, { children, onLoad, onChange, className } = _b, rest = __objRest$1(_b, ["children", "onLoad", "onChange", "className"]);
|
8205
8206
|
const id = useUniqueId();
|
8207
|
+
const { hideEmpty } = ui.useStyles2(getStyles$6);
|
8206
8208
|
const [loaded, setLoaded] = React.useState(false);
|
8207
8209
|
const [isInView, setIsInView] = React.useState(false);
|
8208
8210
|
const innerRef = React.useRef(null);
|
@@ -8228,12 +8230,23 @@ const LazyLoader = React__default["default"].forwardRef(
|
|
8228
8230
|
}
|
8229
8231
|
};
|
8230
8232
|
});
|
8233
|
+
const classes = `${loaded ? hideEmpty : ""} ${className}`;
|
8231
8234
|
return /* @__PURE__ */ React__default["default"].createElement("div", __spreadValues$b({
|
8232
8235
|
id,
|
8233
|
-
ref: innerRef
|
8236
|
+
ref: innerRef,
|
8237
|
+
className: classes
|
8234
8238
|
}, rest), loaded && (typeof children === "function" ? children({ isInView }) : children));
|
8235
8239
|
}
|
8236
8240
|
);
|
8241
|
+
function getStyles$6() {
|
8242
|
+
return {
|
8243
|
+
hideEmpty: css.css({
|
8244
|
+
"&:empty": {
|
8245
|
+
display: "none"
|
8246
|
+
}
|
8247
|
+
})
|
8248
|
+
};
|
8249
|
+
}
|
8237
8250
|
LazyLoader.displayName = "LazyLoader";
|
8238
8251
|
LazyLoader.callbacks = {};
|
8239
8252
|
LazyLoader.addCallback = (id, c) => LazyLoader.callbacks[id] = c;
|
@@ -8742,6 +8755,9 @@ class SceneGridRow extends SceneObjectBase {
|
|
8742
8755
|
height: 1,
|
8743
8756
|
width: GRID_COLUMN_COUNT
|
8744
8757
|
}));
|
8758
|
+
this._variableDependency = new VariableDependencyConfig(this, {
|
8759
|
+
statePaths: ["title"]
|
8760
|
+
});
|
8745
8761
|
this.onCollapseToggle = () => {
|
8746
8762
|
if (!this.state.isCollapsible) {
|
8747
8763
|
return;
|