@grafana/scenes 5.9.1--canary.873.10430729232.0 → 5.9.1--canary.867.10449271599.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/esm/components/VizPanel/VizPanelRenderer.js +6 -4
- package/dist/esm/components/VizPanel/VizPanelRenderer.js.map +1 -1
- package/dist/esm/utils/SafeSerializableSceneObject.js +23 -2
- package/dist/esm/utils/SafeSerializableSceneObject.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +49 -26
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
@@ -25,11 +25,13 @@ function VizPanelRenderer({ model }) {
|
|
25
25
|
} = model.useState();
|
26
26
|
const [ref, { width, height }] = useMeasure();
|
27
27
|
const appEvents = useMemo(() => getAppEvents(), []);
|
28
|
-
const setPanelAttention = useCallback(
|
29
|
-
|
30
|
-
|
28
|
+
const setPanelAttention = useCallback(() => {
|
29
|
+
appEvents.publish(new SetPanelAttentionEvent({ panelId: model.state.key }));
|
30
|
+
}, [model.state.key, appEvents]);
|
31
|
+
const debouncedMouseMove = useMemo(
|
32
|
+
() => debounce(setPanelAttention, 100, { leading: true, trailing: false }),
|
33
|
+
[setPanelAttention]
|
31
34
|
);
|
32
|
-
const debouncedMouseMove = useMemo(() => debounce(setPanelAttention, 100), [setPanelAttention]);
|
33
35
|
const plugin = model.getPlugin();
|
34
36
|
const { dragClass, dragClassCancel } = getDragClasses(model);
|
35
37
|
const dataObject = sceneGraph.getData(model);
|
@@ -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 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={context.eventBus}\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,O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,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
|
+
{"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 const debouncedMouseMove = useMemo(\n () => debounce(setPanelAttention, 100, { leading: true, trailing: false }),\n [setPanelAttention]\n );\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={context.eventBus}\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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
+
__accessCheck(obj, member, "read from private field");
|
7
|
+
return getter ? getter.call(obj) : member.get(obj);
|
8
|
+
};
|
9
|
+
var __privateAdd = (obj, member, value) => {
|
10
|
+
if (member.has(obj))
|
11
|
+
throw TypeError("Cannot add the same private member more than once");
|
12
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
13
|
+
};
|
14
|
+
var __privateSet = (obj, member, value, setter) => {
|
15
|
+
__accessCheck(obj, member, "write to private field");
|
16
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
17
|
+
return value;
|
18
|
+
};
|
19
|
+
var _value;
|
1
20
|
class SafeSerializableSceneObject {
|
2
21
|
constructor(value) {
|
22
|
+
__privateAdd(this, _value, void 0);
|
3
23
|
this.text = "__sceneObject";
|
4
24
|
this.valueOf = () => {
|
5
|
-
return this
|
25
|
+
return __privateGet(this, _value);
|
6
26
|
};
|
7
|
-
this
|
27
|
+
__privateSet(this, _value, value);
|
8
28
|
}
|
9
29
|
toString() {
|
10
30
|
return void 0;
|
@@ -13,6 +33,7 @@ class SafeSerializableSceneObject {
|
|
13
33
|
return this;
|
14
34
|
}
|
15
35
|
}
|
36
|
+
_value = new WeakMap();
|
16
37
|
|
17
38
|
export { SafeSerializableSceneObject };
|
18
39
|
//# sourceMappingURL=SafeSerializableSceneObject.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SafeSerializableSceneObject.js","sources":["../../../src/utils/SafeSerializableSceneObject.ts"],"sourcesContent":["import { ScopedVar } from '@grafana/data';\nimport { SceneObject } from '../core/types';\n\nexport class SafeSerializableSceneObject implements ScopedVar {\n
|
1
|
+
{"version":3,"file":"SafeSerializableSceneObject.js","sources":["../../../src/utils/SafeSerializableSceneObject.ts"],"sourcesContent":["import { ScopedVar } from '@grafana/data';\nimport { SceneObject } from '../core/types';\n\nexport class SafeSerializableSceneObject implements ScopedVar {\n #value: SceneObject;\n\n public text = '__sceneObject';\n\n public constructor(value: SceneObject) {\n this.#value = value;\n }\n\n public toString() {\n return undefined;\n }\n\n public valueOf = () => {\n return this.#value;\n };\n\n public get value() {\n return this;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,IAAA,MAAA,CAAA;AAGO,MAAM,2BAAiD,CAAA;AAAA,EAKrD,YAAY,KAAoB,EAAA;AAJvC,IAAA,YAAA,CAAA,IAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAEA,IAAA,IAAA,CAAO,IAAO,GAAA,eAAA,CAAA;AAUd,IAAA,IAAA,CAAO,UAAU,MAAM;AACrB,MAAA,OAAO,YAAK,CAAA,IAAA,EAAA,MAAA,CAAA,CAAA;AAAA,KACd,CAAA;AATE,IAAA,YAAA,CAAA,IAAA,EAAK,MAAS,EAAA,KAAA,CAAA,CAAA;AAAA,GAChB;AAAA,EAEO,QAAW,GAAA;AAChB,IAAO,OAAA,KAAA,CAAA,CAAA;AAAA,GACT;AAAA,EAMA,IAAW,KAAQ,GAAA;AACjB,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AACF,CAAA;AAnBE,MAAA,GAAA,IAAA,OAAA,EAAA;;;;"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
@@ -186,32 +186,32 @@ class UserActionEvent extends data.BusEventWithPayload {
|
|
186
186
|
}
|
187
187
|
UserActionEvent.type = "scene-object-user-action";
|
188
188
|
|
189
|
-
var __accessCheck$
|
189
|
+
var __accessCheck$3 = (obj, member, msg) => {
|
190
190
|
if (!member.has(obj))
|
191
191
|
throw TypeError("Cannot " + msg);
|
192
192
|
};
|
193
|
-
var __privateGet$
|
194
|
-
__accessCheck$
|
193
|
+
var __privateGet$3 = (obj, member, getter) => {
|
194
|
+
__accessCheck$3(obj, member, "read from private field");
|
195
195
|
return getter ? getter.call(obj) : member.get(obj);
|
196
196
|
};
|
197
|
-
var __privateAdd$
|
197
|
+
var __privateAdd$3 = (obj, member, value) => {
|
198
198
|
if (member.has(obj))
|
199
199
|
throw TypeError("Cannot add the same private member more than once");
|
200
200
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
201
201
|
};
|
202
|
-
var __privateSet$
|
203
|
-
__accessCheck$
|
202
|
+
var __privateSet$2 = (obj, member, value, setter) => {
|
203
|
+
__accessCheck$3(obj, member, "write to private field");
|
204
204
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
205
205
|
return value;
|
206
206
|
};
|
207
207
|
var _ref;
|
208
208
|
class SceneObjectRef {
|
209
209
|
constructor(ref) {
|
210
|
-
__privateAdd$
|
211
|
-
__privateSet$
|
210
|
+
__privateAdd$3(this, _ref, void 0);
|
211
|
+
__privateSet$2(this, _ref, ref);
|
212
212
|
}
|
213
213
|
resolve() {
|
214
|
-
return __privateGet$
|
214
|
+
return __privateGet$3(this, _ref);
|
215
215
|
}
|
216
216
|
}
|
217
217
|
_ref = new WeakMap();
|
@@ -1780,15 +1780,15 @@ function isDataLayer(obj) {
|
|
1780
1780
|
return "isDataLayer" in obj;
|
1781
1781
|
}
|
1782
1782
|
|
1783
|
-
var __accessCheck$
|
1783
|
+
var __accessCheck$2 = (obj, member, msg) => {
|
1784
1784
|
if (!member.has(obj))
|
1785
1785
|
throw TypeError("Cannot " + msg);
|
1786
1786
|
};
|
1787
|
-
var __privateGet$
|
1788
|
-
__accessCheck$
|
1787
|
+
var __privateGet$2 = (obj, member, getter) => {
|
1788
|
+
__accessCheck$2(obj, member, "read from private field");
|
1789
1789
|
return getter ? getter.call(obj) : member.get(obj);
|
1790
1790
|
};
|
1791
|
-
var __privateAdd$
|
1791
|
+
var __privateAdd$2 = (obj, member, value) => {
|
1792
1792
|
if (member.has(obj))
|
1793
1793
|
throw TypeError("Cannot add the same private member more than once");
|
1794
1794
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
@@ -1801,25 +1801,25 @@ class SceneQueryController extends SceneObjectBase {
|
|
1801
1801
|
constructor() {
|
1802
1802
|
super({ isRunning: false });
|
1803
1803
|
this.isQueryController = true;
|
1804
|
-
__privateAdd$
|
1804
|
+
__privateAdd$2(this, _running, /* @__PURE__ */ new Set());
|
1805
1805
|
this.addActivationHandler(() => {
|
1806
|
-
return () => __privateGet$
|
1806
|
+
return () => __privateGet$2(this, _running).clear();
|
1807
1807
|
});
|
1808
1808
|
}
|
1809
1809
|
queryStarted(entry) {
|
1810
|
-
__privateGet$
|
1810
|
+
__privateGet$2(this, _running).add(entry);
|
1811
1811
|
this.changeRunningQueryCount(1);
|
1812
1812
|
if (!this.state.isRunning) {
|
1813
1813
|
this.setState({ isRunning: true });
|
1814
1814
|
}
|
1815
1815
|
}
|
1816
1816
|
queryCompleted(entry) {
|
1817
|
-
if (!__privateGet$
|
1817
|
+
if (!__privateGet$2(this, _running).has(entry)) {
|
1818
1818
|
return;
|
1819
1819
|
}
|
1820
|
-
__privateGet$
|
1820
|
+
__privateGet$2(this, _running).delete(entry);
|
1821
1821
|
this.changeRunningQueryCount(-1);
|
1822
|
-
if (__privateGet$
|
1822
|
+
if (__privateGet$2(this, _running).size === 0) {
|
1823
1823
|
this.setState({ isRunning: false });
|
1824
1824
|
}
|
1825
1825
|
}
|
@@ -1829,7 +1829,7 @@ class SceneQueryController extends SceneObjectBase {
|
|
1829
1829
|
}
|
1830
1830
|
cancelAll() {
|
1831
1831
|
var _a;
|
1832
|
-
for (const entry of __privateGet$
|
1832
|
+
for (const entry of __privateGet$2(this, _running).values()) {
|
1833
1833
|
(_a = entry.cancel) == null ? void 0 : _a.call(entry);
|
1834
1834
|
}
|
1835
1835
|
}
|
@@ -2735,13 +2735,33 @@ function getEnrichedFiltersRequest(sourceRunner) {
|
|
2735
2735
|
return null;
|
2736
2736
|
}
|
2737
2737
|
|
2738
|
+
var __accessCheck$1 = (obj, member, msg) => {
|
2739
|
+
if (!member.has(obj))
|
2740
|
+
throw TypeError("Cannot " + msg);
|
2741
|
+
};
|
2742
|
+
var __privateGet$1 = (obj, member, getter) => {
|
2743
|
+
__accessCheck$1(obj, member, "read from private field");
|
2744
|
+
return getter ? getter.call(obj) : member.get(obj);
|
2745
|
+
};
|
2746
|
+
var __privateAdd$1 = (obj, member, value) => {
|
2747
|
+
if (member.has(obj))
|
2748
|
+
throw TypeError("Cannot add the same private member more than once");
|
2749
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
2750
|
+
};
|
2751
|
+
var __privateSet$1 = (obj, member, value, setter) => {
|
2752
|
+
__accessCheck$1(obj, member, "write to private field");
|
2753
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
2754
|
+
return value;
|
2755
|
+
};
|
2756
|
+
var _value;
|
2738
2757
|
class SafeSerializableSceneObject {
|
2739
2758
|
constructor(value) {
|
2759
|
+
__privateAdd$1(this, _value, void 0);
|
2740
2760
|
this.text = "__sceneObject";
|
2741
2761
|
this.valueOf = () => {
|
2742
|
-
return this
|
2762
|
+
return __privateGet$1(this, _value);
|
2743
2763
|
};
|
2744
|
-
this
|
2764
|
+
__privateSet$1(this, _value, value);
|
2745
2765
|
}
|
2746
2766
|
toString() {
|
2747
2767
|
return void 0;
|
@@ -2750,6 +2770,7 @@ class SafeSerializableSceneObject {
|
|
2750
2770
|
return this;
|
2751
2771
|
}
|
2752
2772
|
}
|
2773
|
+
_value = new WeakMap();
|
2753
2774
|
|
2754
2775
|
var __defProp$z = Object.defineProperty;
|
2755
2776
|
var __defProps$n = Object.defineProperties;
|
@@ -5249,11 +5270,13 @@ function VizPanelRenderer({ model }) {
|
|
5249
5270
|
} = model.useState();
|
5250
5271
|
const [ref, { width, height }] = reactUse.useMeasure();
|
5251
5272
|
const appEvents = React.useMemo(() => runtime.getAppEvents(), []);
|
5252
|
-
const setPanelAttention = React.useCallback(
|
5253
|
-
|
5254
|
-
|
5273
|
+
const setPanelAttention = React.useCallback(() => {
|
5274
|
+
appEvents.publish(new data.SetPanelAttentionEvent({ panelId: model.state.key }));
|
5275
|
+
}, [model.state.key, appEvents]);
|
5276
|
+
const debouncedMouseMove = React.useMemo(
|
5277
|
+
() => lodash.debounce(setPanelAttention, 100, { leading: true, trailing: false }),
|
5278
|
+
[setPanelAttention]
|
5255
5279
|
);
|
5256
|
-
const debouncedMouseMove = React.useMemo(() => lodash.debounce(setPanelAttention, 100), [setPanelAttention]);
|
5257
5280
|
const plugin = model.getPlugin();
|
5258
5281
|
const { dragClass, dragClassCancel } = getDragClasses(model);
|
5259
5282
|
const dataObject = sceneGraph.getData(model);
|