@deephaven/dashboard 0.22.3-beta.15 → 0.22.3-beta.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/Dashboard.d.ts +1 -1
  2. package/dist/Dashboard.d.ts.map +1 -1
  3. package/dist/Dashboard.js +4 -15
  4. package/dist/Dashboard.js.map +1 -1
  5. package/dist/DashboardConstants.js.map +1 -1
  6. package/dist/DashboardLayout.d.ts +4 -4
  7. package/dist/DashboardLayout.d.ts.map +1 -1
  8. package/dist/DashboardLayout.js +11 -24
  9. package/dist/DashboardLayout.js.map +1 -1
  10. package/dist/DashboardPlugin.js +0 -1
  11. package/dist/DashboardPlugin.js.map +1 -1
  12. package/dist/DashboardUtils.js +1 -9
  13. package/dist/DashboardUtils.js.map +1 -1
  14. package/dist/PanelErrorBoundary.js +0 -8
  15. package/dist/PanelErrorBoundary.js.map +1 -1
  16. package/dist/PanelEvent.js.map +1 -1
  17. package/dist/PanelManager.js +15 -62
  18. package/dist/PanelManager.js.map +1 -1
  19. package/dist/PanelPlaceholder.d.ts.map +1 -1
  20. package/dist/PanelPlaceholder.js +1 -1
  21. package/dist/PanelPlaceholder.js.map +1 -1
  22. package/dist/index.d.ts +2 -1
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +2 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/layout/GLPropTypes.js.map +1 -1
  27. package/dist/layout/GoldenLayoutThemeExport.js +0 -1
  28. package/dist/layout/GoldenLayoutThemeExport.js.map +1 -1
  29. package/dist/layout/LayoutUtils.js +50 -176
  30. package/dist/layout/LayoutUtils.js.map +1 -1
  31. package/dist/layout/hooks.js.map +1 -1
  32. package/dist/layout/index.js.map +1 -1
  33. package/dist/redux/actionTypes.js.map +1 -1
  34. package/dist/redux/actions.js +1 -5
  35. package/dist/redux/actions.js.map +1 -1
  36. package/dist/redux/index.js.map +1 -1
  37. package/dist/redux/reducers/dashboardData.js.map +1 -1
  38. package/dist/redux/reducers/index.js.map +1 -1
  39. package/dist/redux/selectors.js +3 -7
  40. package/dist/redux/selectors.js.map +1 -1
  41. package/package.json +10 -10
@@ -17,6 +17,6 @@ export declare type DashboardProps = {
17
17
  hydrate?: PanelHydrateFunction;
18
18
  dehydrate?: PanelDehydrateFunction;
19
19
  };
20
- export declare const Dashboard: ({ id, children, emptyDashboard, layoutConfig, layoutSettings, onLayoutConfigChange, onGoldenLayoutChange, onLayoutInitialized, fallbackComponent, hydrate, dehydrate, }: DashboardProps) => JSX.Element;
20
+ export declare function Dashboard({ id, children, emptyDashboard, layoutConfig, layoutSettings, onLayoutConfigChange, onGoldenLayoutChange, onLayoutInitialized, fallbackComponent, hydrate, dehydrate, }: DashboardProps): JSX.Element;
21
21
  export default Dashboard;
22
22
  //# sourceMappingURL=Dashboard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Dashboard.d.ts","sourceRoot":"","sources":["../src/Dashboard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,yBAAyB,EACzB,aAAa,EAKd,MAAM,OAAO,CAAC;AAEf,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,4BAA4B,CAAC;AAIpC,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,UAAU,EACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,kBAAkB,CAAC;AAQ1B,oBAAY,cAAc,GAAG;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IAC/C,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACjC,YAAY,CAAC,EAAE,cAAc,EAAE,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC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AC,EAAE,MAAM,IAAI,CAAC;IACjC,iBAAiB,CAAC,EAAE,yBAAyB,CAC3C,UAAU,GAAG,aAAa,CAAC,cAAc,CAAC,CAC3C,CAAC;IACF,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,SAAS,CAAC,EAAE,sBAAsB,CAAC;CACpC,CAAC;AAEF,wBAAgB,SAAS,CAAC,EACxB,EAAc,EACd,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,cAA6B,EAC7B,oBAAuC,EACvC,oBAAuC,EACvC,mBAAsC,EACtC,iBAAoC,EACpC,OAAO,EACP,SAAS,GACV,EAAE,cAAc,GAAG,GAAG,CAAC,OAAO,CA4F9B;AAED,eAAe,SAAS,CAAC"}
package/dist/Dashboard.js CHANGED
@@ -1,9 +1,6 @@
1
1
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
-
3
2
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
-
5
3
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
7
4
  import React, { useEffect, useMemo, useRef, useState } from 'react';
8
5
  import throttle from 'lodash.throttle';
9
6
  import GoldenLayout from '@deephaven/golden-layout';
@@ -13,11 +10,9 @@ import PanelPlaceholder from "./PanelPlaceholder.js";
13
10
  import DashboardLayout from "./DashboardLayout.js";
14
11
  import "./Dashboard.css";
15
12
  var RESIZE_THROTTLE = 100;
16
-
17
13
  var DEFAULT_CALLBACK = () => undefined;
18
-
19
14
  var EMPTY_OBJECT = Object.freeze({});
20
- export var Dashboard = _ref => {
15
+ export function Dashboard(_ref) {
21
16
  var {
22
17
  id = 'default',
23
18
  children,
@@ -39,29 +34,23 @@ export var Dashboard = _ref => {
39
34
  setLayout(undefined);
40
35
  return;
41
36
  }
42
-
43
37
  var config = _objectSpread({}, LayoutUtils.makeDefaultLayout());
44
-
45
38
  if (config.settings === undefined) {
46
39
  config.settings = {};
47
40
  }
41
+ Object.assign(config.settings, layoutSettings);
48
42
 
49
- Object.assign(config.settings, layoutSettings); // Load our content later after plugins have registered
50
-
43
+ // Load our content later after plugins have registered
51
44
  config.content = [];
52
45
  var newLayout = new GoldenLayout(config, layoutElement.current);
53
-
54
46
  var onInit = () => {
55
47
  newLayout.off('initialised', onInit);
56
48
  setIsInitialized(true);
57
49
  };
58
-
59
50
  newLayout.on('initialised', onInit);
60
-
61
51
  if (fallbackComponent != null) {
62
52
  newLayout.setFallbackComponent(fallbackComponent);
63
53
  }
64
-
65
54
  newLayout.init();
66
55
  setLayout(newLayout);
67
56
  onGoldenLayoutChange(newLayout);
@@ -95,6 +84,6 @@ export var Dashboard = _ref => {
95
84
  hydrate: hydrate,
96
85
  dehydrate: dehydrate
97
86
  }, children));
98
- };
87
+ }
99
88
  export default Dashboard;
100
89
  //# sourceMappingURL=Dashboard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Dashboard.js","names":["React","useEffect","useMemo","useRef","useState","throttle","GoldenLayout","LayoutUtils","PanelPlaceholder","DashboardLayout","RESIZE_THROTTLE","DEFAULT_CALLBACK","undefined","EMPTY_OBJECT","Object","freeze","Dashboard","id","children","emptyDashboard","layoutConfig","layoutSettings","onLayoutConfigChange","onGoldenLayoutChange","onLayoutInitialized","fallbackComponent","hydrate","dehydrate","layoutElement","isInitialized","setIsInitialized","layout","setLayout","initDashboard","current","config","makeDefaultLayout","settings","assign","content","newLayout","onInit","off","on","setFallbackComponent","init","destroy","handleResize","isInitialised","updateSize","initResizeEventListner","window","addEventListener","removeEventListener"],"sources":["../src/Dashboard.tsx"],"sourcesContent":["import React, {\n ForwardRefExoticComponent,\n RefAttributes,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport throttle from 'lodash.throttle';\nimport GoldenLayout from '@deephaven/golden-layout';\nimport type { ItemConfigType } from '@deephaven/golden-layout';\nimport './layout/GoldenLayout.scss';\nimport LayoutUtils from './layout/LayoutUtils';\nimport PanelPlaceholder from './PanelPlaceholder';\nimport DashboardLayout from './DashboardLayout';\nimport {\n PanelDehydrateFunction,\n PanelHydrateFunction,\n PanelProps,\n} from './DashboardPlugin';\nimport './Dashboard.scss';\n\nconst RESIZE_THROTTLE = 100;\n\nconst DEFAULT_CALLBACK = () => undefined;\n\nconst EMPTY_OBJECT = Object.freeze({});\n\nexport type DashboardProps = {\n id?: string;\n children?: React.ReactNode | React.ReactNode[];\n emptyDashboard?: React.ReactNode;\n layoutConfig?: ItemConfigType[];\n layoutSettings?: Record<string, unknown>;\n onLayoutConfigChange?: () => void;\n onGoldenLayoutChange?: (goldenLayout: GoldenLayout) => void;\n onLayoutInitialized?: () => void;\n fallbackComponent?: ForwardRefExoticComponent<\n PanelProps & RefAttributes<HTMLDivElement>\n >;\n hydrate?: PanelHydrateFunction;\n dehydrate?: PanelDehydrateFunction;\n};\n\nexport const Dashboard = ({\n id = 'default',\n children,\n emptyDashboard,\n layoutConfig,\n layoutSettings = EMPTY_OBJECT,\n onLayoutConfigChange = DEFAULT_CALLBACK,\n onGoldenLayoutChange = DEFAULT_CALLBACK,\n onLayoutInitialized = DEFAULT_CALLBACK,\n fallbackComponent = PanelPlaceholder,\n hydrate,\n dehydrate,\n}: DashboardProps): JSX.Element => {\n const layoutElement = useRef<HTMLDivElement>(null);\n const [isInitialized, setIsInitialized] = useState(false);\n const [layout, setLayout] = useState<GoldenLayout>();\n\n useEffect(\n function initDashboard() {\n if (!layoutElement.current) {\n setLayout(undefined);\n return;\n }\n const config = {\n ...LayoutUtils.makeDefaultLayout(),\n };\n if (config.settings === undefined) {\n config.settings = {};\n }\n Object.assign(config.settings, layoutSettings);\n\n // Load our content later after plugins have registered\n config.content = [];\n\n const newLayout = new GoldenLayout(config, layoutElement.current);\n\n const onInit = () => {\n newLayout.off('initialised', onInit);\n setIsInitialized(true);\n };\n newLayout.on('initialised', onInit);\n\n if (fallbackComponent != null) {\n newLayout.setFallbackComponent(fallbackComponent);\n }\n\n newLayout.init();\n\n setLayout(newLayout);\n\n onGoldenLayoutChange(newLayout);\n\n return () => {\n newLayout.destroy();\n };\n },\n [\n layoutSettings,\n fallbackComponent,\n onGoldenLayoutChange,\n setIsInitialized,\n setLayout,\n ]\n );\n\n const handleResize = useMemo(\n () =>\n throttle(() => {\n if (layout != null && layout.isInitialised) {\n layout?.updateSize();\n }\n }, RESIZE_THROTTLE),\n [layout]\n );\n\n useEffect(\n function initResizeEventListner() {\n window.addEventListener('resize', handleResize);\n return () => {\n window.removeEventListener('resize', handleResize);\n };\n },\n [handleResize]\n );\n\n return (\n <div className=\"dashboard-container w-100 h-100\">\n <div className=\"w-100 h-100\" ref={layoutElement} />\n {isInitialized && layout && (\n <DashboardLayout\n emptyDashboard={emptyDashboard}\n id={id}\n layout={layout}\n layoutConfig={layoutConfig}\n onLayoutChange={onLayoutConfigChange}\n onLayoutInitialized={onLayoutInitialized}\n hydrate={hydrate}\n dehydrate={dehydrate}\n >\n {children}\n </DashboardLayout>\n )}\n </div>\n );\n};\n\nexport default Dashboard;\n"],"mappings":";;;;;;AAAA,OAAOA,KAAP,IAGEC,SAHF,EAIEC,OAJF,EAKEC,MALF,EAMEC,QANF,QAOO,OAPP;AAQA,OAAOC,QAAP,MAAqB,iBAArB;AACA,OAAOC,YAAP,MAAyB,0BAAzB;;OAGOC,W;OACAC,gB;OACAC,e;;AAQP,IAAMC,eAAe,GAAG,GAA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,OAPX;IAQE,SAAS,EAAEC;EARb,GAUGT,QAVH,CAHJ,CADF;AAmBD,CAxGM;AA0GP,eAAeF,SAAf"}
1
+ {"version":3,"file":"Dashboard.js","names":["React","useEffect","useMemo","useRef","useState","throttle","GoldenLayout","LayoutUtils","PanelPlaceholder","DashboardLayout","RESIZE_THROTTLE","DEFAULT_CALLBACK","undefined","EMPTY_OBJECT","Object","freeze","Dashboard","id","children","emptyDashboard","layoutConfig","layoutSettings","onLayoutConfigChange","onGoldenLayoutChange","onLayoutInitialized","fallbackComponent","hydrate","dehydrate","layoutElement","isInitialized","setIsInitialized","layout","setLayout","initDashboard","current","config","makeDefaultLayout","settings","assign","content","newLayout","onInit","off","on","setFallbackComponent","init","destroy","handleResize","isInitialised","updateSize","initResizeEventListner","window","addEventListener","removeEventListener"],"sources":["../src/Dashboard.tsx"],"sourcesContent":["import React, {\n ForwardRefExoticComponent,\n RefAttributes,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport throttle from 'lodash.throttle';\nimport GoldenLayout from '@deephaven/golden-layout';\nimport type { ItemConfigType } from '@deephaven/golden-layout';\nimport './layout/GoldenLayout.scss';\nimport LayoutUtils from './layout/LayoutUtils';\nimport PanelPlaceholder from './PanelPlaceholder';\nimport DashboardLayout from './DashboardLayout';\nimport {\n PanelDehydrateFunction,\n PanelHydrateFunction,\n PanelProps,\n} from './DashboardPlugin';\nimport './Dashboard.scss';\n\nconst RESIZE_THROTTLE = 100;\n\nconst DEFAULT_CALLBACK = () => undefined;\n\nconst EMPTY_OBJECT = Object.freeze({});\n\nexport type DashboardProps = {\n id?: string;\n children?: React.ReactNode | React.ReactNode[];\n emptyDashboard?: React.ReactNode;\n layoutConfig?: ItemConfigType[];\n layoutSettings?: Record<string, unknown>;\n onLayoutConfigChange?: () => void;\n onGoldenLayoutChange?: (goldenLayout: GoldenLayout) => void;\n onLayoutInitialized?: () => void;\n fallbackComponent?: ForwardRefExoticComponent<\n PanelProps & RefAttributes<HTMLDivElement>\n >;\n hydrate?: PanelHydrateFunction;\n dehydrate?: PanelDehydrateFunction;\n};\n\nexport function Dashboard({\n id = 'default',\n children,\n emptyDashboard,\n layoutConfig,\n layoutSettings = EMPTY_OBJECT,\n onLayoutConfigChange = DEFAULT_CALLBACK,\n onGoldenLayoutChange = DEFAULT_CALLBACK,\n onLayoutInitialized = DEFAULT_CALLBACK,\n fallbackComponent = PanelPlaceholder,\n hydrate,\n dehydrate,\n}: DashboardProps): JSX.Element {\n const layoutElement = useRef<HTMLDivElement>(null);\n const [isInitialized, setIsInitialized] = useState(false);\n const [layout, setLayout] = useState<GoldenLayout>();\n\n useEffect(\n function initDashboard() {\n if (!layoutElement.current) {\n setLayout(undefined);\n return;\n }\n const config = {\n ...LayoutUtils.makeDefaultLayout(),\n };\n if (config.settings === undefined) {\n config.settings = {};\n }\n Object.assign(config.settings, layoutSettings);\n\n // Load our content later after plugins have registered\n config.content = [];\n\n const newLayout = new GoldenLayout(config, layoutElement.current);\n\n const onInit = () => {\n newLayout.off('initialised', onInit);\n setIsInitialized(true);\n };\n newLayout.on('initialised', onInit);\n\n if (fallbackComponent != null) {\n newLayout.setFallbackComponent(fallbackComponent);\n }\n\n newLayout.init();\n\n setLayout(newLayout);\n\n onGoldenLayoutChange(newLayout);\n\n return () => {\n newLayout.destroy();\n };\n },\n [\n layoutSettings,\n fallbackComponent,\n onGoldenLayoutChange,\n setIsInitialized,\n setLayout,\n ]\n );\n\n const handleResize = useMemo(\n () =>\n throttle(() => {\n if (layout != null && layout.isInitialised) {\n layout?.updateSize();\n }\n }, RESIZE_THROTTLE),\n [layout]\n );\n\n useEffect(\n function initResizeEventListner() {\n window.addEventListener('resize', handleResize);\n return () => {\n window.removeEventListener('resize', handleResize);\n };\n },\n [handleResize]\n );\n\n return (\n <div className=\"dashboard-container w-100 h-100\">\n <div className=\"w-100 h-100\" ref={layoutElement} />\n {isInitialized && layout && (\n <DashboardLayout\n emptyDashboard={emptyDashboard}\n id={id}\n layout={layout}\n layoutConfig={layoutConfig}\n onLayoutChange={onLayoutConfigChange}\n onLayoutInitialized={onLayoutInitialized}\n hydrate={hydrate}\n dehydrate={dehydrate}\n >\n {children}\n </DashboardLayout>\n )}\n </div>\n );\n}\n\nexport default Dashboard;\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAGVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AACd,OAAOC,QAAQ,MAAM,iBAAiB;AACtC,OAAOC,YAAY,MAAM,0BAA0B;AAAC;AAAA,OAG7CC,WAAW;AAAA,OACXC,gBAAgB;AAAA,OAChBC,eAAe;AAAA;AAQtB,IAAMC,eAAe,GAAG,GAAG;AAE3B,IAAMC,gBAAgB,GAAG,MAAMC,SAAS;AAExC,IAAMC,YAAY,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,CAAC;AAkBtC,OAAO,SAASC,SAAS,OAYO;EAAA,IAZN;IACxBC,EAAE,GAAG,SAAS;IACdC,QAAQ;IACRC,cAAc;IACdC,YAAY;IACZC,cAAc,GAAGR,YAAY;IAC7BS,oBAAoB,GAAGX,gBAAgB;IACvCY,oBAAoB,GAAGZ,gBAAgB;IACvCa,mBAAmB,GAAGb,gBAAgB;IACtCc,iBAAiB,GAAGjB,gBAAgB;IACpCkB,OAAO;IACPC;EACc,CAAC;EACf,IAAMC,aAAa,GAAGzB,MAAM,CAAiB,IAAI,CAAC;EAClD,IAAM,CAAC0B,aAAa,EAAEC,gBAAgB,CAAC,GAAG1B,QAAQ,CAAC,KAAK,CAAC;EACzD,IAAM,CAAC2B,MAAM,EAAEC,SAAS,CAAC,GAAG5B,QAAQ,EAAgB;EAEpDH,SAAS,CACP,SAASgC,aAAa,GAAG;IACvB,IAAI,CAACL,aAAa,CAACM,OAAO,EAAE;MAC1BF,SAAS,CAACpB,SAAS,CAAC;MACpB;IACF;IACA,IAAMuB,MAAM,qBACP5B,WAAW,CAAC6B,iBAAiB,EAAE,CACnC;IACD,IAAID,M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AACE,mBAAmB,CAAC,QAAQ,EAAEN,YAAY,CAAC;IACpD,CAAC;EACH,CAAC,EACD,CAACA,YAAY,CAAC,CACf;EAED,oBACE;IAAK,SAAS,EAAC;EAAiC,gBAC9C;IAAK,SAAS,EAAC,aAAa;IAAC,GAAG,EAAEnB;EAAc,EAAG,EAClDC,aAAa,IAAIE,MAAM,iBACtB,oBAAC,eAAe;IACd,cAAc,EAAEZ,cAAe;IAC/B,EAAE,EAAEF,EAAG;IACP,MAAM,EAAEc,MAAO;IACf,YAAY,EAAEX,YAAa;IAC3B,cAAc,EAAEE,oBAAqB;IACrC,mBAAmB,EAAEE,mBAAoB;IACzC,OAAO,EAAEE,OAAQ;IACjB,SAAS,EAAEC;EAAU,GAEpBT,QAAQ,CAEZ,CACG;AAEV;AAEA,eAAeF,SAAS"}
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardConstants.js","names":["DEFAULT_DASHBOARD_ID"],"sources":["../src/DashboardConstants.ts"],"sourcesContent":["// eslint-disable-next-line import/prefer-default-export\nexport const DEFAULT_DASHBOARD_ID = 'default';\n"],"mappings":"AAAA;AACA,OAAO,IAAMA,oBAAoB,GAAG,SAA7B"}
1
+ {"version":3,"file":"DashboardConstants.js","names":["DEFAULT_DASHBOARD_ID"],"sources":["../src/DashboardConstants.ts"],"sourcesContent":["// eslint-disable-next-line import/prefer-default-export\nexport const DEFAULT_DASHBOARD_ID = 'default';\n"],"mappings":"AAAA;AACA,OAAO,IAAMA,oBAAoB,GAAG,SAAS"}
@@ -23,9 +23,9 @@ interface DashboardLayoutProps {
23
23
  /**
24
24
  * DashboardLayout component. Handles hydrating, dehydrating components, listening for dragging panels.
25
25
  */
26
- export declare const DashboardLayout: {
27
- ({ id, children, emptyDashboard, layout, layoutConfig, onLayoutChange, onLayoutInitialized, hydrate, dehydrate, }: DashboardLayoutProps): JSX.Element;
28
- propTypes: {
26
+ export declare function DashboardLayout({ id, children, emptyDashboard, layout, layoutConfig, onLayoutChange, onLayoutInitialized, hydrate, dehydrate, }: DashboardLayoutProps): JSX.Element;
27
+ export declare namespace DashboardLayout {
28
+ var propTypes: {
29
29
  id: PropTypes.Validator<string>;
30
30
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
31
31
  data: PropTypes.Requireable<PropTypes.InferProps<{}>>;
@@ -47,6 +47,6 @@ export declare const DashboardLayout: {
47
47
  onLayoutChange: PropTypes.Requireable<(...args: any[]) => any>;
48
48
  onLayoutInitialized: PropTypes.Requireable<(...args: any[]) => any>;
49
49
  };
50
- };
50
+ }
51
51
  export default DashboardLayout;
52
52
  //# sourceMappingURL=DashboardLayout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardLayout.d.ts","sourceRoot":"","sources":["../src/DashboardLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AACf,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,KAAK,EAGV,cAAc,EAEf,MAAM,0BAA0B,CAAC;AAKlC,OAAqB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAU5D,OAAO,EAEL,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAE3B,oBAAY,qBAAqB,GAAG,cAAc,EAAE,CAAC;AAarD,aAAK,aAAa,GAAG;IACnB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF,UAAU,oBAAoB;IAC5B,EAAE,EAAE,MAAM,CAAC;IAGX,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,SAAS,CAAC,EAAE,sBAAsB,CAAC;IACnC,MAAM,EAAE,YAAY,CAAC;IACrB,YAAY,CAAC,EAAE,qBAAqB,CAAC;IACrC,cAAc,CAAC,EAAE,CAAC,gBAAgB,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACnE,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC,IAAI,CAAC,EAAE,a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AAS,CAAC;CAClC;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAC9B,EAAE,EACF,QAAQ,EACR,cAA+C,EAC/C,MAAM,EACN,YAAoC,EACpC,cAAiC,EACjC,mBAAsC,EACtC,OAAwB,EACxB,SAA4B,GAC7B,EAAE,oBAAoB,GAAG,GAAG,CAAC,OAAO,CAkOpC;yBA5Oe,eAAe;;;;;;;;;;;;;;;;;;;;;;;;AAyP/B,eAAe,eAAe,CAAC"}
@@ -1,5 +1,4 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
2
  import React, { useCallback, useEffect, useMemo, useState } from 'react';
4
3
  import PropTypes from 'prop-types';
5
4
  import Log from '@deephaven/log';
@@ -15,18 +14,15 @@ import { getDashboardData, updateDashboardData } from "./redux/index.js";
15
14
  var log = Log.module('DashboardLayout');
16
15
  var EMPTY_OBJECT = Object.freeze({});
17
16
  var DEFAULT_LAYOUT_CONFIG = [];
17
+ var DEFAULT_CALLBACK = () => undefined;
18
18
 
19
- var DEFAULT_CALLBACK = () => undefined; // If a component isn't registered, just pass through the props so they are saved if a plugin is loaded later
20
-
21
-
19
+ // If a component isn't registered, just pass through the props so they are saved if a plugin is loaded later
22
20
  var FALLBACK_CALLBACK = props => props;
23
-
24
21
  /**
25
22
  * DashboardLayout component. Handles hydrating, dehydrating components, listening for dragging panels.
26
23
  */
27
- export var DashboardLayout = _ref => {
24
+ export function DashboardLayout(_ref) {
28
25
  var _useSelector, _closed;
29
-
30
26
  var {
31
27
  id,
32
28
  children,
@@ -52,14 +48,14 @@ export var DashboardLayout = _ref => {
52
48
  var componentHydrate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : hydrate;
53
49
  var componentDehydrate = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : dehydrate;
54
50
  log.debug2('registerComponent', name, componentType, componentHydrate, componentDehydrate);
55
-
56
51
  function renderComponent(props, ref) {
57
52
  // Cast it to an `any` type so we can pass the ref in correctly.
58
53
  // ComponentType doesn't seem to work right, ReactNode is also incorrect
59
54
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
60
- var CType = componentType; // Props supplied by GoldenLayout
61
- // eslint-disable-next-line react/prop-types
55
+ var CType = componentType;
62
56
 
57
+ // Props supplied by GoldenLayout
58
+ // eslint-disable-next-line react/prop-types
63
59
  var {
64
60
  glContainer,
65
61
  glEventHub
@@ -73,7 +69,6 @@ export var DashboardLayout = _ref => {
73
69
  ref: ref
74
70
  }))));
75
71
  }
76
-
77
72
  var wrappedComponent = /*#__PURE__*/React.forwardRef(renderComponent);
78
73
  var cleanup = layout.registerComponent(name, wrappedComponent);
79
74
  hydrateMap.set(name, componentHydrate);
@@ -82,12 +77,10 @@ export var DashboardLayout = _ref => {
82
77
  }, [hydrate, dehydrate, hydrateMap, dehydrateMap, layout, store]);
83
78
  var hydrateComponent = useCallback((name, props) => {
84
79
  var _hydrateMap$get;
85
-
86
80
  return ((_hydrateMap$get = hydrateMap.get(name)) !== null && _hydrateMap$get !== void 0 ? _hydrateMap$get : FALLBACK_CALLBACK)(props, id);
87
81
  }, [hydrateMap, id]);
88
82
  var dehydrateComponent = useCallback((name, config) => {
89
83
  var _dehydrateMap$get;
90
-
91
84
  return ((_dehydrateMap$get = dehydrateMap.get(name)) !== null && _dehydrateMap$get !== void 0 ? _dehydrateMap$get : FALLBACK_CALLBACK)(config, id);
92
85
  }, [dehydrateMap, id]);
93
86
  var panelManager = useMemo(() => new PanelManager(layout, hydrateComponent, dehydrateComponent, new Map(), initialClosedPanels, _ref2 => {
@@ -104,18 +97,15 @@ export var DashboardLayout = _ref => {
104
97
  // we don't want to emit stateChanges that happen during item drags or else
105
98
  // we risk the last saved state being one without that panel in the layout entirely
106
99
  if (isItemDragging) return;
107
-
108
100
  if (!isDashboardInitialized) {
109
101
  onLayoutInitialized();
110
102
  setIsDashboardInitialized(true);
111
103
  }
112
-
113
104
  var glConfig = layout.toConfig();
114
105
  var contentConfig = glConfig.content;
115
106
  var dehydratedLayoutConfig = LayoutUtils.dehydrateLayoutConfig(contentConfig, dehydrateComponent);
116
107
  var hasChanged = lastConfig == null || !LayoutUtils.isEqual(lastConfig, dehydratedLayoutConfig);
117
108
  log.debug('handleLayoutStateChanged', hasChanged, contentConfig, dehydratedLayoutConfig);
118
-
119
109
  if (hasChanged) {
120
110
  setIsDashboardEmpty(layout.root.contentItems.length === 0);
121
111
  setLastConfig(dehydratedLayoutConfig);
@@ -130,11 +120,9 @@ export var DashboardLayout = _ref => {
130
120
  }, []);
131
121
  var handleComponentCreated = useCallback(item => {
132
122
  log.debug2('handleComponentCreated', item);
133
-
134
123
  if (item == null || item.config == null || item.config.component == null || item.element == null) {
135
124
  return;
136
125
  }
137
-
138
126
  var cssComponent = item.config.component.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
139
127
  var cssClass = "".concat(cssComponent, "-component");
140
128
  item.element.addClass(cssClass);
@@ -148,17 +136,16 @@ export var DashboardLayout = _ref => {
148
136
  useEffect(function loadNewConfig() {
149
137
  if (previousLayoutConfig !== layoutConfig && layoutConfig !== lastConfig) {
150
138
  log.debug('Setting new layout content...');
151
- var content = LayoutUtils.hydrateLayoutConfig(layoutConfig, hydrateComponent); // Remove the old layout before add the new one
152
-
139
+ var content = LayoutUtils.hydrateLayoutConfig(layoutConfig, hydrateComponent);
140
+ // Remove the old layout before add the new one
153
141
  while (layout.root.contentItems.length > 0) {
154
142
  layout.root.contentItems[0].remove();
155
- } // Add the new content. It is usally just one item from the root
156
-
143
+ }
157
144
 
145
+ // Add the new content. It is usally just one item from the root
158
146
  for (var i = 0; i < content.length; i += 1) {
159
147
  layout.root.addChild(content[i]);
160
148
  }
161
-
162
149
  setIsDashboardEmpty(layout.root.contentItems.length === 0);
163
150
  }
164
151
  }, [hydrateComponent, layout, layoutConfig, lastConfig, panelManager, previousLayoutConfig]);
@@ -168,7 +155,7 @@ export var DashboardLayout = _ref => {
168
155
  panelManager,
169
156
  registerComponent
170
157
  }) : null));
171
- };
158
+ }
172
159
  DashboardLayout.propTypes = {
173
160
  id: PropTypes.string.isRequired,
174
161
  children: PropTypes.node,
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardLayout.js","names":["React","useCallback","useEffect","useMemo","useState","PropTypes","Log","usePrevious","Provider","useDispatch","useSelector","useStore","PanelManager","PanelErrorBoundary","LayoutUtils","dehydrate","dehydrateDefault","hydrate","hydrateDefault","PanelEvent","GLPropTypes","useListener","getDashboardData","updateDashboardData","log","module","EMPTY_OBJECT","Object","freeze","DEFAULT_LAYOUT_CONFIG","DEFAULT_CALLBACK","undefined","FALLBACK_CALLBACK","props","DashboardLayout","id","children","emptyDashboard","layout","layoutConfig","onLayoutChange","onLayoutInitialized","dispatch","data","state","isDashboardEmpty","setIsDashboardEmpty","isItemDragging","setIsItemDragging","lastConfig","setLastConfig","initialClosedPanels","closed","isDashboardInitialized","setIsDashboardInitialized","hydrateMap","Map","dehydrateMap","store","registerComponent","name","componentType","componentHydrate","componentDehydrate","debug2","renderComponent","ref","CType","glContainer","glEventHub","wrappedComponent","forwardRef","cleanup","set","hydrateComponent","get","dehydrateComponent","config","panelManager","openedMap","handleLayoutStateChanged","glConfig","toConfig","contentConfig","content","dehydratedLayoutConfig","dehydrateLayoutConfig","hasChanged","isEqual","debug","root","contentItems","length","handleLayoutItemPickedUp","handleLayoutItemDropped","handleComponentCreated","item","component","element","cssComponent","replace","toLowerCase","cssClass","addClass","eventHub","TITLE_CHANGED","previousLayoutConfig","loadNewConfig","hydrateLayoutConfig","remove","i","addChild","Children","map","child","cloneElement","propTypes","string","isRequired","node","shape","Layout","arrayOf","func"],"sources":["../src/DashboardLayout.tsx"],"sourcesContent":["import React, {\n ReactElement,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport PropTypes from 'prop-types';\nimport GoldenLayout from '@deephaven/golden-layout';\nimport type {\n Container,\n EventEmitter,\n ItemConfigType,\n ReactComponentConfig,\n} from '@deephaven/golden-layout';\nimport Log from '@deephaven/log';\nimport { usePrevious } from '@deephaven/react-hooks';\nimport { RootState } from '@deephaven/redux';\nimport { Provider, useDispatch, useSelector, useStore } from 'react-redux';\nimport PanelManager, { ClosedPanels } from './PanelManager';\nimport PanelErrorBoundary from './PanelErrorBoundary';\nimport LayoutUtils from './layout/LayoutUtils';\nimport {\n dehydrate as dehydrateDefault,\n hydrate as hydrateDefault,\n} from './DashboardUtils';\nimport PanelEvent from './PanelEvent';\nimport { GLPropTypes, useListener } from './layout';\nimport { getDashboardData, updateDashboardData } from './redux';\nimport {\n PanelComponentType,\n PanelDehydrateFunction,\n PanelHydrateFunction,\n} from './DashboardPlugin';\n\nexport type DashboardLayoutConfig = ItemConfigType[];\n\nconst log = Log.module('DashboardLayout');\n\nconst EMPTY_OBJECT = Object.freeze({});\n\nconst DEFAULT_LAYOUT_CONFIG: DashboardLayoutConfig = [];\n\nconst DEFAULT_CALLBACK = () => undefined;\n\n// If a component isn't registered, just pass through the props so they are saved if a plugin is loaded later\nconst FALLBACK_CALLBACK = (props: unknown) => props;\n\ntype DashboardData = {\n closed?: ClosedPanels;\n};\n\ninterface DashboardLayoutProps {\n id: string;\n\n // Default hydrate/dehydration functions\n hydrate?: PanelHydrateFunction;\n dehydrate?: PanelDehydrateFunction;\n layout: GoldenLayout;\n layoutConfig?: DashboardLayoutConfig;\n onLayoutChange?: (dehydratedLayout: DashboardLayoutConfig) => void;\n onLayoutInitialized?: () => void;\n data?: DashboardData;\n children?: React.ReactNode | React.ReactNode[];\n emptyDashboard?: React.ReactNode;\n}\n\n/**\n * DashboardLayout component. Handles hydrating, dehydrating components, listening for dragging panels.\n */\nexport const DashboardLayout = ({\n id,\n children,\n emptyDashboard = <div>Dashboard is empty.</div>,\n layout,\n layoutConfig = DEFAULT_LAYOUT_CONFIG,\n onLayoutChange = DEFAULT_CALLBACK,\n onLayoutInitialized = DEFAULT_CALLBACK,\n hydrate = hydrateDefault,\n dehydrate = dehydrateDefault,\n}: DashboardLayoutProps): JSX.Element => {\n const dispatch = useDispatch();\n const data =\n useSelector<RootState>(state => getDashboardData(state, id)) ??\n EMPTY_OBJECT;\n\n const [isDashboardEmpty, setIsDashboardEmpty] = useState(false);\n const [isItemDragging, setIsItemDragging] = useState(false);\n const [lastConfig, setLastConfig] = useState<DashboardLayoutConfig>();\n const [initialClosedPanels] = useState<ReactComponentConfig[] | undefined>(\n (data as DashboardData)?.closed ?? []\n );\n const [isDashboardInitialized, setIsDashboardInitialized] = useState(false);\n\n const hydrateMap = useMemo(() => new Map(), []);\n const dehydrateMap = useMemo(() => new Map(), []);\n const store = useStore();\n const registerComponent = useCallback(\n (\n name: string,\n componentType: PanelComponentType,\n componentHydrate = hydrate,\n componentDehydrate = dehydrate\n ) => {\n log.debug2(\n 'registerComponent',\n name,\n componentType,\n componentHydrate,\n componentDehydrate\n );\n\n function renderComponent(\n props: { glContainer: Container; glEventHub: EventEmitter },\n ref: unknown\n ) {\n // Cast it to an `any` type so we can pass the ref in correctly.\n // ComponentType doesn't seem to work right, ReactNode is also incorrect\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const CType = componentType as any;\n\n // Props supplied by GoldenLayout\n // eslint-disable-next-line react/prop-types\n const { glContainer, glEventHub } = props;\n return (\n <Provider store={store}>\n <PanelErrorBoundary\n glContainer={glContainer}\n glEventHub={glEventHub}\n >\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <CType {...props} ref={ref} />\n </PanelErrorBoundary>\n </Provider>\n );\n }\n\n const wrappedComponent = React.forwardRef(renderComponent);\n const cleanup = layout.registerComponent(name, wrappedComponent);\n hydrateMap.set(name, componentHydrate);\n dehydrateMap.set(name, componentDehydrate);\n return cleanup;\n },\n [hydrate, dehydrate, hydrateMap, dehydrateMap, layout, store]\n );\n const hydrateComponent = useCallback(\n (name, props) => (hydrateMap.get(name) ?? FALLBACK_CALLBACK)(props, id),\n [hydrateMap, id]\n );\n const dehydrateComponent = useCallback(\n (name, config) => (dehydrateMap.get(name) ?? FALLBACK_CALLBACK)(config, id),\n [dehydrateMap, id]\n );\n const panelManager = useMemo(\n () =>\n new PanelManager(\n layout,\n hydrateComponent,\n dehydrateComponent,\n new Map(),\n initialClosedPanels,\n ({ closed, openedMap }) => {\n dispatch(updateDashboardData(id, { closed, openedMap }));\n }\n ),\n [\n dehydrateComponent,\n dispatch,\n hydrateComponent,\n id,\n initialClosedPanels,\n layout,\n ]\n );\n\n const handleLayoutStateChanged = useCallback(() => {\n // we don't want to emit stateChanges that happen during item drags or else\n // we risk the last saved state being one without that panel in the layout entirely\n if (isItemDragging) return;\n\n if (!isDashboardInitialized) {\n onLayoutInitialized();\n setIsDashboardInitialized(true);\n }\n\n const glConfig = layout.toConfig();\n const contentConfig = glConfig.content;\n const dehydratedLayoutConfig = LayoutUtils.dehydrateLayoutConfig(\n contentConfig,\n dehydrateComponent\n );\n const hasChanged =\n lastConfig == null ||\n !LayoutUtils.isEqual(lastConfig, dehydratedLayoutConfig);\n\n log.debug(\n 'handleLayoutStateChanged',\n hasChanged,\n contentConfig,\n dehydratedLayoutConfig\n );\n\n if (hasChanged) {\n setIsDashboardEmpty(layout.root.contentItems.length === 0);\n\n setLastConfig(dehydratedLayoutConfig);\n\n onLayoutChange(dehydratedLayoutConfig);\n }\n }, [\n dehydrateComponent,\n isDashboardInitialized,\n isItemDragging,\n lastConfig,\n layout,\n onLayoutChange,\n onLayoutInitialized,\n ]);\n\n const handleLayoutItemPickedUp = useCallback(() => {\n setIsItemDragging(true);\n }, []);\n\n const handleLayoutItemDropped = useCallback(() => {\n setIsItemDragging(false);\n }, []);\n\n const handleComponentCreated = useCallback(item => {\n log.debug2('handleComponentCreated', item);\n\n if (\n item == null ||\n item.config == null ||\n item.config.component == null ||\n item.element == null\n ) {\n return;\n }\n\n const cssComponent = item.config.component\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .toLowerCase();\n const cssClass = `${cssComponent}-component`;\n item.element.addClass(cssClass);\n }, []);\n\n useListener(layout, 'stateChanged', handleLayoutStateChanged);\n useListener(layout, 'itemPickedUp', handleLayoutItemPickedUp);\n useListener(layout, 'itemDropped', handleLayoutItemDropped);\n useListener(layout, 'componentCreated', handleComponentCreated);\n useListener(\n layout.eventHub,\n PanelEvent.TITLE_CHANGED,\n handleLayoutStateChanged\n );\n\n const previousLayoutConfig = usePrevious(layoutConfig);\n useEffect(\n function loadNewConfig() {\n if (\n previousLayoutConfig !== layoutConfig &&\n layoutConfig !== lastConfig\n ) {\n log.debug('Setting new layout content...');\n const content = LayoutUtils.hydrateLayoutConfig(\n layoutConfig,\n hydrateComponent\n );\n // Remove the old layout before add the new one\n while (layout.root.contentItems.length > 0) {\n layout.root.contentItems[0].remove();\n }\n\n // Add the new content. It is usally just one item from the root\n for (let i = 0; i < content.length; i += 1) {\n layout.root.addChild(content[i]);\n }\n\n setIsDashboardEmpty(layout.root.contentItems.length === 0);\n }\n },\n [\n hydrateComponent,\n layout,\n layoutConfig,\n lastConfig,\n panelManager,\n previousLayoutConfig,\n ]\n );\n\n return (\n <>\n {isDashboardEmpty && emptyDashboard}\n {React.Children.map(children, child =>\n child != null\n ? React.cloneElement(child as ReactElement, {\n id,\n layout,\n panelManager,\n registerComponent,\n })\n : null\n )}\n </>\n );\n};\n\nDashboardLayout.propTypes = {\n id: PropTypes.string.isRequired,\n children: PropTypes.node,\n data: PropTypes.shape({}),\n emptyDashboard: PropTypes.node,\n layout: GLPropTypes.Layout.isRequired,\n layoutConfig: PropTypes.arrayOf(PropTypes.shape({})),\n onLayoutChange: PropTypes.func,\n onLayoutInitialized: PropTypes.func,\n};\n\nexport default DashboardLayout;\n"],"mappings":";;AAAA,OAAOA,KAAP,IAEEC,WAFF,EAGEC,SAHF,EAIEC,OAJF,EAKEC,QALF,QAMO,OANP;AAOA,OAAOC,SAAP,MAAsB,YAAtB;AAQA,OAAOC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AAoCkB,CAAC,IAAI,CAAzC,EAA4C;QAC1CxE,MAAM,CAACoD,IAAP,CAAYqB,QAAZ,CAAqB3B,OAAO,CAAC0B,CAAD,CAA5B;MACD;;MAEDhE,mBAAmB,CAACR,MAAM,CAACoD,IAAP,CAAYC,YAAZ,CAAyBC,MAAzB,KAAoC,CAArC,CAAnB;IACD;EACF,CAvBM,EAwBP,CACElB,gBADF,EAEEpC,MAFF,EAGEC,YAHF,EAIEU,UAJF,EAKE6B,YALF,EAME4B,oBANF,CAxBO,CAAT;EAkCA,oBACE,0CACG7D,gBAAgB,IAAIR,cADvB,EAEGrC,KAAK,CAACgH,QAAN,CAAeC,GAAf,CAAmB7E,QAAnB,EAA6B8E,KAAK,IACjCA,KAAK,IAAI,IAAT,gBACIlH,KAAK,CAACmH,YAAN,CAAmBD,KAAnB,EAA0C;IACxC/E,EADwC;IAExCG,MAFwC;IAGxCwC,YAHwC;IAIxCnB;EAJwC,CAA1C,CADJ,GAOI,IARL,CAFH,CADF;AAeD,CA5OM;AA8OPzB,eAAe,CAACkF,SAAhB,GAA4B;EAC1BjF,EAAE,EAAE9B,SAAS,CAACgH,MAAV,CAAiBC,UADK;EAE1BlF,QAAQ,EAAE/B,SAAS,CAACkH,IAFM;EAG1B5E,IAAI,EAAEtC,SAAS,CAACmH,KAAV,CAAgB,EAAhB,CAHoB;EAI1BnF,cAAc,EAAEhC,SAAS,CAACkH,IAJA;EAK1BjF,MAAM,EAAElB,WAAW,CAACqG,MAAZ,CAAmBH,UALD;EAM1B/E,YAAY,EAAElC,SAAS,CAACqH,OAAV,CAAkBrH,SAAS,CAACmH,KAAV,CAAgB,EAAhB,CAAlB,CANY;EAO1BhF,cAAc,EAAEnC,SAAS,CAACsH,IAPA;EAQ1BlF,mBAAmB,EAAEpC,SAAS,CAACsH;AARL,CAA5B;AAWA,eAAezF,eAAf"}
1
+ {"version":3,"file":"DashboardLayout.js","names":["React","useCallback","useEffect","useMemo","useState","PropTypes","Log","usePrevious","Provider","useDispatch","useSelector","useStore","PanelManager","PanelErrorBoundary","LayoutUtils","dehydrate","dehydrateDefault","hydrate","hydrateDefault","PanelEvent","GLPropTypes","useListener","getDashboardData","updateDashboardData","log","module","EMPTY_OBJECT","Object","freeze","DEFAULT_LAYOUT_CONFIG","DEFAULT_CALLBACK","undefined","FALLBACK_CALLBACK","props","DashboardLayout","id","children","emptyDashboard","layout","layoutConfig","onLayoutChange","onLayoutInitialized","dispatch","data","state","isDashboardEmpty","setIsDashboardEmpty","isItemDragging","setIsItemDragging","lastConfig","setLastConfig","initialClosedPanels","closed","isDashboardInitialized","setIsDashboardInitialized","hydrateMap","Map","dehydrateMap","store","registerComponent","name","componentType","componentHydrate","componentDehydrate","debug2","renderComponent","ref","CType","glContainer","glEventHub","wrappedComponent","forwardRef","cleanup","set","hydrateComponent","get","dehydrateComponent","config","panelManager","openedMap","handleLayoutStateChanged","glConfig","toConfig","contentConfig","content","dehydratedLayoutConfig","dehydrateLayoutConfig","hasChanged","isEqual","debug","root","contentItems","length","handleLayoutItemPickedUp","handleLayoutItemDropped","handleComponentCreated","item","component","element","cssComponent","replace","toLowerCase","cssClass","addClass","eventHub","TITLE_CHANGED","previousLayoutConfig","loadNewConfig","hydrateLayoutConfig","remove","i","addChild","Children","map","child","cloneElement","propTypes","string","isRequired","node","shape","Layout","arrayOf","func"],"sources":["../src/DashboardLayout.tsx"],"sourcesContent":["import React, {\n ReactElement,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport PropTypes from 'prop-types';\nimport GoldenLayout from '@deephaven/golden-layout';\nimport type {\n Container,\n EventEmitter,\n ItemConfigType,\n ReactComponentConfig,\n} from '@deephaven/golden-layout';\nimport Log from '@deephaven/log';\nimport { usePrevious } from '@deephaven/react-hooks';\nimport { RootState } from '@deephaven/redux';\nimport { Provider, useDispatch, useSelector, useStore } from 'react-redux';\nimport PanelManager, { ClosedPanels } from './PanelManager';\nimport PanelErrorBoundary from './PanelErrorBoundary';\nimport LayoutUtils from './layout/LayoutUtils';\nimport {\n dehydrate as dehydrateDefault,\n hydrate as hydrateDefault,\n} from './DashboardUtils';\nimport PanelEvent from './PanelEvent';\nimport { GLPropTypes, useListener } from './layout';\nimport { getDashboardData, updateDashboardData } from './redux';\nimport {\n PanelComponentType,\n PanelDehydrateFunction,\n PanelHydrateFunction,\n} from './DashboardPlugin';\n\nexport type DashboardLayoutConfig = ItemConfigType[];\n\nconst log = Log.module('DashboardLayout');\n\nconst EMPTY_OBJECT = Object.freeze({});\n\nconst DEFAULT_LAYOUT_CONFIG: DashboardLayoutConfig = [];\n\nconst DEFAULT_CALLBACK = () => undefined;\n\n// If a component isn't registered, just pass through the props so they are saved if a plugin is loaded later\nconst FALLBACK_CALLBACK = (props: unknown) => props;\n\ntype DashboardData = {\n closed?: ClosedPanels;\n};\n\ninterface DashboardLayoutProps {\n id: string;\n\n // Default hydrate/dehydration functions\n hydrate?: PanelHydrateFunction;\n dehydrate?: PanelDehydrateFunction;\n layout: GoldenLayout;\n layoutConfig?: DashboardLayoutConfig;\n onLayoutChange?: (dehydratedLayout: DashboardLayoutConfig) => void;\n onLayoutInitialized?: () => void;\n data?: DashboardData;\n children?: React.ReactNode | React.ReactNode[];\n emptyDashboard?: React.ReactNode;\n}\n\n/**\n * DashboardLayout component. Handles hydrating, dehydrating components, listening for dragging panels.\n */\nexport function DashboardLayout({\n id,\n children,\n emptyDashboard = <div>Dashboard is empty.</div>,\n layout,\n layoutConfig = DEFAULT_LAYOUT_CONFIG,\n onLayoutChange = DEFAULT_CALLBACK,\n onLayoutInitialized = DEFAULT_CALLBACK,\n hydrate = hydrateDefault,\n dehydrate = dehydrateDefault,\n}: DashboardLayoutProps): JSX.Element {\n const dispatch = useDispatch();\n const data =\n useSelector<RootState>(state => getDashboardData(state, id)) ??\n EMPTY_OBJECT;\n\n const [isDashboardEmpty, setIsDashboardEmpty] = useState(false);\n const [isItemDragging, setIsItemDragging] = useState(false);\n const [lastConfig, setLastConfig] = useState<DashboardLayoutConfig>();\n const [initialClosedPanels] = useState<ReactComponentConfig[] | undefined>(\n (data as DashboardData)?.closed ?? []\n );\n const [isDashboardInitialized, setIsDashboardInitialized] = useState(false);\n\n const hydrateMap = useMemo(() => new Map(), []);\n const dehydrateMap = useMemo(() => new Map(), []);\n const store = useStore();\n const registerComponent = useCallback(\n (\n name: string,\n componentType: PanelComponentType,\n componentHydrate = hydrate,\n componentDehydrate = dehydrate\n ) => {\n log.debug2(\n 'registerComponent',\n name,\n componentType,\n componentHydrate,\n componentDehydrate\n );\n\n function renderComponent(\n props: { glContainer: Container; glEventHub: EventEmitter },\n ref: unknown\n ) {\n // Cast it to an `any` type so we can pass the ref in correctly.\n // ComponentType doesn't seem to work right, ReactNode is also incorrect\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const CType = componentType as any;\n\n // Props supplied by GoldenLayout\n // eslint-disable-next-line react/prop-types\n const { glContainer, glEventHub } = props;\n return (\n <Provider store={store}>\n <PanelErrorBoundary\n glContainer={glContainer}\n glEventHub={glEventHub}\n >\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <CType {...props} ref={ref} />\n </PanelErrorBoundary>\n </Provider>\n );\n }\n\n const wrappedComponent = React.forwardRef(renderComponent);\n const cleanup = layout.registerComponent(name, wrappedComponent);\n hydrateMap.set(name, componentHydrate);\n dehydrateMap.set(name, componentDehydrate);\n return cleanup;\n },\n [hydrate, dehydrate, hydrateMap, dehydrateMap, layout, store]\n );\n const hydrateComponent = useCallback(\n (name, props) => (hydrateMap.get(name) ?? FALLBACK_CALLBACK)(props, id),\n [hydrateMap, id]\n );\n const dehydrateComponent = useCallback(\n (name, config) => (dehydrateMap.get(name) ?? FALLBACK_CALLBACK)(config, id),\n [dehydrateMap, id]\n );\n const panelManager = useMemo(\n () =>\n new PanelManager(\n layout,\n hydrateComponent,\n dehydrateComponent,\n new Map(),\n initialClosedPanels,\n ({ closed, openedMap }) => {\n dispatch(updateDashboardData(id, { closed, openedMap }));\n }\n ),\n [\n dehydrateComponent,\n dispatch,\n hydrateComponent,\n id,\n initialClosedPanels,\n layout,\n ]\n );\n\n const handleLayoutStateChanged = useCallback(() => {\n // we don't want to emit stateChanges that happen during item drags or else\n // we risk the last saved state being one without that panel in the layout entirely\n if (isItemDragging) return;\n\n if (!isDashboardInitialized) {\n onLayoutInitialized();\n setIsDashboardInitialized(true);\n }\n\n const glConfig = layout.toConfig();\n const contentConfig = glConfig.content;\n const dehydratedLayoutConfig = LayoutUtils.dehydrateLayoutConfig(\n contentConfig,\n dehydrateComponent\n );\n const hasChanged =\n lastConfig == null ||\n !LayoutUtils.isEqual(lastConfig, dehydratedLayoutConfig);\n\n log.debug(\n 'handleLayoutStateChanged',\n hasChanged,\n contentConfig,\n dehydratedLayoutConfig\n );\n\n if (hasChanged) {\n setIsDashboardEmpty(layout.root.contentItems.length === 0);\n\n setLastConfig(dehydratedLayoutConfig);\n\n onLayoutChange(dehydratedLayoutConfig);\n }\n }, [\n dehydrateComponent,\n isDashboardInitialized,\n isItemDragging,\n lastConfig,\n layout,\n onLayoutChange,\n onLayoutInitialized,\n ]);\n\n const handleLayoutItemPickedUp = useCallback(() => {\n setIsItemDragging(true);\n }, []);\n\n const handleLayoutItemDropped = useCallback(() => {\n setIsItemDragging(false);\n }, []);\n\n const handleComponentCreated = useCallback(item => {\n log.debug2('handleComponentCreated', item);\n\n if (\n item == null ||\n item.config == null ||\n item.config.component == null ||\n item.element == null\n ) {\n return;\n }\n\n const cssComponent = item.config.component\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .toLowerCase();\n const cssClass = `${cssComponent}-component`;\n item.element.addClass(cssClass);\n }, []);\n\n useListener(layout, 'stateChanged', handleLayoutStateChanged);\n useListener(layout, 'itemPickedUp', handleLayoutItemPickedUp);\n useListener(layout, 'itemDropped', handleLayoutItemDropped);\n useListener(layout, 'componentCreated', handleComponentCreated);\n useListener(\n layout.eventHub,\n PanelEvent.TITLE_CHANGED,\n handleLayoutStateChanged\n );\n\n const previousLayoutConfig = usePrevious(layoutConfig);\n useEffect(\n function loadNewConfig() {\n if (\n previousLayoutConfig !== layoutConfig &&\n layoutConfig !== lastConfig\n ) {\n log.debug('Setting new layout content...');\n const content = LayoutUtils.hydrateLayoutConfig(\n layoutConfig,\n hydrateComponent\n );\n // Remove the old layout before add the new one\n while (layout.root.contentItems.length > 0) {\n layout.root.contentItems[0].remove();\n }\n\n // Add the new content. It is usally just one item from the root\n for (let i = 0; i < content.length; i += 1) {\n layout.root.addChild(content[i]);\n }\n\n setIsDashboardEmpty(layout.root.contentItems.length === 0);\n }\n },\n [\n hydrateComponent,\n layout,\n layoutConfig,\n lastConfig,\n panelManager,\n previousLayoutConfig,\n ]\n );\n\n return (\n <>\n {isDashboardEmpty && emptyDashboard}\n {React.Children.map(children, child =>\n child != null\n ? React.cloneElement(child as ReactElement, {\n id,\n layout,\n panelManager,\n registerComponent,\n })\n : null\n )}\n </>\n );\n}\n\nDashboardLayout.propTypes = {\n id: PropTypes.string.isRequired,\n children: PropTypes.node,\n data: PropTypes.shape({}),\n emptyDashboard: PropTypes.node,\n layout: GLPropTypes.Layout.isRequired,\n layoutConfig: PropTypes.arrayOf(PropTypes.shape({})),\n onLayoutChange: PropTypes.func,\n onLayoutInitialized: PropTypes.func,\n};\n\nexport default DashboardLayout;\n"],"mappings":";AAAA,OAAOA,KAAK,IAEVC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,QAAQ,QACH,OAAO;AACd,OAAOC,SAAS,MAAM,YAAY;AAQlC,OAAOC,GAAG,MAAM,gBAAgB;AAChC,SAASC,WAAW,QAAQ,wBAAwB;AAEpD,SAASC,QAAQ,EAAEC,WAAW,EAAEC,WAAW,EAAEC,QAAQ,QAAQ,aAAa;AAAC,OACpEC,YAAY;AAAA,OACZC,kBAAkB;AAAA,OAClBC,WAAW;AAAA,SAEhBC,SAAS,IAAIC,gBAAgB,EAC7BC,OAAO,IAAIC,cAAc;AAAA,OAEpBC,UAAU;AAAA,SACRC,WAAW,EA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B,EAChBpC,MAAM,EACNC,YAAY,EACZU,UAAU,EACV6B,YAAY,EACZ4B,oBAAoB,CACrB,CACF;EAED,oBACE,0CACG7D,gBAAgB,IAAIR,cAAc,EAClCrC,KAAK,CAACgH,QAAQ,CAACC,GAAG,CAAC7E,QAAQ,EAAE8E,KAAK,IACjCA,KAAK,IAAI,IAAI,gBACTlH,KAAK,CAACmH,YAAY,CAACD,KAAK,EAAkB;IACxC/E,EAAE;IACFG,MAAM;IACNwC,YAAY;IACZnB;EACF,CAAC,CAAC,GACF,IAAI,CACT,CACA;AAEP;AAEAzB,eAAe,CAACkF,SAAS,GAAG;EAC1BjF,EAAE,EAAE9B,SAAS,CAACgH,MAAM,CAACC,UAAU;EAC/BlF,QAAQ,EAAE/B,SAAS,CAACkH,IAAI;EACxB5E,IAAI,EAAEtC,SAAS,CAACmH,KAAK,CAAC,CAAC,CAAC,CAAC;EACzBnF,cAAc,EAAEhC,SAAS,CAACkH,IAAI;EAC9BjF,MAAM,EAAElB,WAAW,CAACqG,MAAM,CAACH,UAAU;EACrC/E,YAAY,EAAElC,SAAS,CAACqH,OAAO,CAACrH,SAAS,CAACmH,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;EACpDhF,cAAc,EAAEnC,SAAS,CAACsH,IAAI;EAC9BlF,mBAAmB,EAAEpC,SAAS,CAACsH;AACjC,CAAC;AAED,eAAezF,eAAe"}
@@ -4,7 +4,6 @@ import PanelManager from "./PanelManager.js";
4
4
  export function isWrappedComponent(type) {
5
5
  return (type === null || type === void 0 ? void 0 : type.WrappedComponent) !== undefined;
6
6
  }
7
-
8
7
  /**
9
8
  * Takes a partial DashboardPluginComponentProps and verifies all the dashboard component fields are filled in.
10
9
  * @param props The props to check
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardPlugin.js","names":["ComponentType","GoldenLayout","PanelManager","isWrappedComponent","type","WrappedComponent","undefined","isDashboardPluginProps","props","id","layout","panelManager","registerComponent","assertIsDashboardPluginProps","Error"],"sources":["../src/DashboardPlugin.ts"],"sourcesContent":["import { Component, ComponentType } from 'react';\nimport { ConnectedComponent } from 'react-redux';\nimport GoldenLayout from '@deephaven/golden-layout';\nimport type {\n ReactComponentConfig,\n EventEmitter,\n Container,\n} from '@deephaven/golden-layout';\nimport PanelManager from './PanelManager';\n\nexport type WrappedComponentType<\n P extends PanelProps,\n C extends ComponentType<P>\n> = ConnectedComponent<C, P>;\n\nexport type PanelComponentType<\n P extends PanelProps = PanelProps,\n C extends ComponentType<P> = ComponentType<P>\n> = ComponentType<P> | WrappedComponentType<P, C>;\n\nexport function isWrappedComponent<\n P extends PanelProps,\n C extends ComponentType<P>\n>(type: PanelComponentType<P, C>): type is WrappedComponentType<P, C> {\n return (type as WrappedComponentType<P, C>)?.WrappedComponent !== undefined;\n}\n\nexport type PanelProps = {\n glContainer: Container;\n glEventHub: EventEmitter;\n};\n\nexport type PanelComponent<T extends PanelProps = PanelProps> = Component<T>;\n\nexport type PanelConfig = ReactComponentConfig & {\n componentState?: Record<string, unknown> | null;\n};\n\nexport type DashboardConfig = {\n id: string;\n layout: GoldenLayout;\n panelManager: PanelManager;\n};\n\nexport interface DashboardPanelDefinition {\n name: string;\n definition: ComponentType;\n}\n\nexport type DeregisterComponentFunction = () => void;\n\nexport type PanelHydrateFunction<T = PanelProps> = (\n props: T,\n dashboardId: string\n) => PanelProps;\n\nexport type PanelDehydrateFunction = (\n config: PanelConfig,\n dashboardId: string\n) => PanelConfig | null;\n\nexport type DashboardPluginComponentProps = {\n id: string;\n layout: GoldenLayout;\n panelManager: PanelManager;\n registerComponent: <P extends PanelProps, C extends ComponentType<P>>(\n name: string,\n ComponentType: PanelComponentType<P, C>,\n hydrate?: PanelHydrateFunction<P>,\n dehydrate?: PanelDehydrateFunction\n ) => DeregisterComponentFunction;\n};\n\nexport interface DashboardPlugin {\n panels?: DashboardPanelDefinition[];\n\n /** Hydrate the provided panel and props. Return the same object if no changes made. */\n hydrateComponent?: (name: string, props: PanelProps) => PanelProps;\n\n /** Dehydrate a component. Return the same object if no changes made, or `null` if the component should not be saved */\n dehydrateComponent?: (\n name: string,\n config: PanelConfig\n ) => PanelConfig | null;\n\n /** Called when the dashboard is initialized and layout is ready. */\n initialize?: (config: DashboardConfig) => void;\n\n /** Called when the dashboard is unintialized and layout is about to be destroyed */\n deinitialize?: (config: DashboardConfig) => void;\n}\n\n/**\n * Takes a partial DashboardPluginComponentProps and verifies all the dashboard component fields are filled in.\n * @param props The props to check\n * @returns True if the props are valid DashboardPluginComponentProps, false otherwise\n */\nexport function isDashboardPluginProps(\n props: Partial<DashboardPluginComponentProps>\n): props is DashboardPluginComponentProps {\n return (\n typeof props.id === 'string' &&\n props.layout instanceof GoldenLayout &&\n props.panelManager instanceof PanelManager &&\n typeof props.registerComponent === 'function'\n );\n}\n\nexport function assertIsDashboardPluginProps(\n props: Partial<DashboardPluginComponentProps>\n): asserts props is DashboardPluginComponentProps {\n if (!isDashboardPluginProps(props)) {\n throw new Error(\n `Expected dashboard plugin props, but instead received ${props}`\n );\n }\n}\n"],"mappings":"AAAA,SAAoBA,aAApB,QAAyC,OAAzC;AAEA,OAAOC,YAAP,MAAyB,0BAAzB;OAMOC,Y;AAYP,OAAO,SAASC,kBAAT,CAGLC,IAHK,EAG+D;EACpE,OAAO,CAACA,IAAD,aAACA,IAAD,uBAACA,IAAD,CAAsCC,gBAAtC,MAA2DC,SAAlE;AACD;;AAmED;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAT,CACLC,KADK,EAEmC;EACxC,OACE,OAAOA,KAAK,CAACC,EAAb,KAAoB,QAApB,IACAD,KAAK,CAACE,MAAN,YAAwBT,YADxB,IAEAO,KAAK,CAACG,YAAN,YAA8BT,YAF9B,IAGA,OAAOM,KAAK,CAACI,iBAAb,KAAmC,UAJrC;AAMD;AAED,OAAO,SAASC,4BAAT,CACLL,KADK,EAE2C;EAChD,IAAI,CAACD,sBAAsB,CAACC,KAAD,CAA3B,EAAoC;IAClC,MAAM,IAAIM,KAAJ,iEACqDN,KADrD,EAAN;EAGD;AACF"}
1
+ {"version":3,"file":"DashboardPlugin.js","names":["ComponentType","GoldenLayout","PanelManager","isWrappedComponent","type","WrappedComponent","undefined","isDashboardPluginProps","props","id","layout","panelManager","registerComponent","assertIsDashboardPluginProps","Error"],"sources":["../src/DashboardPlugin.ts"],"sourcesContent":["import { Component, ComponentType } from 'react';\nimport { ConnectedComponent } from 'react-redux';\nimport GoldenLayout from '@deephaven/golden-layout';\nimport type {\n ReactComponentConfig,\n EventEmitter,\n Container,\n} from '@deephaven/golden-layout';\nimport PanelManager from './PanelManager';\n\nexport type WrappedComponentType<\n P extends PanelProps,\n C extends ComponentType<P>\n> = ConnectedComponent<C, P>;\n\nexport type PanelComponentType<\n P extends PanelProps = PanelProps,\n C extends ComponentType<P> = ComponentType<P>\n> = ComponentType<P> | WrappedComponentType<P, C>;\n\nexport function isWrappedComponent<\n P extends PanelProps,\n C extends ComponentType<P>\n>(type: PanelComponentType<P, C>): type is WrappedComponentType<P, C> {\n return (type as WrappedComponentType<P, C>)?.WrappedComponent !== undefined;\n}\n\nexport type PanelProps = {\n glContainer: Container;\n glEventHub: EventEmitter;\n};\n\nexport type PanelComponent<T extends PanelProps = PanelProps> = Component<T>;\n\nexport type PanelConfig = ReactComponentConfig & {\n componentState?: Record<string, unknown> | null;\n};\n\nexport type DashboardConfig = {\n id: string;\n layout: GoldenLayout;\n panelManager: PanelManager;\n};\n\nexport interface DashboardPanelDefinition {\n name: string;\n definition: ComponentType;\n}\n\nexport type DeregisterComponentFunction = () => void;\n\nexport type PanelHydrateFunction<T = PanelProps> = (\n props: T,\n dashboardId: string\n) => PanelProps;\n\nexport type PanelDehydrateFunction = (\n config: PanelConfig,\n dashboardId: string\n) => PanelConfig | null;\n\nexport type DashboardPluginComponentProps = {\n id: string;\n layout: GoldenLayout;\n panelManager: PanelManager;\n registerComponent: <P extends PanelProps, C extends ComponentType<P>>(\n name: string,\n ComponentType: PanelComponentType<P, C>,\n hydrate?: PanelHydrateFunction<P>,\n dehydrate?: PanelDehydrateFunction\n ) => DeregisterComponentFunction;\n};\n\nexport interface DashboardPlugin {\n panels?: DashboardPanelDefinition[];\n\n /** Hydrate the provided panel and props. Return the same object if no changes made. */\n hydrateComponent?: (name: string, props: PanelProps) => PanelProps;\n\n /** Dehydrate a component. Return the same object if no changes made, or `null` if the component should not be saved */\n dehydrateComponent?: (\n name: string,\n config: PanelConfig\n ) => PanelConfig | null;\n\n /** Called when the dashboard is initialized and layout is ready. */\n initialize?: (config: DashboardConfig) => void;\n\n /** Called when the dashboard is unintialized and layout is about to be destroyed */\n deinitialize?: (config: DashboardConfig) => void;\n}\n\n/**\n * Takes a partial DashboardPluginComponentProps and verifies all the dashboard component fields are filled in.\n * @param props The props to check\n * @returns True if the props are valid DashboardPluginComponentProps, false otherwise\n */\nexport function isDashboardPluginProps(\n props: Partial<DashboardPluginComponentProps>\n): props is DashboardPluginComponentProps {\n return (\n typeof props.id === 'string' &&\n props.layout instanceof GoldenLayout &&\n props.panelManager instanceof PanelManager &&\n typeof props.registerComponent === 'function'\n );\n}\n\nexport function assertIsDashboardPluginProps(\n props: Partial<DashboardPluginComponentProps>\n): asserts props is DashboardPluginComponentProps {\n if (!isDashboardPluginProps(props)) {\n throw new Error(\n `Expected dashboard plugin props, but instead received ${props}`\n );\n }\n}\n"],"mappings":"AAAA,SAAoBA,aAAa,QAAQ,OAAO;AAEhD,OAAOC,YAAY,MAAM,0BAA0B;AAAC,OAM7CC,YAAY;AAYnB,OAAO,SAASC,kBAAkB,CAGhCC,IAA8B,EAAsC;EACpE,OAAO,CAACA,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAiCC,gBAAgB,MAAKC,SAAS;AAC7E;AAmEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsB,CACpCC,KAA6C,EACL;EACxC,OACE,OAAOA,KAAK,CAACC,EAAE,KAAK,QAAQ,IAC5BD,KAAK,CAACE,MAAM,YAAYT,YAAY,IACpCO,KAAK,CAACG,YAAY,YAAYT,YAAY,IAC1C,OAAOM,KAAK,CAACI,iBAAiB,KAAK,UAAU;AAEjD;AAEA,OAAO,SAASC,4BAA4B,CAC1CL,KAA6C,EACG;EAChD,IAAI,CAACD,sBAAsB,CAACC,KAAK,CAAC,EAAE;IAClC,MAAM,IAAIM,KAAK,iEAC4CN,KAAK,EAC/D;EACH;AACF"}
@@ -1,9 +1,6 @@
1
1
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
-
3
2
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
-
5
3
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
7
4
  /**
8
5
  * Dehydrate an existing panel to allow it to be serialized/saved.
9
6
  * Just takes what's in the panels `metadata` in the props and `panelState` in
@@ -22,29 +19,25 @@ export function dehydrate(config) {
22
19
  var {
23
20
  panelState = null
24
21
  } = props;
25
-
26
22
  if (componentState) {
27
23
  ({
28
24
  panelState
29
25
  } = componentState);
30
26
  }
31
-
32
27
  var newProps = {};
33
-
34
28
  if (metadata != null) {
35
29
  newProps.metadata = metadata;
36
30
  }
37
-
38
31
  if (panelState != null) {
39
32
  newProps.panelState = panelState;
40
33
  }
41
-
42
34
  return _objectSpread(_objectSpread({}, config), {}, {
43
35
  componentState: null,
44
36
  props: newProps,
45
37
  type: 'react-component'
46
38
  });
47
39
  }
40
+
48
41
  /**
49
42
  * Default hydration function. Just applies the dashboard ID. When used with dehydrate above,
50
43
  * the panels state will be stored in `panelState` prop.
@@ -52,7 +45,6 @@ export function dehydrate(config) {
52
45
  * @param localDashboardId The local dashboard ID to hydrate the panel with
53
46
  * @returns The hydrated panel props
54
47
  */
55
-
56
48
  export function hydrate(props) {
57
49
  var localDashboardId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
58
50
  return _objectSpread(_objectSpread({
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardUtils.js","names":["dehydrate","config","props","componentState","metadata","panelState","newProps","type","hydrate","localDashboardId"],"sources":["../src/DashboardUtils.ts"],"sourcesContent":["import { PanelConfig, PanelProps } from './DashboardPlugin';\n\nexport type DashboardPanelProps = PanelProps & {\n localDashboardId: string;\n metadata?: Record<string, unknown>;\n};\n\n/**\n * Dehydrate an existing panel to allow it to be serialized/saved.\n * Just takes what's in the panels `metadata` in the props and `panelState` in\n * the component state, assumes it's serializable, and saves it.\n * @param config The panel config to dehydrate\n * @returns The dehydrated PanelConfig\n */\nexport function dehydrate(config: PanelConfig): PanelConfig | null {\n const { props, componentState } = config;\n const { metadata } = props;\n let { panelState = null } = props;\n if (componentState) {\n ({ panelState } = componentState);\n }\n const newProps: Record<string, unknown> = {};\n if (metadata != null) {\n newProps.metadata = metadata;\n }\n if (panelState != null) {\n newProps.panelState = panelState;\n }\n\n return {\n ...config,\n componentState: null,\n props: newProps,\n type: 'react-component',\n };\n}\n\n/**\n * Default hydration function. Just applies the dashboard ID. When used with dehydrate above,\n * the panels state will be stored in `panelState` prop.\n * @param props Panel props to hydrate\n * @param localDashboardId The local dashboard ID to hydrate the panel with\n * @returns The hydrated panel props\n */\nexport function hydrate(\n props: PanelProps & Record<string, unknown>,\n localDashboardId = ''\n): DashboardPanelProps {\n return {\n metadata: {},\n ...props,\n localDashboardId,\n };\n}\n\nexport default {\n dehydrate,\n hydrate,\n};\n"],"mappings":";;;;;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,SAAT,CAAmBC,MAAnB,EAA4D;EACjE,IAAM;IAAEC,KAAF;IAASC;EAAT,IAA4BF,MAAlC;EACA,IAAM;IAAEG;EAAF,IAAeF,KAArB;EACA,IAAI;IAAEG,UAAU,GAAG;EAAf,IAAwBH,KAA5B;;EACA,IAAIC,cAAJ,EAAoB;IAClB,CAAC;MAAEE;IAAF,IAAiBF,cAAlB;EACD;;EACD,IAAMG,QAAiC,GAAG,EAA1C;;EACA,IAAIF,QAAQ,IAAI,IAAhB,EAAsB;IACpBE,QAAQ,CAACF,QAAT,GAAoBA,QAApB;EACD;;EACD,IAAIC,UAAU,IAAI,IAAlB,EAAwB;IACtBC,QAAQ,CAACD,UAAT,GAAsBA,UAAtB;EACD;;EAED,uCACKJ,MADL;IAEEE,cAAc,EAAE,IAFlB;IAGED,KAAK,EAAEI,QAHT;IAIEC,IAAI,EAAE;EAJR;AAMD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,OAAT,CACLN,KADK,EAGgB;EAAA,IADrBO,gBACqB,uEADF,EACE;EACrB;IACEL,QAAQ,EAAE;EADZ,GAEKF,KAFL;IAGEO;EAHF;AAKD;AAED,eAAe;EACbT,SADa;EAEbQ;AAFa,CAAf"}
1
+ {"version":3,"file":"DashboardUtils.js","names":["dehydrate","config","props","componentState","metadata","panelState","newProps","type","hydrate","localDashboardId"],"sources":["../src/DashboardUtils.ts"],"sourcesContent":["import { PanelConfig, PanelProps } from './DashboardPlugin';\n\nexport type DashboardPanelProps = PanelProps & {\n localDashboardId: string;\n metadata?: Record<string, unknown>;\n};\n\n/**\n * Dehydrate an existing panel to allow it to be serialized/saved.\n * Just takes what's in the panels `metadata` in the props and `panelState` in\n * the component state, assumes it's serializable, and saves it.\n * @param config The panel config to dehydrate\n * @returns The dehydrated PanelConfig\n */\nexport function dehydrate(config: PanelConfig): PanelConfig | null {\n const { props, componentState } = config;\n const { metadata } = props;\n let { panelState = null } = props;\n if (componentState) {\n ({ panelState } = componentState);\n }\n const newProps: Record<string, unknown> = {};\n if (metadata != null) {\n newProps.metadata = metadata;\n }\n if (panelState != null) {\n newProps.panelState = panelState;\n }\n\n return {\n ...config,\n componentState: null,\n props: newProps,\n type: 'react-component',\n };\n}\n\n/**\n * Default hydration function. Just applies the dashboard ID. When used with dehydrate above,\n * the panels state will be stored in `panelState` prop.\n * @param props Panel props to hydrate\n * @param localDashboardId The local dashboard ID to hydrate the panel with\n * @returns The hydrated panel props\n */\nexport function hydrate(\n props: PanelProps & Record<string, unknown>,\n localDashboardId = ''\n): DashboardPanelProps {\n return {\n metadata: {},\n ...props,\n localDashboardId,\n };\n}\n\nexport default {\n dehydrate,\n hydrate,\n};\n"],"mappings":";;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,SAAS,CAACC,MAAmB,EAAsB;EACjE,IAAM;IAAEC,KAAK;IAAEC;EAAe,CAAC,GAAGF,MAAM;EACxC,IAAM;IAAEG;EAAS,CAAC,GAAGF,KAAK;EAC1B,IAAI;IAAEG,UAAU,GAAG;EAAK,CAAC,GAAGH,KAAK;EACjC,IAAIC,cAAc,EAAE;IAClB,CAAC;MAAEE;IAAW,CAAC,GAAGF,cAAc;EAClC;EACA,IAAMG,QAAiC,GAAG,CAAC,CAAC;EAC5C,IAAIF,QAAQ,IAAI,IAAI,EAAE;IACpBE,QAAQ,CAACF,QAAQ,GAAGA,QAAQ;EAC9B;EACA,IAAIC,UAAU,IAAI,IAAI,EAAE;IACtBC,QAAQ,CAACD,UAAU,GAAGA,UAAU;EAClC;EAEA,uCACKJ,MAAM;IACTE,cAAc,EAAE,IAAI;IACpBD,KAAK,EAAEI,QAAQ;IACfC,IAAI,EAAE;EAAiB;AAE3B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,OAAO,CACrBN,KAA2C,EAEtB;EAAA,IADrBO,gBAAgB,uEAAG,EAAE;EAErB;IACEL,QAAQ,EAAE,CAAC;EAAC,GACTF,KAAK;IACRO;EAAgB;AAEpB;AAEA,eAAe;EACbT,SAAS;EACTQ;AACF,CAAC"}
@@ -5,7 +5,6 @@ import PanelEvent from "./PanelEvent.js";
5
5
  import LayoutUtils from "./layout/LayoutUtils.js";
6
6
  import "./PanelErrorBoundary.css";
7
7
  var log = Log.module('PanelErrorBoundary');
8
-
9
8
  /**
10
9
  * Panel wrapper implementing Error Boundary and emitting Closed event.
11
10
  * Closed event has to be emitted from the wrapper instead of the panel itself
@@ -19,13 +18,11 @@ class PanelErrorBoundary extends Component {
19
18
  error: null
20
19
  };
21
20
  }
22
-
23
21
  componentDidCatch(error) {
24
22
  this.setState({
25
23
  error
26
24
  });
27
25
  }
28
-
29
26
  componentWillUnmount() {
30
27
  var {
31
28
  glContainer,
@@ -35,7 +32,6 @@ class PanelErrorBoundary extends Component {
35
32
  log.debug('componentWillUnmount', panelId);
36
33
  glEventHub.emit(PanelEvent.CLOSED, panelId, glContainer);
37
34
  }
38
-
39
35
  render() {
40
36
  var {
41
37
  children
@@ -43,7 +39,6 @@ class PanelErrorBoundary extends Component {
43
39
  var {
44
40
  error
45
41
  } = this.state;
46
-
47
42
  if (error != null) {
48
43
  return /*#__PURE__*/React.createElement("div", {
49
44
  className: "panel-error-boundary"
@@ -53,11 +48,8 @@ class PanelErrorBoundary extends Component {
53
48
  isLoaded: false
54
49
  }));
55
50
  }
56
-
57
51
  return children;
58
52
  }
59
-
60
53
  }
61
-
62
54
  export default PanelErrorBoundary;
63
55
  //# sourceMappingURL=PanelErrorBoundary.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PanelErrorBoundary.js","names":["React","Component","LoadingOverlay","Log","PanelEvent","LayoutUtils","log","module","PanelErrorBoundary","constructor","props","state","error","componentDidCatch","setState","componentWillUnmount","glContainer","glEventHub","panelId","getIdFromContainer","debug","emit","CLOSED","render","children"],"sources":["../src/PanelErrorBoundary.tsx"],"sourcesContent":["import React, { Component, ReactNode } from 'react';\nimport { LoadingOverlay } from '@deephaven/components';\nimport type { Container, EventEmitter } from '@deephaven/golden-layout';\nimport Log from '@deephaven/log';\nimport PanelEvent from './PanelEvent';\nimport LayoutUtils from './layout/LayoutUtils';\nimport './PanelErrorBoundary.scss';\n\nconst log = Log.module('PanelErrorBoundary');\n\ninterface PanelErrorBoundaryProps {\n children: ReactNode;\n glContainer: Container;\n glEventHub: EventEmitter;\n}\n\ninterface PanelErrorBoundaryState {\n error: Error | null;\n}\n/**\n * Panel wrapper implementing Error Boundary and emitting Closed event.\n * Closed event has to be emitted from the wrapper instead of the panel itself\n * because the panel can get unmounted on errors\n * and we want to differentiate between unmount on error vs panel being intentionally closed.\n */\nclass PanelErrorBoundary extends Component<\n PanelErrorBoundaryProps,\n PanelErrorBoundaryState\n> {\n constructor(props: PanelErrorBoundaryProps) {\n super(props);\n this.state = { error: null };\n }\n\n componentDidCatch(error: Error): void {\n this.setState({ error });\n }\n\n componentWillUnmount(): void {\n const { glContainer, glEventHub } = this.props;\n const panelId = LayoutUtils.getIdFromContainer(glContainer);\n log.debug('componentWillUnmount', panelId);\n glEventHub.emit(PanelEvent.CLOSED, panelId, glContainer);\n }\n\n render(): ReactNode {\n const { children } = this.props;\n const { error } = this.state;\n if (error != null) {\n return (\n <div className=\"panel-error-boundary\">\n <LoadingOverlay\n errorMessage={`${error}`}\n isLoading={false}\n isLoaded={false}\n />\n </div>\n );\n }\n return children;\n }\n}\n\nexport default PanelErrorBoundary;\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAA4C,OAA5C;AACA,SAASC,cAAT,QAA+B,uBAA/B;AAEA,OAAOC,GAAP,MAAgB,gBAAhB;OACOC,U;OACAC,W;;AAGP,IAAMC,GAAG,GAAGH,GAAG,CAACI,MAAJ,CAAW,oBAAX,CAAZ;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,kBAAN,SAAiCP,SAAjC,CAGE;EACAQ,WAAW,CAACC,KAAD,EAAiC;IAC1C,MAAMA,KAAN;IACA,KAAKC,KAAL,GAAa;MAAEC,KAAK,EAAE;IAAT,CAAb;EACD;;EAEDC,iBAAiB,CAACD,KAAD,EAAqB;IACpC,KAAKE,QAAL,CAAc;MAAEF;IAAF,CAAd;EACD;;EAEDG,oBAAoB,GAAS;IAC3B,IAAM;MAAEC,WAAF;MAAeC;IAAf,IAA8B,KAAKP,KAAzC;IACA,IAAMQ,OAAO,GAAGb,WAAW,CAACc,kBAAZ,CAA+BH,WAA/B,CAAhB;IACAV,GAAG,CAACc,KAAJ,CAAU,sBAAV,EAAkCF,OAAlC;IACAD,UAAU,CAACI,IAAX,CAAgBjB,UAAU,CAACkB,MAA3B,EAAmCJ,OAAnC,EAA4CF,WAA5C;EACD;;EAEDO,MAAM,GAAc;IAClB,IAAM;MAAEC;IAAF,IAAe,KAAKd,KAA1B;IACA,IAAM;MAAEE;IAAF,IAAY,KAAKD,KAAvB;;IACA,IAAIC,KAAK,IAAI,IAAb,EAAmB;MACjB,oBACE;QAAK,SAAS,EAAC;MAAf,gBACE,oBAAC,cAAD;QACE,YAAY,YAAKA,KAAL,CADd;QAEE,SAAS,EAAE,KAFb;QAGE,QAAQ,EAAE;MAHZ,EADF,CADF;IASD;;IACD,OAAOY,QAAP;EACD;;AAhCD;;AAmCF,eAAehB,kBAAf"}
1
+ {"version":3,"file":"PanelErrorBoundary.js","names":["React","Component","LoadingOverlay","Log","PanelEvent","LayoutUtils","log","module","PanelErrorBoundary","constructor","props","state","error","componentDidCatch","setState","componentWillUnmount","glContainer","glEventHub","panelId","getIdFromContainer","debug","emit","CLOSED","render","children"],"sources":["../src/PanelErrorBoundary.tsx"],"sourcesContent":["import React, { Component, ReactNode } from 'react';\nimport { LoadingOverlay } from '@deephaven/components';\nimport type { Container, EventEmitter } from '@deephaven/golden-layout';\nimport Log from '@deephaven/log';\nimport PanelEvent from './PanelEvent';\nimport LayoutUtils from './layout/LayoutUtils';\nimport './PanelErrorBoundary.scss';\n\nconst log = Log.module('PanelErrorBoundary');\n\ninterface PanelErrorBoundaryProps {\n children: ReactNode;\n glContainer: Container;\n glEventHub: EventEmitter;\n}\n\ninterface PanelErrorBoundaryState {\n error: Error | null;\n}\n/**\n * Panel wrapper implementing Error Boundary and emitting Closed event.\n * Closed event has to be emitted from the wrapper instead of the panel itself\n * because the panel can get unmounted on errors\n * and we want to differentiate between unmount on error vs panel being intentionally closed.\n */\nclass PanelErrorBoundary extends Component<\n PanelErrorBoundaryProps,\n PanelErrorBoundaryState\n> {\n constructor(props: PanelErrorBoundaryProps) {\n super(props);\n this.state = { error: null };\n }\n\n componentDidCatch(error: Error): void {\n this.setState({ error });\n }\n\n componentWillUnmount(): void {\n const { glContainer, glEventHub } = this.props;\n const panelId = LayoutUtils.getIdFromContainer(glContainer);\n log.debug('componentWillUnmount', panelId);\n glEventHub.emit(PanelEvent.CLOSED, panelId, glContainer);\n }\n\n render(): ReactNode {\n const { children } = this.props;\n const { error } = this.state;\n if (error != null) {\n return (\n <div className=\"panel-error-boundary\">\n <LoadingOverlay\n errorMessage={`${error}`}\n isLoading={false}\n isLoaded={false}\n />\n </div>\n );\n }\n return children;\n }\n}\n\nexport default PanelErrorBoundary;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,QAAmB,OAAO;AACnD,SAASC,cAAc,QAAQ,uBAAuB;AAEtD,OAAOC,GAAG,MAAM,gBAAgB;AAAC,OAC1BC,UAAU;AAAA,OACVC,WAAW;AAAA;AAGlB,IAAMC,GAAG,GAAGH,GAAG,CAACI,MAAM,CAAC,oBAAoB,CAAC;AAW5C;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,kBAAkB,SAASP,SAAS,CAGxC;EACAQ,WAAW,CAACC,KAA8B,EAAE;IAC1C,KAAK,CAACA,KAAK,CAAC;IACZ,IAAI,CAACC,KAAK,GAAG;MAAEC,KAAK,EAAE;IAAK,CAAC;EAC9B;EAEAC,iBAAiB,CAACD,KAAY,EAAQ;IACpC,IAAI,CAACE,QAAQ,CAAC;MAAEF;IAAM,CAAC,CAAC;EAC1B;EAEAG,oBAAoB,GAAS;IAC3B,IAAM;MAAEC,WAAW;MAAEC;IAAW,CAAC,GAAG,IAAI,CAACP,KAAK;IAC9C,IAAMQ,OAAO,GAAGb,WAAW,CAACc,kBAAkB,CAACH,WAAW,CAAC;IAC3DV,GAAG,CAACc,KAAK,CAAC,sBAAsB,EAAEF,OAAO,CAAC;IAC1CD,UAAU,CAACI,IAAI,CAACjB,UAAU,CAACkB,MAAM,EAAEJ,OAAO,EAAEF,WAAW,CAAC;EAC1D;EAEAO,MAAM,GAAc;IAClB,IAAM;MAAEC;IAAS,CAAC,GAAG,IAAI,CAACd,KAAK;IAC/B,IAAM;MAAEE;IAAM,CAAC,GAAG,IAAI,CAACD,KAAK;IAC5B,IAAIC,KAAK,IAAI,IAAI,EAAE;MACjB,oBACE;QAAK,SAAS,EAAC;MAAsB,gBACnC,oBAAC,cAAc;QACb,YAAY,YAAKA,KAAK,CAAG;QACzB,SAAS,EAAE,KAAM;QACjB,QAAQ,EAAE;MAAM,EAChB,CACE;IAEV;IACA,OAAOY,QAAQ;EACjB;AACF;AAEA,eAAehB,kBAAkB"}
@@ -1 +1 @@
1
- {"version":3,"file":"PanelEvent.js","names":["Object","freeze","FOCUS","MOUNT","UNMOUNT","TITLE_CHANGED","REOPEN","DELETE","CLONED","CLOSED","OPEN","CLOSE"],"sources":["../src/PanelEvent.ts"],"sourcesContent":["/**\n * Events emitted by panels and to control panels\n */\nexport default Object.freeze({\n // Panel has received focus\n FOCUS: 'PanelEvent.FOCUS',\n\n // Panel has been mounted\n MOUNT: 'PanelEvent.MOUNT',\n\n // Panel has been unmounted\n UNMOUNT: 'PanelEvent.UNMOUNT',\n\n // The title of the panel has changed\n TITLE_CHANGED: 'PanelEvent.TITLE_CHANGED',\n\n // Panel was re-opened from a dehydrated state\n REOPEN: 'PanelEvent.REOPEN',\n\n // Panel was deleted\n DELETE: 'PanelEvent.DELETE',\n\n // Panel was cloned/copied\n CLONED: 'PanelEvent.CLONED',\n\n // Panel was closed\n CLOSED: 'PanelEvent.CLOSED',\n\n // Event to open a new panel\n // Plugins will need to register to open based on this event.\n // Multiple plugins could open panels for the same event if desired.\n OPEN: 'PanelEvent.OPEN',\n\n // Event to close a panel that's currently open\n CLOSE: 'PanelEvent.CLOSE',\n});\n"],"mappings":"AAAA;AACA;AACA;AACA,eAAeA,MAAM,CAACC,MAAP,CAAc;EAC3B;EACAC,KAAK,EAAE,kBAFoB;EAI3B;EACAC,KAAK,EAAE,kBALoB;EAO3B;EACAC,OAAO,EAAE,oBARkB;EAU3B;EACAC,aAAa,EAAE,0BAXY;EAa3B;EACAC,MAAM,EAAE,mBAdmB;EAgB3B;EACAC,MAAM,EAAE,mBAjBmB;EAmB3B;EACAC,MAAM,EAAE,mBApBmB;EAsB3B;EACAC,MAAM,EAAE,mBAvBmB;EAyB3B;EACA;EACA;EACAC,IAAI,EAAE,iBA5BqB;EA8B3B;EACAC,KAAK,EAAE;AA/BoB,CAAd,CAAf"}
1
+ {"version":3,"file":"PanelEvent.js","names":["Object","freeze","FOCUS","MOUNT","UNMOUNT","TITLE_CHANGED","REOPEN","DELETE","CLONED","CLOSED","OPEN","CLOSE"],"sources":["../src/PanelEvent.ts"],"sourcesContent":["/**\n * Events emitted by panels and to control panels\n */\nexport default Object.freeze({\n // Panel has received focus\n FOCUS: 'PanelEvent.FOCUS',\n\n // Panel has been mounted\n MOUNT: 'PanelEvent.MOUNT',\n\n // Panel has been unmounted\n UNMOUNT: 'PanelEvent.UNMOUNT',\n\n // The title of the panel has changed\n TITLE_CHANGED: 'PanelEvent.TITLE_CHANGED',\n\n // Panel was re-opened from a dehydrated state\n REOPEN: 'PanelEvent.REOPEN',\n\n // Panel was deleted\n DELETE: 'PanelEvent.DELETE',\n\n // Panel was cloned/copied\n CLONED: 'PanelEvent.CLONED',\n\n // Panel was closed\n CLOSED: 'PanelEvent.CLOSED',\n\n // Event to open a new panel\n // Plugins will need to register to open based on this event.\n // Multiple plugins could open panels for the same event if desired.\n OPEN: 'PanelEvent.OPEN',\n\n // Event to close a panel that's currently open\n CLOSE: 'PanelEvent.CLOSE',\n});\n"],"mappings":"AAAA;AACA;AACA;AACA,eAAeA,MAAM,CAACC,MAAM,CAAC;EAC3B;EACAC,KAAK,EAAE,kBAAkB;EAEzB;EACAC,KAAK,EAAE,kBAAkB;EAEzB;EACAC,OAAO,EAAE,oBAAoB;EAE7B;EACAC,aAAa,EAAE,0BAA0B;EAEzC;EACAC,MAAM,EAAE,mBAAmB;EAE3B;EACAC,MAAM,EAAE,mBAAmB;EAE3B;EACAC,MAAM,EAAE,mBAAmB;EAE3B;EACAC,MAAM,EAAE,mBAAmB;EAE3B;EACA;EACA;EACAC,IAAI,EAAE,iBAAiB;EAEvB;EACAC,KAAK,EAAE;AACT,CAAC,CAAC"}