@deephaven/dashboard 0.109.1-beta.9 → 1.0.1-beta.0

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.
@@ -17,7 +17,7 @@ import PanelEvent from "./PanelEvent.js";
17
17
  import { GLPropTypes, useListener } from "./layout/index.js";
18
18
  import { getDashboardData, updateDashboardData } from "./redux/index.js";
19
19
  import DashboardPanelWrapper from "./DashboardPanelWrapper.js";
20
- import { DhIdContext } from "./useDhId.js";
20
+ import { PanelIdContext } from "./usePanelId.js";
21
21
  import { jsx as _jsx } from "react/jsx-runtime";
22
22
  import { Fragment as _Fragment } from "react/jsx-runtime";
23
23
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -83,7 +83,7 @@ export function DashboardLayout(_ref) {
83
83
  return /*#__PURE__*/_jsx(PanelErrorBoundary, {
84
84
  glContainer: glContainer,
85
85
  glEventHub: glEventHub,
86
- children: /*#__PURE__*/_jsx(DhIdContext.Provider, {
86
+ children: /*#__PURE__*/_jsx(PanelIdContext.Provider, {
87
87
  value: panelId,
88
88
  children: /*#__PURE__*/_jsx(PanelWrapperType, _objectSpread(_objectSpread({}, props), {}, {
89
89
  children: hasRef ?
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardLayout.js","names":["React","useCallback","useEffect","useMemo","useState","PropTypes","Log","usePrevious","useThrottledCallback","ErrorBoundary","useDispatch","useSelector","PanelManager","PanelErrorBoundary","LayoutUtils","canHaveRef","dehydrate","dehydrateDefault","hydrate","hydrateDefault","PanelEvent","GLPropTypes","useListener","getDashboardData","updateDashboardData","DashboardPanelWrapper","DhIdContext","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","log","module","EMPTY_OBJECT","Object","freeze","DEFAULT_LAYOUT_CONFIG","DEFAULT_CALLBACK","undefined","STATE_CHANGE_THROTTLE_MS","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","layoutChildren","setLayoutChildren","getReactChildren","hydrateMap","Map","dehydrateMap","registerComponent","name","componentType","_componentType$displa","componentHydrate","arguments","length","componentDehydrate","debug2","wrappedComponent","ref","CType","PanelWrapperType","hasRef","glContainer","glEventHub","panelId","getIdFromContainer","Provider","value","_objectSpread","displayName","concat","cleanup","forwardRef","set","hydrateComponent","_hydrateMap$get","get","dehydrateComponent","config","_dehydrateMap$get","panelManager","_ref2","openedMap","throttledProcessDehydratedLayoutConfig","dehydratedLayoutConfig","hasChanged","isEqual","debug","root","contentItems","flushOnUnmount","flush","handleLayoutStateChanged","glConfig","toConfig","contentConfig","content","dehydrateLayoutConfig","handleLayoutItemPickedUp","component","componentId","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","fallback","cloneElement","propTypes","string","isRequired","node","shape","Layout","arrayOf","func"],"sources":["../src/DashboardLayout.tsx"],"sourcesContent":["import React, {\n type ComponentType,\n type ReactElement,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport PropTypes from 'prop-types';\nimport type GoldenLayout from '@deephaven/golden-layout';\nimport type {\n Container,\n ItemConfig,\n ReactComponentConfig,\n} from '@deephaven/golden-layout';\nimport Log from '@deephaven/log';\nimport { usePrevious, useThrottledCallback } from '@deephaven/react-hooks';\nimport { ErrorBoundary } from '@deephaven/components';\nimport { type RootState } from '@deephaven/redux';\nimport { useDispatch, useSelector } from 'react-redux';\nimport PanelManager, { type 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 type PanelComponentType,\n type PanelDehydrateFunction,\n type PanelHydrateFunction,\n type PanelProps,\n} from './DashboardPlugin';\nimport DashboardPanelWrapper from './DashboardPanelWrapper';\nimport { DhIdContext } from './useDhId';\n\nexport type DashboardLayoutConfig = ItemConfig[];\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\nconst STATE_CHANGE_THROTTLE_MS = 1000;\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 [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 const panelId = LayoutUtils.getIdFromContainer(glContainer);\n return (\n <PanelErrorBoundary glContainer={glContainer} glEventHub={glEventHub}>\n <DhIdContext.Provider value={panelId as string | null}>\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 </DhIdContext.Provider>\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 // Throttle the calls so that we don't flood comparing these layouts\n const throttledProcessDehydratedLayoutConfig = useThrottledCallback(\n (dehydratedLayoutConfig: DashboardLayoutConfig) => {\n const hasChanged =\n lastConfig == null ||\n !LayoutUtils.isEqual(lastConfig, dehydratedLayoutConfig);\n\n log.debug('handleLayoutStateChanged', hasChanged, dehydratedLayoutConfig);\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 STATE_CHANGE_THROTTLE_MS,\n { flushOnUnmount: true }\n );\n\n useEffect(\n () => () => throttledProcessDehydratedLayoutConfig.flush(),\n [throttledProcessDehydratedLayoutConfig]\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 const glConfig = layout.toConfig();\n const contentConfig = glConfig.content;\n const dehydratedLayoutConfig = LayoutUtils.dehydrateLayoutConfig(\n contentConfig,\n dehydrateComponent\n );\n throttledProcessDehydratedLayoutConfig(dehydratedLayoutConfig);\n }, [\n dehydrateComponent,\n isItemDragging,\n layout,\n throttledProcessDehydratedLayoutConfig,\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 // This should be the last hook called in this component\n // Ensures it runs after any other effects on mount\n // Fire only once after the layout is mounted\n // This should ensure DashboardPlugins have been mounted\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useEffect(() => onLayoutInitialized(), []);\n\n return (\n <>\n {isDashboardEmpty && emptyDashboard}\n {layoutChildren}\n {React.Children.map(children, child =>\n child != null ? (\n // Have fallback be an empty array so that we don't show the error message over entire app\n // Look into using toast message in the future\n <ErrorBoundary fallback={[]}>\n {React.cloneElement(child as ReactElement, {\n id,\n layout,\n panelManager,\n registerComponent,\n })}\n </ErrorBoundary>\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,EAAEC,oBAAoB,QAAQ,wBAAwB;AAC1E,SAASC,aAAa,QAAQ,uBAAuB;AAErD,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;A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CAACnB,aAAa;MAAC6I,QAAQ,EAAE,EAAG;MAAArG,QAAA,eACzBjD,KAAK,CAACuJ,YAAY,CAACF,KAAK,EAAkB;QACzCrG,EAAE;QACFG,MAAM;QACNsD,YAAY;QACZhC;MACF,CAAC;IAAC,CACW,CAAC,GACd,IACN,CAAC;EAAA,CACD,CAAC;AAEP;AAEA7B,eAAe,CAAC4G,SAAS,GAAG;EAC1BxG,EAAE,EAAE3C,SAAS,CAACoJ,MAAM,CAACC,UAAU;EAC/BzG,QAAQ,EAAE5C,SAAS,CAACsJ,IAAI;EACxBlG,IAAI,EAAEpD,SAAS,CAACuJ,KAAK,CAAC,CAAC,CAAC,CAAC;EACzB1G,cAAc,EAAE7C,SAAS,CAACsJ,IAAI;EAC9BxG,MAAM,EAAE9B,WAAW,CAACwI,MAAM,CAACH,UAAU;EACrCtG,YAAY,EAAE/C,SAAS,CAACyJ,OAAO,CAACzJ,SAAS,CAACuJ,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;EACpDvG,cAAc,EAAEhD,SAAS,CAAC0J,IAAI;EAC9BzG,mBAAmB,EAAEjD,SAAS,CAAC0J;AACjC,CAAC;AAED,eAAenH,eAAe"}
1
+ {"version":3,"file":"DashboardLayout.js","names":["React","useCallback","useEffect","useMemo","useState","PropTypes","Log","usePrevious","useThrottledCallback","ErrorBoundary","useDispatch","useSelector","PanelManager","PanelErrorBoundary","LayoutUtils","canHaveRef","dehydrate","dehydrateDefault","hydrate","hydrateDefault","PanelEvent","GLPropTypes","useListener","getDashboardData","updateDashboardData","DashboardPanelWrapper","PanelIdContext","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","log","module","EMPTY_OBJECT","Object","freeze","DEFAULT_LAYOUT_CONFIG","DEFAULT_CALLBACK","undefined","STATE_CHANGE_THROTTLE_MS","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","layoutChildren","setLayoutChildren","getReactChildren","hydrateMap","Map","dehydrateMap","registerComponent","name","componentType","_componentType$displa","componentHydrate","arguments","length","componentDehydrate","debug2","wrappedComponent","ref","CType","PanelWrapperType","hasRef","glContainer","glEventHub","panelId","getIdFromContainer","Provider","value","_objectSpread","displayName","concat","cleanup","forwardRef","set","hydrateComponent","_hydrateMap$get","get","dehydrateComponent","config","_dehydrateMap$get","panelManager","_ref2","openedMap","throttledProcessDehydratedLayoutConfig","dehydratedLayoutConfig","hasChanged","isEqual","debug","root","contentItems","flushOnUnmount","flush","handleLayoutStateChanged","glConfig","toConfig","contentConfig","content","dehydrateLayoutConfig","handleLayoutItemPickedUp","component","componentId","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","fallback","cloneElement","propTypes","string","isRequired","node","shape","Layout","arrayOf","func"],"sources":["../src/DashboardLayout.tsx"],"sourcesContent":["import React, {\n type ComponentType,\n type ReactElement,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport PropTypes from 'prop-types';\nimport type GoldenLayout from '@deephaven/golden-layout';\nimport type {\n Container,\n ItemConfig,\n ReactComponentConfig,\n} from '@deephaven/golden-layout';\nimport Log from '@deephaven/log';\nimport { usePrevious, useThrottledCallback } from '@deephaven/react-hooks';\nimport { ErrorBoundary } from '@deephaven/components';\nimport { type RootState } from '@deephaven/redux';\nimport { useDispatch, useSelector } from 'react-redux';\nimport PanelManager, { type 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 type PanelComponentType,\n type PanelDehydrateFunction,\n type PanelHydrateFunction,\n type PanelProps,\n} from './DashboardPlugin';\nimport DashboardPanelWrapper from './DashboardPanelWrapper';\nimport { PanelIdContext } from './usePanelId';\n\nexport type DashboardLayoutConfig = ItemConfig[];\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\nconst STATE_CHANGE_THROTTLE_MS = 1000;\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 [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 const panelId = LayoutUtils.getIdFromContainer(glContainer);\n return (\n <PanelErrorBoundary glContainer={glContainer} glEventHub={glEventHub}>\n <PanelIdContext.Provider value={panelId as string | null}>\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 </PanelIdContext.Provider>\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 // Throttle the calls so that we don't flood comparing these layouts\n const throttledProcessDehydratedLayoutConfig = useThrottledCallback(\n (dehydratedLayoutConfig: DashboardLayoutConfig) => {\n const hasChanged =\n lastConfig == null ||\n !LayoutUtils.isEqual(lastConfig, dehydratedLayoutConfig);\n\n log.debug('handleLayoutStateChanged', hasChanged, dehydratedLayoutConfig);\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 STATE_CHANGE_THROTTLE_MS,\n { flushOnUnmount: true }\n );\n\n useEffect(\n () => () => throttledProcessDehydratedLayoutConfig.flush(),\n [throttledProcessDehydratedLayoutConfig]\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 const glConfig = layout.toConfig();\n const contentConfig = glConfig.content;\n const dehydratedLayoutConfig = LayoutUtils.dehydrateLayoutConfig(\n contentConfig,\n dehydrateComponent\n );\n throttledProcessDehydratedLayoutConfig(dehydratedLayoutConfig);\n }, [\n dehydrateComponent,\n isItemDragging,\n layout,\n throttledProcessDehydratedLayoutConfig,\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 // This should be the last hook called in this component\n // Ensures it runs after any other effects on mount\n // Fire only once after the layout is mounted\n // This should ensure DashboardPlugins have been mounted\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useEffect(() => onLayoutInitialized(), []);\n\n return (\n <>\n {isDashboardEmpty && emptyDashboard}\n {layoutChildren}\n {React.Children.map(children, child =>\n child != null ? (\n // Have fallback be an empty array so that we don't show the error message over entire app\n // Look into using toast message in the future\n <ErrorBoundary fallback={[]}>\n {React.cloneElement(child as ReactElement, {\n id,\n layout,\n panelManager,\n registerComponent,\n })}\n </ErrorBoundary>\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,EAAEC,oBAAoB,QAAQ,wBAAwB;AAC1E,SAASC,aAAa,QAAQ,uBAAuB;AAErD,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,SACnBC,cAAc;AAAA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AAQ,EAAE,EAAG;MAAArG,QAAA,eACzBjD,KAAK,CAACuJ,YAAY,CAACF,KAAK,EAAkB;QACzCrG,EAAE;QACFG,MAAM;QACNsD,YAAY;QACZhC;MACF,CAAC;IAAC,CACW,CAAC,GACd,IACN,CAAC;EAAA,CACD,CAAC;AAEP;AAEA7B,eAAe,CAAC4G,SAAS,GAAG;EAC1BxG,EAAE,EAAE3C,SAAS,CAACoJ,MAAM,CAACC,UAAU;EAC/BzG,QAAQ,EAAE5C,SAAS,CAACsJ,IAAI;EACxBlG,IAAI,EAAEpD,SAAS,CAACuJ,KAAK,CAAC,CAAC,CAAC,CAAC;EACzB1G,cAAc,EAAE7C,SAAS,CAACsJ,IAAI;EAC9BxG,MAAM,EAAE9B,WAAW,CAACwI,MAAM,CAACH,UAAU;EACrCtG,YAAY,EAAE/C,SAAS,CAACyJ,OAAO,CAACzJ,SAAS,CAACuJ,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;EACpDvG,cAAc,EAAEhD,SAAS,CAAC0J,IAAI;EAC9BzG,mBAAmB,EAAEjD,SAAS,CAAC0J;AACjC,CAAC;AAED,eAAenH,eAAe"}
package/dist/index.d.ts CHANGED
@@ -18,4 +18,5 @@ export { default as PanelManager } from './PanelManager';
18
18
  export { default as TabEvent } from './TabEvent';
19
19
  export * from './useDashboardId';
20
20
  export * from './useDhId';
21
+ export * from './usePanelId';
21
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,eAAe,SAAS,CAAC;AAEzB,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE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AAQ,EAAE,MAAM,YAAY,CAAC;AACjD,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -20,4 +20,5 @@ export { default as PanelManager } from "./PanelManager.js";
20
20
  export { default as TabEvent } from "./TabEvent.js";
21
21
  export * from "./useDashboardId.js";
22
22
  export * from "./useDhId.js";
23
+ export * from "./usePanelId.js";
23
24
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Dashboard","default","DashboardUtils","BasePanel","Panel","PanelErrorBoundary","PanelManager","TabEvent"],"sources":["../src/index.ts"],"sourcesContent":["import Dashboard from './Dashboard';\n\nexport default Dashboard;\n\nexport * from './Dashboard';\nexport * from './DashboardConstants';\nexport * from './DashboardEvents';\nexport * from './DashboardPlugin';\nexport * from './DashboardLayout';\nexport * from './DashboardUtils';\nexport { default as DashboardUtils } from './DashboardUtils';\nexport * from './LazyDashboard';\nexport * from './layout';\nexport * from './redux';\nexport {\n type BasePanelProps,\n default as BasePanel,\n // Alias for BasePanel\n default as Panel,\n} from './BasePanel';\nexport * from './PanelManager';\nexport * from './PanelEvent';\nexport { default as PanelErrorBoundary } from './PanelErrorBoundary';\nexport { default as PanelManager } from './PanelManager';\nexport { default as TabEvent } from './TabEvent';\nexport * from './useDashboardId';\nexport * from './useDhId';\n"],"mappings":"OAAOA,SAAS;AAEhB,eAAeA,SAAS;AAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAQhBC,OAAO,IAAIC,cAAc;AAAA;AAAA;AAAA;AAAA,SAMhCD,OAAO,IAAIE,SAAS;AACpB;AACAF,OAAO,IAAIG,KAAK;AAAA;AAAA;AAAA,SAITH,OAAO,IAAII,kBAAkB;AAAA,SAC7BJ,OAAO,IAAIK,YAAY;AAAA,SACvBL,OAAO,IAAIM,QAAQ;AAAA;AAAA"}
1
+ {"version":3,"file":"index.js","names":["Dashboard","default","DashboardUtils","BasePanel","Panel","PanelErrorBoundary","PanelManager","TabEvent"],"sources":["../src/index.ts"],"sourcesContent":["import Dashboard from './Dashboard';\n\nexport default Dashboard;\n\nexport * from './Dashboard';\nexport * from './DashboardConstants';\nexport * from './DashboardEvents';\nexport * from './DashboardPlugin';\nexport * from './DashboardLayout';\nexport * from './DashboardUtils';\nexport { default as DashboardUtils } from './DashboardUtils';\nexport * from './LazyDashboard';\nexport * from './layout';\nexport * from './redux';\nexport {\n type BasePanelProps,\n default as BasePanel,\n // Alias for BasePanel\n default as Panel,\n} from './BasePanel';\nexport * from './PanelManager';\nexport * from './PanelEvent';\nexport { default as PanelErrorBoundary } from './PanelErrorBoundary';\nexport { default as PanelManager } from './PanelManager';\nexport { default as TabEvent } from './TabEvent';\nexport * from './useDashboardId';\nexport * from './useDhId';\nexport * from './usePanelId';\n"],"mappings":"OAAOA,SAAS;AAEhB,eAAeA,SAAS;AAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAQhBC,OAAO,IAAIC,cAAc;AAAA;AAAA;AAAA;AAAA,SAMhCD,OAAO,IAAIE,SAAS;AACpB;AACAF,OAAO,IAAIG,KAAK;AAAA;AAAA;AAAA,SAITH,OAAO,IAAII,kBAAkB;AAAA,SAC7BJ,OAAO,IAAIK,YAAY;AAAA,SACvBL,OAAO,IAAIM,QAAQ;AAAA;AAAA;AAAA"}
package/dist/useDhId.d.ts CHANGED
@@ -1,12 +1,11 @@
1
1
  export declare const DH_ID_PROP = "__dhId";
2
- export declare const DhIdContext: import("react").Context<string | null>;
3
2
  /**
4
3
  * Gets the Deephaven ID of a component.
5
4
  * This is used to identify the component within a dashboard.
6
5
  * Usually this is just a panel ID, but in some contexts such as dh.ui,
7
6
  * it may be an ID for a component within a panel.
8
7
  *
9
- * Looks for a __dhId prop on the component, and if not found, looks in the DhIdContext.
8
+ * Looks for a __dhId prop on the component, and if not found, looks in the PanelIdContext.
10
9
  * @param props The props of the component using this hook
11
10
  * @returns The Deephaven ID of the component or null if not found.
12
11
  */
@@ -1 +1 @@
1
- {"version":3,"file":"useDhId.d.ts","sourceRoot":"","sources":["../src/useDhId.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,UAAU,WAAW,CAAC;AAEnC,eAAO,MAAM,WAAW,wCAAqC,CAAC;AAE9D;;;;;;;;;GASG;AACH,wBAAgB,OAAO,IAAI,MAAM,GAAG,IAAI,CAwBvC"}
1
+ {"version":3,"file":"useDhId.d.ts","sourceRoot":"","sources":["../src/useDhId.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,UAAU,WAAW,CAAC;AAEnC;;;;;;;;;GASG;AACH,wBAAgB,OAAO,IAAI,MAAM,GAAG,IAAI,CAwBvC"}
package/dist/useDhId.js CHANGED
@@ -1,9 +1,8 @@
1
- import { createContext, useContext } from 'react';
2
1
  import Log from '@deephaven/log';
3
2
  import { useFiber } from "./useFiber.js";
3
+ import { usePanelId } from "./usePanelId.js";
4
4
  var log = Log.module('useDhId');
5
5
  export var DH_ID_PROP = '__dhId';
6
- export var DhIdContext = /*#__PURE__*/createContext(null);
7
6
 
8
7
  /**
9
8
  * Gets the Deephaven ID of a component.
@@ -11,7 +10,7 @@ export var DhIdContext = /*#__PURE__*/createContext(null);
11
10
  * Usually this is just a panel ID, but in some contexts such as dh.ui,
12
11
  * it may be an ID for a component within a panel.
13
12
  *
14
- * Looks for a __dhId prop on the component, and if not found, looks in the DhIdContext.
13
+ * Looks for a __dhId prop on the component, and if not found, looks in the PanelIdContext.
15
14
  * @param props The props of the component using this hook
16
15
  * @returns The Deephaven ID of the component or null if not found.
17
16
  */
@@ -20,17 +19,17 @@ export function useDhId() {
20
19
  // pendingProps are the props passed to the fiber node
21
20
  var props = (_ref = (_useFiber = useFiber()) === null || _useFiber === void 0 ? void 0 : _useFiber.pendingProps) !== null && _ref !== void 0 ? _ref : {};
22
21
  var dhIdProp = props[DH_ID_PROP];
23
- var dhId = useContext(DhIdContext);
22
+ var panelId = usePanelId();
24
23
  if (dhIdProp != null) {
25
24
  if (typeof dhIdProp !== 'string') {
26
25
  throw new Error("useDhId expected prop ".concat(DH_ID_PROP, " to be a string, but got ").concat(typeof dhIdProp));
27
26
  }
28
27
  return dhIdProp;
29
28
  }
30
- if (dhId == null) {
31
- log.warn("useDhId must be used within a DhIdContext provider if there is no ".concat(DH_ID_PROP, " prop. Defaulting to null."));
29
+ if (panelId == null) {
30
+ log.warn("useDhId must be used within a PanelIdContext provider if there is no ".concat(DH_ID_PROP, " prop. Defaulting to null."));
32
31
  return null;
33
32
  }
34
- return dhId;
33
+ return panelId;
35
34
  }
36
35
  //# sourceMappingURL=useDhId.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDhId.js","names":["createContext","useContext","Log","useFiber","log","module","DH_ID_PROP","DhIdContext","useDhId","_ref","_useFiber","props","pendingProps","dhIdProp","dhId","Error","concat","warn"],"sources":["../src/useDhId.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport Log from '@deephaven/log';\nimport { useFiber } from './useFiber';\n\nconst log = Log.module('useDhId');\n\nexport const DH_ID_PROP = '__dhId';\n\nexport const DhIdContext = createContext<string | null>(null);\n\n/**\n * Gets the Deephaven ID of a component.\n * This is used to identify the component within a dashboard.\n * Usually this is just a panel ID, but in some contexts such as dh.ui,\n * it may be an ID for a component within a panel.\n *\n * Looks for a __dhId prop on the component, and if not found, looks in the DhIdContext.\n * @param props The props of the component using this hook\n * @returns The Deephaven ID of the component or null if not found.\n */\nexport function useDhId(): string | null {\n // pendingProps are the props passed to the fiber node\n const props =\n (useFiber()?.pendingProps as Record<string, unknown> | undefined) ?? {};\n const dhIdProp = props[DH_ID_PROP];\n const dhId = useContext(DhIdContext);\n\n if (dhIdProp != null) {\n if (typeof dhIdProp !== 'string') {\n throw new Error(\n `useDhId expected prop ${DH_ID_PROP} to be a string, but got ${typeof dhIdProp}`\n );\n }\n return dhIdProp;\n }\n\n if (dhId == null) {\n log.warn(\n `useDhId must be used within a DhIdContext provider if there is no ${DH_ID_PROP} prop. Defaulting to null.`\n );\n return null;\n }\n\n return dhId;\n}\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO;AACjD,OAAOC,GAAG,MAAM,gBAAgB;AAAC,SACxBC,QAAQ;AAEjB,IAAMC,GAAG,GAAGF,GAAG,CAACG,MAAM,CAAC,SAAS,CAAC;AAEjC,OAAO,IAAMC,UAAU,GAAG,QAAQ;AAElC,OAAO,IAAMC,WAAW,gBAAGP,aAAa,CAAgB,IAAI,CAAC;;AAE7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,OAAOA,CAAA,EAAkB;EAAA,IAAAC,IAAA,EAAAC,SAAA;EACvC;EACA,IAAMC,KAAK,IAAAF,IAAA,IAAAC,SAAA,GACRP,QAAQ,CAAC,CAAC,cAAAO,SAAA,uBAAVA,SAAA,CAAYE,YAAY,cAAAH,IAAA,cAAAA,IAAA,GAA4C,CAAC,CAAC;EACzE,IAAMI,QAAQ,GAAGF,KAAK,CAACL,UAAU,CAAC;EAClC,IAAMQ,IAAI,GAAGb,UAAU,CAACM,WAAW,CAAC;EAEpC,IAAIM,QAAQ,IAAI,IAAI,EAAE;IACpB,IAAI,OAAOA,QAAQ,KAAK,QAAQ,EAAE;MAChC,MAAM,IAAIE,KAAK,0BAAAC,MAAA,CACYV,UAAU,+BAAAU,MAAA,CAA4B,OAAOH,QAAQ,CAChF,CAAC;IACH;IACA,OAAOA,QAAQ;EACjB;EAEA,IAAIC,IAAI,IAAI,IAAI,EAAE;IAChBV,GAAG,CAACa,IAAI,sEAAAD,MAAA,CAC+DV,UAAU,+BACjF,CAAC;IACD,OAAO,IAAI;EACb;EAEA,OAAOQ,IAAI;AACb"}
1
+ {"version":3,"file":"useDhId.js","names":["Log","useFiber","usePanelId","log","module","DH_ID_PROP","useDhId","_ref","_useFiber","props","pendingProps","dhIdProp","panelId","Error","concat","warn"],"sources":["../src/useDhId.ts"],"sourcesContent":["import Log from '@deephaven/log';\nimport { useFiber } from './useFiber';\nimport { usePanelId } from './usePanelId';\n\nconst log = Log.module('useDhId');\n\nexport const DH_ID_PROP = '__dhId';\n\n/**\n * Gets the Deephaven ID of a component.\n * This is used to identify the component within a dashboard.\n * Usually this is just a panel ID, but in some contexts such as dh.ui,\n * it may be an ID for a component within a panel.\n *\n * Looks for a __dhId prop on the component, and if not found, looks in the PanelIdContext.\n * @param props The props of the component using this hook\n * @returns The Deephaven ID of the component or null if not found.\n */\nexport function useDhId(): string | null {\n // pendingProps are the props passed to the fiber node\n const props =\n (useFiber()?.pendingProps as Record<string, unknown> | undefined) ?? {};\n const dhIdProp = props[DH_ID_PROP];\n const panelId = usePanelId();\n\n if (dhIdProp != null) {\n if (typeof dhIdProp !== 'string') {\n throw new Error(\n `useDhId expected prop ${DH_ID_PROP} to be a string, but got ${typeof dhIdProp}`\n );\n }\n return dhIdProp;\n }\n\n if (panelId == null) {\n log.warn(\n `useDhId must be used within a PanelIdContext provider if there is no ${DH_ID_PROP} prop. Defaulting to null.`\n );\n return null;\n }\n\n return panelId;\n}\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,gBAAgB;AAAC,SACxBC,QAAQ;AAAA,SACRC,UAAU;AAEnB,IAAMC,GAAG,GAAGH,GAAG,CAACI,MAAM,CAAC,SAAS,CAAC;AAEjC,OAAO,IAAMC,UAAU,GAAG,QAAQ;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,OAAOA,CAAA,EAAkB;EAAA,IAAAC,IAAA,EAAAC,SAAA;EACvC;EACA,IAAMC,KAAK,IAAAF,IAAA,IAAAC,SAAA,GACRP,QAAQ,CAAC,CAAC,cAAAO,SAAA,uBAAVA,SAAA,CAAYE,YAAY,cAAAH,IAAA,cAAAA,IAAA,GAA4C,CAAC,CAAC;EACzE,IAAMI,QAAQ,GAAGF,KAAK,CAACJ,UAAU,CAAC;EAClC,IAAMO,OAAO,GAAGV,UAAU,CAAC,CAAC;EAE5B,IAAIS,QAAQ,IAAI,IAAI,EAAE;IACpB,IAAI,OAAOA,QAAQ,KAAK,QAAQ,EAAE;MAChC,MAAM,IAAIE,KAAK,0BAAAC,MAAA,CACYT,UAAU,+BAAAS,MAAA,CAA4B,OAAOH,QAAQ,CAChF,CAAC;IACH;IACA,OAAOA,QAAQ;EACjB;EAEA,IAAIC,OAAO,IAAI,IAAI,EAAE;IACnBT,GAAG,CAACY,IAAI,yEAAAD,MAAA,CACkET,UAAU,+BACpF,CAAC;IACD,OAAO,IAAI;EACb;EAEA,OAAOO,OAAO;AAChB"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Context to provide the golden layout panel ID.
3
+ */
4
+ export declare const PanelIdContext: import("react").Context<string | null>;
5
+ /**
6
+ * Gets the current panel ID from the nearest context.
7
+ * @returns The current panel ID from the context, or null if not set or there is no context.
8
+ */
9
+ export declare function usePanelId(): string | null;
10
+ //# sourceMappingURL=usePanelId.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePanelId.d.ts","sourceRoot":"","sources":["../src/usePanelId.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,cAAc,wCAAqC,CAAC;AAEjE;;;GAGG;AACH,wBAAgB,UAAU,IAAI,MAAM,GAAG,IAAI,CAE1C"}
@@ -0,0 +1,15 @@
1
+ import { createContext, useContext } from 'react';
2
+
3
+ /**
4
+ * Context to provide the golden layout panel ID.
5
+ */
6
+ export var PanelIdContext = /*#__PURE__*/createContext(null);
7
+
8
+ /**
9
+ * Gets the current panel ID from the nearest context.
10
+ * @returns The current panel ID from the context, or null if not set or there is no context.
11
+ */
12
+ export function usePanelId() {
13
+ return useContext(PanelIdContext);
14
+ }
15
+ //# sourceMappingURL=usePanelId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePanelId.js","names":["createContext","useContext","PanelIdContext","usePanelId"],"sources":["../src/usePanelId.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\n\n/**\n * Context to provide the golden layout panel ID.\n */\nexport const PanelIdContext = createContext<string | null>(null);\n\n/**\n * Gets the current panel ID from the nearest context.\n * @returns The current panel ID from the context, or null if not set or there is no context.\n */\nexport function usePanelId(): string | null {\n return useContext(PanelIdContext);\n}\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO;;AAEjD;AACA;AACA;AACA,OAAO,IAAMC,cAAc,gBAAGF,aAAa,CAAgB,IAAI,CAAC;;AAEhE;AACA;AACA;AACA;AACA,OAAO,SAASG,UAAUA,CAAA,EAAkB;EAC1C,OAAOF,UAAU,CAACC,cAAc,CAAC;AACnC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deephaven/dashboard",
3
- "version": "0.109.1-beta.9+ce171b91",
3
+ "version": "1.0.1-beta.0+5edf3b38",
4
4
  "description": "Deephaven Dashboard",
5
5
  "author": "Deephaven Data Labs LLC",
6
6
  "license": "Apache-2.0",
@@ -22,12 +22,12 @@
22
22
  "build:sass": "sass --embed-sources --load-path=../../node_modules ./src:./dist"
23
23
  },
24
24
  "dependencies": {
25
- "@deephaven/components": "^0.109.1-beta.9+ce171b91",
26
- "@deephaven/golden-layout": "^0.109.1-beta.9+ce171b91",
27
- "@deephaven/log": "^0.109.1-beta.9+ce171b91",
28
- "@deephaven/react-hooks": "^0.109.1-beta.9+ce171b91",
29
- "@deephaven/redux": "^0.109.1-beta.9+ce171b91",
30
- "@deephaven/utils": "^0.109.1-beta.9+ce171b91",
25
+ "@deephaven/components": "^1.0.1-beta.0+5edf3b38",
26
+ "@deephaven/golden-layout": "^1.0.1-beta.0+5edf3b38",
27
+ "@deephaven/log": "^1.0.1-beta.0+5edf3b38",
28
+ "@deephaven/react-hooks": "^1.0.1-beta.0+5edf3b38",
29
+ "@deephaven/redux": "^1.0.1-beta.0+5edf3b38",
30
+ "@deephaven/utils": "^1.0.1-beta.0+5edf3b38",
31
31
  "classnames": "^2.3.1",
32
32
  "fast-deep-equal": "^3.1.3",
33
33
  "lodash.ismatch": "^4.1.1",
@@ -42,8 +42,8 @@
42
42
  "react-redux": "^7.2.4"
43
43
  },
44
44
  "devDependencies": {
45
- "@deephaven/mocks": "^0.109.1-beta.9+ce171b91",
46
- "@deephaven/test-utils": "^0.109.1-beta.9+ce171b91",
45
+ "@deephaven/mocks": "^1.0.1-beta.0+5edf3b38",
46
+ "@deephaven/test-utils": "^1.0.1-beta.0+5edf3b38",
47
47
  "@types/lodash.ismatch": "^4.4.0",
48
48
  "@types/react-reconciler": "^0.32.0"
49
49
  },
@@ -53,5 +53,5 @@
53
53
  "publishConfig": {
54
54
  "access": "public"
55
55
  },
56
- "gitHead": "ce171b9146e5ba3ff169cd0a9f498921188ca9f6"
56
+ "gitHead": "5edf3b380e7573795df3afe764fe29cb126203f6"
57
57
  }