@deephaven/dashboard 0.50.1-beta.5 → 0.51.1-alpha-theme-fix.1
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.
- package/dist/Dashboard.js.map +1 -1
- package/dist/DashboardLayout.js.map +1 -1
- package/dist/DashboardPanelWrapper.js.map +1 -1
- package/dist/DashboardPlugin.js +6 -0
- package/dist/DashboardPlugin.js.map +1 -1
- package/dist/DashboardUtils.js.map +1 -1
- package/dist/PanelErrorBoundary.js.map +1 -1
- package/dist/PanelManager.js.map +1 -1
- package/dist/PanelPlaceholder.js.map +1 -1
- package/dist/layout/GLPropTypes.js.map +1 -1
- package/dist/layout/LayoutUtils.js.map +1 -1
- package/dist/layout/useDashboardPanel.js.map +1 -1
- package/dist/layout/useListener.js.map +1 -1
- package/dist/layout/usePanelRegistration.js.map +1 -1
- package/dist/redux/actions.js.map +1 -1
- package/dist/redux/index.js.map +1 -1
- package/dist/redux/selectors.js.map +1 -1
- package/package.json +10 -10
package/dist/Dashboard.js.map
CHANGED
|
@@ -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","panelWrapper","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 ComponentType,\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 = (): void => 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 /** Component to wrap each panel with */\n panelWrapper?: ComponentType;\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 panelWrapper,\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 = (): void => {\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 panelWrapper={panelWrapper}\n >\n {children}\n </DashboardLayout>\n )}\n </div>\n );\n}\n\nexport default Dashboard;\n"],"mappings":";;;;;AAAA,OAAOA,KAAK,IAIVC,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;AAAA;AAAA;AAQtB,IAAMC,eAAe,GAAG,GAAG;AAE3B,IAAMC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"Dashboard.js","names":["React","useEffect","useMemo","useRef","useState","throttle","GoldenLayout","LayoutUtils","PanelPlaceholder","DashboardLayout","jsx","_jsx","jsxs","_jsxs","RESIZE_THROTTLE","DEFAULT_CALLBACK","undefined","EMPTY_OBJECT","Object","freeze","Dashboard","_ref","id","children","emptyDashboard","layoutConfig","layoutSettings","onLayoutConfigChange","onGoldenLayoutChange","onLayoutInitialized","fallbackComponent","hydrate","dehydrate","panelWrapper","layoutElement","isInitialized","setIsInitialized","layout","setLayout","initDashboard","current","config","_objectSpread","makeDefaultLayout","settings","assign","content","newLayout","onInit","off","on","setFallbackComponent","init","destroy","handleResize","isInitialised","updateSize","initResizeEventListner","window","addEventListener","removeEventListener","className","ref","onLayoutChange"],"sources":["../src/Dashboard.tsx"],"sourcesContent":["import React, {\n ComponentType,\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 = (): void => 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 /** Component to wrap each panel with */\n panelWrapper?: ComponentType;\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 panelWrapper,\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 = (): void => {\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 panelWrapper={panelWrapper}\n >\n {children}\n </DashboardLayout>\n )}\n </div>\n );\n}\n\nexport default Dashboard;\n"],"mappings":";;;;;AAAA,OAAOA,KAAK,IAIVC,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;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAQtB,IAAMC,eAAe,GAAG,GAAG;AAE3B,IAAMC,gBAAgB,GAAGA,CAAA,KAAYC,SAAS;AAE9C,IAAMC,YAAY,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,CAAC;AAqBtC,OAAO,SAASC,SAASA,CAAAC,IAAA,EAaO;EAAA,IAbN;IACxBC,EAAE,GAAG,SAAS;IACdC,QAAQ;IACRC,cAAc;IACdC,YAAY;IACZC,cAAc,GAAGT,YAAY;IAC7BU,oBAAoB,GAAGZ,gBAAgB;IACvCa,oBAAoB,GAAGb,gBAAgB;IACvCc,mBAAmB,GAAGd,gBAAgB;IACtCe,iBAAiB,GAAGtB,gBAAgB;IACpCuB,OAAO;IACPC,SAAS;IACTC;EACc,CAAC,GAAAZ,IAAA;EACf,IAAMa,aAAa,GAAG/B,MAAM,CAAiB,IAAI,CAAC;EAClD,IAAM,CAACgC,aAAa,EAAEC,gBAAgB,CAAC,GAAGhC,QAAQ,CAAC,KAAK,CAAC;EACzD,IAAM,CAACiC,MAAM,EAAEC,SAAS,CAAC,GAAGlC,QAAQ,CAAe,CAAC;EAEpDH,SAAS,CACP,SAASsC,aAAaA,CAAA,EAAG;IACvB,IAAI,CAACL,aAAa,CAACM,OAAO,EAAE;MAC1BF,SAAS,CAAC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uB,MAAM,CACT,CAAC;EAEDpC,SAAS,CACP,SAASwD,sBAAsBA,CAAA,EAAG;IAChCC,MAAM,CAACC,gBAAgB,CAAC,QAAQ,EAAEL,YAAY,CAAC;IAC/C,OAAO,MAAM;MACXI,MAAM,CAACE,mBAAmB,CAAC,QAAQ,EAAEN,YAAY,CAAC;IACpD,CAAC;EACH,CAAC,EACD,CAACA,YAAY,CACf,CAAC;EAED,oBACEzC,KAAA;IAAKgD,SAAS,EAAC,iCAAiC;IAAAtC,QAAA,gBAC9CZ,IAAA;MAAKkD,SAAS,EAAC,aAAa;MAACC,GAAG,EAAE5B;IAAc,CAAE,CAAC,EAClDC,aAAa,IAAIE,MAAM,iBACtB1B,IAAA,CAACF,eAAe;MACde,cAAc,EAAEA,cAAe;MAC/BF,EAAE,EAAEA,EAAG;MACPe,MAAM,EAAEA,MAAO;MACfZ,YAAY,EAAEA,YAAa;MAC3BsC,cAAc,EAAEpC,oBAAqB;MACrCE,mBAAmB,EAAEA,mBAAoB;MACzCE,OAAO,EAAEA,OAAQ;MACjBC,SAAS,EAAEA,SAAU;MACrBC,YAAY,EAAEA,YAAa;MAAAV,QAAA,EAE1BA;IAAQ,CACM,CAClB;EAAA,CACE,CAAC;AAEV;AAEA,eAAeH,SAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardLayout.js","names":["React","useCallback","useEffect","useMemo","useState","PropTypes","Log","usePrevious","useDispatch","useSelector","PanelManager","PanelErrorBoundary","LayoutUtils","canHaveRef","dehydrate","dehydrateDefault","hydrate","hydrateDefault","PanelEvent","GLPropTypes","useListener","getDashboardData","updateDashboardData","DashboardPanelWrapper","log","module","EMPTY_OBJECT","Object","freeze","DEFAULT_LAYOUT_CONFIG","DEFAULT_CALLBACK","undefined","FALLBACK_CALLBACK","props","DashboardLayout","id","children","emptyDashboard","layout","layoutConfig","onLayoutChange","onLayoutInitialized","panelWrapper","dispatch","data","state","isDashboardEmpty","setIsDashboardEmpty","isItemDragging","setIsItemDragging","lastConfig","setLastConfig","initialClosedPanels","closed","isDashboardInitialized","setIsDashboardInitialized","layoutChildren","setLayoutChildren","getReactChildren","hydrateMap","Map","dehydrateMap","registerComponent","name","componentType","componentHydrate","componentDehydrate","debug2","wrappedComponent","ref","CType","PanelWrapperType","hasRef","glContainer","glEventHub","displayName","cleanup","forwardRef","set","hydrateComponent","get","dehydrateComponent","config","panelManager","openedMap","handleLayoutStateChanged","glConfig","toConfig","contentConfig","content","dehydratedLayoutConfig","dehydrateLayoutConfig","hasChanged","isEqual","debug","root","contentItems","length","handleLayoutItemPickedUp","component","componentId","getIdFromContainer","eventHub","emit","DRAGGING","handleLayoutItemDropped","DROPPED","handleComponentCreated","item","element","cssComponent","replace","toLowerCase","cssClass","addClass","handleReactChildrenChange","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 ComponentType,\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 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 { useDispatch, useSelector } from 'react-redux';\nimport PanelManager, { ClosedPanels } from './PanelManager';\nimport PanelErrorBoundary from './PanelErrorBoundary';\nimport LayoutUtils from './layout/LayoutUtils';\nimport {\n canHaveRef,\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 PanelProps,\n} from './DashboardPlugin';\nimport DashboardPanelWrapper from './DashboardPanelWrapper';\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 = (): void => 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): 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 /** Component to wrap each panel with */\n panelWrapper?: ComponentType;\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 panelWrapper = DashboardPanelWrapper,\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 const [layoutChildren, setLayoutChildren] = useState(\n layout.getReactChildren()\n );\n\n const hydrateMap = useMemo(() => new Map(), []);\n const dehydrateMap = useMemo(() => new Map(), []);\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 wrappedComponent(\n props: PanelProps,\n ref: React.Ref<unknown>\n ): JSX.Element {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const CType = componentType as any;\n const PanelWrapperType = panelWrapper;\n\n /**\n * The ref is used to detect changes to class component state so we\n * can track changes to panelState. We should opt for more explicit\n * state changes in the future and in functional components.\n */\n const hasRef = canHaveRef(CType);\n\n // Props supplied by GoldenLayout\n const { glContainer, glEventHub } = props;\n return (\n <PanelErrorBoundary glContainer={glContainer} glEventHub={glEventHub}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <PanelWrapperType {...props}>\n {hasRef ? (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <CType {...props} ref={ref} />\n ) : (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <CType {...props} />\n )}\n </PanelWrapperType>\n </PanelErrorBoundary>\n );\n }\n\n wrappedComponent.displayName = `DashboardWrapper(${\n componentType.displayName ?? name\n })`;\n\n const cleanup = layout.registerComponent(\n name,\n React.forwardRef(wrappedComponent)\n );\n hydrateMap.set(name, componentHydrate);\n dehydrateMap.set(name, componentDehydrate);\n return cleanup;\n },\n [hydrate, dehydrate, hydrateMap, dehydrateMap, layout, panelWrapper]\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 setLayoutChildren(layout.getReactChildren());\n }\n }, [\n dehydrateComponent,\n isDashboardInitialized,\n isItemDragging,\n lastConfig,\n layout,\n onLayoutChange,\n onLayoutInitialized,\n ]);\n\n const handleLayoutItemPickedUp = useCallback(\n (component: Container) => {\n const componentId = LayoutUtils.getIdFromContainer(component);\n layout.eventHub.emit(PanelEvent.DRAGGING, componentId);\n setIsItemDragging(true);\n },\n [layout.eventHub]\n );\n\n const handleLayoutItemDropped = useCallback(\n (component: Container) => {\n const componentId = LayoutUtils.getIdFromContainer(component);\n layout.eventHub.emit(PanelEvent.DROPPED, componentId);\n setIsItemDragging(false);\n },\n [layout.eventHub]\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 const handleReactChildrenChange = useCallback(() => {\n setLayoutChildren(layout.getReactChildren());\n }, [layout]);\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 useListener(layout, 'reactChildrenChanged', handleReactChildrenChange);\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 {layoutChildren}\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;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C,IAAI,CAAC,EAAE;QAC1CnF,MAAM,CAACyD,IAAI,CAAC2B,QAAQ,CAACjC,OAAO,CAACgC,CAAC,CAAC,CAAC;MAClC;MAEA1E,mBAAmB,CAACT,MAAM,CAACyD,IAAI,CAACC,YAAY,CAACC,MAAM,KAAK,CAAC,CAAC;IAC5D;EACF,CAAC,EACD,CACElB,gBAAgB,EAChBzC,MAAM,EACNC,YAAY,EACZW,UAAU,EACViC,YAAY,EACZkC,oBAAoB,CACrB,CACF;EAED,oBACE;IAAA,WACGvE,gBAAgB,IAAIT,cAAc,EAClCmB,cAAc,EACdxD,KAAK,CAAC2H,QAAQ,CAACC,GAAG,CAACxF,QAAQ,EAAEyF,KAAK,IACjCA,KAAK,IAAI,IAAI,gBACT7H,KAAK,CAAC8H,YAAY,CAACD,KAAK,EAAkB;MACxC1F,EAAE;MACFG,MAAM;MACN6C,YAAY;MACZrB;IACF,CAAC,CAAC,GACF,IAAI,CACT;EAAA,EACA;AAEP;AAEA5B,eAAe,CAAC6F,SAAS,GAAG;EAC1B5F,EAAE,EAAE9B,SAAS,CAAC2H,MAAM,CAACC,UAAU;EAC/B7F,QAAQ,EAAE/B,SAAS,CAAC6H,IAAI;EACxBtF,IAAI,EAAEvC,SAAS,CAAC8H,KAAK,CAAC,CAAC,CAAC,CAAC;EACzB9F,cAAc,EAAEhC,SAAS,CAAC6H,IAAI;EAC9B5F,MAAM,EAAEnB,WAAW,CAACiH,MAAM,CAACH,UAAU;EACrC1F,YAAY,EAAElC,SAAS,CAACgI,OAAO,CAAChI,SAAS,CAAC8H,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;EACpD3F,cAAc,EAAEnC,SAAS,CAACiI,IAAI;EAC9B7F,mBAAmB,EAAEpC,SAAS,CAACiI;AACjC,CAAC;AAED,eAAepG,eAAe"}
|
|
1
|
+
{"version":3,"file":"DashboardLayout.js","names":["React","useCallback","useEffect","useMemo","useState","PropTypes","Log","usePrevious","useDispatch","useSelector","PanelManager","PanelErrorBoundary","LayoutUtils","canHaveRef","dehydrate","dehydrateDefault","hydrate","hydrateDefault","PanelEvent","GLPropTypes","useListener","getDashboardData","updateDashboardData","DashboardPanelWrapper","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","log","module","EMPTY_OBJECT","Object","freeze","DEFAULT_LAYOUT_CONFIG","DEFAULT_CALLBACK","undefined","FALLBACK_CALLBACK","props","DashboardLayout","_ref","_useSelector","_closed","id","children","emptyDashboard","layout","layoutConfig","onLayoutChange","onLayoutInitialized","panelWrapper","dispatch","data","state","isDashboardEmpty","setIsDashboardEmpty","isItemDragging","setIsItemDragging","lastConfig","setLastConfig","initialClosedPanels","closed","isDashboardInitialized","setIsDashboardInitialized","layoutChildren","setLayoutChildren","getReactChildren","hydrateMap","Map","dehydrateMap","registerComponent","name","componentType","_componentType$displa","componentHydrate","arguments","length","componentDehydrate","debug2","wrappedComponent","ref","CType","PanelWrapperType","hasRef","glContainer","glEventHub","_objectSpread","displayName","concat","cleanup","forwardRef","set","hydrateComponent","_hydrateMap$get","get","dehydrateComponent","config","_dehydrateMap$get","panelManager","_ref2","openedMap","handleLayoutStateChanged","glConfig","toConfig","contentConfig","content","dehydratedLayoutConfig","dehydrateLayoutConfig","hasChanged","isEqual","debug","root","contentItems","handleLayoutItemPickedUp","component","componentId","getIdFromContainer","eventHub","emit","DRAGGING","handleLayoutItemDropped","DROPPED","handleComponentCreated","item","element","cssComponent","replace","toLowerCase","cssClass","addClass","handleReactChildrenChange","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 ComponentType,\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 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 { useDispatch, useSelector } from 'react-redux';\nimport PanelManager, { ClosedPanels } from './PanelManager';\nimport PanelErrorBoundary from './PanelErrorBoundary';\nimport LayoutUtils from './layout/LayoutUtils';\nimport {\n canHaveRef,\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 PanelProps,\n} from './DashboardPlugin';\nimport DashboardPanelWrapper from './DashboardPanelWrapper';\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 = (): void => 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): 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 /** Component to wrap each panel with */\n panelWrapper?: ComponentType;\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 panelWrapper = DashboardPanelWrapper,\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 const [layoutChildren, setLayoutChildren] = useState(\n layout.getReactChildren()\n );\n\n const hydrateMap = useMemo(() => new Map(), []);\n const dehydrateMap = useMemo(() => new Map(), []);\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 wrappedComponent(\n props: PanelProps,\n ref: React.Ref<unknown>\n ): JSX.Element {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const CType = componentType as any;\n const PanelWrapperType = panelWrapper;\n\n /**\n * The ref is used to detect changes to class component state so we\n * can track changes to panelState. We should opt for more explicit\n * state changes in the future and in functional components.\n */\n const hasRef = canHaveRef(CType);\n\n // Props supplied by GoldenLayout\n const { glContainer, glEventHub } = props;\n return (\n <PanelErrorBoundary glContainer={glContainer} glEventHub={glEventHub}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <PanelWrapperType {...props}>\n {hasRef ? (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <CType {...props} ref={ref} />\n ) : (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <CType {...props} />\n )}\n </PanelWrapperType>\n </PanelErrorBoundary>\n );\n }\n\n wrappedComponent.displayName = `DashboardWrapper(${\n componentType.displayName ?? name\n })`;\n\n const cleanup = layout.registerComponent(\n name,\n React.forwardRef(wrappedComponent)\n );\n hydrateMap.set(name, componentHydrate);\n dehydrateMap.set(name, componentDehydrate);\n return cleanup;\n },\n [hydrate, dehydrate, hydrateMap, dehydrateMap, layout, panelWrapper]\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 setLayoutChildren(layout.getReactChildren());\n }\n }, [\n dehydrateComponent,\n isDashboardInitialized,\n isItemDragging,\n lastConfig,\n layout,\n onLayoutChange,\n onLayoutInitialized,\n ]);\n\n const handleLayoutItemPickedUp = useCallback(\n (component: Container) => {\n const componentId = LayoutUtils.getIdFromContainer(component);\n layout.eventHub.emit(PanelEvent.DRAGGING, componentId);\n setIsItemDragging(true);\n },\n [layout.eventHub]\n );\n\n const handleLayoutItemDropped = useCallback(\n (component: Container) => {\n const componentId = LayoutUtils.getIdFromContainer(component);\n layout.eventHub.emit(PanelEvent.DROPPED, componentId);\n setIsItemDragging(false);\n },\n [layout.eventHub]\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 const handleReactChildrenChange = useCallback(() => {\n setLayoutChildren(layout.getReactChildren());\n }, [layout]);\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 useListener(layout, 'reactChildrenChanged', handleReactChildrenChange);\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 {layoutChildren}\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,IAGVC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,QAAQ,QACH,OAAO;AACd,OAAOC,SAAS,MAAM,YAAY;AAOlC,OAAOC,GAAG,MAAM,gBAAgB;AAChC,SAASC,WAAW,QAAQ,wBAAwB;AAEpD,SAASC,WAAW,EAAEC,WAAW,QAAQ,aAAa;AAAC,OAChDC,YAAY;AAAA,OACZC,kBAAkB;AAAA,OAClBC,WAAW;AAAA,SAEhBC,UAAU,EACVC,SAAS,IAAIC,gBAAgB,EAC7BC,OAAO,IAAIC,cAAc;AAAA,OAEpBC,UAAU;AAAA,SACRC,WAAW,EAAEC,WAAW;AAAA,SACxBC,gBAAgB,EAAEC,mBAAmB;AAAA,OAOvCC,qBAAqB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAI5B,IAAMC,GAAG,GAAGxB,GAAG,CAACyB,MAAM,CAAC,iBAAiB,CAAC;AAEzC,IAAMC,YAAY,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,CAAC;AAEtC,IAAMC,qBAA4C,GAAG,EAAE;AAEvD,IAAMC,gBAAgB,GAAGA,CAAA,KAAYC,SAA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ashboardPanelWrapper.js","names":["React","DashboardPanelWrapper","children"],"sources":["../src/DashboardPanelWrapper.tsx"],"sourcesContent":["import React, { PropsWithChildren } from 'react';\n\nexport function DashboardPanelWrapper({\n children,\n}: PropsWithChildren<object>): JSX.Element {\n // eslint-disable-next-line react/jsx-no-useless-fragment\n return <>{children}</>;\n}\n\nexport default DashboardPanelWrapper;\n"],"mappings":"AAAA,OAAOA,KAAK,MAA6B,OAAO;AAAC;AAAA;AAEjD,OAAO,SAASC,
|
|
1
|
+
{"version":3,"file":"DashboardPanelWrapper.js","names":["React","Fragment","_Fragment","jsx","_jsx","DashboardPanelWrapper","_ref","children"],"sources":["../src/DashboardPanelWrapper.tsx"],"sourcesContent":["import React, { PropsWithChildren } from 'react';\n\nexport function DashboardPanelWrapper({\n children,\n}: PropsWithChildren<object>): JSX.Element {\n // eslint-disable-next-line react/jsx-no-useless-fragment\n return <>{children}</>;\n}\n\nexport default DashboardPanelWrapper;\n"],"mappings":"AAAA,OAAOA,KAAK,MAA6B,OAAO;AAAC,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAEjD,OAAO,SAASC,qBAAqBA,CAAAC,IAAA,EAEM;EAAA,IAFL;IACpCC;EACyB,CAAC,GAAAD,IAAA;EAC1B;EACA,oBAAOF,IAAA,CAAAF,SAAA;IAAAK,QAAA,EAAGA;EAAQ,CAAG,CAAC;AACxB;AAEA,eAAeF,qBAAqB"}
|
package/dist/DashboardPlugin.js
CHANGED
|
@@ -4,6 +4,12 @@ import PanelManager from "./PanelManager.js";
|
|
|
4
4
|
* Panel components can provide static props that provide meta data about the
|
|
5
5
|
* panel.
|
|
6
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* Alias for the return type of React.forwardRef()
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Use `PanelComponentType` instead and add generic types to forwardRef call.
|
|
12
|
+
*/
|
|
7
13
|
export function isWrappedComponent(type) {
|
|
8
14
|
return (type === null || type === void 0 ? void 0 : type.WrappedComponent) !== undefined;
|
|
9
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardPlugin.js","names":["GoldenLayout","PanelManager","isWrappedComponent","type","WrappedComponent","undefined","isDashboardPluginProps","props","id","layout","panelManager","registerComponent","assertIsDashboardPluginProps","Error"],"sources":["../src/DashboardPlugin.ts"],"sourcesContent":["import type {\n Component,\n ComponentType,\n ForwardRefExoticComponent,\n PropsWithoutRef,\n RefAttributes,\n} from 'react';\nimport { ConnectedComponent } from 'react-redux';\nimport GoldenLayout from '@deephaven/golden-layout';\nimport type {\n GLPanelProps,\n ReactComponentConfig,\n} from '@deephaven/golden-layout';\nimport PanelManager from './PanelManager';\n\n/**\n * Panel components can provide static props that provide meta data about the\n * panel.\n */\nexport interface PanelStaticMetaData {\n /**\n * Should be set to the same name as the component type.\n * @deprecated Use `displayName` instead.\n */\n COMPONENT?: string;\n\n /** Title of the panel. */\n TITLE?: string;\n}\n\n/**\n * Alias for the return type of React.forwardRef()\n */\ntype ForwardRefComponentType<P, R> = ForwardRefExoticComponent<\n PropsWithoutRef<P> & RefAttributes<R>\n>;\n\n/**\n * @deprecated Use `PanelComponentType` instead and add generic types to forwardRef call.\n */\nexport type PanelFunctionComponentType<P, R> = ForwardRefComponentType<P, R> &\n PanelStaticMetaData;\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>) & PanelStaticMetaData;\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 PanelMetadata = { id?: string; name?: string; type?: string };\n\nexport type PanelProps = GLPanelProps & {\n metadata?: PanelMetadata;\n};\n\nexport type DehydratedPanelProps = Omit<PanelProps, keyof GLPanelProps>;\n\nexport type DashboardPanelProps = PanelProps & { localDashboardId: string };\n\nexport type DehydratedDashboardPanelProps = Omit<\n DashboardPanelProps,\n keyof GLPanelProps\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<\n T extends DehydratedDashboardPanelProps = DehydratedDashboardPanelProps,\n R extends T = T,\n> = (props: T, dashboardId: string) => R;\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: <\n P extends DashboardPanelProps,\n C extends ComponentType<P>,\n >(\n name: string,\n ComponentType: PanelComponentType<P, C>,\n hydrate?: PanelHydrateFunction,\n dehydrate?: PanelDehydrateFunction\n ) => DeregisterComponentFunction;\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":"AAQA,OAAOA,YAAY,MAAM,0BAA0B;AAAC,OAK7CC,YAAY;AAEnB;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":"DashboardPlugin.js","names":["GoldenLayout","PanelManager","isWrappedComponent","type","WrappedComponent","undefined","isDashboardPluginProps","props","id","layout","panelManager","registerComponent","assertIsDashboardPluginProps","Error","concat"],"sources":["../src/DashboardPlugin.ts"],"sourcesContent":["import type {\n Component,\n ComponentType,\n ForwardRefExoticComponent,\n PropsWithoutRef,\n RefAttributes,\n} from 'react';\nimport { ConnectedComponent } from 'react-redux';\nimport GoldenLayout from '@deephaven/golden-layout';\nimport type {\n GLPanelProps,\n ReactComponentConfig,\n} from '@deephaven/golden-layout';\nimport PanelManager from './PanelManager';\n\n/**\n * Panel components can provide static props that provide meta data about the\n * panel.\n */\nexport interface PanelStaticMetaData {\n /**\n * Should be set to the same name as the component type.\n * @deprecated Use `displayName` instead.\n */\n COMPONENT?: string;\n\n /** Title of the panel. */\n TITLE?: string;\n}\n\n/**\n * Alias for the return type of React.forwardRef()\n */\ntype ForwardRefComponentType<P, R> = ForwardRefExoticComponent<\n PropsWithoutRef<P> & RefAttributes<R>\n>;\n\n/**\n * @deprecated Use `PanelComponentType` instead and add generic types to forwardRef call.\n */\nexport type PanelFunctionComponentType<P, R> = ForwardRefComponentType<P, R> &\n PanelStaticMetaData;\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>) & PanelStaticMetaData;\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 PanelMetadata = { id?: string; name?: string; type?: string };\n\nexport type PanelProps = GLPanelProps & {\n metadata?: PanelMetadata;\n};\n\nexport type DehydratedPanelProps = Omit<PanelProps, keyof GLPanelProps>;\n\nexport type DashboardPanelProps = PanelProps & { localDashboardId: string };\n\nexport type DehydratedDashboardPanelProps = Omit<\n DashboardPanelProps,\n keyof GLPanelProps\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<\n T extends DehydratedDashboardPanelProps = DehydratedDashboardPanelProps,\n R extends T = T,\n> = (props: T, dashboardId: string) => R;\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: <\n P extends DashboardPanelProps,\n C extends ComponentType<P>,\n >(\n name: string,\n ComponentType: PanelComponentType<P, C>,\n hydrate?: PanelHydrateFunction,\n dehydrate?: PanelDehydrateFunction\n ) => DeregisterComponentFunction;\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":"AAQA,OAAOA,YAAY,MAAM,0BAA0B;AAAC,OAK7CC,YAAY;AAEnB;AACA;AACA;AACA;AAYA;AACA;AACA;AAKA;AACA;AACA;AAcA,OAAO,SAASC,kBAAkBA,CAGhCC,IAA8B,EAAsC;EACpE,OAAO,CAACA,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAiCC,gBAAgB,MAAKC,SAAS;AAC7E;AA6DA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,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,4BAA4BA,CAC1CL,KAA6C,EACG;EAChD,IAAI,CAACD,sBAAsB,CAACC,KAAK,CAAC,EAAE;IAClC,MAAM,IAAIM,KAAK,0DAAAC,MAAA,CAC4CP,KAAK,CAChE,CAAC;EACH;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardUtils.js","names":["ForwardRef","isWrappedComponent","dehydrate","config","props","componentState","metadata","panelState","newProps","type","hydrate","localDashboardId","canHaveRef","component","isClassComponent","WrappedComponent","prototype","isReactComponent","isForwardRef","$$typeof"],"sources":["../src/DashboardUtils.tsx"],"sourcesContent":["import { ForwardRef } from 'react-is';\nimport {\n DehydratedDashboardPanelProps,\n isWrappedComponent,\n PanelComponentType,\n PanelConfig,\n} from './DashboardPlugin';\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<T extends DehydratedDashboardPanelProps>(\n props: T,\n localDashboardId = ''\n): T {\n return {\n metadata: {},\n ...props,\n localDashboardId,\n };\n}\n\n/**\n * Checks if a panel component can take a ref. Helps silence react dev errors\n * if a ref is passed to a functional component without forwardRef.\n * @param component The panel component to check if it can take a ref\n * @returns Wheter the component can take a ref or not\n */\nexport function canHaveRef(component: PanelComponentType): boolean {\n // Might be a redux connect wrapped component\n const isClassComponent =\n (isWrappedComponent(component) &&\n component.WrappedComponent.prototype != null &&\n component.WrappedComponent.prototype.isReactComponent != null) ||\n (component.prototype != null &&\n component.prototype.isReactComponent != null);\n\n const isForwardRef =\n !isWrappedComponent(component) &&\n '$$typeof' in component &&\n component.$$typeof === ForwardRef;\n\n return isClassComponent || isForwardRef;\n}\n\nexport default {\n dehydrate,\n hydrate,\n};\n"],"mappings":";;;;;AAAA,SAASA,UAAU,QAAQ,UAAU;AAAC,SAGpCC,kBAAkB;AAKpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,
|
|
1
|
+
{"version":3,"file":"DashboardUtils.js","names":["ForwardRef","isWrappedComponent","dehydrate","config","props","componentState","metadata","panelState","newProps","_objectSpread","type","hydrate","localDashboardId","arguments","length","undefined","canHaveRef","component","isClassComponent","WrappedComponent","prototype","isReactComponent","isForwardRef","$$typeof"],"sources":["../src/DashboardUtils.tsx"],"sourcesContent":["import { ForwardRef } from 'react-is';\nimport {\n DehydratedDashboardPanelProps,\n isWrappedComponent,\n PanelComponentType,\n PanelConfig,\n} from './DashboardPlugin';\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<T extends DehydratedDashboardPanelProps>(\n props: T,\n localDashboardId = ''\n): T {\n return {\n metadata: {},\n ...props,\n localDashboardId,\n };\n}\n\n/**\n * Checks if a panel component can take a ref. Helps silence react dev errors\n * if a ref is passed to a functional component without forwardRef.\n * @param component The panel component to check if it can take a ref\n * @returns Wheter the component can take a ref or not\n */\nexport function canHaveRef(component: PanelComponentType): boolean {\n // Might be a redux connect wrapped component\n const isClassComponent =\n (isWrappedComponent(component) &&\n component.WrappedComponent.prototype != null &&\n component.WrappedComponent.prototype.isReactComponent != null) ||\n (component.prototype != null &&\n component.prototype.isReactComponent != null);\n\n const isForwardRef =\n !isWrappedComponent(component) &&\n '$$typeof' in component &&\n component.$$typeof === ForwardRef;\n\n return isClassComponent || isForwardRef;\n}\n\nexport default {\n dehydrate,\n hydrate,\n};\n"],"mappings":";;;;;AAAA,SAASA,UAAU,QAAQ,UAAU;AAAC,SAGpCC,kBAAkB;AAKpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,SAASA,CAACC,MAAmB,EAAsB;EACjE,IAAM;IAA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gB,SAAS,CAAC,IAC9B,UAAU,IAAIA,SAAS,IACvBA,SAAS,CAACM,QAAQ,KAAKvB,UAAU;EAEnC,OAAOkB,gBAAgB,IAAII,YAAY;AACzC;AAEA,eAAe;EACbpB,SAAS;EACTS;AACF,CAAC"}
|
|
@@ -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,KAAK,IAAIC,SAAS,QAAmB,OAAO;AACnD,SAASC,cAAc,QAAQ,uBAAuB;AAEtD,OAAOC,GAAG,MAAM,gBAAgB;AAAC,OAC1BC,UAAU;AAAA,OACVC,WAAW;AAAA;AAAA;AAGlB,IAAMC,GAAG,
|
|
1
|
+
{"version":3,"file":"PanelErrorBoundary.js","names":["React","Component","LoadingOverlay","Log","PanelEvent","LayoutUtils","jsx","_jsx","log","module","PanelErrorBoundary","constructor","props","state","error","componentDidCatch","setState","componentWillUnmount","glContainer","glEventHub","panelId","getIdFromContainer","debug","emit","CLOSED","render","children","className","errorMessage","concat","isLoading","isLoaded"],"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;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAGlB,IAAMC,GAAG,GAAGL,GAAG,CAACM,MAAM,CAAC,oBAAoB,CAAC;AAW5C;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,kBAAkB,SAAST,SAAS,CAGxC;EACAU,WAAWA,CAACC,KAA8B,EAAE;IAC1C,KAAK,CAACA,KAAK,CAAC;IACZ,IAAI,CAACC,KAAK,GAAG;MAAEC,KAAK,EAAE;IAAK,CAAC;EAC9B;EAEAC,iBAAiBA,CAACD,KAAY,EAAQ;IACpC,IAAI,CAACE,QAAQ,CAAC;MAAEF;IAAM,CAAC,CAAC;EAC1B;EAEAG,oBAAoBA,CAAA,EAAS;IAC3B,IAAM;MAAEC,WAAW;MAAEC;IAAW,CAAC,GAAG,IAAI,CAACP,KAAK;IAC9C,IAAMQ,OAAO,GAAGf,WAAW,CAACgB,kBAAkB,CAACH,WAAW,CAAC;IAC3DV,GAAG,CAACc,KAAK,CAAC,sBAAsB,EAAEF,OAAO,CAAC;IAC1CD,UAAU,CAACI,IAAI,CAACnB,UAAU,CAACoB,MAAM,EAAEJ,OAAO,EAAEF,WAAW,CAAC;EAC1D;EAEAO,MAAMA,CAAA,EAAc;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,oBACEP,IAAA;QAAKoB,SAAS,EAAC,sBAAsB;QAAAD,QAAA,eACnCnB,IAAA,CAACL,cAAc;UACb0B,YAAY,KAAAC,MAAA,CAAKf,KAAK,CAAG;UACzBgB,SAAS,EAAE,KAAM;UACjBC,QAAQ,EAAE;QAAM,CACjB;MAAC,CACC,CAAC;IAEV;IACA,OAAOL,QAAQ;EACjB;AACF;AAEA,eAAehB,kBAAkB"}
|
package/dist/PanelManager.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelManager.js","names":["Log","PanelEvent","LayoutUtils","isReactComponentConfig","isWrappedComponent","log","module","PanelManager","constructor","layout","hydrateComponent","name","props","dehydrateComponent","config","openedMap","Map","closed","onPanelsUpdated","undefined","handleFocus","bind","handleMount","handleUnmount","handleReopen","handleDeleted","handleClosed","handleControlClose","startListening","eventHub","on","FOCUS","MOUNT","UNMOUNT","REOPEN","DELETE","CLOSED","CLOSE","stopListening","off","getClosedPanelConfigsOfType","typeString","filter","panel","component","getOpenedPanels","Array","from","values","getOpenedPanelConfigs","map","glContainer","getComponentConfigFromContainer","getOpenedPanelConfigsOfType","getOpenedPanelById","panelId","get","getContainerByPanelId","stack","getStackForConfig","root","id","getContentItemInStack","getLastUsedPanel","matcher","opened","i","length","getLastUsedPanelOfType","type","getLastUsedPanelOfTypes","types","some","WrappedComponent","updatePanel","getIdFromPanel","error","debug2","delete","set","removePanel","has","debug","removeClosedPanelConfig","panelConfig","index","findIndex","closedConfig","splice","sendUpdate","replaceConfig","openComponent","addClosedPanel","closeComponent","dehydratedConfig","push"],"sources":["../src/PanelManager.ts"],"sourcesContent":["import { ComponentType } from 'react';\nimport GoldenLayout from '@deephaven/golden-layout';\nimport type {\n Container,\n ContentItem,\n ItemConfigType,\n ReactComponentConfig,\n} from '@deephaven/golden-layout';\nimport Log from '@deephaven/log';\nimport PanelEvent from './PanelEvent';\nimport LayoutUtils, { isReactComponentConfig } from './layout/LayoutUtils';\nimport {\n isWrappedComponent,\n PanelComponent,\n PanelComponentType,\n PanelProps,\n} from './DashboardPlugin';\n\nconst log = Log.module('PanelManager');\n\nexport type PanelHydraterFunction = (\n name: string,\n props: PanelProps\n) => PanelProps;\n\nexport type PanelDehydraterFunction = (\n name: string,\n config: ReactComponentConfig\n) => ReactComponentConfig;\n\nexport type ClosedPanel = ReactComponentConfig;\n\nexport type ClosedPanels = ClosedPanel[];\n\nexport type OpenedPanelMap = Map<string | string[], PanelComponent>;\n\nexport type PanelsUpdateData = {\n closed: ClosedPanels;\n openedMap: OpenedPanelMap;\n};\n\nexport type PanelsUpdateCallback = (panelUpdateData: PanelsUpdateData) => void;\n\n/**\n * Class to keep track of which panels are open, have been closed, and also events to close panels.\n */\nclass PanelManager {\n static MAX_CLOSED_PANEL_COUNT = 100;\n\n layout: GoldenLayout;\n\n hydrateComponent: PanelHydraterFunction;\n\n dehydrateComponent: PanelDehydraterFunction;\n\n onPanelsUpdated: PanelsUpdateCallback;\n\n closed: ClosedPanels;\n\n openedMap: OpenedPanelMap;\n\n /**\n * @param layout The GoldenLayout object to attach to\n * @param hydrateComponent Function to hydrate a panel from a dehydrated state\n * @param dehydrateComponent Function to dehydrate a panel\n * @param openedMap Map of opened panels\n * @param closed Array of closed panels in a dehydrated state\n * @param onPanelsUpdated Triggered when the panels are updated\n */\n constructor(\n layout: GoldenLayout,\n hydrateComponent: PanelHydraterFunction = (name, props) => props,\n dehydrateComponent: PanelDehydraterFunction = (name, config) => config,\n openedMap: OpenedPanelMap = new Map(),\n closed: ClosedPanel[] = [],\n onPanelsUpdated: PanelsUpdateCallback = () => undefined\n ) {\n this.handleFocus = this.handleFocus.bind(this);\n this.handleMount = this.handleMount.bind(this);\n // Panel can be unmounted on error but still keep the tab until it's closed\n // Use PanelEvent.MOUNT/UNMOUNT to track open (active) panels\n // and PanelEvent.CLOSED for cleanup (delete links, add panel to closed panels list, etc)\n this.handleUnmount = this.handleUnmount.bind(this);\n this.handleReopen = this.handleReopen.bind(this);\n this.handleDeleted = this.handleDeleted.bind(this);\n this.handleClosed = this.handleClosed.bind(this);\n this.handleControlClose = this.handleControlClose.bind(this);\n\n this.layout = layout;\n this.hydrateComponent = hydrateComponent;\n this.dehydrateComponent = dehydrateComponent;\n this.onPanelsUpdated = onPanelsUpdated;\n\n // Store the opened and closed panels\n this.openedMap = new Map(openedMap);\n\n // Closed panels are stored in their dehydrated state\n this.closed = [...closed];\n\n this.startListening();\n }\n\n startListening(): void {\n const { eventHub } = this.layout;\n eventHub.on(PanelEvent.FOCUS, this.handleFocus);\n eventHub.on(PanelEvent.MOUNT, this.handleMount);\n eventHub.on(PanelEvent.UNMOUNT, this.handleUnmount);\n eventHub.on(PanelEvent.REOPEN, this.handleReopen);\n eventHub.on(PanelEvent.DELETE, this.handleDeleted);\n eventHub.on(PanelEvent.CLOSED, this.handleClosed);\n eventHub.on(PanelEvent.CLOSE, this.handleControlClose);\n // PanelEvent.OPEN should be listened to by plugins to open a panel\n }\n\n stopListening(): void {\n const { eventHub } = this.layout;\n eventHub.off(PanelEvent.FOCUS, this.handleFocus);\n eventHub.off(PanelEvent.MOUNT, this.handleMount);\n eventHub.off(PanelEvent.UNMOUNT, this.handleUnmount);\n eventHub.off(PanelEvent.REOPEN, this.handleReopen);\n eventHub.off(PanelEvent.DELETE, this.handleDeleted);\n eventHub.off(PanelEvent.CLOSED, this.handleClosed);\n eventHub.off(PanelEvent.CLOSE, this.handleControlClose);\n }\n\n getClosedPanelConfigsOfType(typeString: string): ClosedPanels {\n return this.closed.filter(panel => panel.component === typeString);\n }\n\n getOpenedPanels(): PanelComponent[] {\n return Array.from(this.openedMap.values());\n }\n\n getOpenedPanelConfigs(): (ItemConfigType | null)[] {\n return this.getOpenedPanels().map(panel => {\n const { glContainer } = panel.props;\n return LayoutUtils.getComponentConfigFromContainer(glContainer);\n });\n }\n\n getOpenedPanelConfigsOfType(typeString: string): ReactComponentConfig[] {\n return this.getOpenedPanelConfigs().filter(\n config =>\n config != null &&\n isReactComponentConfig(config) &&\n config.component === typeString\n ) as ReactComponentConfig[];\n }\n\n getOpenedPanelById(panelId: string | string[]): PanelComponent | undefined {\n return this.openedMap.get(panelId);\n }\n\n getContainerByPanelId(panelId: string | string[]): ContentItem | null {\n const stack = LayoutUtils.getStackForConfig(this.layout.root, {\n id: panelId,\n });\n return (\n (stack && LayoutUtils.getContentItemInStack(stack, { id: panelId })) ??\n null\n );\n }\n\n getLastUsedPanel<T extends PanelComponent = PanelComponent>(\n matcher: (panel: PanelComponent) => boolean\n ): T | undefined {\n const opened = this.getOpenedPanels();\n for (let i = opened.length - 1; i >= 0; i -= 1) {\n const panel = opened[i];\n if (matcher == null || matcher(panel)) {\n return panel as T;\n }\n }\n\n return undefined;\n }\n\n getLastUsedPanelOfType<\n P extends PanelProps = PanelProps,\n C extends ComponentType<P> = ComponentType<P>,\n >(type: PanelComponentType<P, C>): PanelComponent<P> | undefined {\n return this.getLastUsedPanelOfTypes([type]);\n }\n\n getLastUsedPanelOfTypes<\n P extends PanelProps = PanelProps,\n C extends ComponentType<P> = ComponentType<P>,\n >(types: PanelComponentType<P, C>[]): PanelComponent<P> | undefined {\n return this.getLastUsedPanel(panel =>\n types.some(\n type =>\n (isWrappedComponent(type) &&\n panel instanceof type.WrappedComponent) ||\n (!isWrappedComponent(type) && panel instanceof type)\n )\n );\n }\n\n updatePanel(panel: PanelComponent): void {\n const panelId = LayoutUtils.getIdFromPanel(panel);\n if (panelId == null) {\n log.error('updatePanel Panel did not have an ID', panel);\n return;\n }\n log.debug2(`Updating panel ID ${panelId} in open panels map`);\n // Delete the entry before it's set to maintain correct ordering in the open panels map.\n // The last updated (focused) panel should be the last inserted.\n // Deleting the entry from the map directly instead of calling this.removePanel to skip the checks.\n this.openedMap.delete(panelId);\n this.openedMap.set(panelId, panel);\n }\n\n removePanel(panel: PanelComponent): void {\n const panelId = LayoutUtils.getIdFromPanel(panel);\n if (panelId == null) {\n log.error('removePanel Panel did not have an ID', panel);\n return;\n }\n if (!this.openedMap.has(panelId)) {\n log.error(`Missing panel ID ${panelId} in open panels map`);\n return;\n }\n if (this.openedMap.get(panelId) !== panel) {\n // We mount a new panel before un-mounting the existing one\n // when replacing existing panels in openComponent/openComponentInStack.\n // Skip map delete if the panelId entry already refers to the new panel.\n log.debug(\n `Panel argument doesn't match the open panels map entry for ${panelId}, removePanel ignored`\n );\n return;\n }\n log.debug2(`Removing panel ID ${panelId} from open panels map`);\n this.openedMap.delete(panelId);\n }\n\n removeClosedPanelConfig(panelConfig: ClosedPanel): void {\n const index = this.closed.findIndex(\n closedConfig =>\n closedConfig === panelConfig ||\n (closedConfig.id != null &&\n panelConfig.id != null &&\n closedConfig.id === panelConfig.id)\n );\n if (index >= 0) {\n this.closed.splice(index, 1);\n }\n }\n\n handleFocus(panel: PanelComponent): void {\n log.debug2('Focus: ', panel);\n this.updatePanel(panel);\n }\n\n handleMount(panel: PanelComponent): void {\n log.debug2('Mount: ', panel);\n this.updatePanel(panel);\n this.sendUpdate();\n }\n\n handleUnmount(panel: PanelComponent): void {\n log.debug2('Unmount: ', panel);\n this.removePanel(panel);\n this.sendUpdate();\n }\n\n /**\n *\n * @param panelConfig The config to hydrate and load\n * @param replaceConfig The config to place\n */\n handleReopen(\n panelConfig: ClosedPanel,\n replaceConfig?: Partial<ItemConfigType>\n ): void {\n log.debug2('Reopen:', panelConfig, replaceConfig);\n\n this.removeClosedPanelConfig(panelConfig);\n // Don't need to send an update yet, it will get sent when component is mounted\n\n // Rehydrate the panel before adding it back\n const { component } = panelConfig;\n let { props } = panelConfig;\n props = this.hydrateComponent(component, props);\n\n const config = {\n ...panelConfig,\n props,\n };\n\n const { root } = this.layout;\n LayoutUtils.openComponent({ root, config, replaceConfig });\n }\n\n handleDeleted(panelConfig: ClosedPanel): void {\n log.debug2('Deleted:', panelConfig);\n\n this.removeClosedPanelConfig(panelConfig);\n\n this.sendUpdate();\n }\n\n handleClosed(panelId: string, glContainer: Container): void {\n // Panel component should be already unmounted at this point\n // so the emitted event sends the container object instead of the panel.\n log.debug2('Closed: ', panelId);\n this.addClosedPanel(glContainer);\n this.sendUpdate();\n }\n\n handleControlClose(id: string): void {\n const config = { id };\n const { root } = this.layout;\n LayoutUtils.closeComponent(root, config);\n }\n\n addClosedPanel(glContainer: Container): void {\n const config = LayoutUtils.getComponentConfigFromContainer(glContainer);\n if (config && isReactComponentConfig(config)) {\n const dehydratedConfig = this.dehydrateComponent(\n config.component,\n config\n );\n if (dehydratedConfig != null) {\n this.closed.push(dehydratedConfig);\n }\n }\n }\n\n sendUpdate(): void {\n const { closed, openedMap } = this;\n this.onPanelsUpdated({\n closed: [...closed],\n openedMap: new Map(openedMap),\n });\n }\n}\n\nexport default PanelManager;\n"],"mappings":";;;;;AAQA,OAAOA,GAAG,MAAM,gBAAgB;AAAC,OAC1BC,UAAU;AAAA,OACVC,WAAW,IAAIC,sBAAsB;AAAA,SAE1CC,kBAAkB;AAMpB,IAAMC,GAAG,GAAGL,GAAG,CAACM,MAAM,CAAC,cAAc,CAAC;AAyBtC;AACA;AACA;AACA,MAAMC,YAAY,CAAC;EAejB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,WAAW,CACTC,MAAoB,EAMpB;IAAA,IALAC,gBAAuC,uEAAG,CAACC,IAAI,EAAEC,KAAK,KAAKA,KAAK;IAAA,IAChEC,kBAA2C,uEAAG,CAACF,IAAI,EAAEG,MAAM,KAAKA,MAAM;IAAA,IACtEC,SAAyB,uEAAG,IAAIC,GAAG,EAAE;IAAA,IACrCC,MAAqB,uEAAG,EAAE;IAAA,IAC1BC,eAAqC,uEAAG,MAAMC,SAAS;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAEvD,IAAI,CAACC,WAAW,GAAG,IAAI,CAACA,WAAW,CAACC,IAAI,CAAC,IAAI,CAAC;IA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,CAC9CC,MAAM,CAAC8B,SAAS,EAChB9B,MAAM,CACP;MACD,IAAIgF,gBAAgB,IAAI,IAAI,EAAE;QAC5B,IAAI,CAAC7E,MAAM,CAAC8E,IAAI,CAACD,gBAAgB,CAAC;MACpC;IACF;EACF;EAEAL,UAAU,GAAS;IACjB,IAAM;MAAExE,MAAM;MAAEF;IAAU,CAAC,GAAG,IAAI;IAClC,IAAI,CAACG,eAAe,CAAC;MACnBD,MAAM,EAAE,CAAC,GAAGA,MAAM,CAAC;MACnBF,SAAS,EAAE,IAAIC,GAAG,CAACD,SAAS;IAC9B,CAAC,CAAC;EACJ;AACF;AAAC,gBAjSKR,YAAY,4BACgB,GAAG;AAkSrC,eAAeA,YAAY"}
|
|
1
|
+
{"version":3,"file":"PanelManager.js","names":["Log","PanelEvent","LayoutUtils","isReactComponentConfig","isWrappedComponent","log","module","PanelManager","constructor","layout","hydrateComponent","arguments","length","undefined","name","props","dehydrateComponent","config","openedMap","Map","closed","onPanelsUpdated","_defineProperty","handleFocus","bind","handleMount","handleUnmount","handleReopen","handleDeleted","handleClosed","handleControlClose","startListening","eventHub","on","FOCUS","MOUNT","UNMOUNT","REOPEN","DELETE","CLOSED","CLOSE","stopListening","off","getClosedPanelConfigsOfType","typeString","filter","panel","component","getOpenedPanels","Array","from","values","getOpenedPanelConfigs","map","glContainer","getComponentConfigFromContainer","getOpenedPanelConfigsOfType","getOpenedPanelById","panelId","get","getContainerByPanelId","_ref","stack","getStackForConfig","root","id","getContentItemInStack","getLastUsedPanel","matcher","opened","i","getLastUsedPanelOfType","type","getLastUsedPanelOfTypes","types","some","WrappedComponent","updatePanel","getIdFromPanel","error","debug2","concat","delete","set","removePanel","has","debug","removeClosedPanelConfig","panelConfig","index","findIndex","closedConfig","splice","sendUpdate","replaceConfig","_objectSpread","openComponent","addClosedPanel","closeComponent","dehydratedConfig","push"],"sources":["../src/PanelManager.ts"],"sourcesContent":["import { ComponentType } from 'react';\nimport GoldenLayout from '@deephaven/golden-layout';\nimport type {\n Container,\n ContentItem,\n ItemConfigType,\n ReactComponentConfig,\n} from '@deephaven/golden-layout';\nimport Log from '@deephaven/log';\nimport PanelEvent from './PanelEvent';\nimport LayoutUtils, { isReactComponentConfig } from './layout/LayoutUtils';\nimport {\n isWrappedComponent,\n PanelComponent,\n PanelComponentType,\n PanelProps,\n} from './DashboardPlugin';\n\nconst log = Log.module('PanelManager');\n\nexport type PanelHydraterFunction = (\n name: string,\n props: PanelProps\n) => PanelProps;\n\nexport type PanelDehydraterFunction = (\n name: string,\n config: ReactComponentConfig\n) => ReactComponentConfig;\n\nexport type ClosedPanel = ReactComponentConfig;\n\nexport type ClosedPanels = ClosedPanel[];\n\nexport type OpenedPanelMap = Map<string | string[], PanelComponent>;\n\nexport type PanelsUpdateData = {\n closed: ClosedPanels;\n openedMap: OpenedPanelMap;\n};\n\nexport type PanelsUpdateCallback = (panelUpdateData: PanelsUpdateData) => void;\n\n/**\n * Class to keep track of which panels are open, have been closed, and also events to close panels.\n */\nclass PanelManager {\n static MAX_CLOSED_PANEL_COUNT = 100;\n\n layout: GoldenLayout;\n\n hydrateComponent: PanelHydraterFunction;\n\n dehydrateComponent: PanelDehydraterFunction;\n\n onPanelsUpdated: PanelsUpdateCallback;\n\n closed: ClosedPanels;\n\n openedMap: OpenedPanelMap;\n\n /**\n * @param layout The GoldenLayout object to attach to\n * @param hydrateComponent Function to hydrate a panel from a dehydrated state\n * @param dehydrateComponent Function to dehydrate a panel\n * @param openedMap Map of opened panels\n * @param closed Array of closed panels in a dehydrated state\n * @param onPanelsUpdated Triggered when the panels are updated\n */\n constructor(\n layout: GoldenLayout,\n hydrateComponent: PanelHydraterFunction = (name, props) => props,\n dehydrateComponent: PanelDehydraterFunction = (name, config) => config,\n openedMap: OpenedPanelMap = new Map(),\n closed: ClosedPanel[] = [],\n onPanelsUpdated: PanelsUpdateCallback = () => undefined\n ) {\n this.handleFocus = this.handleFocus.bind(this);\n this.handleMount = this.handleMount.bind(this);\n // Panel can be unmounted on error but still keep the tab until it's closed\n // Use PanelEvent.MOUNT/UNMOUNT to track open (active) panels\n // and PanelEvent.CLOSED for cleanup (delete links, add panel to closed panels list, etc)\n this.handleUnmount = this.handleUnmount.bind(this);\n this.handleReopen = this.handleReopen.bind(this);\n this.handleDeleted = this.handleDeleted.bind(this);\n this.handleClosed = this.handleClosed.bind(this);\n this.handleControlClose = this.handleControlClose.bind(this);\n\n this.layout = layout;\n this.hydrateComponent = hydrateComponent;\n this.dehydrateComponent = dehydrateComponent;\n this.onPanelsUpdated = onPanelsUpdated;\n\n // Store the opened and closed panels\n this.openedMap = new Map(openedMap);\n\n // Closed panels are stored in their dehydrated state\n this.closed = [...closed];\n\n this.startListening();\n }\n\n startListening(): void {\n const { eventHub } = this.layout;\n eventHub.on(PanelEvent.FOCUS, this.handleFocus);\n eventHub.on(PanelEvent.MOUNT, this.handleMount);\n eventHub.on(PanelEvent.UNMOUNT, this.handleUnmount);\n eventHub.on(PanelEvent.REOPEN, this.handleReopen);\n eventHub.on(PanelEvent.DELETE, this.handleDeleted);\n eventHub.on(PanelEvent.CLOSED, this.handleClosed);\n eventHub.on(PanelEvent.CLOSE, this.handleControlClose);\n // PanelEvent.OPEN should be listened to by plugins to open a panel\n }\n\n stopListening(): void {\n const { eventHub } = this.layout;\n eventHub.off(PanelEvent.FOCUS, this.handleFocus);\n eventHub.off(PanelEvent.MOUNT, this.handleMount);\n eventHub.off(PanelEvent.UNMOUNT, this.handleUnmount);\n eventHub.off(PanelEvent.REOPEN, this.handleReopen);\n eventHub.off(PanelEvent.DELETE, this.handleDeleted);\n eventHub.off(PanelEvent.CLOSED, this.handleClosed);\n eventHub.off(PanelEvent.CLOSE, this.handleControlClose);\n }\n\n getClosedPanelConfigsOfType(typeString: string): ClosedPanels {\n return this.closed.filter(panel => panel.component === typeString);\n }\n\n getOpenedPanels(): PanelComponent[] {\n return Array.from(this.openedMap.values());\n }\n\n getOpenedPanelConfigs(): (ItemConfigType | null)[] {\n return this.getOpenedPanels().map(panel => {\n const { glContainer } = panel.props;\n return LayoutUtils.getComponentConfigFromContainer(glContainer);\n });\n }\n\n getOpenedPanelConfigsOfType(typeString: string): ReactComponentConfig[] {\n return this.getOpenedPanelConfigs().filter(\n config =>\n config != null &&\n isReactComponentConfig(config) &&\n config.component === typeString\n ) as ReactComponentConfig[];\n }\n\n getOpenedPanelById(panelId: string | string[]): PanelComponent | undefined {\n return this.openedMap.get(panelId);\n }\n\n getContainerByPanelId(panelId: string | string[]): ContentItem | null {\n const stack = LayoutUtils.getStackForConfig(this.layout.root, {\n id: panelId,\n });\n return (\n (stack && LayoutUtils.getContentItemInStack(stack, { id: panelId })) ??\n null\n );\n }\n\n getLastUsedPanel<T extends PanelComponent = PanelComponent>(\n matcher: (panel: PanelComponent) => boolean\n ): T | undefined {\n const opened = this.getOpenedPanels();\n for (let i = opened.length - 1; i >= 0; i -= 1) {\n const panel = opened[i];\n if (matcher == null || matcher(panel)) {\n return panel as T;\n }\n }\n\n return undefined;\n }\n\n getLastUsedPanelOfType<\n P extends PanelProps = PanelProps,\n C extends ComponentType<P> = ComponentType<P>,\n >(type: PanelComponentType<P, C>): PanelComponent<P> | undefined {\n return this.getLastUsedPanelOfTypes([type]);\n }\n\n getLastUsedPanelOfTypes<\n P extends PanelProps = PanelProps,\n C extends ComponentType<P> = ComponentType<P>,\n >(types: PanelComponentType<P, C>[]): PanelComponent<P> | undefined {\n return this.getLastUsedPanel(panel =>\n types.some(\n type =>\n (isWrappedComponent(type) &&\n panel instanceof type.WrappedComponent) ||\n (!isWrappedComponent(type) && panel instanceof type)\n )\n );\n }\n\n updatePanel(panel: PanelComponent): void {\n const panelId = LayoutUtils.getIdFromPanel(panel);\n if (panelId == null) {\n log.error('updatePanel Panel did not have an ID', panel);\n return;\n }\n log.debug2(`Updating panel ID ${panelId} in open panels map`);\n // Delete the entry before it's set to maintain correct ordering in the open panels map.\n // The last updated (focused) panel should be the last inserted.\n // Deleting the entry from the map directly instead of calling this.removePanel to skip the checks.\n this.openedMap.delete(panelId);\n this.openedMap.set(panelId, panel);\n }\n\n removePanel(panel: PanelComponent): void {\n const panelId = LayoutUtils.getIdFromPanel(panel);\n if (panelId == null) {\n log.error('removePanel Panel did not have an ID', panel);\n return;\n }\n if (!this.openedMap.has(panelId)) {\n log.error(`Missing panel ID ${panelId} in open panels map`);\n return;\n }\n if (this.openedMap.get(panelId) !== panel) {\n // We mount a new panel before un-mounting the existing one\n // when replacing existing panels in openComponent/openComponentInStack.\n // Skip map delete if the panelId entry already refers to the new panel.\n log.debug(\n `Panel argument doesn't match the open panels map entry for ${panelId}, removePanel ignored`\n );\n return;\n }\n log.debug2(`Removing panel ID ${panelId} from open panels map`);\n this.openedMap.delete(panelId);\n }\n\n removeClosedPanelConfig(panelConfig: ClosedPanel): void {\n const index = this.closed.findIndex(\n closedConfig =>\n closedConfig === panelConfig ||\n (closedConfig.id != null &&\n panelConfig.id != null &&\n closedConfig.id === panelConfig.id)\n );\n if (index >= 0) {\n this.closed.splice(index, 1);\n }\n }\n\n handleFocus(panel: PanelComponent): void {\n log.debug2('Focus: ', panel);\n this.updatePanel(panel);\n }\n\n handleMount(panel: PanelComponent): void {\n log.debug2('Mount: ', panel);\n this.updatePanel(panel);\n this.sendUpdate();\n }\n\n handleUnmount(panel: PanelComponent): void {\n log.debug2('Unmount: ', panel);\n this.removePanel(panel);\n this.sendUpdate();\n }\n\n /**\n *\n * @param panelConfig The config to hydrate and load\n * @param replaceConfig The config to place\n */\n handleReopen(\n panelConfig: ClosedPanel,\n replaceConfig?: Partial<ItemConfigType>\n ): void {\n log.debug2('Reopen:', panelConfig, replaceConfig);\n\n this.removeClosedPanelConfig(panelConfig);\n // Don't need to send an update yet, it will get sent when component is mounted\n\n // Rehydrate the panel before adding it back\n const { component } = panelConfig;\n let { props } = panelConfig;\n props = this.hydrateComponent(component, props);\n\n const config = {\n ...panelConfig,\n props,\n };\n\n const { root } = this.layout;\n LayoutUtils.openComponent({ root, config, replaceConfig });\n }\n\n handleDeleted(panelConfig: ClosedPanel): void {\n log.debug2('Deleted:', panelConfig);\n\n this.removeClosedPanelConfig(panelConfig);\n\n this.sendUpdate();\n }\n\n handleClosed(panelId: string, glContainer: Container): void {\n // Panel component should be already unmounted at this point\n // so the emitted event sends the container object instead of the panel.\n log.debug2('Closed: ', panelId);\n this.addClosedPanel(glContainer);\n this.sendUpdate();\n }\n\n handleControlClose(id: string): void {\n const config = { id };\n const { root } = this.layout;\n LayoutUtils.closeComponent(root, config);\n }\n\n addClosedPanel(glContainer: Container): void {\n const config = LayoutUtils.getComponentConfigFromContainer(glContainer);\n if (config && isReactComponentConfig(config)) {\n const dehydratedConfig = this.dehydrateComponent(\n config.component,\n config\n );\n if (dehydratedConfig != null) {\n this.closed.push(dehydratedConfig);\n }\n }\n }\n\n sendUpdate(): void {\n const { closed, openedMap } = this;\n this.onPanelsUpdated({\n closed: [...closed],\n openedMap: new Map(openedMap),\n });\n }\n}\n\nexport default PanelManager;\n"],"mappings":";;;;;AAQA,OAAOA,GAAG,MAAM,gBAAgB;AAAC,OAC1BC,UAAU;AAAA,OACVC,WAAW,IAAIC,sBAAsB;AAAA,SAE1CC,kBAAkB;AAMpB,IAAMC,GAAG,GAAGL,GAAG,CAACM,MAAM,CAAC,cAAc,CAAC;AAyBtC;AACA;AACA;AACA,MAAMC,YAAY,CAAC;EAejB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,WAAWA,CACTC,MAAoB,EAMpB;IAAA,IALAC,gBAAuC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAACG,IAAI,EAAEC,KAAK,KAAKA,KAAK;IAAA,IAChEC,kBAA2C,GAAAL,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAACG,IAAI,EAAEG,MAAM,KAAKA,MAAM;IAAA,IACtEC,SAAyB,GAAAP,SAAA,CAAAC,MAAA,QAAAD,SAAA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laceholder","forwardRef","props","ref","component","getComponentNameFromPanel","displayName"],"sources":["../src/PanelPlaceholder.tsx"],"sourcesContent":["import React, { ForwardedRef } from 'react';\nimport './PanelPlaceholder.scss';\nimport LayoutUtils from './layout/LayoutUtils';\nimport { PanelProps } from './DashboardPlugin';\n\n/**\n * Displays a placeholder for unregistered panel types.\n */\nconst PanelPlaceholder = React.forwardRef(\n (props: PanelProps, ref: ForwardedRef<HTMLDivElement>) => {\n const component = LayoutUtils.getComponentNameFromPanel({ props });\n return (\n <div ref={ref} className=\"panel-placeholder\">\n <div>Component "{component}" is not registered.</div>\n </div>\n );\n }\n);\n\nPanelPlaceholder.displayName = 'PanelPlaceholder';\n\nexport default PanelPlaceholder;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAwB,OAAO;AAAC;AAAA,OAErCC,WAAW;AAAA;AAAA;AAGlB;AACA;AACA;AACA,IAAMC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"PanelPlaceholder.js","names":["React","LayoutUtils","jsxs","_jsxs","jsx","_jsx","PanelPlaceholder","forwardRef","props","ref","component","getComponentNameFromPanel","className","children","displayName"],"sources":["../src/PanelPlaceholder.tsx"],"sourcesContent":["import React, { ForwardedRef } from 'react';\nimport './PanelPlaceholder.scss';\nimport LayoutUtils from './layout/LayoutUtils';\nimport { PanelProps } from './DashboardPlugin';\n\n/**\n * Displays a placeholder for unregistered panel types.\n */\nconst PanelPlaceholder = React.forwardRef(\n (props: PanelProps, ref: ForwardedRef<HTMLDivElement>) => {\n const component = LayoutUtils.getComponentNameFromPanel({ props });\n return (\n <div ref={ref} className=\"panel-placeholder\">\n <div>Component "{component}" is not registered.</div>\n </div>\n );\n }\n);\n\nPanelPlaceholder.displayName = 'PanelPlaceholder';\n\nexport default PanelPlaceholder;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAwB,OAAO;AAAC;AAAA,OAErCC,WAAW;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAGlB;AACA;AACA;AACA,IAAMC,gBAAgB,gBAAGN,KAAK,CAACO,UAAU,CACvC,CAACC,KAAiB,EAAEC,GAAiC,KAAK;EACxD,IAAMC,SAAS,GAAGT,WAAW,CAACU,yBAAyB,CAAC;IAAEH;EAAM,CAAC,CAAC;EAClE,oBACEH,IAAA;IAAKI,GAAG,EAAEA,GAAI;IAACG,SAAS,EAAC,mBAAmB;IAAAC,QAAA,eAC1CV,KAAA;MAAAU,QAAA,GAAK,cAAgB,EAACH,SAAS,EAAC,uBAAyB;IAAA,CAAK;EAAC,CAC5D,CAAC;AAEV,CACF,CAAC;AAEDJ,gBAAgB,CAACQ,WAAW,GAAG,kBAAkB;AAEjD,eAAeR,gBAAgB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GLPropTypes.js","names":["PropTypes","Container","shape","on","func","off","isHidden","bool","tab","header","tabs","arrayOf","contentItem","title","string","setTitle","close","EventHub","emit","Layout","registerComponent","root","addChild","eventHub","GLPropTypes","Object","freeze"],"sources":["../../src/layout/GLPropTypes.ts"],"sourcesContent":["import PropTypes from 'prop-types';\n\nconst Container = PropTypes.shape({\n on: PropTypes.func,\n off: PropTypes.func,\n isHidden: PropTypes.bool,\n tab: PropTypes.shape({\n header: PropTypes.shape({\n tabs: PropTypes.arrayOf(\n PropTypes.shape({\n contentItem: PropTypes.shape({}),\n })\n ),\n }),\n }),\n title: PropTypes.string,\n setTitle: PropTypes.func,\n close: PropTypes.func,\n});\n\nconst EventHub = PropTypes.shape({\n on: PropTypes.func,\n off: PropTypes.func,\n emit: PropTypes.func,\n});\n\nconst Layout = PropTypes.shape({\n registerComponent: PropTypes.func,\n root: PropTypes.shape({ addChild: PropTypes.func }),\n on: PropTypes.func,\n off: PropTypes.func,\n eventHub: EventHub,\n});\n\nconst GLPropTypes = Object.freeze({ Container, EventHub, Layout });\n\nexport default GLPropTypes;\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,YAAY;AAElC,IAAMC,SAAS,GAAGD,SAAS,CAACE,KAAK,CAAC;EAChCC,EAAE,EAAEH,SAAS,CAACI,IAAI;EAClBC,GAAG,EAAEL,SAAS,CAACI,IAAI;EACnBE,QAAQ,EAAEN,SAAS,CAACO,IAAI;EACxBC,GAAG,EAAER,SAAS,CAACE,KAAK,CAAC;IACnBO,MAAM,EAAET,SAAS,CAACE,KAAK,CAAC;MACtBQ,IAAI,EAAEV,SAAS,CAACW,OAAO,CACrBX,SAAS,CAACE,KAAK,CAAC;QACdU,WAAW,EAAEZ,SAAS,CAACE,KAAK,CAAC,CAAC,CAAC;MACjC,CAAC,
|
|
1
|
+
{"version":3,"file":"GLPropTypes.js","names":["PropTypes","Container","shape","on","func","off","isHidden","bool","tab","header","tabs","arrayOf","contentItem","title","string","setTitle","close","EventHub","emit","Layout","registerComponent","root","addChild","eventHub","GLPropTypes","Object","freeze"],"sources":["../../src/layout/GLPropTypes.ts"],"sourcesContent":["import PropTypes from 'prop-types';\n\nconst Container = PropTypes.shape({\n on: PropTypes.func,\n off: PropTypes.func,\n isHidden: PropTypes.bool,\n tab: PropTypes.shape({\n header: PropTypes.shape({\n tabs: PropTypes.arrayOf(\n PropTypes.shape({\n contentItem: PropTypes.shape({}),\n })\n ),\n }),\n }),\n title: PropTypes.string,\n setTitle: PropTypes.func,\n close: PropTypes.func,\n});\n\nconst EventHub = PropTypes.shape({\n on: PropTypes.func,\n off: PropTypes.func,\n emit: PropTypes.func,\n});\n\nconst Layout = PropTypes.shape({\n registerComponent: PropTypes.func,\n root: PropTypes.shape({ addChild: PropTypes.func }),\n on: PropTypes.func,\n off: PropTypes.func,\n eventHub: EventHub,\n});\n\nconst GLPropTypes = Object.freeze({ Container, EventHub, Layout });\n\nexport default GLPropTypes;\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,YAAY;AAElC,IAAMC,SAAS,GAAGD,SAAS,CAACE,KAAK,CAAC;EAChCC,EAAE,EAAEH,SAAS,CAACI,IAAI;EAClBC,GAAG,EAAEL,SAAS,CAACI,IAAI;EACnBE,QAAQ,EAAEN,SAAS,CAACO,IAAI;EACxBC,GAAG,EAAER,SAAS,CAACE,KAAK,CAAC;IACnBO,MAAM,EAAET,SAAS,CAACE,KAAK,CAAC;MACtBQ,IAAI,EAAEV,SAAS,CAACW,OAAO,CACrBX,SAAS,CAACE,KAAK,CAAC;QACdU,WAAW,EAAEZ,SAAS,CAACE,KAAK,CAAC,CAAC,CAAC;MACjC,CAAC,CACH;IACF,CAAC;EACH,CAAC,CAAC;EACFW,KAAK,EAAEb,SAAS,CAACc,MAAM;EACvBC,QAAQ,EAAEf,SAAS,CAACI,IAAI;EACxBY,KAAK,EAAEhB,SAAS,CAACI;AACnB,CAAC,CAAC;AAEF,IAAMa,QAAQ,GAAGjB,SAAS,CAACE,KAAK,CAAC;EAC/BC,EAAE,EAAEH,SAAS,CAACI,IAAI;EAClBC,GAAG,EAAEL,SAAS,CAACI,IAAI;EACnBc,IAAI,EAAElB,SAAS,CAACI;AAClB,CAAC,CAAC;AAEF,IAAMe,MAAM,GAAGnB,SAAS,CAACE,KAAK,CAAC;EAC7BkB,iBAAiB,EAAEpB,SAAS,CAACI,IAAI;EACjCiB,IAAI,EAAErB,SAAS,CAACE,KAAK,CAAC;IAAEoB,QAAQ,EAAEtB,SAAS,CAACI;EAAK,CAAC,CAAC;EACnDD,EAAE,EAAEH,SAAS,CAACI,IAAI;EAClBC,GAAG,EAAEL,SAAS,CAACI,IAAI;EACnBmB,QAAQ,EAAEN;AACZ,CAAC,CAAC;AAEF,IAAMO,WAAW,GAAGC,MAAM,CAACC,MAAM,CAAC;EAAEzB,SAAS;EAAEgB,QAAQ;EAAEE;AAAO,CAAC,CAAC;AAElE,eAAeK,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutUtils.js","names":["deepEqual","shortid","isMatch","Log","isComponent","isRoot","isStack","GoldenLayoutThemeExport","assertNotNull","log","module","isComponentConfig","config","componentName","undefined","isReactComponentConfig","reactConfig","type","component","isHTMLElement","element","focus","isStackItemConfig","LayoutUtils","activateTab","root","stack","getStackForRoot","error","contentItem","getContentItemInStack","setActiveContentItem","isActiveTab","activeItem","getActiveContentItem","addStack","parent","columnPreferred","contentItems","length","addChild","child","isCorrectType","isColumn","isRow","removeChild","maintainFocusElement","document","activeElement","newParent","getStackForConfig","item","allowEmptyStack","i","createIfNecessary","matchComponentType","getStackForComponentTypes","types","isLastType","dehydrateLayoutConfig","dehydrateComponent","dehydratedConfig","itemConfig","content","dehydratedComponent","push","debug2","layoutItemConfig","getTabPoint","glContainer","tab","Error","tabRect","getBoundingClientRect","left","width","bottom","dropLayoutMinorChange","activeItemIndex","props","panelState","id","irisGridState","sorts","quickFilters","isEqual","layout1","layout2","major","layout1Clone","cloneLayout","layout2Clone","layout","JSON","parse","stringify","hydrateLayoutConfig","hydrateComponent","hydratedConfig","contentConfig","warn","openComponent","configParam","replaceExisting","replaceConfig","createNewStack","focusElement","dragEvent","generate","layoutManager","createDragSourceFromEvent","searchConfig","oldContentItem","onComponentCreated","event","debug","off","origin","requestAnimationFrame","on","index","indexOf","openComponentInStack","closeComponent","closeOptions","container","close","contains","renameComponent","newTitle","setTitle","cloneComponent","getPanelComponentState","cloneConfig","title","componentState","makeDefaultLayout","dimensions","headerHeight","tabHeight","borderWidth","dragBorderWidth","borderGrabWidth","settings","showPopoutIcon","showCloseIcon","constrainDragToContainer","getRootFromContainer","getComponentConfigFromContainer","_config","getTitleFromContainer","getTitleFromTab","getIdFromContainer","getIdFromPanel","panel","getComponentNameFromPanel","getComponentName","name","WrappedComponent","displayName","selector","DEFAULT_FOCUS_SELECTOR","querySelector","onInitialized","Promise","resolve","isInitialised","onInit"],"sources":["../../src/layout/LayoutUtils.ts"],"sourcesContent":["import { DragEvent } from 'react';\nimport deepEqual from 'deep-equal';\nimport shortid from 'shortid';\nimport isMatch from 'lodash.ismatch';\nimport Log from '@deephaven/log';\nimport GoldenLayout, {\n isComponent,\n isRoot,\n isStack,\n GoldenLayoutThemeExport,\n} from '@deephaven/golden-layout';\nimport type {\n ComponentConfig,\n Config,\n Container,\n ContentItem,\n ItemConfig,\n ItemConfigType,\n ReactComponentConfig,\n Stack,\n Tab,\n CloseOptions,\n} from '@deephaven/golden-layout';\nimport { assertNotNull } from '@deephaven/utils';\nimport { DashboardLayoutConfig } from '../DashboardLayout';\nimport { PanelConfig } from '../DashboardPlugin';\n\nconst log = Log.module('LayoutUtils');\n\ntype LayoutConfig = { id?: string; component?: string };\n\nexport type StackItemConfig = ItemConfig & {\n activeItemIndex?: number;\n};\n\nfunction isComponentConfig(config: ItemConfigType): config is ComponentConfig {\n return (config as ComponentConfig).componentName !== undefined;\n}\n\nexport function isReactComponentConfig(\n config: ItemConfigType\n): config is ReactComponentConfig {\n const reactConfig = config as ReactComponentConfig;\n // Golden layout sets the type to 'component' and componentName to 'lm-react-component' in `createContentItem`, then changes it back in `toConfig`\n // For our purposes, we need to check both.\n return (\n ((isComponentConfig(config) &&\n config.componentName === 'lm-react-component') ||\n config.type === 'react-component') &&\n reactConfig.component !== undefined\n );\n}\n\nfunction isHTMLElement(element: Element): element is HTMLElement {\n return (element as HTMLElement).focus !== undefined;\n}\n\nfunction isStackItemConfig(config: ItemConfigType): config is StackItemConfig {\n return config.type === 'stack';\n}\nclass LayoutUtils {\n static DEFAULT_FOCUS_SELECTOR = 'input, select, textarea, button';\n\n static activateTab(root: ContentItem, config: Partial<ItemConfigType>): void {\n const stack = LayoutUtils.getStackForRoot(root, config, false);\n if (!stack) {\n log.error('Could not find stack for config', config);\n return;\n }\n // Find the tab with the specified table and activate it\n const contentItem = LayoutUtils.getContentItemInStack(stack, config);\n if (contentItem) {\n stack.setActiveContentItem(contentItem);\n }\n }\n\n /**\n * Is the tab with the given config active\n * @param root A GoldenLayout content item with the tab\n * @param config Tab config to match\n * @returns True if the tab is active\n */\n static isActiveTab(\n root: ContentItem,\n config: Partial<ReactComponentConfig>\n ): boolean {\n const stack = LayoutUtils.getStackForRoot(root, config, false);\n if (!stack) {\n log.error('Could not find stack for config', config);\n return false;\n }\n // Find the item with the specified config and compare with active item\n const contentItem = LayoutUtils.getContentItemInStack(stack, config);\n const activeItem = stack.getActiveContentItem();\n return activeItem === contentItem;\n }\n\n /**\n * Adds a stack to the root layout specified. Adds to the first row/column with only one item\n * @param parent A GoldenLayout content item to add the stack to\n * @returns The newly created stack.\n */\n static addStack(parent: ContentItem, columnPreferred = true): Stack {\n const type = columnPreferred ? 'column' : 'row';\n if (isRoot(parent)) {\n if (parent.contentItems == null || parent.contentItems.length === 0) {\n parent.addChild({ type });\n }\n\n const child = parent.contentItems[0];\n const isCorrectType = columnPreferred ? child.isColumn : child.isRow;\n if (!isCorrectType) {\n parent.removeChild(child, true);\n parent.addChild({ type });\n\n // The addChild may cause the element that has focus to be removed from the DOM, which changes focus to the body\n // Try and maintain the focus as best we can. The unfocused element may still send a blur/focus event so that needs to be handled correctly.\n const maintainFocusElement = document.activeElement;\n parent.contentItems[0].addChild(child);\n if (\n maintainFocusElement &&\n (maintainFocusElement as HTMLElement).focus != null\n ) {\n (maintainFocusElement as HTMLElement).focus();\n }\n }\n\n return this.addStack(parent.contentItems[0], columnPreferred);\n }\n\n if (parent.contentItems.length < 2) {\n parent.addChild({ type: 'stack' });\n return parent.contentItems[parent.contentItems.length - 1] as Stack;\n }\n let newParent = parent.contentItems[parent.contentItems.length - 1];\n const isCorrectType = !columnPreferred\n ? newParent.isColumn\n : newParent.isRow;\n if (!isCorrectType) {\n parent.addChild({ type: !columnPreferred ? 'column' : 'row' });\n parent.removeChild(newParent, true);\n parent.contentItems[parent.contentItems.length - 1].addChild(newParent);\n newParent = parent.contentItems[parent.contentItems.length - 1];\n }\n\n return this.addStack(newParent, !columnPreferred);\n }\n\n /**\n * Gets the first stack which contains a contentItem with the given config values\n * @param item Golden layout content item to search for the stack\n * @param config The item properties to match\n */\n static getStackForConfig(\n item: ContentItem,\n config: Partial<ItemConfigType> = {},\n allowEmptyStack = false\n ): Stack | null {\n if (allowEmptyStack && isStack(item) && item.contentItems.length === 0) {\n return item;\n }\n\n if (item.contentItems == null) {\n return null;\n }\n\n for (let i = 0; i < item.contentItems.length; i += 1) {\n const contentItem = item.contentItems[i];\n if (contentItem.isComponent && contentItem.config != null) {\n if (isMatch(contentItem.config, config)) {\n return item as Stack;\n }\n }\n\n const stack = this.getStackForConfig(\n contentItem,\n config,\n allowEmptyStack\n );\n if (stack) {\n return stack;\n }\n }\n\n return null;\n }\n\n /**\n * Gets a stack matching the specified config\n * @param root The root GoldenLayout element\n * @param config The item config type to match, eg. { component: 'IrisGridPanel', title: 'Table Name' }\n * @param createIfNecessary Whether to create the stack if it does not exist.\n * @param matchComponentType If the config doesn't match exactly, just find another one of the same component type\n * @param allowEmptyStack If no configs match, search for an empty stack that can be used\n */\n static getStackForRoot(\n root: ContentItem,\n config: Partial<ReactComponentConfig>,\n createIfNecessary = true,\n matchComponentType = true,\n allowEmptyStack = true\n ): Stack | null {\n let stack = this.getStackForConfig(root, config);\n if (!stack && matchComponentType) {\n stack = this.getStackForConfig(\n root,\n { component: config.component },\n allowEmptyStack\n );\n }\n\n if (!stack && createIfNecessary) {\n stack = this.addStack(root);\n }\n\n return stack;\n }\n\n /**\n * Gets a stack matching one of the specified types, creates new stack if necessary\n * @param root The GoldenLayout root to find or create the stack in\n * @param types The array of component types to match\n * @param createIfNecessary Whether to create the stack if it does not exist\n * @param matchComponentType If the config doesn't match exactly, just find another one of the same component type\n * @param allowEmptyStack If no configs match, search for an empty stack that can be used\n */\n static getStackForComponentTypes(\n root: ContentItem,\n types: string[],\n createIfNecessary = true,\n matchComponentType = true,\n allowEmptyStack = true\n ): Stack | null {\n for (let i = 0; i < types.length; i += 1) {\n const component = types[i];\n const isLastType = i === types.length - 1;\n const stack = LayoutUtils.getStackForRoot(\n root,\n { component },\n createIfNecessary && isLastType,\n matchComponentType,\n allowEmptyStack\n );\n if (stack) {\n return stack;\n }\n }\n return null;\n }\n\n /**\n * Gets first content item with the specified config in stack.\n * @param stack The stack to search for the item\n * @param config The item config type to match, eg. { component: 'IrisGridPanel', title: 'Table Name' }\n * @returns Returns the found content item, null if not found.\n */\n static getContentItemInStack(\n stack: ContentItem | null,\n config: Partial<ItemConfigType>\n ): ContentItem | null {\n if (!stack) {\n return null;\n }\n for (let i = 0; i < stack.contentItems.length; i += 1) {\n const contentItem = stack.contentItems[i];\n if (contentItem.isComponent && contentItem.config != null) {\n if (isMatch(contentItem.config, config)) {\n return contentItem;\n }\n }\n }\n return null;\n }\n\n /**\n * Removes dynamic props from components in the given config so this config could be serialized\n * @param config Config objec\n * @returns Dehydrated config\n */\n static dehydrateLayoutConfig(\n config: ItemConfigType[],\n dehydrateComponent: (\n componentName: string,\n config: ItemConfigType\n ) => PanelConfig\n ): (PanelConfig | ItemConfig)[] {\n if (config == null || !config.length) {\n return [];\n }\n const dehydratedConfig: (PanelConfig | ItemConfig)[] = [];\n\n for (let i = 0; i < config.length; i += 1) {\n const itemConfig = config[i];\n const { component, content } = itemConfig as ReactComponentConfig;\n if (component) {\n const dehydratedComponent = dehydrateComponent(component, itemConfig);\n if (dehydratedComponent != null) {\n dehydratedConfig.push(dehydratedComponent);\n } else {\n log.debug2(\n `dehydrateLayoutConfig: skipping unmapped component \"${component}\"`\n );\n }\n } else if (content) {\n const layoutItemConfig = {\n ...itemConfig,\n content: LayoutUtils.dehydrateLayoutConfig(\n content,\n dehydrateComponent\n ),\n };\n dehydratedConfig.push(layoutItemConfig);\n } else {\n dehydratedConfig.push(itemConfig);\n }\n }\n return dehydratedConfig;\n }\n\n static getTabPoint(glContainer: Container): [number, number] {\n const { tab } = glContainer;\n if (tab == null) {\n throw new Error(`Cannot get tab for panel container ${glContainer}`);\n }\n const tabRect = tab.element[0].getBoundingClientRect();\n\n return [tabRect.left + tabRect.width * 0.5, tabRect.bottom - 8];\n }\n\n /**\n * Drop minor changes in Layout Configuration for deep comparison\n * @param config Layout Configuration\n *\n * minor changes:\n * 1. sorts in grid\n * 2. quick filters in grid\n * 3. active item\n *\n * item id is also removed\n */\n static dropLayoutMinorChange(config: DashboardLayoutConfig): void {\n for (let i = 0; i < config.length; i += 1) {\n const itemConfig = config[i];\n const { content } = itemConfig;\n if (content !== undefined) {\n if (isStackItemConfig(itemConfig)) {\n delete itemConfig.activeItemIndex;\n }\n LayoutUtils.dropLayoutMinorChange(content);\n } else if (\n isReactComponentConfig(itemConfig) &&\n itemConfig.component === 'IrisGridPanel'\n ) {\n if (itemConfig.props.panelState != null) {\n delete itemConfig.id;\n itemConfig.props.panelState.irisGridState.sorts = [];\n itemConfig.props.panelState.irisGridState.quickFilters = [];\n }\n }\n }\n }\n\n /**\n * Compare two layouts to see if they are equivalent\n * @param layout1 A Golden Layout config object\n * @param layout2 Another Golden layout config object\n * @param major When true, will ignore \"minor\" property differences (eg. sorts)\n */\n static isEqual(\n layout1: DashboardLayoutConfig,\n layout2: DashboardLayoutConfig,\n major = false\n ): boolean {\n if (major) {\n const layout1Clone = LayoutUtils.cloneLayout(layout1);\n const layout2Clone = LayoutUtils.cloneLayout(layout2);\n LayoutUtils.dropLayoutMinorChange(layout1Clone);\n LayoutUtils.dropLayoutMinorChange(layout2Clone);\n return deepEqual(layout1Clone, layout2Clone);\n }\n return deepEqual(layout1, layout2);\n }\n\n static cloneLayout(layout: DashboardLayoutConfig): DashboardLayoutConfig {\n return JSON.parse(JSON.stringify(layout));\n }\n\n /**\n * Adds dynamic props to components in the given config so this config could be used to initialize a layout\n * @param config Dehydrated config object\n * @param hydrateComponent Function to hydrate the component\n * @returns Hydrated config\n */\n static hydrateLayoutConfig(\n config: (PanelConfig | ItemConfig)[],\n hydrateComponent: (\n componentName: string,\n config: PanelConfig | ItemConfig\n ) => ReactComponentConfig\n ): DashboardLayoutConfig {\n if (config == null || !config.length) {\n return [];\n }\n const hydratedConfig = [];\n\n for (let i = 0; i < config.length; i += 1) {\n const itemConfig = config[i];\n if (isReactComponentConfig(itemConfig)) {\n const { component, props = {} } = itemConfig;\n hydratedConfig.push({\n ...itemConfig,\n id: itemConfig?.id ?? shortid(),\n props: hydrateComponent(component, props),\n });\n } else if (itemConfig.content !== undefined) {\n const contentConfig = LayoutUtils.hydrateLayoutConfig(\n itemConfig.content,\n hydrateComponent\n );\n if (\n isStackItemConfig(itemConfig) &&\n itemConfig.activeItemIndex != null &&\n itemConfig.activeItemIndex >= contentConfig.length\n ) {\n log.warn(\n 'Fixing bad activeItemIndex!',\n itemConfig.activeItemIndex,\n itemConfig\n );\n itemConfig.activeItemIndex = 0;\n }\n hydratedConfig.push({\n ...itemConfig,\n content: contentConfig,\n });\n } else {\n hydratedConfig.push(itemConfig);\n }\n }\n\n return hydratedConfig;\n }\n\n /**\n * Opens a component. It will try and open the component in an existing stack of the same component.\n * If `replaceExisting` is true and there is a component found with the same `config.id`, it will replace that component with this one.\n * If `allowStack` is true and there is a component of the same type found, it will open in that stack (potentially covering up a panel).\n * @param root The GoldenLayout root to open the component in\n * @param config The component config definition to open\n * @param replaceExisting Whether it should replace the existing one matching component type and id, or open a new one\n * @param replaceConfig The component config to replace\n * @param createNewStack True to force opening in a new stack, false to try and open in a stack with the same type of component.\n * @param focusElement The element to focus on\n * @param dragEvent Whether component is being created with a drag, mouse event is initial position for drag proxy\n */\n static openComponent({\n root,\n config: configParam,\n replaceExisting = true,\n replaceConfig = undefined,\n createNewStack = false,\n focusElement = undefined,\n dragEvent = undefined,\n }: {\n root?: ContentItem;\n config?: Partial<ReactComponentConfig>;\n replaceExisting?: boolean;\n replaceConfig?: Partial<ItemConfigType>;\n createNewStack?: boolean;\n focusElement?: string;\n dragEvent?: DragEvent;\n } = {}): void {\n // attempt to retain focus after dom manipulation, which can break focus\n const maintainFocusElement = document.activeElement;\n const config = { ...configParam } as ReactComponentConfig;\n\n if (config.id == null) {\n config.id = shortid.generate();\n }\n\n if (dragEvent != null) {\n root?.layoutManager.createDragSourceFromEvent(config, dragEvent);\n return;\n }\n\n const searchConfig = replaceConfig || {\n id: config.id,\n component: config.component,\n };\n assertNotNull(root);\n const stack = createNewStack\n ? LayoutUtils.addStack(root)\n : LayoutUtils.getStackForRoot(root, searchConfig);\n\n assertNotNull(stack);\n const oldContentItem = LayoutUtils.getContentItemInStack(\n stack,\n searchConfig\n );\n\n if (focusElement != null) {\n // We need to listen for when the stack is created\n const onComponentCreated = (event: {\n origin: { element: Element[] };\n }): void => {\n log.debug('Component created, focusing element', focusElement);\n\n stack.off('componentCreated', onComponentCreated);\n\n const { element } = event.origin;\n\n // Need to wait until the component actually renders.\n requestAnimationFrame(() => {\n LayoutUtils.focusElement(element[0], focusElement);\n });\n };\n stack.on('componentCreated', onComponentCreated);\n }\n if (replaceExisting && oldContentItem) {\n const index = stack.contentItems.indexOf(oldContentItem);\n\n // Using remove/add here instead of replaceChild because I was getting errors with replaceChild... should be the same.\n // Add first so that the stack doesn't get screwed up\n stack.addChild(config, index + 1);\n stack.removeChild(oldContentItem);\n\n stack.setActiveContentItem(stack.contentItems[index]);\n } else {\n stack.addChild(config);\n }\n\n if (\n focusElement == null &&\n maintainFocusElement &&\n isHTMLElement(maintainFocusElement)\n ) {\n maintainFocusElement.focus();\n }\n }\n\n /**\n * Opens a component in an given stack.\n * If `replaceExisting` is true and there is a component found with the same `config.id`, it will replace that component with this one\n * @param stack The GoldenLayout stack to open the component in\n * @param config The component config definition to open\n * @param replaceExisting Whether it should replace the existing one matching component type and id, or open a new one\n */\n static openComponentInStack(\n stack: Stack | null,\n config: ItemConfigType & Record<string, unknown>,\n replaceExisting = true\n ): void {\n const maintainFocusElement = document.activeElement; // attempt to retain focus after dom manipulation, which can break focus\n\n const searchConfig = { id: config.id };\n\n const oldContentItem = LayoutUtils.getContentItemInStack(\n stack,\n searchConfig\n );\n\n if (replaceExisting && oldContentItem && stack) {\n const index = stack?.contentItems.indexOf(oldContentItem);\n\n // Using remove/add here instead of replaceChild because I was getting errors with replaceChild... should be the same.\n // Add first so that the stack doesn't get screwed up\n stack.addChild(config, index + 1);\n stack.removeChild(oldContentItem);\n\n stack.setActiveContentItem(stack.contentItems[index]);\n } else {\n stack?.addChild(config);\n }\n\n if (maintainFocusElement && isHTMLElement(maintainFocusElement)) {\n maintainFocusElement.focus();\n }\n }\n\n /**\n * Close the specified component and remove it from the stack it's currently in\n * @param root The GoldenLayout root to search and close the component in\n * @param config The GoldenLayout component config definition to close, eg. { component: 'IrisGridPanel', id: 'table-t' }\n */\n static closeComponent(\n root: ContentItem,\n config: LayoutConfig,\n closeOptions?: CloseOptions\n ): void {\n const stack = LayoutUtils.getStackForRoot(\n root,\n config,\n false,\n false,\n false\n );\n\n if (!stack) {\n log.warn('Cannot find stack for component, ignoring close', config);\n return;\n }\n\n // Find the tab with the specified config and remove it\n // Same component was used to get the stack above, so getContentItemInStack shouldn't return null\n const oldContentItem = LayoutUtils.getContentItemInStack(stack, config);\n const maintainFocusElement = document.activeElement; // attempt to retain focus after dom manipulation, which can break focus\n if (oldContentItem) {\n if (isComponent(oldContentItem)) {\n oldContentItem.container.close(closeOptions);\n } else {\n stack.removeChild(oldContentItem);\n }\n }\n // if focused element is still in dom restore focus, note it could have been in the removed panel so check first\n if (\n maintainFocusElement &&\n document.contains(maintainFocusElement) &&\n isHTMLElement(maintainFocusElement)\n ) {\n maintainFocusElement.focus();\n }\n }\n\n static renameComponent(\n root: ContentItem,\n config: Partial<ItemConfigType>,\n newTitle: string\n ): void {\n const stack = LayoutUtils.getStackForRoot(root, config, false);\n if (!stack) {\n log.error('Could not find stack for config', config);\n return;\n }\n // Find the tab with the specified config and rename it\n const contentItem = LayoutUtils.getContentItemInStack(stack, config);\n if (contentItem) {\n contentItem.setTitle(newTitle);\n }\n }\n\n /**\n * Create a component clone based on the given config\n * @param root The GoldenLayout root to clone the component in\n * @param config The config to clone\n * @returns Clone config\n */\n static cloneComponent(\n root: ContentItem,\n config: ReactComponentConfig\n ): ReactComponentConfig | null {\n const stack = LayoutUtils.getStackForRoot(root, config, false);\n if (!stack) {\n log.error('Could not find stack for config', config);\n return null;\n }\n const { props = {} } = config;\n const panelState = LayoutUtils.getPanelComponentState(config);\n const cloneConfig = {\n type: 'react-component' as const,\n component: config.component,\n props: {\n ...props,\n panelState,\n },\n title: `${config.title} Copy`,\n id: shortid.generate(),\n };\n LayoutUtils.openComponentInStack(stack, cloneConfig);\n return cloneConfig;\n }\n\n /**\n * Get panel component state for the given config\n * @param config Panel config\n * @returns Panel state\n */\n static getPanelComponentState(config: ItemConfigType): unknown {\n if (isComponentConfig(config)) {\n return config.componentState?.panelState;\n }\n if (isReactComponentConfig(config)) {\n return config.props?.panelState;\n }\n return null;\n }\n\n static makeDefaultLayout(): Config {\n return {\n dimensions: {\n headerHeight: GoldenLayoutThemeExport.tabHeight,\n borderWidth: GoldenLayoutThemeExport.dragBorderWidth,\n borderGrabWidth: 10,\n },\n settings: {\n showPopoutIcon: false,\n showCloseIcon: false,\n constrainDragToContainer: false,\n },\n } as Config;\n }\n\n /**\n * Gets a containers root node\n * @param container The Golden Layout container to get the root for\n */\n static getRootFromContainer(container: Container): ContentItem {\n return container.layoutManager.root;\n }\n\n /**\n * Gets the config for the panel component given a glContainer\n * @param container The Golden Layout container to get the config for\n */\n static getComponentConfigFromContainer(\n container?: Container\n ): ItemConfigType | null {\n if (container) {\n if (container.tab != null && container.tab.contentItem != null) {\n return container.tab.contentItem.config;\n }\n\n // If the container hasn't populated the tab yet, just get the config directly from the container\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore private api usage\n // eslint-disable-next-line no-underscore-dangle\n return container._config;\n }\n\n return null;\n }\n\n static getTitleFromContainer(\n container: Container\n ): string | null | undefined {\n if (\n container != null &&\n container.tab != null &&\n container.tab.contentItem != null\n ) {\n return container.tab.contentItem.config.title;\n }\n return null;\n }\n\n static getTitleFromTab(tab: Tab): string | null | undefined {\n if (tab != null && tab.contentItem != null) {\n return tab.contentItem.config.title;\n }\n return null;\n }\n\n /**\n * Retrieve the panel ID for the provided golden layout container\n * @param glContainer The container to get the panel ID for\n * @returns Panel ID\n */\n static getIdFromContainer(\n glContainer: Container\n ): string | string[] | null | undefined {\n const config = LayoutUtils.getComponentConfigFromContainer(glContainer);\n if (config) {\n return config.id;\n }\n return null;\n }\n\n /**\n * Retrieve the ID of the panel provided\n * @param panel The panel to get the ID for\n * @returns Panel ID\n */\n static getIdFromPanel(panel: {\n props: { glContainer: Container };\n }): string | string[] | null | undefined {\n const { glContainer } = panel.props;\n return LayoutUtils.getIdFromContainer(glContainer);\n }\n\n /**\n * Get component name from the panel instance\n * @param panel Panel to get component name for\n * @returns Component name or null if unable to retrieve name\n */\n static getComponentNameFromPanel(panel: {\n props: { glContainer: Container };\n }): string | null {\n const { glContainer } = panel.props;\n const config = LayoutUtils.getComponentConfigFromContainer(glContainer);\n if (config && isReactComponentConfig(config)) {\n return config.component ?? null;\n }\n return null;\n }\n\n /**\n * Get component name for wrapped and un-wrapped components\n * @param component Component to get name for\n * @returns Component name\n * @throws If displayName for the component is not defined\n */\n static getComponentName(component: {\n displayName?: string;\n WrappedComponent?: { displayName?: string };\n }): string {\n const name =\n component.WrappedComponent?.displayName ?? component.displayName;\n if (name == null) {\n throw new Error(`Component displayName not defined ${component}`);\n }\n return name;\n }\n\n /**\n * Put focus on the first \"input\" element (input, button, select, textarea) within an element\n * If element is null or input element not found, does nothing\n * @param element The element to put focus in.\n * @param selector The first element matching this selector will be focused.\n * @returns The element that was focused, null if not focused\n */\n static focusElement(\n element: Element,\n selector = LayoutUtils.DEFAULT_FOCUS_SELECTOR\n ): Element | null {\n if (element == null) {\n return null;\n }\n const focusElement = element.querySelector(selector);\n if (focusElement == null) {\n return null;\n }\n\n if (isHTMLElement(focusElement)) {\n focusElement.focus();\n }\n return focusElement;\n }\n\n /**\n * Get a promise that initializes when layout is initialized\n * @param layout The layout to await initialization on\n * @returns Promise that resolves when layout is initialized\n */\n static onInitialized(layout: GoldenLayout): Promise<void> {\n return new Promise(resolve => {\n if (layout.isInitialised) {\n resolve();\n return;\n }\n const onInit = (): void => {\n layout.off('initialised', onInit);\n resolve();\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AAC8I,aAAa,CAACF,QAAQ,CAAC;IACpD,IAAItD,YAAY,IAAI,IAAI,EAAE;MACxB,OAAO,IAAI;IACb;IAEA,IAAIvF,aAAa,CAACuF,YAAY,CAAC,EAAE;MAC/BA,YAAY,CAACrF,KAAK,EAAE;IACtB;IACA,OAAOqF,YAAY;EACrB;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAOyD,aAAa,CAACvE,MAAoB,EAAiB;IACxD,OAAO,IAAIwE,OAAO,CAACC,OAAO,IAAI;MAC5B,IAAIzE,MAAM,CAAC0E,aAAa,EAAE;QACxBD,OAAO,EAAE;QACT;MACF;MACA,IAAME,MAAM,GAAG,MAAY;QACzB3E,MAAM,CAACwB,GAAG,CAAC,aAAa,EAAEmD,MAAM,CAAC;QACjCF,OAAO,EAAE;MACX,CAAC;MACDzE,MAAM,CAAC2B,EAAE,CAAC,aAAa,EAAEgD,MAAM,CAAC;IAClC,CAAC,CAAC;EACJ;AACF;AAAC,gBA3xBKhJ,WAAW,4BACiB,iCAAiC;AA4xBnE,eAAeA,WAAW"}
|
|
1
|
+
{"version":3,"file":"LayoutUtils.js","names":["deepEqual","shortid","isMatch","Log","isComponent","isRoot","isStack","GoldenLayoutThemeExport","assertNotNull","log","module","isComponentConfig","config","componentName","undefined","isReactComponentConfig","reactConfig","type","component","isHTMLElement","element","focus","isStackItemConfig","LayoutUtils","activateTab","root","stack","getStackForRoot","error","contentItem","getContentItemInStack","setActiveContentItem","isActiveTab","activeItem","getActiveContentItem","addStack","parent","columnPreferred","arguments","length","contentItems","addChild","child","isCorrectType","isColumn","isRow","removeChild","maintainFocusElement","document","activeElement","newParent","getStackForConfig","item","allowEmptyStack","i","createIfNecessary","matchComponentType","getStackForComponentTypes","types","isLastType","dehydrateLayoutConfig","dehydrateComponent","dehydratedConfig","itemConfig","content","dehydratedComponent","push","debug2","concat","layoutItemConfig","_objectSpread","getTabPoint","glContainer","tab","Error","tabRect","getBoundingClientRect","left","width","bottom","dropLayoutMinorChange","activeItemIndex","props","panelState","id","irisGridState","sorts","quickFilters","isEqual","layout1","layout2","major","layout1Clone","cloneLayout","layout2Clone","layout","JSON","parse","stringify","hydrateLayoutConfig","hydrateComponent","hydratedConfig","_itemConfig$id","contentConfig","warn","openComponent","configParam","replaceExisting","replaceConfig","createNewStack","focusElement","dragEvent","generate","layoutManager","createDragSourceFromEvent","searchConfig","oldContentItem","onComponentCreated","event","debug","off","origin","requestAnimationFrame","on","index","indexOf","openComponentInStack","closeComponent","closeOptions","container","close","contains","renameComponent","newTitle","setTitle","cloneComponent","getPanelComponentState","cloneConfig","title","_config$componentStat","componentState","_config$props","makeDefaultLayout","dimensions","headerHeight","tabHeight","borderWidth","dragBorderWidth","borderGrabWidth","settings","showPopoutIcon","showCloseIcon","constrainDragToContainer","getRootFromContainer","getComponentConfigFromContainer","_config","getTitleFromContainer","getTitleFromTab","getIdFromContainer","getIdFromPanel","panel","getComponentNameFromPanel","_config$component","getComponentName","_component$WrappedCom","_component$WrappedCom2","name","WrappedComponent","displayName","selector","DEFAULT_FOCUS_SELECTOR","querySelector","onInitialized","Promise","resolve","isInitialised","onInit","_defineProperty"],"sources":["../../src/layout/LayoutUtils.ts"],"sourcesContent":["import { DragEvent } from 'react';\nimport deepEqual from 'deep-equal';\nimport shortid from 'shortid';\nimport isMatch from 'lodash.ismatch';\nimport Log from '@deephaven/log';\nimport GoldenLayout, {\n isComponent,\n isRoot,\n isStack,\n GoldenLayoutThemeExport,\n} from '@deephaven/golden-layout';\nimport type {\n ComponentConfig,\n Config,\n Container,\n ContentItem,\n ItemConfig,\n ItemConfigType,\n ReactComponentConfig,\n Stack,\n Tab,\n CloseOptions,\n} from '@deephaven/golden-layout';\nimport { assertNotNull } from '@deephaven/utils';\nimport { DashboardLayoutConfig } from '../DashboardLayout';\nimport { PanelConfig } from '../DashboardPlugin';\n\nconst log = Log.module('LayoutUtils');\n\ntype LayoutConfig = { id?: string; component?: string };\n\nexport type StackItemConfig = ItemConfig & {\n activeItemIndex?: number;\n};\n\nfunction isComponentConfig(config: ItemConfigType): config is ComponentConfig {\n return (config as ComponentConfig).componentName !== undefined;\n}\n\nexport function isReactComponentConfig(\n config: ItemConfigType\n): config is ReactComponentConfig {\n const reactConfig = config as ReactComponentConfig;\n // Golden layout sets the type to 'component' and componentName to 'lm-react-component' in `createContentItem`, then changes it back in `toConfig`\n // For our purposes, we need to check both.\n return (\n ((isComponentConfig(config) &&\n config.componentName === 'lm-react-component') ||\n config.type === 'react-component') &&\n reactConfig.component !== undefined\n );\n}\n\nfunction isHTMLElement(element: Element): element is HTMLElement {\n return (element as HTMLElement).focus !== undefined;\n}\n\nfunction isStackItemConfig(config: ItemConfigType): config is StackItemConfig {\n return config.type === 'stack';\n}\nclass LayoutUtils {\n static DEFAULT_FOCUS_SELECTOR = 'input, select, textarea, button';\n\n static activateTab(root: ContentItem, config: Partial<ItemConfigType>): void {\n const stack = LayoutUtils.getStackForRoot(root, config, false);\n if (!stack) {\n log.error('Could not find stack for config', config);\n return;\n }\n // Find the tab with the specified table and activate it\n const contentItem = LayoutUtils.getContentItemInStack(stack, config);\n if (contentItem) {\n stack.setActiveContentItem(contentItem);\n }\n }\n\n /**\n * Is the tab with the given config active\n * @param root A GoldenLayout content item with the tab\n * @param config Tab config to match\n * @returns True if the tab is active\n */\n static isActiveTab(\n root: ContentItem,\n config: Partial<ReactComponentConfig>\n ): boolean {\n const stack = LayoutUtils.getStackForRoot(root, config, false);\n if (!stack) {\n log.error('Could not find stack for config', config);\n return false;\n }\n // Find the item with the specified config and compare with active item\n const contentItem = LayoutUtils.getContentItemInStack(stack, config);\n const activeItem = stack.getActiveContentItem();\n return activeItem === contentItem;\n }\n\n /**\n * Adds a stack to the root layout specified. Adds to the first row/column with only one item\n * @param parent A GoldenLayout content item to add the stack to\n * @returns The newly created stack.\n */\n static addStack(parent: ContentItem, columnPreferred = true): Stack {\n const type = columnPreferred ? 'column' : 'row';\n if (isRoot(parent)) {\n if (parent.contentItems == null || parent.contentItems.length === 0) {\n parent.addChild({ type });\n }\n\n const child = parent.contentItems[0];\n const isCorrectType = columnPreferred ? child.isColumn : child.isRow;\n if (!isCorrectType) {\n parent.removeChild(child, true);\n parent.addChild({ type });\n\n // The addChild may cause the element that has focus to be removed from the DOM, which changes focus to the body\n // Try and maintain the focus as best we can. The unfocused element may still send a blur/focus event so that needs to be handled correctly.\n const maintainFocusElement = document.activeElement;\n parent.contentItems[0].addChild(child);\n if (\n maintainFocusElement &&\n (maintainFocusElement as HTMLElement).focus != null\n ) {\n (maintainFocusElement as HTMLElement).focus();\n }\n }\n\n return this.addStack(parent.contentItems[0], columnPreferred);\n }\n\n if (parent.contentItems.length < 2) {\n parent.addChild({ type: 'stack' });\n return parent.contentItems[parent.contentItems.length - 1] as Stack;\n }\n let newParent = parent.contentItems[parent.contentItems.length - 1];\n const isCorrectType = !columnPreferred\n ? newParent.isColumn\n : newParent.isRow;\n if (!isCorrectType) {\n parent.addChild({ type: !columnPreferred ? 'column' : 'row' });\n parent.removeChild(newParent, true);\n parent.contentItems[parent.contentItems.length - 1].addChild(newParent);\n newParent = parent.contentItems[parent.contentItems.length - 1];\n }\n\n return this.addStack(newParent, !columnPreferred);\n }\n\n /**\n * Gets the first stack which contains a contentItem with the given config values\n * @param item Golden layout content item to search for the stack\n * @param config The item properties to match\n */\n static getStackForConfig(\n item: ContentItem,\n config: Partial<ItemConfigType> = {},\n allowEmptyStack = false\n ): Stack | null {\n if (allowEmptyStack && isStack(item) && item.contentItems.length === 0) {\n return item;\n }\n\n if (item.contentItems == null) {\n return null;\n }\n\n for (let i = 0; i < item.contentItems.length; i += 1) {\n const contentItem = item.contentItems[i];\n if (contentItem.isComponent && contentItem.config != null) {\n if (isMatch(contentItem.config, config)) {\n return item as Stack;\n }\n }\n\n const stack = this.getStackForConfig(\n contentItem,\n config,\n allowEmptyStack\n );\n if (stack) {\n return stack;\n }\n }\n\n return null;\n }\n\n /**\n * Gets a stack matching the specified config\n * @param root The root GoldenLayout element\n * @param config The item config type to match, eg. { component: 'IrisGridPanel', title: 'Table Name' }\n * @param createIfNecessary Whether to create the stack if it does not exist.\n * @param matchComponentType If the config doesn't match exactly, just find another one of the same component type\n * @param allowEmptyStack If no configs match, search for an empty stack that can be used\n */\n static getStackForRoot(\n root: ContentItem,\n config: Partial<ReactComponentConfig>,\n createIfNecessary = true,\n matchComponentType = true,\n allowEmptyStack = true\n ): Stack | null {\n let stack = this.getStackForConfig(root, config);\n if (!stack && matchComponentType) {\n stack = this.getStackForConfig(\n root,\n { component: config.component },\n allowEmptyStack\n );\n }\n\n if (!stack && createIfNecessary) {\n stack = this.addStack(root);\n }\n\n return stack;\n }\n\n /**\n * Gets a stack matching one of the specified types, creates new stack if necessary\n * @param root The GoldenLayout root to find or create the stack in\n * @param types The array of component types to match\n * @param createIfNecessary Whether to create the stack if it does not exist\n * @param matchComponentType If the config doesn't match exactly, just find another one of the same component type\n * @param allowEmptyStack If no configs match, search for an empty stack that can be used\n */\n static getStackForComponentTypes(\n root: ContentItem,\n types: string[],\n createIfNecessary = true,\n matchComponentType = true,\n allowEmptyStack = true\n ): Stack | null {\n for (let i = 0; i < types.length; i += 1) {\n const component = types[i];\n const isLastType = i === types.length - 1;\n const stack = LayoutUtils.getStackForRoot(\n root,\n { component },\n createIfNecessary && isLastType,\n matchComponentType,\n allowEmptyStack\n );\n if (stack) {\n return stack;\n }\n }\n return null;\n }\n\n /**\n * Gets first content item with the specified config in stack.\n * @param stack The stack to search for the item\n * @param config The item config type to match, eg. { component: 'IrisGridPanel', title: 'Table Name' }\n * @returns Returns the found content item, null if not found.\n */\n static getContentItemInStack(\n stack: ContentItem | null,\n config: Partial<ItemConfigType>\n ): ContentItem | null {\n if (!stack) {\n return null;\n }\n for (let i = 0; i < stack.contentItems.length; i += 1) {\n const contentItem = stack.contentItems[i];\n if (contentItem.isComponent && contentItem.config != null) {\n if (isMatch(contentItem.config, config)) {\n return contentItem;\n }\n }\n }\n return null;\n }\n\n /**\n * Removes dynamic props from components in the given config so this config could be serialized\n * @param config Config objec\n * @returns Dehydrated config\n */\n static dehydrateLayoutConfig(\n config: ItemConfigType[],\n dehydrateComponent: (\n componentName: string,\n config: ItemConfigType\n ) => PanelConfig\n ): (PanelConfig | ItemConfig)[] {\n if (config == null || !config.length) {\n return [];\n }\n const dehydratedConfig: (PanelConfig | ItemConfig)[] = [];\n\n for (let i = 0; i < config.length; i += 1) {\n const itemConfig = config[i];\n const { component, content } = itemConfig as ReactComponentConfig;\n if (component) {\n const dehydratedComponent = dehydrateComponent(component, itemConfig);\n if (dehydratedComponent != null) {\n dehydratedConfig.push(dehydratedComponent);\n } else {\n log.debug2(\n `dehydrateLayoutConfig: skipping unmapped component \"${component}\"`\n );\n }\n } else if (content) {\n const layoutItemConfig = {\n ...itemConfig,\n content: LayoutUtils.dehydrateLayoutConfig(\n content,\n dehydrateComponent\n ),\n };\n dehydratedConfig.push(layoutItemConfig);\n } else {\n dehydratedConfig.push(itemConfig);\n }\n }\n return dehydratedConfig;\n }\n\n static getTabPoint(glContainer: Container): [number, number] {\n const { tab } = glContainer;\n if (tab == null) {\n throw new Error(`Cannot get tab for panel container ${glContainer}`);\n }\n const tabRect = tab.element[0].getBoundingClientRect();\n\n return [tabRect.left + tabRect.width * 0.5, tabRect.bottom - 8];\n }\n\n /**\n * Drop minor changes in Layout Configuration for deep comparison\n * @param config Layout Configuration\n *\n * minor changes:\n * 1. sorts in grid\n * 2. quick filters in grid\n * 3. active item\n *\n * item id is also removed\n */\n static dropLayoutMinorChange(config: DashboardLayoutConfig): void {\n for (let i = 0; i < config.length; i += 1) {\n const itemConfig = config[i];\n const { content } = itemConfig;\n if (content !== undefined) {\n if (isStackItemConfig(itemConfig)) {\n delete itemConfig.activeItemIndex;\n }\n LayoutUtils.dropLayoutMinorChange(content);\n } else if (\n isReactComponentConfig(itemConfig) &&\n itemConfig.component === 'IrisGridPanel'\n ) {\n if (itemConfig.props.panelState != null) {\n delete itemConfig.id;\n itemConfig.props.panelState.irisGridState.sorts = [];\n itemConfig.props.panelState.irisGridState.quickFilters = [];\n }\n }\n }\n }\n\n /**\n * Compare two layouts to see if they are equivalent\n * @param layout1 A Golden Layout config object\n * @param layout2 Another Golden layout config object\n * @param major When true, will ignore \"minor\" property differences (eg. sorts)\n */\n static isEqual(\n layout1: DashboardLayoutConfig,\n layout2: DashboardLayoutConfig,\n major = false\n ): boolean {\n if (major) {\n const layout1Clone = LayoutUtils.cloneLayout(layout1);\n const layout2Clone = LayoutUtils.cloneLayout(layout2);\n LayoutUtils.dropLayoutMinorChange(layout1Clone);\n LayoutUtils.dropLayoutMinorChange(layout2Clone);\n return deepEqual(layout1Clone, layout2Clone);\n }\n return deepEqual(layout1, layout2);\n }\n\n static cloneLayout(layout: DashboardLayoutConfig): DashboardLayoutConfig {\n return JSON.parse(JSON.stringify(layout));\n }\n\n /**\n * Adds dynamic props to components in the given config so this config could be used to initialize a layout\n * @param config Dehydrated config object\n * @param hydrateComponent Function to hydrate the component\n * @returns Hydrated config\n */\n static hydrateLayoutConfig(\n config: (PanelConfig | ItemConfig)[],\n hydrateComponent: (\n componentName: string,\n config: PanelConfig | ItemConfig\n ) => ReactComponentConfig\n ): DashboardLayoutConfig {\n if (config == null || !config.length) {\n return [];\n }\n const hydratedConfig = [];\n\n for (let i = 0; i < config.length; i += 1) {\n const itemConfig = config[i];\n if (isReactComponentConfig(itemConfig)) {\n const { component, props = {} } = itemConfig;\n hydratedConfig.push({\n ...itemConfig,\n id: itemConfig?.id ?? shortid(),\n props: hydrateComponent(component, props),\n });\n } else if (itemConfig.content !== undefined) {\n const contentConfig = LayoutUtils.hydrateLayoutConfig(\n itemConfig.content,\n hydrateComponent\n );\n if (\n isStackItemConfig(itemConfig) &&\n itemConfig.activeItemIndex != null &&\n itemConfig.activeItemIndex >= contentConfig.length\n ) {\n log.warn(\n 'Fixing bad activeItemIndex!',\n itemConfig.activeItemIndex,\n itemConfig\n );\n itemConfig.activeItemIndex = 0;\n }\n hydratedConfig.push({\n ...itemConfig,\n content: contentConfig,\n });\n } else {\n hydratedConfig.push(itemConfig);\n }\n }\n\n return hydratedConfig;\n }\n\n /**\n * Opens a component. It will try and open the component in an existing stack of the same component.\n * If `replaceExisting` is true and there is a component found with the same `config.id`, it will replace that component with this one.\n * If `allowStack` is true and there is a component of the same type found, it will open in that stack (potentially covering up a panel).\n * @param root The GoldenLayout root to open the component in\n * @param config The component config definition to open\n * @param replaceExisting Whether it should replace the existing one matching component type and id, or open a new one\n * @param replaceConfig The component config to replace\n * @param createNewStack True to force opening in a new stack, false to try and open in a stack with the same type of component.\n * @param focusElement The element to focus on\n * @param dragEvent Whether component is being created with a drag, mouse event is initial position for drag proxy\n */\n static openComponent({\n root,\n config: configParam,\n replaceExisting = true,\n replaceConfig = undefined,\n createNewStack = false,\n focusElement = undefined,\n dragEvent = undefined,\n }: {\n root?: ContentItem;\n config?: Partial<ReactComponentConfig>;\n replaceExisting?: boolean;\n replaceConfig?: Partial<ItemConfigType>;\n createNewStack?: boolean;\n focusElement?: string;\n dragEvent?: DragEvent;\n } = {}): void {\n // attempt to retain focus after dom manipulation, which can break focus\n const maintainFocusElement = document.activeElement;\n const config = { ...configParam } as ReactComponentConfig;\n\n if (config.id == null) {\n config.id = shortid.generate();\n }\n\n if (dragEvent != null) {\n root?.layoutManager.createDragSourceFromEvent(config, dragEvent);\n return;\n }\n\n const searchConfig = replaceConfig || {\n id: config.id,\n component: config.component,\n };\n assertNotNull(root);\n const stack = createNewStack\n ? LayoutUtils.addStack(root)\n : LayoutUtils.getStackForRoot(root, searchConfig);\n\n assertNotNull(stack);\n const oldContentItem = LayoutUtils.getContentItemInStack(\n stack,\n searchConfig\n );\n\n if (focusElement != null) {\n // We need to listen for when the stack is created\n const onComponentCreated = (event: {\n origin: { element: Element[] };\n }): void => {\n log.debug('Component created, focusing element', focusElement);\n\n stack.off('componentCreated', onComponentCreated);\n\n const { element } = event.origin;\n\n // Need to wait until the component actually renders.\n requestAnimationFrame(() => {\n LayoutUtils.focusElement(element[0], focusElement);\n });\n };\n stack.on('componentCreated', onComponentCreated);\n }\n if (replaceExisting && oldContentItem) {\n const index = stack.contentItems.indexOf(oldContentItem);\n\n // Using remove/add here instead of replaceChild because I was getting errors with replaceChild... should be the same.\n // Add first so that the stack doesn't get screwed up\n stack.addChild(config, index + 1);\n stack.removeChild(oldContentItem);\n\n stack.setActiveContentItem(stack.contentItems[index]);\n } else {\n stack.addChild(config);\n }\n\n if (\n focusElement == null &&\n maintainFocusElement &&\n isHTMLElement(maintainFocusElement)\n ) {\n maintainFocusElement.focus();\n }\n }\n\n /**\n * Opens a component in an given stack.\n * If `replaceExisting` is true and there is a component found with the same `config.id`, it will replace that component with this one\n * @param stack The GoldenLayout stack to open the component in\n * @param config The component config definition to open\n * @param replaceExisting Whether it should replace the existing one matching component type and id, or open a new one\n */\n static openComponentInStack(\n stack: Stack | null,\n config: ItemConfigType & Record<string, unknown>,\n replaceExisting = true\n ): void {\n const maintainFocusElement = document.activeElement; // attempt to retain focus after dom manipulation, which can break focus\n\n const searchConfig = { id: config.id };\n\n const oldContentItem = LayoutUtils.getContentItemInStack(\n stack,\n searchConfig\n );\n\n if (replaceExisting && oldContentItem && stack) {\n const index = stack?.contentItems.indexOf(oldContentItem);\n\n // Using remove/add here instead of replaceChild because I was getting errors with replaceChild... should be the same.\n // Add first so that the stack doesn't get screwed up\n stack.addChild(config, index + 1);\n stack.removeChild(oldContentItem);\n\n stack.setActiveContentItem(stack.contentItems[index]);\n } else {\n stack?.addChild(config);\n }\n\n if (maintainFocusElement && isHTMLElement(maintainFocusElement)) {\n maintainFocusElement.focus();\n }\n }\n\n /**\n * Close the specified component and remove it from the stack it's currently in\n * @param root The GoldenLayout root to search and close the component in\n * @param config The GoldenLayout component config definition to close, eg. { component: 'IrisGridPanel', id: 'table-t' }\n */\n static closeComponent(\n root: ContentItem,\n config: LayoutConfig,\n closeOptions?: CloseOptions\n ): void {\n const stack = LayoutUtils.getStackForRoot(\n root,\n config,\n false,\n false,\n false\n );\n\n if (!stack) {\n log.warn('Cannot find stack for component, ignoring close', config);\n return;\n }\n\n // Find the tab with the specified config and remove it\n // Same component was used to get the stack above, so getContentItemInStack shouldn't return null\n const oldContentItem = LayoutUtils.getContentItemInStack(stack, config);\n const maintainFocusElement = document.activeElement; // attempt to retain focus after dom manipulation, which can break focus\n if (oldContentItem) {\n if (isComponent(oldContentItem)) {\n oldContentItem.container.close(closeOptions);\n } else {\n stack.removeChild(oldContentItem);\n }\n }\n // if focused element is still in dom restore focus, note it could have been in the removed panel so check first\n if (\n maintainFocusElement &&\n document.contains(maintainFocusElement) &&\n isHTMLElement(maintainFocusElement)\n ) {\n maintainFocusElement.focus();\n }\n }\n\n static renameComponent(\n root: ContentItem,\n config: Partial<ItemConfigType>,\n newTitle: string\n ): void {\n const stack = LayoutUtils.getStackForRoot(root, config, false);\n if (!stack) {\n log.error('Could not find stack for config', config);\n return;\n }\n // Find the tab with the specified config and rename it\n const contentItem = LayoutUtils.getContentItemInStack(stack, config);\n if (contentItem) {\n contentItem.setTitle(newTitle);\n }\n }\n\n /**\n * Create a component clone based on the given config\n * @param root The GoldenLayout root to clone the component in\n * @param config The config to clone\n * @returns Clone config\n */\n static cloneComponent(\n root: ContentItem,\n config: ReactComponentConfig\n ): ReactComponentConfig | null {\n const stack = LayoutUtils.getStackForRoot(root, config, false);\n if (!stack) {\n log.error('Could not find stack for config', config);\n return null;\n }\n const { props = {} } = config;\n const panelState = LayoutUtils.getPanelComponentState(config);\n const cloneConfig = {\n type: 'react-component' as const,\n component: config.component,\n props: {\n ...props,\n panelState,\n },\n title: `${config.title} Copy`,\n id: shortid.generate(),\n };\n LayoutUtils.openComponentInStack(stack, cloneConfig);\n return cloneConfig;\n }\n\n /**\n * Get panel component state for the given config\n * @param config Panel config\n * @returns Panel state\n */\n static getPanelComponentState(config: ItemConfigType): unknown {\n if (isComponentConfig(config)) {\n return config.componentState?.panelState;\n }\n if (isReactComponentConfig(config)) {\n return config.props?.panelState;\n }\n return null;\n }\n\n static makeDefaultLayout(): Config {\n return {\n dimensions: {\n headerHeight: GoldenLayoutThemeExport.tabHeight,\n borderWidth: GoldenLayoutThemeExport.dragBorderWidth,\n borderGrabWidth: 10,\n },\n settings: {\n showPopoutIcon: false,\n showCloseIcon: false,\n constrainDragToContainer: false,\n },\n } as Config;\n }\n\n /**\n * Gets a containers root node\n * @param container The Golden Layout container to get the root for\n */\n static getRootFromContainer(container: Container): ContentItem {\n return container.layoutManager.root;\n }\n\n /**\n * Gets the config for the panel component given a glContainer\n * @param container The Golden Layout container to get the config for\n */\n static getComponentConfigFromContainer(\n container?: Container\n ): ItemConfigType | null {\n if (container) {\n if (container.tab != null && container.tab.contentItem != null) {\n return container.tab.contentItem.config;\n }\n\n // If the container hasn't populated the tab yet, just get the config directly from the container\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore private api usage\n // eslint-disable-next-line no-underscore-dangle\n return container._config;\n }\n\n return null;\n }\n\n static getTitleFromContainer(\n container: Container\n ): string | null | undefined {\n if (\n container != null &&\n container.tab != null &&\n container.tab.contentItem != null\n ) {\n return container.tab.contentItem.config.title;\n }\n return null;\n }\n\n static getTitleFromTab(tab: Tab): string | null | undefined {\n if (tab != null && tab.contentItem != null) {\n return tab.contentItem.config.title;\n }\n return null;\n }\n\n /**\n * Retrieve the panel ID for the provided golden layout container\n * @param glContainer The container to get the panel ID for\n * @returns Panel ID\n */\n static getIdFromContainer(\n glContainer: Container\n ): string | string[] | null | undefined {\n const config = LayoutUtils.getComponentConfigFromContainer(glContainer);\n if (config) {\n return config.id;\n }\n return null;\n }\n\n /**\n * Retrieve the ID of the panel provided\n * @param panel The panel to get the ID for\n * @returns Panel ID\n */\n static getIdFromPanel(panel: {\n props: { glContainer: Container };\n }): string | string[] | null | undefined {\n const { glContainer } = panel.props;\n return LayoutUtils.getIdFromContainer(glContainer);\n }\n\n /**\n * Get component name from the panel instance\n * @param panel Panel to get component name for\n * @returns Component name or null if unable to retrieve name\n */\n static getComponentNameFromPanel(panel: {\n props: { glContainer: Container };\n }): string | null {\n const { glContainer } = panel.props;\n const config = LayoutUtils.getComponentConfigFromContainer(glContainer);\n if (config && isReactComponentConfig(config)) {\n return config.component ?? null;\n }\n return null;\n }\n\n /**\n * Get component name for wrapped and un-wrapped components\n * @param component Component to get name for\n * @returns Component name\n * @throws If displayName for the component is not defined\n */\n static getComponentName(component: {\n displayName?: string;\n WrappedComponent?: { displayName?: string };\n }): string {\n const name =\n component.WrappedComponent?.displayName ?? component.displayName;\n if (name == null) {\n throw new Error(`Component displayName not defined ${component}`);\n }\n return name;\n }\n\n /**\n * Put focus on the first \"input\" element (input, button, select, textarea) within an element\n * If element is null or input element not found, does nothing\n * @param element The element to put focus in.\n * @param selector The first element matching this selector will be focused.\n * @returns The element that was focused, null if not focused\n */\n static focusElement(\n element: Element,\n selector = LayoutUtils.DEFAULT_FOCUS_SELECTOR\n ): Element | null {\n if (element == null) {\n return null;\n }\n const focusElement = element.querySelector(selector);\n if (focusElement == null) {\n return null;\n }\n\n if (isHTMLElement(focusElement)) {\n focusElement.focus();\n }\n return focusElement;\n }\n\n /**\n * Get a promise that initializes when layout is initialized\n * @param layout The layout to await initialization on\n * @returns Promise that resolves when layout is initialized\n */\n static onInitialized(layout: GoldenLayout): Promise<void> {\n return new Promise(resolve => {\n if (layout.isInitialised) {\n resolve();\n return;\n }\n const onInit = (): void => {\n layout.off('initialised', onInit);\n resolve();\n };\n layout.on('initialised', onInit);\n });\n }\n}\n\nexport default LayoutUtils;\n"],"mappings":";;;;;AACA,OAAOA,SAAS,MAAM,YAAY;AAClC,OAAOC,OAAO,MAAM,SAAS;AAC7B,OAAOC,OAAO,MAAM,gBAAgB;AACpC,OAAOC,GAAG,MAAM,gBAAgB;AAChC,SACEC,WAAW,EACXC,MAAM,EACNC,OAAO,EACPC,uBAAuB,QAClB,0BAA0B;AAajC,SAASC,aAAa,QAAQ,kBAAkB;AAIhD,IAAMC,GAAG,GAAGN,GAAG,CAACO,MAAM,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Y,IAAI,IAAI,EAAE;MACxB,OAAO,IAAI;IACb;IAEA,IAAI3F,aAAa,CAAC2F,YAAY,CAAC,EAAE;MAC/BA,YAAY,CAACzF,KAAK,CAAC,CAAC;IACtB;IACA,OAAOyF,YAAY;EACrB;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAO8D,aAAaA,CAAC7E,MAAoB,EAAiB;IACxD,OAAO,IAAI8E,OAAO,CAACC,OAAO,IAAI;MAC5B,IAAI/E,MAAM,CAACgF,aAAa,EAAE;QACxBD,OAAO,CAAC,CAAC;QACT;MACF;MACA,IAAME,MAAM,GAAGA,CAAA,KAAY;QACzBjF,MAAM,CAACyB,GAAG,CAAC,aAAa,EAAEwD,MAAM,CAAC;QACjCF,OAAO,CAAC,CAAC;MACX,CAAC;MACD/E,MAAM,CAAC4B,EAAE,CAAC,aAAa,EAAEqD,MAAM,CAAC;IAClC,CAAC,CAAC;EACJ;AACF;AAACC,eAAA,CA3xBK1J,WAAW,4BACiB,iCAAiC;AA4xBnE,eAAeA,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDashboardPanel.js","names":["useCallback","shortid","PanelEvent","LayoutUtils","useListener","usePanelRegistration","useDashboardPanel","dashboardProps","componentName","component","supportedTypes","hydrate","dehydrate","id","layout","registerComponent","handlePanelOpen","dragEvent","fetch","panelId","generate","widget","widgetId","type","name","title","isSupportedType","Array","isArray","includes","metadata","props","localDashboardId","config","root","openComponent","eventHub","OPEN"],"sources":["../../src/layout/useDashboardPanel.ts"],"sourcesContent":["import { ComponentType, useCallback } from 'react';\nimport type { ReactComponentConfig } from '@deephaven/golden-layout';\nimport shortid from 'shortid';\nimport {\n DashboardPanelProps,\n DashboardPluginComponentProps,\n DehydratedDashboardPanelProps,\n PanelComponentType,\n PanelDehydrateFunction,\n PanelHydrateFunction,\n} from '../DashboardPlugin';\nimport PanelEvent, { PanelOpenEventDetail } from '../PanelEvent';\nimport LayoutUtils from './LayoutUtils';\nimport useListener from './useListener';\nimport usePanelRegistration from './usePanelRegistration';\n\n/**\n * Register a panel that will be opened when one of the `supportedTypes` objects is triggered.\n */\nexport function useDashboardPanel<\n P extends DashboardPanelProps,\n C extends ComponentType<P>,\n>({\n dashboardProps,\n componentName,\n component,\n supportedTypes,\n hydrate,\n dehydrate,\n}: {\n /** Props from the dashboard this panel is being registered in */\n dashboardProps: DashboardPluginComponentProps;\n\n /** Name of the component to register */\n componentName: string;\n\n /** Component type to register */\n component: PanelComponentType<P, C>;\n\n /** Names of the supported variable types this panel opens for */\n supportedTypes: string | string[];\n\n /** Custom hydration function to call when opening a panel */\n hydrate?: PanelHydrateFunction;\n\n /** Custom dehydration function to call when saving a panel's state to the layout */\n dehydrate?: PanelDehydrateFunction;\n}): void {\n const { id, layout, registerComponent } = dashboardProps;\n\n const handlePanelOpen = useCallback(\n ({\n dragEvent,\n fetch,\n panelId = shortid.generate(),\n widget,\n }: PanelOpenEventDetail) => {\n const { id: widgetId, type } = widget;\n const name = widget.title ?? widget.name;\n const isSupportedType =\n (Array.isArray(supportedTypes) && supportedTypes.includes(type)) ||\n type === supportedTypes;\n if (!isSupportedType) {\n // Only want to listen for your custom variable types\n return;\n }\n const metadata = { id: widgetId, name, type };\n let props: DehydratedDashboardPanelProps & { fetch?: typeof fetch } = {\n localDashboardId: id,\n metadata,\n fetch,\n };\n if (hydrate != null) {\n props = hydrate(props, id);\n }\n const config: ReactComponentConfig = {\n type: 'react-component',\n component: componentName,\n props,\n title: name,\n id: panelId,\n };\n\n const { root } = layout;\n LayoutUtils.openComponent({ root, config, dragEvent });\n },\n [componentName, hydrate, id, layout, supportedTypes]\n );\n\n /**\n * Register our custom component type so the layout know hows to open it\n */\n usePanelRegistration(registerComponent, component, hydrate, dehydrate);\n\n /**\n * Listen for panel open events so we know when to open a panel\n */\n useListener(layout.eventHub, PanelEvent.OPEN, handlePanelOpen);\n}\n\nexport default useDashboardPanel;\n"],"mappings":"AAAA,SAAwBA,WAAW,QAAQ,OAAO;AAElD,OAAOC,OAAO,MAAM,SAAS;AAAC,OASvBC,UAAU;AAAA,OACVC,WAAW;AAAA,OACXC,WAAW;AAAA,OACXC,oBAAoB;AAE3B;AACA;AACA;AACA,OAAO,SAASC,
|
|
1
|
+
{"version":3,"file":"useDashboardPanel.js","names":["useCallback","shortid","PanelEvent","LayoutUtils","useListener","usePanelRegistration","useDashboardPanel","_ref","dashboardProps","componentName","component","supportedTypes","hydrate","dehydrate","id","layout","registerComponent","handlePanelOpen","_ref2","_widget$title","dragEvent","fetch","panelId","generate","widget","widgetId","type","name","title","isSupportedType","Array","isArray","includes","metadata","props","localDashboardId","config","root","openComponent","eventHub","OPEN"],"sources":["../../src/layout/useDashboardPanel.ts"],"sourcesContent":["import { ComponentType, useCallback } from 'react';\nimport type { ReactComponentConfig } from '@deephaven/golden-layout';\nimport shortid from 'shortid';\nimport {\n DashboardPanelProps,\n DashboardPluginComponentProps,\n DehydratedDashboardPanelProps,\n PanelComponentType,\n PanelDehydrateFunction,\n PanelHydrateFunction,\n} from '../DashboardPlugin';\nimport PanelEvent, { PanelOpenEventDetail } from '../PanelEvent';\nimport LayoutUtils from './LayoutUtils';\nimport useListener from './useListener';\nimport usePanelRegistration from './usePanelRegistration';\n\n/**\n * Register a panel that will be opened when one of the `supportedTypes` objects is triggered.\n */\nexport function useDashboardPanel<\n P extends DashboardPanelProps,\n C extends ComponentType<P>,\n>({\n dashboardProps,\n componentName,\n component,\n supportedTypes,\n hydrate,\n dehydrate,\n}: {\n /** Props from the dashboard this panel is being registered in */\n dashboardProps: DashboardPluginComponentProps;\n\n /** Name of the component to register */\n componentName: string;\n\n /** Component type to register */\n component: PanelComponentType<P, C>;\n\n /** Names of the supported variable types this panel opens for */\n supportedTypes: string | string[];\n\n /** Custom hydration function to call when opening a panel */\n hydrate?: PanelHydrateFunction;\n\n /** Custom dehydration function to call when saving a panel's state to the layout */\n dehydrate?: PanelDehydrateFunction;\n}): void {\n const { id, layout, registerComponent } = dashboardProps;\n\n const handlePanelOpen = useCallback(\n ({\n dragEvent,\n fetch,\n panelId = shortid.generate(),\n widget,\n }: PanelOpenEventDetail) => {\n const { id: widgetId, type } = widget;\n const name = widget.title ?? widget.name;\n const isSupportedType =\n (Array.isArray(supportedTypes) && supportedTypes.includes(type)) ||\n type === supportedTypes;\n if (!isSupportedType) {\n // Only want to listen for your custom variable types\n return;\n }\n const metadata = { id: widgetId, name, type };\n let props: DehydratedDashboardPanelProps & { fetch?: typeof fetch } = {\n localDashboardId: id,\n metadata,\n fetch,\n };\n if (hydrate != null) {\n props = hydrate(props, id);\n }\n const config: ReactComponentConfig = {\n type: 'react-component',\n component: componentName,\n props,\n title: name,\n id: panelId,\n };\n\n const { root } = layout;\n LayoutUtils.openComponent({ root, config, dragEvent });\n },\n [componentName, hydrate, id, layout, supportedTypes]\n );\n\n /**\n * Register our custom component type so the layout know hows to open it\n */\n usePanelRegistration(registerComponent, component, hydrate, dehydrate);\n\n /**\n * Listen for panel open events so we know when to open a panel\n */\n useListener(layout.eventHub, PanelEvent.OPEN, handlePanelOpen);\n}\n\nexport default useDashboardPanel;\n"],"mappings":"AAAA,SAAwBA,WAAW,QAAQ,OAAO;AAElD,OAAOC,OAAO,MAAM,SAAS;AAAC,OASvBC,UAAU;AAAA,OACVC,WAAW;AAAA,OACXC,WAAW;AAAA,OACXC,oBAAoB;AAE3B;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAAAC,IAAA,EA4BxB;EAAA,IAzBP;IACAC,cAAc;IACdC,aAAa;IACbC,SAAS;IACTC,cAAc;IACdC,OAAO;IACPC;EAmBF,CAAC,GAAAN,IAAA;EACC,IAAM;IAAEO,EAAE;IAAEC,MAAM;IAAEC;EAAkB,CAAC,GAAGR,cAAc;EAExD,IAAMS,eAAe,GAAGjB,WAAW,CACjCkB,KAAA,IAK4B;IAAA,IAAAC,aAAA;IAAA,IAL3B;MACCC,SAAS;MACTC,KAAK;MACLC,OAAO,GAAGrB,OAAO,CAACsB,QAAQ,CAAC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I,EAAEvB,eAAe,CAAC;AAChE;AAEA,eAAeX,iBAAiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useListener.js","names":["useEffect","useListener","eventEmitter","eventName","callback","initEventEmitter","on","off"],"sources":["../../src/layout/useListener.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport type { EventEmitter } from '@deephaven/golden-layout';\n\n/**\n * Listen for a specific event on an EventEmitter\n * @param eventEmitter EventEmitter to listen to\n * @param eventName Name of the event to listen to\n * @param callback Callback to call when the event is triggered\n */\nexport function useListener(\n eventEmitter: EventEmitter,\n eventName: string,\n // eslint-disable-next-line @typescript-eslint/ban-types\n callback: Function\n): void {\n useEffect(\n function initEventEmitter() {\n eventEmitter.on(eventName, callback);\n\n return () => {\n eventEmitter.off(eventName, callback);\n };\n },\n [eventEmitter, eventName, callback]\n );\n}\n\nexport default useListener;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AAGjC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,
|
|
1
|
+
{"version":3,"file":"useListener.js","names":["useEffect","useListener","eventEmitter","eventName","callback","initEventEmitter","on","off"],"sources":["../../src/layout/useListener.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport type { EventEmitter } from '@deephaven/golden-layout';\n\n/**\n * Listen for a specific event on an EventEmitter\n * @param eventEmitter EventEmitter to listen to\n * @param eventName Name of the event to listen to\n * @param callback Callback to call when the event is triggered\n */\nexport function useListener(\n eventEmitter: EventEmitter,\n eventName: string,\n // eslint-disable-next-line @typescript-eslint/ban-types\n callback: Function\n): void {\n useEffect(\n function initEventEmitter() {\n eventEmitter.on(eventName, callback);\n\n return () => {\n eventEmitter.off(eventName, callback);\n };\n },\n [eventEmitter, eventName, callback]\n );\n}\n\nexport default useListener;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AAGjC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CACzBC,YAA0B,EAC1BC,SAAiB;AACjB;AACAC,QAAkB,EACZ;EACNJ,SAAS,CACP,SAASK,gBAAgBA,CAAA,EAAG;IAC1BH,YAAY,CAACI,EAAE,CAACH,SAAS,EAAEC,QAAQ,CAAC;IAEpC,OAAO,MAAM;MACXF,YAAY,CAACK,GAAG,CAACJ,SAAS,EAAEC,QAAQ,CAAC;IACvC,CAAC;EACH,CAAC,EACD,CAACF,YAAY,EAAEC,SAAS,EAAEC,QAAQ,CACpC,CAAC;AACH;AAEA,eAAeH,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePanelRegistration.js","names":["React","usePanelRegistration","registerComponent","ComponentType","hydrate","dehydrate","name","COMPONENT","displayName","Error","useEffect","deregister"],"sources":["../../src/layout/usePanelRegistration.ts"],"sourcesContent":["import React from 'react';\nimport {\n DashboardPanelProps,\n DashboardPluginComponentProps,\n PanelComponentType,\n PanelDehydrateFunction,\n PanelHydrateFunction,\n} from '../DashboardPlugin';\n\n/**\n * Registers a given panel component. Also runs a `useEffect` that will\n * automatically de-register then panel on unmount.\n * @param registerComponent\n * @param ComponentType\n * @param hydrate\n * @param dehydrate\n */\nexport default function usePanelRegistration<\n P extends DashboardPanelProps,\n C extends React.ComponentType<P>,\n>(\n registerComponent: DashboardPluginComponentProps['registerComponent'],\n ComponentType: PanelComponentType<P, C>,\n hydrate?: PanelHydrateFunction,\n dehydrate?: PanelDehydrateFunction\n): void {\n const name = ComponentType.COMPONENT ?? ComponentType.displayName;\n\n if (name == null) {\n throw new Error(\n 'ComponentType must have a `COMPONENT` or `displayName` attribute.'\n );\n }\n\n React.useEffect(() => {\n const deregister = registerComponent(\n name,\n ComponentType,\n hydrate,\n dehydrate\n );\n\n return () => {\n deregister();\n };\n }, [ComponentType, dehydrate, hydrate, name, registerComponent]);\n}\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AASzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,
|
|
1
|
+
{"version":3,"file":"usePanelRegistration.js","names":["React","usePanelRegistration","registerComponent","ComponentType","hydrate","dehydrate","_ComponentType$COMPON","name","COMPONENT","displayName","Error","useEffect","deregister"],"sources":["../../src/layout/usePanelRegistration.ts"],"sourcesContent":["import React from 'react';\nimport {\n DashboardPanelProps,\n DashboardPluginComponentProps,\n PanelComponentType,\n PanelDehydrateFunction,\n PanelHydrateFunction,\n} from '../DashboardPlugin';\n\n/**\n * Registers a given panel component. Also runs a `useEffect` that will\n * automatically de-register then panel on unmount.\n * @param registerComponent\n * @param ComponentType\n * @param hydrate\n * @param dehydrate\n */\nexport default function usePanelRegistration<\n P extends DashboardPanelProps,\n C extends React.ComponentType<P>,\n>(\n registerComponent: DashboardPluginComponentProps['registerComponent'],\n ComponentType: PanelComponentType<P, C>,\n hydrate?: PanelHydrateFunction,\n dehydrate?: PanelDehydrateFunction\n): void {\n const name = ComponentType.COMPONENT ?? ComponentType.displayName;\n\n if (name == null) {\n throw new Error(\n 'ComponentType must have a `COMPONENT` or `displayName` attribute.'\n );\n }\n\n React.useEffect(() => {\n const deregister = registerComponent(\n name,\n ComponentType,\n hydrate,\n dehydrate\n );\n\n return () => {\n deregister();\n };\n }, [ComponentType, dehydrate, hydrate, name, registerComponent]);\n}\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AASzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,oBAAoBA,CAI1CC,iBAAqE,EACrEC,aAAuC,EACvCC,OAA8B,EAC9BC,SAAkC,EAC5B;EAAA,IAAAC,qBAAA;EACN,IAAMC,IAAI,IAAAD,qBAAA,GAAGH,aAAa,CAACK,SAAS,cAAAF,qBAAA,cAAAA,qBAAA,GAAIH,aAAa,CAACM,WAAW;EAEjE,IAAIF,IAAI,IAAI,IAAI,EAAE;IAChB,MAAM,IAAIG,KAAK,CACb,mEACF,CAAC;EACH;EAEAV,KAAK,CAACW,SAAS,CAAC,MAAM;IACpB,IAAMC,UAAU,GAAGV,iBAAiB,CAClCK,IAAI,EACJJ,aAAa,EACbC,OAAO,EACPC,SACF,CAAC;IAED,OAAO,MAAM;MACXO,UAAU,CAAC,CAAC;IACd,CAAC;EACH,CAAC,EAAE,CAACT,aAAa,EAAEE,SAAS,EAAED,OAAO,EAAEG,IAAI,EAAEL,iBAAiB,CAAC,CAAC;AAClE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","names":["SET_DASHBOARD_DATA","getDashboardData","setDashboardData","id","data","type","payload","updateDashboardData","dispatch","getState"],"sources":["../../src/redux/actions.ts"],"sourcesContent":["import { DashboardData, RootState } from '@deephaven/redux';\nimport type { Action } from 'redux';\nimport type { ThunkAction } from 'redux-thunk';\nimport { SET_DASHBOARD_DATA } from './actionTypes';\nimport { getDashboardData } from './selectors';\n\n/**\n * Action to replace the dashboard data for a dashboard\n * @param id The ID of the dashboard to set the data on\n * @param data Data for the dashboard\n * @returns The action to get dispatched\n */\nexport const setDashboardData = (\n id: string,\n data: DashboardData\n): {\n type: string;\n id: string;\n payload: DashboardData;\n} => ({\n type: SET_DASHBOARD_DATA,\n id,\n payload: data,\n});\n\n/**\n * Action to update the dashboard data. Will combine the update with any existing dashboard data.\n * @param id The id of the dashboard to update the data on\n * @param updateData The data to combine with the existing dashboard data\n * @returns\n */\nexport const updateDashboardData =\n (\n id: string,\n data: DashboardData\n ): ThunkAction<unknown, RootState, undefined, Action<unknown>> =>\n (dispatch, getState) =>\n dispatch(\n setDashboardData(id, {\n ...getDashboardData(getState(), id),\n ...data,\n })\n );\n"],"mappings":";;;;;SAGSA,kBAAkB;AAAA,SAClBC,gBAAgB;AAEzB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"actions.js","names":["SET_DASHBOARD_DATA","getDashboardData","setDashboardData","id","data","type","payload","updateDashboardData","dispatch","getState","_objectSpread"],"sources":["../../src/redux/actions.ts"],"sourcesContent":["import { DashboardData, RootState } from '@deephaven/redux';\nimport type { Action } from 'redux';\nimport type { ThunkAction } from 'redux-thunk';\nimport { SET_DASHBOARD_DATA } from './actionTypes';\nimport { getDashboardData } from './selectors';\n\n/**\n * Action to replace the dashboard data for a dashboard\n * @param id The ID of the dashboard to set the data on\n * @param data Data for the dashboard\n * @returns The action to get dispatched\n */\nexport const setDashboardData = (\n id: string,\n data: DashboardData\n): {\n type: string;\n id: string;\n payload: DashboardData;\n} => ({\n type: SET_DASHBOARD_DATA,\n id,\n payload: data,\n});\n\n/**\n * Action to update the dashboard data. Will combine the update with any existing dashboard data.\n * @param id The id of the dashboard to update the data on\n * @param updateData The data to combine with the existing dashboard data\n * @returns\n */\nexport const updateDashboardData =\n (\n id: string,\n data: DashboardData\n ): ThunkAction<unknown, RootState, undefined, Action<unknown>> =>\n (dispatch, getState) =>\n dispatch(\n setDashboardData(id, {\n ...getDashboardData(getState(), id),\n ...data,\n })\n );\n"],"mappings":";;;;;SAGSA,kBAAkB;AAAA,SAClBC,gBAAgB;AAEzB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMC,gBAAgB,GAAGA,CAC9BC,EAAU,EACVC,IAAmB,MAKf;EACJC,IAAI,EAAEL,kBAAkB;EACxBG,EAAE;EACFG,OAAO,EAAEF;AACX,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMG,mBAAmB,GAC9BA,CACEJ,EAAU,EACVC,IAAmB,KAErB,CAACI,QAAQ,EAAEC,QAAQ,KACjBD,QAAQ,CACNN,gBAAgB,CAACC,EAAE,EAAAO,aAAA,CAAAA,aAAA,KACdT,gBAAgB,CAACQ,QAAQ,CAAC,CAAC,EAAEN,EAAE,CAAC,GAChCC,IAAI,CACR,CACH,CAAC"}
|
package/dist/redux/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["reducerRegistry","reducers","Object","entries","map","name","reducer","register"],"sources":["../../src/redux/index.ts"],"sourcesContent":["import { reducerRegistry } from '@deephaven/redux';\nimport reducers from './reducers';\n\nObject.entries(reducers).map(([name, reducer]) =>\n reducerRegistry.register(name, reducer)\n);\n\nexport { reducers };\nexport * from './actions';\nexport * from './actionTypes';\nexport * from './selectors';\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,kBAAkB;AAAC,OAC5CC,QAAQ;AAEfC,MAAM,CAACC,OAAO,CAACF,QAAQ,CAAC,CAACG,GAAG,
|
|
1
|
+
{"version":3,"file":"index.js","names":["reducerRegistry","reducers","Object","entries","map","_ref","name","reducer","register"],"sources":["../../src/redux/index.ts"],"sourcesContent":["import { reducerRegistry } from '@deephaven/redux';\nimport reducers from './reducers';\n\nObject.entries(reducers).map(([name, reducer]) =>\n reducerRegistry.register(name, reducer)\n);\n\nexport { reducers };\nexport * from './actions';\nexport * from './actionTypes';\nexport * from './selectors';\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,kBAAkB;AAAC,OAC5CC,QAAQ;AAEfC,MAAM,CAACC,OAAO,CAACF,QAAQ,CAAC,CAACG,GAAG,CAACC,IAAA;EAAA,IAAC,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAAF,IAAA;EAAA,OAC3CL,eAAe,CAACQ,QAAQ,CAACF,IAAI,EAAEC,OAAO,CAAC;AAAA,CACzC,CAAC;AAED,SAASN,QAAQ;AAAG;AAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.js","names":["EMPTY_MAP","Map","EMPTY_OBJECT","Object","freeze","EMPTY_ARRAY","getAllDashboardsData","store","dashboardData","getDashboardData","dashboardId","getClosedPanelsForDashboard","closed","getOpenedPanelMapForDashboard","openedMap"],"sources":["../../src/redux/selectors.ts"],"sourcesContent":["import { DashboardData, RootState } from '@deephaven/redux';\nimport { ClosedPanels, OpenedPanelMap } from '../PanelManager';\n\nconst EMPTY_MAP = new Map();\n\nconst EMPTY_OBJECT = Object.freeze({});\n\nconst EMPTY_ARRAY = Object.freeze([]);\n\ntype Selector<R> = (state: RootState) => R;\n\n/**\n * Retrieve the data for all dashboards\n * @param store The redux store\n * @returns Property mapping dashboard ID to data for that dashboard\n */\nexport const getAllDashboardsData: Selector<\n Record<string, DashboardData>\n> = store => store.dashboardData;\n\n/**\n * @param store The redux store\n * @param dashboardId The dashboard ID to get data for\n * @returns The data object for the dashboard with the specified ID\n */\nexport const getDashboardData = (\n store: RootState,\n dashboardId: string\n): DashboardData => getAllDashboardsData(store)[dashboardId] ?? EMPTY_OBJECT;\n\n/**\n * @param store The redux store\n * @param dashboardId The dashboard ID to get data for\n * @returns The ClosedPanel array of panels that were previously closed/dehydrated\n */\nexport const getClosedPanelsForDashboard = (\n store: RootState,\n dashboardId: string\n): ClosedPanels =>\n (getDashboardData(store, dashboardId).closed ?? EMPTY_ARRAY) as ClosedPanels;\n\n/**\n * @param store The redux store\n * @param dashboardId The dashboard ID to get data for\n * @returns The map of panel IDs to components of all currently open components\n */\nexport const getOpenedPanelMapForDashboard = (\n store: RootState,\n dashboardId: string\n): OpenedPanelMap =>\n (getDashboardData(store, dashboardId).openedMap ??\n EMPTY_MAP) as OpenedPanelMap;\n"],"mappings":"AAGA,IAAMA,SAAS,GAAG,IAAIC,GAAG,
|
|
1
|
+
{"version":3,"file":"selectors.js","names":["EMPTY_MAP","Map","EMPTY_OBJECT","Object","freeze","EMPTY_ARRAY","getAllDashboardsData","store","dashboardData","getDashboardData","dashboardId","_getAllDashboardsData","getClosedPanelsForDashboard","_getDashboardData$clo","closed","getOpenedPanelMapForDashboard","_getDashboardData$ope","openedMap"],"sources":["../../src/redux/selectors.ts"],"sourcesContent":["import { DashboardData, RootState } from '@deephaven/redux';\nimport { ClosedPanels, OpenedPanelMap } from '../PanelManager';\n\nconst EMPTY_MAP = new Map();\n\nconst EMPTY_OBJECT = Object.freeze({});\n\nconst EMPTY_ARRAY = Object.freeze([]);\n\ntype Selector<R> = (state: RootState) => R;\n\n/**\n * Retrieve the data for all dashboards\n * @param store The redux store\n * @returns Property mapping dashboard ID to data for that dashboard\n */\nexport const getAllDashboardsData: Selector<\n Record<string, DashboardData>\n> = store => store.dashboardData;\n\n/**\n * @param store The redux store\n * @param dashboardId The dashboard ID to get data for\n * @returns The data object for the dashboard with the specified ID\n */\nexport const getDashboardData = (\n store: RootState,\n dashboardId: string\n): DashboardData => getAllDashboardsData(store)[dashboardId] ?? EMPTY_OBJECT;\n\n/**\n * @param store The redux store\n * @param dashboardId The dashboard ID to get data for\n * @returns The ClosedPanel array of panels that were previously closed/dehydrated\n */\nexport const getClosedPanelsForDashboard = (\n store: RootState,\n dashboardId: string\n): ClosedPanels =>\n (getDashboardData(store, dashboardId).closed ?? EMPTY_ARRAY) as ClosedPanels;\n\n/**\n * @param store The redux store\n * @param dashboardId The dashboard ID to get data for\n * @returns The map of panel IDs to components of all currently open components\n */\nexport const getOpenedPanelMapForDashboard = (\n store: RootState,\n dashboardId: string\n): OpenedPanelMap =>\n (getDashboardData(store, dashboardId).openedMap ??\n EMPTY_MAP) as OpenedPanelMap;\n"],"mappings":"AAGA,IAAMA,SAAS,GAAG,IAAIC,GAAG,CAAC,CAAC;AAE3B,IAAMC,YAAY,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,CAAC;AAEtC,IAAMC,WAAW,GAAGF,MAAM,CAACC,MAAM,CAAC,EAAE,CAAC;AAIrC;AACA;AACA;AACA;AACA;AACA,OAAO,IAAME,oBAEZ,GAAGC,KAAK,IAAIA,KAAK,CAACC,aAAa;;AAEhC;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMC,gBAAgB,GAAGA,CAC9BF,KAAgB,EAChBG,WAAmB;EAAA,IAAAC,qBAAA;EAAA,QAAAA,qBAAA,GACDL,oBAAoB,CAACC,KAAK,CAAC,CAACG,WAAW,CAAC,cAAAC,qBAAA,cAAAA,qBAAA,GAAIT,YAAY;AAAA;;AAE5E;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMU,2BAA2B,GAAGA,CACzCL,KAAgB,EAChBG,WAAmB;EAAA,IAAAG,qBAAA;EAAA,QAAAA,qBAAA,GAElBJ,gBAAgB,CAACF,KAAK,EAAEG,WAAW,CAAC,CAACI,MAAM,cAAAD,qBAAA,cAAAA,qBAAA,GAAIR,WAAW;AAAA,CAAiB;;AAE9E;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMU,6BAA6B,GAAGA,CAC3CR,KAAgB,EAChBG,WAAmB;EAAA,IAAAM,qBAAA;EAAA,QAAAA,qBAAA,GAElBP,gBAAgB,CAACF,KAAK,EAAEG,WAAW,CAAC,CAACO,SAAS,cAAAD,qBAAA,cAAAA,qBAAA,GAC7ChB,SAAS;AAAA,CAAmB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deephaven/dashboard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.1-alpha-theme-fix.1+add15f1b",
|
|
4
4
|
"description": "Deephaven Dashboard",
|
|
5
5
|
"author": "Deephaven Data Labs LLC",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"build:sass": "sass --embed-sources --load-path=../../node_modules ./src:./dist"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@deephaven/components": "^0.
|
|
26
|
-
"@deephaven/golden-layout": "^0.
|
|
27
|
-
"@deephaven/jsapi-bootstrap": "^0.
|
|
28
|
-
"@deephaven/log": "^0.
|
|
29
|
-
"@deephaven/react-hooks": "^0.
|
|
30
|
-
"@deephaven/redux": "^0.
|
|
31
|
-
"@deephaven/utils": "^0.
|
|
25
|
+
"@deephaven/components": "^0.51.1-alpha-theme-fix.1+add15f1b",
|
|
26
|
+
"@deephaven/golden-layout": "^0.51.1-alpha-theme-fix.1+add15f1b",
|
|
27
|
+
"@deephaven/jsapi-bootstrap": "^0.51.1-alpha-theme-fix.1+add15f1b",
|
|
28
|
+
"@deephaven/log": "^0.51.1-alpha-theme-fix.1+add15f1b",
|
|
29
|
+
"@deephaven/react-hooks": "^0.51.1-alpha-theme-fix.1+add15f1b",
|
|
30
|
+
"@deephaven/redux": "^0.51.1-alpha-theme-fix.1+add15f1b",
|
|
31
|
+
"@deephaven/utils": "^0.51.1-alpha-theme-fix.1+add15f1b",
|
|
32
32
|
"deep-equal": "^2.0.5",
|
|
33
33
|
"lodash.ismatch": "^4.1.1",
|
|
34
34
|
"lodash.throttle": "^4.1.1",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"react-redux": "^7.2.4"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@deephaven/mocks": "^0.
|
|
45
|
+
"@deephaven/mocks": "^0.51.1-alpha-theme-fix.1+add15f1b",
|
|
46
46
|
"@types/lodash.ismatch": "^4.4.0"
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "add15f1b1ce7ad96bf40849a39c80434070b54c0"
|
|
55
55
|
}
|