@deephaven/dashboard 1.22.1 → 1.22.2-alpha-pivot-builder.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.
Files changed (39) hide show
  1. package/dist/BasePanel.js +48 -75
  2. package/dist/BasePanel.js.map +1 -1
  3. package/dist/Dashboard.js +32 -16
  4. package/dist/Dashboard.js.map +1 -1
  5. package/dist/DashboardEvents.js +10 -10
  6. package/dist/DashboardEvents.js.map +1 -1
  7. package/dist/DashboardLayout.js +42 -25
  8. package/dist/DashboardLayout.js.map +1 -1
  9. package/dist/DashboardPanelWrapper.js +19 -14
  10. package/dist/DashboardPanelWrapper.js.map +1 -1
  11. package/dist/DashboardUtils.js +6 -13
  12. package/dist/DashboardUtils.js.map +1 -1
  13. package/dist/LazyDashboard.js +13 -6
  14. package/dist/LazyDashboard.js.map +1 -1
  15. package/dist/NavigationEvent.js +20 -20
  16. package/dist/NavigationEvent.js.map +1 -1
  17. package/dist/PanelContextMenu.js +13 -24
  18. package/dist/PanelContextMenu.js.map +1 -1
  19. package/dist/PanelErrorBoundary.js +5 -10
  20. package/dist/PanelErrorBoundary.js.map +1 -1
  21. package/dist/PanelEvent.js +10 -11
  22. package/dist/PanelEvent.js.map +1 -1
  23. package/dist/PanelManager.js +10 -28
  24. package/dist/PanelManager.js.map +1 -1
  25. package/dist/PersistentStateContext.js +22 -19
  26. package/dist/PersistentStateContext.js.map +1 -1
  27. package/dist/RenameDialog.js +17 -34
  28. package/dist/RenameDialog.js.map +1 -1
  29. package/dist/layout/LayoutUtils.js +28 -37
  30. package/dist/layout/LayoutUtils.js.map +1 -1
  31. package/dist/layout/useDashboardPanel.js +16 -25
  32. package/dist/layout/useDashboardPanel.js.map +1 -1
  33. package/dist/redux/index.js +9 -1
  34. package/dist/redux/index.js.map +1 -1
  35. package/dist/useFiber.js +10 -4
  36. package/dist/useFiber.js.map +1 -1
  37. package/dist/usePersistentState.js +25 -16
  38. package/dist/usePersistentState.js.map +1 -1
  39. package/package.json +10 -10
@@ -306,9 +306,7 @@ class LayoutUtils {
306
306
  var dehydratedConfig = [];
307
307
  for (var i = 0; i < config.length; i += 1) {
308
308
  var itemConfig = config[i];
309
- var {
310
- content
311
- } = itemConfig;
309
+ var content = itemConfig.content;
312
310
  if (isReactComponentConfig(itemConfig)) {
313
311
  var dehydratedComponent = dehydrateComponent(itemConfig.component, itemConfig);
314
312
  if (dehydratedComponent != null) {
@@ -328,9 +326,7 @@ class LayoutUtils {
328
326
  return dehydratedConfig;
329
327
  }
330
328
  static getTabPoint(glContainer) {
331
- var {
332
- tab
333
- } = glContainer;
329
+ var tab = glContainer.tab;
334
330
  if (tab == null) {
335
331
  throw new Error("Cannot get tab for panel container ".concat(glContainer));
336
332
  }
@@ -353,9 +349,7 @@ class LayoutUtils {
353
349
  static dropLayoutMinorChange(config) {
354
350
  for (var i = 0; i < config.length; i += 1) {
355
351
  var itemConfig = config[i];
356
- var {
357
- content
358
- } = itemConfig;
352
+ var content = itemConfig.content;
359
353
  if (content !== undefined) {
360
354
  if (isStackItemConfig(itemConfig)) {
361
355
  delete itemConfig.activeItemIndex;
@@ -411,10 +405,9 @@ class LayoutUtils {
411
405
  var itemConfig = config[i];
412
406
  if (isReactComponentConfig(itemConfig)) {
413
407
  var _itemConfig$id;
414
- var {
415
- component,
416
- props = {}
417
- } = itemConfig;
408
+ var component = itemConfig.component,
409
+ _itemConfig$props = itemConfig.props,
410
+ props = _itemConfig$props === void 0 ? {} : _itemConfig$props;
418
411
  hydratedConfig.push(_objectSpread(_objectSpread({}, itemConfig), {}, {
419
412
  id: (_itemConfig$id = itemConfig === null || itemConfig === void 0 ? void 0 : itemConfig.id) !== null && _itemConfig$id !== void 0 ? _itemConfig$id : nanoid(),
420
413
  props: hydrateComponent(component, props)
@@ -448,16 +441,21 @@ class LayoutUtils {
448
441
  * @param dragEvent Whether component is being created with a drag, mouse event is initial position for drag proxy
449
442
  */
450
443
  static openComponent() {
451
- var {
452
- root,
453
- config: configParam,
454
- stack: stackParam = undefined,
455
- replaceExisting = true,
456
- replaceConfig = undefined,
457
- createNewStack = false,
458
- focusElement = undefined,
459
- dragEvent = undefined
460
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
444
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
445
+ root = _ref.root,
446
+ configParam = _ref.config,
447
+ _ref$stack = _ref.stack,
448
+ stackParam = _ref$stack === void 0 ? undefined : _ref$stack,
449
+ _ref$replaceExisting = _ref.replaceExisting,
450
+ replaceExisting = _ref$replaceExisting === void 0 ? true : _ref$replaceExisting,
451
+ _ref$replaceConfig = _ref.replaceConfig,
452
+ replaceConfig = _ref$replaceConfig === void 0 ? undefined : _ref$replaceConfig,
453
+ _ref$createNewStack = _ref.createNewStack,
454
+ createNewStack = _ref$createNewStack === void 0 ? false : _ref$createNewStack,
455
+ _ref$focusElement = _ref.focusElement,
456
+ focusElement = _ref$focusElement === void 0 ? undefined : _ref$focusElement,
457
+ _ref$dragEvent = _ref.dragEvent,
458
+ dragEvent = _ref$dragEvent === void 0 ? undefined : _ref$dragEvent;
461
459
  // attempt to retain focus after dom manipulation, which can break focus
462
460
  var maintainFocusElement = document.activeElement;
463
461
  var config = _objectSpread({}, configParam);
@@ -481,9 +479,7 @@ class LayoutUtils {
481
479
  var onComponentCreated = event => {
482
480
  log.debug('Component created, focusing element', focusElement);
483
481
  stack.off('componentCreated', onComponentCreated);
484
- var {
485
- element
486
- } = event.origin;
482
+ var element = event.origin.element;
487
483
 
488
484
  // Need to wait until the component actually renders.
489
485
  requestAnimationFrame(() => {
@@ -592,9 +588,8 @@ class LayoutUtils {
592
588
  log.error('Could not find stack for config', config);
593
589
  return null;
594
590
  }
595
- var {
596
- props = {}
597
- } = config;
591
+ var _config$props = config.props,
592
+ props = _config$props === void 0 ? {} : _config$props;
598
593
  var panelState = LayoutUtils.getPanelComponentState(config);
599
594
  var cloneConfig = {
600
595
  type: 'react-component',
@@ -620,8 +615,8 @@ class LayoutUtils {
620
615
  return (_config$componentStat = config.componentState) === null || _config$componentStat === void 0 ? void 0 : _config$componentStat.panelState;
621
616
  }
622
617
  if (isReactComponentConfig(config)) {
623
- var _config$props;
624
- return (_config$props = config.props) === null || _config$props === void 0 ? void 0 : _config$props.panelState;
618
+ var _config$props2;
619
+ return (_config$props2 = config.props) === null || _config$props2 === void 0 ? void 0 : _config$props2.panelState;
625
620
  }
626
621
  return null;
627
622
  }
@@ -698,9 +693,7 @@ class LayoutUtils {
698
693
  * @returns Panel ID
699
694
  */
700
695
  static getIdFromPanel(panel) {
701
- var {
702
- glContainer
703
- } = panel.props;
696
+ var glContainer = panel.props.glContainer;
704
697
  return LayoutUtils.getIdFromContainer(glContainer);
705
698
  }
706
699
 
@@ -710,9 +703,7 @@ class LayoutUtils {
710
703
  * @returns Component name or null if unable to retrieve name
711
704
  */
712
705
  static getComponentNameFromPanel(panel) {
713
- var {
714
- glContainer
715
- } = panel.props;
706
+ var glContainer = panel.props.glContainer;
716
707
  var config = LayoutUtils.getComponentConfigFromContainer(glContainer);
717
708
  if (config && isReactComponentConfig(config)) {
718
709
  var _config$component;
@@ -1 +1 @@
1
- {"version":3,"file":"LayoutUtils.js","names":["deepEqual","nanoid","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","rowOrColConfig","contentItems","addChild","child","isCorrectType","isColumn","isRow","removeChild","maintainFocusElement","document","activeElement","newParent","_newParent$config","_newParent$config2","inverseRowOrColConfig","layoutManager","createContentItem","height","width","replaceChild","getAllStackContainers","layout","_findAllStackContainers","getFocusedStackIndex","allStacks","findIndex","header","tabs","some","tab","classList","contains","getFocusedStack","focusedStackIndex","getStackById","item","searchId","_item$config","allowEmptyStack","id","Error","concat","i","getContentItemById","_item$config2","getStackForConfig","createIfNecessary","matchComponentType","getStackForComponentTypes","types","isLastType","dehydrateLayoutConfig","dehydrateComponent","dehydratedConfig","itemConfig","content","dehydratedComponent","push","debug2","layoutItemConfig","_objectSpread","getTabPoint","glContainer","tabRect","getBoundingClientRect","left","bottom","dropLayoutMinorChange","activeItemIndex","props","panelState","irisGridState","sorts","quickFilters","gridState","isStuckToBottom","isStuckToRight","isEqual","layout1","layout2","major","layout1Clone","cloneLayout","layout2Clone","JSON","parse","stringify","hydrateLayoutConfig","hydrateComponent","hydratedConfig","_itemConfig$id","contentConfig","warn","openComponent","configParam","stackParam","replaceExisting","replaceConfig","createNewStack","focusElement","dragEvent","createDragSourceFromEvent","searchConfig","oldContentItem","onComponentCreated","event","debug","off","origin","requestAnimationFrame","on","index","indexOf","openComponentInStack","closeComponent","closeOptions","container","close","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 deepEqual from 'fast-deep-equal';\nimport { nanoid } from 'nanoid';\nimport isMatch from 'lodash.ismatch';\nimport Log from '@deephaven/log';\nimport type GoldenLayout from '@deephaven/golden-layout';\nimport {\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 ReactComponentConfig,\n Stack,\n Tab,\n CloseOptions,\n GLPanelProps,\n} from '@deephaven/golden-layout';\nimport { assertNotNull, type Brand } from '@deephaven/utils';\nimport { type DashboardLayoutConfig } from '../DashboardLayout';\nimport {\n type PanelConfig,\n type DehydratedPanelProps,\n type DehydratedDashboardPanelProps,\n type DehydratedPanelConfig,\n} from '../DashboardPlugin';\n\nconst log = Log.module('LayoutUtils');\n\ntype LayoutConfig = { id?: string; component?: string };\n\nexport type PanelId = Brand<'PanelId', string | undefined>;\n\nexport type LayoutPanel = {\n props: GLPanelProps;\n};\n\nexport type StackItemConfig = ItemConfig & {\n activeItemIndex?: number;\n};\n\nfunction isComponentConfig(config: ItemConfig): config is ComponentConfig {\n return (config as ComponentConfig).componentName !== undefined;\n}\n\nexport function isReactComponentConfig(\n config: ItemConfig\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: ItemConfig): 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<ItemConfig>): 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 if (isRoot(parent)) {\n const rowOrColConfig: ItemConfig = {\n type: columnPreferred ? 'column' : 'row',\n };\n\n if (parent.contentItems == null || parent.contentItems.length === 0) {\n parent.addChild(rowOrColConfig);\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(rowOrColConfig);\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\n // This is usually triggered because we hit a stack within the last row/column\n if (!isCorrectType) {\n const inverseRowOrColConfig = parent.layoutManager.createContentItem(\n {\n type: !columnPreferred ? 'column' : 'row',\n height: newParent.config?.height,\n width: newParent.config?.width,\n },\n parent\n );\n parent.replaceChild(newParent, inverseRowOrColConfig);\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 all stack containers in the layout\n * @param layout GoldenLayout instance\n * @returns The found stack containers\n */\n static getAllStackContainers(layout: GoldenLayout): Stack[] {\n // eslint-disable-next-line no-underscore-dangle\n return layout._findAllStackContainers();\n }\n\n /**\n * Get the index of the stack that is currently focused\n * @param allStacks All the stacks\n * @returns The focused stack's index or -1 if not found\n */\n static getFocusedStackIndex(allStacks: Stack[]): number {\n // NOTE: We target the 'lm_focusin' class because GoldenLayout automatically applies this class\n // to tab elements when they receive focus. Until we enhance focus tracking in GoldenLayout, we\n // will have to rely on this internal CSS class.\n return allStacks.findIndex(stack =>\n stack.header.tabs.some(tab =>\n tab.element[0].classList.contains('lm_focusin')\n )\n );\n }\n\n /**\n * Get the stack that is currently focused\n * @param layout GoldenLayout instance\n * @returns The focused stack or undefined if none found\n */\n static getFocusedStack(layout: GoldenLayout): Stack | undefined {\n const allStacks = LayoutUtils.getAllStackContainers(layout);\n const focusedStackIndex = LayoutUtils.getFocusedStackIndex(allStacks);\n return allStacks[focusedStackIndex];\n }\n\n /**\n * Gets a stack by its ID\n * @param item Golden layout content item to search for the stack\n * @param searchId the ID\n */\n static getStackById(\n item: ContentItem,\n searchId: string | string[],\n allowEmptyStack = false\n ): Stack | null {\n if (allowEmptyStack && isStack(item) && item.contentItems.length === 0) {\n return item;\n }\n\n if (searchId === item.config?.id) {\n if (isStack(item)) {\n return item as Stack;\n }\n throw new Error(`Item with ID ${searchId} is not a stack`);\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 stack = this.getStackById(\n item.contentItems[i],\n searchId,\n allowEmptyStack\n );\n if (stack) {\n return stack;\n }\n }\n\n return null;\n }\n\n /**\n * Gets a content item by its ID\n * @param item Golden layout content item to search for the content item. Typically the root.\n * @param searchId the ID\n */\n static getContentItemById(\n item: ContentItem,\n searchId: string | string[]\n ): ContentItem | null {\n if (item.config?.id === searchId) {\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 = this.getContentItemById(\n item.contentItems[i],\n searchId\n );\n if (contentItem) {\n return contentItem;\n }\n }\n\n return null;\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<ItemConfig> = {},\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<ItemConfig>,\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 as { component?: string }).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<ItemConfig>\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: ItemConfig[],\n dehydrateComponent: (\n componentName: string,\n config: PanelConfig\n ) => DehydratedPanelConfig\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 { content } = itemConfig;\n if (isReactComponentConfig(itemConfig)) {\n const dehydratedComponent = dehydrateComponent(\n itemConfig.component,\n itemConfig\n );\n if (dehydratedComponent != null) {\n dehydratedConfig.push(dehydratedComponent);\n } else {\n log.debug2(\n `dehydrateLayoutConfig: skipping unmapped component \"${itemConfig.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 * 4. isStuckToBottom/isStuckToRight\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 itemConfig.props.panelState.gridState.isStuckToBottom = false;\n itemConfig.props.panelState.gridState.isStuckToRight = false;\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 const layout1Clone = LayoutUtils.cloneLayout(layout1);\n const layout2Clone = LayoutUtils.cloneLayout(layout2);\n if (major) {\n LayoutUtils.dropLayoutMinorChange(layout1Clone);\n LayoutUtils.dropLayoutMinorChange(layout2Clone);\n return deepEqual(layout1Clone, layout2Clone);\n }\n // Pass cloned layouts to avoid false negatives\n // when comparing layouts with undefined and missing properties\n return deepEqual(layout1Clone, layout2Clone);\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 props: DehydratedPanelProps\n ) => DehydratedDashboardPanelProps\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 ?? nanoid(),\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 stack: stackParam = undefined,\n replaceExisting = true,\n replaceConfig = undefined,\n createNewStack = false,\n focusElement = undefined,\n dragEvent = undefined,\n }: {\n root?: ContentItem;\n config?: Partial<ReactComponentConfig>;\n stack?: Stack;\n replaceExisting?: boolean;\n replaceConfig?: Partial<ItemConfig>;\n createNewStack?: boolean;\n focusElement?: string;\n dragEvent?: MouseEvent;\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 = nanoid();\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 =\n stackParam ??\n (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: ItemConfig & 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<ItemConfig>,\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: nanoid(),\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: ItemConfig): 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 ): ItemConfig | 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(glContainer: Container): PanelId | null {\n const config = LayoutUtils.getComponentConfigFromContainer(glContainer);\n if (config) {\n return config.id as PanelId;\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: LayoutPanel): PanelId | null {\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: LayoutPanel): 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":";;;;;AAAA,OAAOA,SAAS,MAAM,iBAAiB;AACvC,SAASC,MAAM,QAAQ,QAAQ;AAC/B,OAAOC,OAAO,MAAM,gBAAgB;AACpC,OAAOC,GAAG,MAAM,gBAAgB;AAEhC,SACEC,WAAW,EACXC,MAAM,EACNC,OAAO,EACPC,uBAAuB,QAClB,0BAA0B;AAajC,SAASC,aAAa,QAAoB,kBAAkB;AAS5D,IAAMC,GAAG,GAAGN,GAAG,CAACO,MAAM,CAAC,aAAa,CAAC;AAcrC,SAASC,iBAAiBA,CAACC,MAAkB,EAA6B;EACxE,OAAQA,MAAM,CAAqBC,aAAa,KAAKC,SAAS;AAChE;AAEA,OAAO,SAASC,sBAAsBA,CACpCH,MAAkB,EACc;EAChC,IAAMI,WAAW,GAAGJ,MAA8B;EAClD;EACA;EACA,OACE,CAAED,iBAAiB,CAACC,MAAM,CAAC,IACzBA,MAAM,CAACC,aAAa,KAAK,oBAAoB,IAC7CD,MAAM,CAACK,IAAI,KAAK,iBAAiB,KACnCD,WAAW,CAACE,SA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iL,aAAa,CAACF,QAAQ,CAAC;IACpD,IAAIxD,YAAY,IAAI,IAAI,EAAE;MACxB,OAAO,IAAI;IACb;IAEA,IAAIxH,aAAa,CAACwH,YAAY,CAAC,EAAE;MAC/BA,YAAY,CAACtH,KAAK,CAAC,CAAC;IACtB;IACA,OAAOsH,YAAY;EACrB;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAO2D,aAAaA,CAACzI,MAAoB,EAAiB;IACxD,OAAO,IAAI0I,OAAO,CAACC,OAAO,IAAI;MAC5B,IAAI3I,MAAM,CAAC4I,aAAa,EAAE;QACxBD,OAAO,CAAC,CAAC;QACT;MACF;MACA,IAAME,MAAM,GAAGA,CAAA,KAAY;QACzB7I,MAAM,CAACsF,GAAG,CAAC,aAAa,EAAEuD,MAAM,CAAC;QACjCF,OAAO,CAAC,CAAC;MACX,CAAC;MACD3I,MAAM,CAACyF,EAAE,CAAC,aAAa,EAAEoD,MAAM,CAAC;IAClC,CAAC,CAAC;EACJ;AACF;AAACC,eAAA,CAv5BKpL,WAAW,4BACiB,iCAAiC;AAw5BnE,eAAeA,WAAW","ignoreList":[]}
1
+ {"version":3,"file":"LayoutUtils.js","names":["deepEqual","nanoid","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","rowOrColConfig","contentItems","addChild","child","isCorrectType","isColumn","isRow","removeChild","maintainFocusElement","document","activeElement","newParent","_newParent$config","_newParent$config2","inverseRowOrColConfig","layoutManager","createContentItem","height","width","replaceChild","getAllStackContainers","layout","_findAllStackContainers","getFocusedStackIndex","allStacks","findIndex","header","tabs","some","tab","classList","contains","getFocusedStack","focusedStackIndex","getStackById","item","searchId","_item$config","allowEmptyStack","id","Error","concat","i","getContentItemById","_item$config2","getStackForConfig","createIfNecessary","matchComponentType","getStackForComponentTypes","types","isLastType","dehydrateLayoutConfig","dehydrateComponent","dehydratedConfig","itemConfig","content","dehydratedComponent","push","debug2","layoutItemConfig","_objectSpread","getTabPoint","glContainer","tabRect","getBoundingClientRect","left","bottom","dropLayoutMinorChange","activeItemIndex","props","panelState","irisGridState","sorts","quickFilters","gridState","isStuckToBottom","isStuckToRight","isEqual","layout1","layout2","major","layout1Clone","cloneLayout","layout2Clone","JSON","parse","stringify","hydrateLayoutConfig","hydrateComponent","hydratedConfig","_itemConfig$id","_itemConfig$props","contentConfig","warn","openComponent","_ref","configParam","_ref$stack","stackParam","_ref$replaceExisting","replaceExisting","_ref$replaceConfig","replaceConfig","_ref$createNewStack","createNewStack","_ref$focusElement","focusElement","_ref$dragEvent","dragEvent","createDragSourceFromEvent","searchConfig","oldContentItem","onComponentCreated","event","debug","off","origin","requestAnimationFrame","on","index","indexOf","openComponentInStack","closeComponent","closeOptions","container","close","renameComponent","newTitle","setTitle","cloneComponent","_config$props","getPanelComponentState","cloneConfig","title","_config$componentStat","componentState","_config$props2","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 deepEqual from 'fast-deep-equal';\nimport { nanoid } from 'nanoid';\nimport isMatch from 'lodash.ismatch';\nimport Log from '@deephaven/log';\nimport type GoldenLayout from '@deephaven/golden-layout';\nimport {\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 ReactComponentConfig,\n Stack,\n Tab,\n CloseOptions,\n GLPanelProps,\n} from '@deephaven/golden-layout';\nimport { assertNotNull, type Brand } from '@deephaven/utils';\nimport { type DashboardLayoutConfig } from '../DashboardLayout';\nimport {\n type PanelConfig,\n type DehydratedPanelProps,\n type DehydratedDashboardPanelProps,\n type DehydratedPanelConfig,\n} from '../DashboardPlugin';\n\nconst log = Log.module('LayoutUtils');\n\ntype LayoutConfig = { id?: string; component?: string };\n\nexport type PanelId = Brand<'PanelId', string | undefined>;\n\nexport type LayoutPanel = {\n props: GLPanelProps;\n};\n\nexport type StackItemConfig = ItemConfig & {\n activeItemIndex?: number;\n};\n\nfunction isComponentConfig(config: ItemConfig): config is ComponentConfig {\n return (config as ComponentConfig).componentName !== undefined;\n}\n\nexport function isReactComponentConfig(\n config: ItemConfig\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: ItemConfig): 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<ItemConfig>): 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 if (isRoot(parent)) {\n const rowOrColConfig: ItemConfig = {\n type: columnPreferred ? 'column' : 'row',\n };\n\n if (parent.contentItems == null || parent.contentItems.length === 0) {\n parent.addChild(rowOrColConfig);\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(rowOrColConfig);\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\n // This is usually triggered because we hit a stack within the last row/column\n if (!isCorrectType) {\n const inverseRowOrColConfig = parent.layoutManager.createContentItem(\n {\n type: !columnPreferred ? 'column' : 'row',\n height: newParent.config?.height,\n width: newParent.config?.width,\n },\n parent\n );\n parent.replaceChild(newParent, inverseRowOrColConfig);\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 all stack containers in the layout\n * @param layout GoldenLayout instance\n * @returns The found stack containers\n */\n static getAllStackContainers(layout: GoldenLayout): Stack[] {\n // eslint-disable-next-line no-underscore-dangle\n return layout._findAllStackContainers();\n }\n\n /**\n * Get the index of the stack that is currently focused\n * @param allStacks All the stacks\n * @returns The focused stack's index or -1 if not found\n */\n static getFocusedStackIndex(allStacks: Stack[]): number {\n // NOTE: We target the 'lm_focusin' class because GoldenLayout automatically applies this class\n // to tab elements when they receive focus. Until we enhance focus tracking in GoldenLayout, we\n // will have to rely on this internal CSS class.\n return allStacks.findIndex(stack =>\n stack.header.tabs.some(tab =>\n tab.element[0].classList.contains('lm_focusin')\n )\n );\n }\n\n /**\n * Get the stack that is currently focused\n * @param layout GoldenLayout instance\n * @returns The focused stack or undefined if none found\n */\n static getFocusedStack(layout: GoldenLayout): Stack | undefined {\n const allStacks = LayoutUtils.getAllStackContainers(layout);\n const focusedStackIndex = LayoutUtils.getFocusedStackIndex(allStacks);\n return allStacks[focusedStackIndex];\n }\n\n /**\n * Gets a stack by its ID\n * @param item Golden layout content item to search for the stack\n * @param searchId the ID\n */\n static getStackById(\n item: ContentItem,\n searchId: string | string[],\n allowEmptyStack = false\n ): Stack | null {\n if (allowEmptyStack && isStack(item) && item.contentItems.length === 0) {\n return item;\n }\n\n if (searchId === item.config?.id) {\n if (isStack(item)) {\n return item as Stack;\n }\n throw new Error(`Item with ID ${searchId} is not a stack`);\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 stack = this.getStackById(\n item.contentItems[i],\n searchId,\n allowEmptyStack\n );\n if (stack) {\n return stack;\n }\n }\n\n return null;\n }\n\n /**\n * Gets a content item by its ID\n * @param item Golden layout content item to search for the content item. Typically the root.\n * @param searchId the ID\n */\n static getContentItemById(\n item: ContentItem,\n searchId: string | string[]\n ): ContentItem | null {\n if (item.config?.id === searchId) {\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 = this.getContentItemById(\n item.contentItems[i],\n searchId\n );\n if (contentItem) {\n return contentItem;\n }\n }\n\n return null;\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<ItemConfig> = {},\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<ItemConfig>,\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 as { component?: string }).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<ItemConfig>\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: ItemConfig[],\n dehydrateComponent: (\n componentName: string,\n config: PanelConfig\n ) => DehydratedPanelConfig\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 { content } = itemConfig;\n if (isReactComponentConfig(itemConfig)) {\n const dehydratedComponent = dehydrateComponent(\n itemConfig.component,\n itemConfig\n );\n if (dehydratedComponent != null) {\n dehydratedConfig.push(dehydratedComponent);\n } else {\n log.debug2(\n `dehydrateLayoutConfig: skipping unmapped component \"${itemConfig.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 * 4. isStuckToBottom/isStuckToRight\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 itemConfig.props.panelState.gridState.isStuckToBottom = false;\n itemConfig.props.panelState.gridState.isStuckToRight = false;\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 const layout1Clone = LayoutUtils.cloneLayout(layout1);\n const layout2Clone = LayoutUtils.cloneLayout(layout2);\n if (major) {\n LayoutUtils.dropLayoutMinorChange(layout1Clone);\n LayoutUtils.dropLayoutMinorChange(layout2Clone);\n return deepEqual(layout1Clone, layout2Clone);\n }\n // Pass cloned layouts to avoid false negatives\n // when comparing layouts with undefined and missing properties\n return deepEqual(layout1Clone, layout2Clone);\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 props: DehydratedPanelProps\n ) => DehydratedDashboardPanelProps\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 ?? nanoid(),\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 stack: stackParam = undefined,\n replaceExisting = true,\n replaceConfig = undefined,\n createNewStack = false,\n focusElement = undefined,\n dragEvent = undefined,\n }: {\n root?: ContentItem;\n config?: Partial<ReactComponentConfig>;\n stack?: Stack;\n replaceExisting?: boolean;\n replaceConfig?: Partial<ItemConfig>;\n createNewStack?: boolean;\n focusElement?: string;\n dragEvent?: MouseEvent;\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 = nanoid();\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 =\n stackParam ??\n (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: ItemConfig & 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<ItemConfig>,\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: nanoid(),\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: ItemConfig): 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 ): ItemConfig | 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(glContainer: Container): PanelId | null {\n const config = LayoutUtils.getComponentConfigFromContainer(glContainer);\n if (config) {\n return config.id as PanelId;\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: LayoutPanel): PanelId | null {\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: LayoutPanel): 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":";;;;;AAAA,OAAOA,SAAS,MAAM,iBAAiB;AACvC,SAASC,MAAM,QAAQ,QAAQ;AAC/B,OAAOC,OAAO,MAAM,gBAAgB;AACpC,OAAOC,GAAG,MAAM,gBAAgB;AAEhC,SACEC,WAAW,EACXC,MAAM,EACNC,OAAO,EACPC,uBAAuB,QAClB,0BAA0B;AAajC,SAASC,aAAa,QAAoB,kBAAkB;AAS5D,IAAMC,GAAG,GAAGN,GAAG,CAACO,MAAM,CAAC,aAAa,CAAC;AAcrC,SAASC,iBAAiBA,CAACC,MAAkB,EAA6B;EACxE,OAAQA,MAAM,CAAqBC,aAAa,KAAKC,SAAS;AAChE;AAEA,OAAO,SAASC,sBAAsBA,CACpCH,MAAkB,EACc;EAChC,IAAMI,WAAW,GAAGJ,MAA8B;EAClD;EACA;EACA,OACE,CAAED,iBAAiB,CAACC,MAAM,CAAC,IACzBA,MAAM,CAACC,aAAa,KAAK,oBAAoB,IA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AAM,CAAC;IAClC,CAAC,CAAC;EACJ;AACF;AAACC,eAAA,CAv5BK7L,WAAW,4BACiB,iCAAiC;AAw5BnE,eAAeA,WAAW","ignoreList":[]}
@@ -7,29 +7,22 @@ import usePanelRegistration from "./usePanelRegistration.js";
7
7
  * Register a panel that will be opened when one of the `supportedTypes` objects is triggered.
8
8
  */
9
9
  export function useDashboardPanel(_ref) {
10
- var {
11
- dashboardProps,
12
- componentName,
13
- component,
14
- supportedTypes,
15
- hydrate,
16
- dehydrate
17
- } = _ref;
18
- var {
19
- id,
20
- layout,
21
- registerComponent
22
- } = dashboardProps;
10
+ var dashboardProps = _ref.dashboardProps,
11
+ componentName = _ref.componentName,
12
+ component = _ref.component,
13
+ supportedTypes = _ref.supportedTypes,
14
+ hydrate = _ref.hydrate,
15
+ dehydrate = _ref.dehydrate;
16
+ var id = dashboardProps.id,
17
+ layout = dashboardProps.layout,
18
+ registerComponent = dashboardProps.registerComponent;
23
19
  var handlePanelOpen = useCallback(_ref2 => {
24
- var {
25
- dragEvent,
26
- panelId = nanoid(),
27
- widget
28
- } = _ref2;
29
- var {
30
- name,
31
- type
32
- } = widget;
20
+ var dragEvent = _ref2.dragEvent,
21
+ _ref2$panelId = _ref2.panelId,
22
+ panelId = _ref2$panelId === void 0 ? nanoid() : _ref2$panelId,
23
+ widget = _ref2.widget;
24
+ var name = widget.name,
25
+ type = widget.type;
33
26
  var isSupportedType = type != null && (Array.isArray(supportedTypes) && supportedTypes.includes(type) || type === supportedTypes);
34
27
  if (!isSupportedType) {
35
28
  // Only want to listen for your custom variable types
@@ -49,9 +42,7 @@ export function useDashboardPanel(_ref) {
49
42
  title: name !== null && name !== void 0 ? name : undefined,
50
43
  id: panelId
51
44
  };
52
- var {
53
- root
54
- } = layout;
45
+ var root = layout.root;
55
46
  LayoutUtils.openComponent({
56
47
  root,
57
48
  config,
@@ -1 +1 @@
1
- {"version":3,"file":"useDashboardPanel.js","names":["useCallback","nanoid","usePanelOpenListener","LayoutUtils","usePanelRegistration","useDashboardPanel","_ref","dashboardProps","componentName","component","supportedTypes","hydrate","dehydrate","id","layout","registerComponent","handlePanelOpen","_ref2","dragEvent","panelId","widget","name","type","isSupportedType","Array","isArray","includes","props","localDashboardId","metadata","config","title","undefined","root","openComponent","eventHub"],"sources":["../../src/layout/useDashboardPanel.ts"],"sourcesContent":["import { type ComponentType, useCallback } from 'react';\nimport type { ReactComponentConfig } from '@deephaven/golden-layout';\nimport { nanoid } from 'nanoid';\nimport {\n type DashboardPanelProps,\n type DashboardPluginComponentProps,\n type DehydratedDashboardPanelProps,\n type PanelComponentType,\n type PanelDehydrateFunction,\n type PanelHydrateFunction,\n} from '../DashboardPlugin';\nimport { type PanelOpenEventDetail, usePanelOpenListener } from '../PanelEvent';\nimport LayoutUtils from './LayoutUtils';\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 ({ dragEvent, panelId = nanoid(), widget }: PanelOpenEventDetail) => {\n const { name, type } = widget;\n const isSupportedType =\n type != null &&\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 let props: DehydratedDashboardPanelProps = {\n localDashboardId: id,\n metadata: widget,\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 ?? undefined,\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 usePanelOpenListener(layout.eventHub, handlePanelOpen);\n}\n\nexport default useDashboardPanel;\n"],"mappings":"AAAA,SAA6BA,WAAW,QAAQ,OAAO;AAEvD,SAASC,MAAM,QAAQ,QAAQ;AAAC,SASIC,oBAAoB;AAAA,OACjDC,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,GAAGhB,WAAW,CACjCiB,KAAA,IAAqE;IAAA,IAApE;MAAEC,SAAS;MAAEC,OAAO,GAAGlB,MAAM,CAAC,CAAC;MAAEmB;IAA6B,CAAC,GAAAH,KAAA;IAC9D,IAAM;MAAEI,IAAI;MAAEC;IAAK,CAAC,GAAGF,MAAM;IAC7B,IAAMG,eAAe,GACnBD,IAAI,IAAI,IAAI,KACVE,KAAK,CAACC,OAAO,CAACf,cAAc,CAAC,IAAIA,cAAc,CAACgB,QAAQ,CAACJ,IAAI,CAAC,IAC9DA,IAAI,KAAKZ,cAAc,CAAC;IAC5B,IAAI,CAACa,eAAe,EAAE;MACpB;MACA;IACF;IACA,IAAII,KAAoC,GAAG;MACzCC,gBAAgB,EAAEf,EAAE;MACpBgB,QAAQ,EAAET;IACZ,CAAC;IACD,IAAIT,OAAO,IAAI,IAAI,EAAE;MACnBgB,KAAK,GAAGhB,OAAO,CAACgB,KAAK,EAAEd,EAAE,CAAC;IAC5B;IACA,IAAMiB,MAA4B,GAAG;MACnCR,IAAI,EAAE,iBAAiB;MACvBb,SAAS,EAAED,aAAa;MACxBmB,KAAK;MACLI,KAAK,EAAEV,IAAI,aAAJA,IAAI,cAAJA,IAAI,GAAIW,SAAS;MACxBnB,EAAE,EAAEM;IACN,CAAC;IAED,IAAM;MAAEc;IAAK,CAAC,GAAGnB,MAAM;IACvBX,WAAW,CAAC+B,aAAa,CAAC;MAAED,IAAI;MAAEH,MAAM;MAAEZ;IAAU,CAAC,CAAC;EACxD,CAAC,EACD,CAACV,aAAa,EAAEG,OAAO,EAAEE,EAAE,EAAEC,MAAM,EAAEJ,cAAc,CACrD,CAAC;;EAED;AACF;AACA;EACEN,oBAAoB,CAACW,iBAAiB,EAAEN,SAAS,EAAEE,OAAO,EAAEC,SAAS,CAAC;;EAEtE;AACF;AACA;EACEV,oBAAoB,CAACY,MAAM,CAACqB,QAAQ,EAAEnB,eAAe,CAAC;AACxD;AAEA,eAAeX,iBAAiB","ignoreList":[]}
1
+ {"version":3,"file":"useDashboardPanel.js","names":["useCallback","nanoid","usePanelOpenListener","LayoutUtils","usePanelRegistration","useDashboardPanel","_ref","dashboardProps","componentName","component","supportedTypes","hydrate","dehydrate","id","layout","registerComponent","handlePanelOpen","_ref2","dragEvent","_ref2$panelId","panelId","widget","name","type","isSupportedType","Array","isArray","includes","props","localDashboardId","metadata","config","title","undefined","root","openComponent","eventHub"],"sources":["../../src/layout/useDashboardPanel.ts"],"sourcesContent":["import { type ComponentType, useCallback } from 'react';\nimport type { ReactComponentConfig } from '@deephaven/golden-layout';\nimport { nanoid } from 'nanoid';\nimport {\n type DashboardPanelProps,\n type DashboardPluginComponentProps,\n type DehydratedDashboardPanelProps,\n type PanelComponentType,\n type PanelDehydrateFunction,\n type PanelHydrateFunction,\n} from '../DashboardPlugin';\nimport { type PanelOpenEventDetail, usePanelOpenListener } from '../PanelEvent';\nimport LayoutUtils from './LayoutUtils';\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 ({ dragEvent, panelId = nanoid(), widget }: PanelOpenEventDetail) => {\n const { name, type } = widget;\n const isSupportedType =\n type != null &&\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 let props: DehydratedDashboardPanelProps = {\n localDashboardId: id,\n metadata: widget,\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 ?? undefined,\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 usePanelOpenListener(layout.eventHub, handlePanelOpen);\n}\n\nexport default useDashboardPanel;\n"],"mappings":"AAAA,SAA6BA,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B,KAAK,GAAGjB,OAAO,CAACiB,KAAK,EAAEf,EAAE,CAAC;IAC5B;IACA,IAAMkB,MAA4B,GAAG;MACnCR,IAAI,EAAE,iBAAiB;MACvBd,SAAS,EAAED,aAAa;MACxBoB,KAAK;MACLI,KAAK,EAAEV,IAAI,aAAJA,IAAI,cAAJA,IAAI,GAAIW,SAAS;MACxBpB,EAAE,EAAEO;IACN,CAAC;IAED,IAAQc,IAAI,GAAKpB,MAAM,CAAfoB,IAAI;IACZ/B,WAAW,CAACgC,aAAa,CAAC;MAAED,IAAI;MAAEH,MAAM;MAAEb;IAAU,CAAC,CAAC;EACxD,CAAC,EACD,CAACV,aAAa,EAAEG,OAAO,EAAEE,EAAE,EAAEC,MAAM,EAAEJ,cAAc,CACrD,CAAC;;EAED;AACF;AACA;EACEN,oBAAoB,CAACW,iBAAiB,EAAEN,SAAS,EAAEE,OAAO,EAAEC,SAAS,CAAC;;EAEtE;AACF;AACA;EACEV,oBAAoB,CAACY,MAAM,CAACsB,QAAQ,EAAEpB,eAAe,CAAC;AACxD;AAEA,eAAeX,iBAAiB","ignoreList":[]}
@@ -1,7 +1,15 @@
1
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
1
7
  import { reducerRegistry } from '@deephaven/redux';
2
8
  import reducers from "./reducers/index.js";
3
9
  Object.entries(reducers).map(_ref => {
4
- var [name, reducer] = _ref;
10
+ var _ref2 = _slicedToArray(_ref, 2),
11
+ name = _ref2[0],
12
+ reducer = _ref2[1];
5
13
  return reducerRegistry.register(name, reducer);
6
14
  });
7
15
  export { reducers };
@@ -1 +1 @@
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 './hooks';\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;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["reducerRegistry","reducers","Object","entries","map","_ref","_ref2","_slicedToArray","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 './hooks';\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,IAAAC,KAAA,GAAAC,cAAA,CAAAF,IAAA;IAAEG,IAAI,GAAAF,KAAA;IAAEG,OAAO,GAAAH,KAAA;EAAA,OAC1CN,eAAe,CAACU,QAAQ,CAACF,IAAI,EAAEC,OAAO,CAAC;AAAA,CACzC,CAAC;AAED,SAASR,QAAQ;AAAG;AAAA;AAAA;AAAA","ignoreList":[]}
package/dist/useFiber.js CHANGED
@@ -1,3 +1,9 @@
1
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
1
7
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3
9
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
@@ -85,9 +91,7 @@ export class FiberProvider extends React.Component {
85
91
  _defineProperty(this, "_reactInternals", void 0);
86
92
  }
87
93
  render() {
88
- var {
89
- children
90
- } = this.props;
94
+ var children = this.props.children;
91
95
  return (
92
96
  /*#__PURE__*/
93
97
  // eslint-disable-next-line no-underscore-dangle
@@ -107,7 +111,9 @@ export function useFiber() {
107
111
  if (root === null) {
108
112
  throw new Error('useFiber must be called within a <FiberProvider />!');
109
113
  }
110
- var [id] = React.useState(() => nanoid());
114
+ var _React$useState = React.useState(() => nanoid()),
115
+ _React$useState2 = _slicedToArray(_React$useState, 1),
116
+ id = _React$useState2[0];
111
117
  var actualFiber = React.useMemo(() => {
112
118
  // eslint-disable-next-line no-restricted-syntax
113
119
  for (var maybeFiber of [root, root === null || root === void 0 ? void 0 : root.alternate].filter(r => r != null)) {
@@ -1 +1 @@
1
- {"version":3,"file":"useFiber.js","names":["nanoid","React","jsx","_jsx","traverseFiber","fiber","ascending","selector","child","return","match","sibling","wrapContext","context","Object","defineProperties","_currentRenderer","get","set","_currentRenderer2","_","FiberContext","createContext","displayName","FiberProvider","Component","constructor","arguments","_defineProperty","render","children","props","Provider","value","_reactInternals","useFiber","root","useContext","Error","id","useState","actualFiber","useMemo","maybeFiber","alternate","filter","r","node","state","memoizedState","next"],"sources":["../src/useFiber.tsx"],"sourcesContent":["/**\n * Adapted from https://www.npmjs.com/package/its-fine to support React 17.\n * The main change is using `nanoid` instead of `useId` which doesn't exist in React 17.\n * Also tweaked a bit of the code to match our style and removed the parts we don't use.\n */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { nanoid } from 'nanoid';\nimport * as React from 'react';\nimport type ReactReconciler from 'react-reconciler';\n\n/**\n * Represents a react-internal Fiber node.\n */\ntype Fiber<T = any> = Omit<ReactReconciler.Fiber, 'stateNode'> & {\n stateNode: T;\n};\n\n/**\n * Represents a {@link Fiber} node selector for traversal.\n */\ntype FiberSelector<T = any> = (\n /** The current {@link Fiber} node. */\n node: Fiber<T | null>\n) => boolean | void;\n\n/**\n * Traverses up or down a {@link Fiber}, return `true` to stop and select a node.\n */\nfunction traverseFiber<T = any>(\n /** Input {@link Fiber} to traverse. */\n fiber: Fiber | undefined,\n /** Whether to ascend and walk up the tree. Will walk down if `false`. */\n ascending: boolean,\n /** A {@link Fiber} node selector, returns the first match when `true` is passed. */\n selector: FiberSelector<T>\n): Fiber<T> | undefined {\n if (!fiber) {\n return;\n }\n if (selector(fiber) === true) {\n return fiber;\n }\n\n let child = ascending ? fiber.return : fiber.child;\n while (child) {\n const match = traverseFiber(child, ascending, selector);\n if (match) {\n return match;\n }\n\n child = ascending ? null : child.sibling;\n }\n}\n\n// In development, React will warn about using contexts between renderers.\n// Hide the warning because its-fine fixes this issue\n// https://github.com/facebook/react/pull/12779\nfunction wrapContext<T>(context: React.Context<T>): React.Context<T> {\n try {\n return Object.defineProperties(context, {\n _currentRenderer: {\n get() {\n return null;\n },\n set() {\n /* no-op */\n },\n },\n _currentRenderer2: {\n get() {\n return null;\n },\n set() {\n /* no-op */\n },\n },\n });\n } catch (_) {\n return context;\n }\n}\n\n// eslint-disable-next-line react-refresh/only-export-components\nconst FiberContext = /* @__PURE__ */ wrapContext(\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n /* @__PURE__ */ React.createContext<Fiber>(null!)\n);\nFiberContext.displayName = 'FiberContext';\n\n/**\n * A react-internal {@link Fiber} provider. This component binds React children to the React Fiber tree. Call its-fine hooks within this.\n */\nexport class FiberProvider extends React.Component<{\n children?: React.ReactNode;\n}> {\n private _reactInternals!: Fiber;\n\n render(): JSX.Element {\n const { children } = this.props;\n return (\n // eslint-disable-next-line no-underscore-dangle\n <FiberContext.Provider value={this._reactInternals}>\n {children}\n </FiberContext.Provider>\n );\n }\n}\n\n/**\n * Returns the current react-internal {@link Fiber}. This is an implementation detail of [react-reconciler](https://github.com/facebook/react/tree/main/packages/react-reconciler).\n */\nexport function useFiber(): Fiber<null> | undefined {\n const root = React.useContext(FiberContext);\n if (root === null) {\n throw new Error('useFiber must be called within a <FiberProvider />!');\n }\n\n const [id] = React.useState(() => nanoid());\n const actualFiber = React.useMemo(() => {\n // eslint-disable-next-line no-restricted-syntax\n for (const maybeFiber of [root, root?.alternate].filter(r => r != null)) {\n const fiber = traverseFiber<null>(maybeFiber, false, node => {\n let state = node.memoizedState;\n while (state != null) {\n if (state.memoizedState === id) {\n return true;\n }\n state = state.next;\n }\n });\n\n if (fiber) {\n return fiber;\n }\n }\n }, [root, id]);\n\n return actualFiber;\n}\n"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,QAAQ;AAC/B,OAAO,KAAKC,KAAK,MAAM,OAAO;;AAG9B;AACA;AACA;;AAKA;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AAQA;AACA;AACA;AACA,SAASC,aAAaA,CACpB;AACAC,KAAwB,EACxB;AACAC,SAAkB,EAClB;AACAC,QAA0B,EACJ;E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KAAK;IAC/B;MAAA;MACE;MACA5B,IAAA,CAACkB,YAAY,CAACW,QAAQ;QAACC,KAAK,EAAE,IAAI,CAACC,eAAgB;QAAAJ,QAAA,EAChDA;MAAQ,CACY;IAAC;EAE5B;AACF;;AAEA;AACA;AACA;AACA,OAAO,SAASK,QAAQA,CAAA,EAA4B;EAClD,IAAMC,IAAI,GAAGnC,KAAK,CAACoC,UAAU,CAAChB,YAAY,CAAC;EAC3C,IAAIe,IAAI,KAAK,IAAI,EAAE;IACjB,MAAM,IAAIE,KAAK,CAAC,qDAAqD,CAAC;EACxE;EAEA,IAAM,CAACC,EAAE,CAAC,GAAGtC,KAAK,CAACuC,QAAQ,CAAC,MAAMxC,MAAM,CAAC,CAAC,CAAC;EAC3C,IAAMyC,WAAW,GAAGxC,KAAK,CAACyC,OAAO,CAAC,MAAM;IACtC;IACA,KAAK,IAAMC,UAAU,IAAI,CAACP,IAAI,EAAEA,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEQ,SAAS,CAAC,CAACC,MAAM,CAACC,CAAC,IAAIA,CAAC,IAAI,IAAI,CAAC,EAAE;MACvE,IAAMzC,KAAK,GAAGD,aAAa,CAAOuC,UAAU,EAAE,KAAK,EAAEI,IAAI,IAAI;QAC3D,IAAIC,KAAK,GAAGD,IAAI,CAACE,aAAa;QAC9B,OAAOD,KAAK,IAAI,IAAI,EAAE;UACpB,IAAIA,KAAK,CAACC,aAAa,KAAKV,EAAE,EAAE;YAC9B,OAAO,IAAI;UACb;UACAS,KAAK,GAAGA,KAAK,CAACE,IAAI;QACpB;MACF,CAAC,CAAC;MAEF,IAAI7C,KAAK,EAAE;QACT,OAAOA,KAAK;MACd;IACF;EACF,CAAC,EAAE,CAAC+B,IAAI,EAAEG,EAAE,CAAC,CAAC;EAEd,OAAOE,WAAW;AACpB","ignoreList":[]}
1
+ {"version":3,"file":"useFiber.js","names":["nanoid","React","jsx","_jsx","traverseFiber","fiber","ascending","selector","child","return","match","sibling","wrapContext","context","Object","defineProperties","_currentRenderer","get","set","_currentRenderer2","_","FiberContext","createContext","displayName","FiberProvider","Component","constructor","arguments","_defineProperty","render","children","props","Provider","value","_reactInternals","useFiber","root","useContext","Error","_React$useState","useState","_React$useState2","_slicedToArray","id","actualFiber","useMemo","maybeFiber","alternate","filter","r","node","state","memoizedState","next"],"sources":["../src/useFiber.tsx"],"sourcesContent":["/**\n * Adapted from https://www.npmjs.com/package/its-fine to support React 17.\n * The main change is using `nanoid` instead of `useId` which doesn't exist in React 17.\n * Also tweaked a bit of the code to match our style and removed the parts we don't use.\n */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { nanoid } from 'nanoid';\nimport * as React from 'react';\nimport type ReactReconciler from 'react-reconciler';\n\n/**\n * Represents a react-internal Fiber node.\n */\ntype Fiber<T = any> = Omit<ReactReconciler.Fiber, 'stateNode'> & {\n stateNode: T;\n};\n\n/**\n * Represents a {@link Fiber} node selector for traversal.\n */\ntype FiberSelector<T = any> = (\n /** The current {@link Fiber} node. */\n node: Fiber<T | null>\n) => boolean | void;\n\n/**\n * Traverses up or down a {@link Fiber}, return `true` to stop and select a node.\n */\nfunction traverseFiber<T = any>(\n /** Input {@link Fiber} to traverse. */\n fiber: Fiber | undefined,\n /** Whether to ascend and walk up the tree. Will walk down if `false`. */\n ascending: boolean,\n /** A {@link Fiber} node selector, returns the first match when `true` is passed. */\n selector: FiberSelector<T>\n): Fiber<T> | undefined {\n if (!fiber) {\n return;\n }\n if (selector(fiber) === true) {\n return fiber;\n }\n\n let child = ascending ? fiber.return : fiber.child;\n while (child) {\n const match = traverseFiber(child, ascending, selector);\n if (match) {\n return match;\n }\n\n child = ascending ? null : child.sibling;\n }\n}\n\n// In development, React will warn about using contexts between renderers.\n// Hide the warning because its-fine fixes this issue\n// https://github.com/facebook/react/pull/12779\nfunction wrapContext<T>(context: React.Context<T>): React.Context<T> {\n try {\n return Object.defineProperties(context, {\n _currentRenderer: {\n get() {\n return null;\n },\n set() {\n /* no-op */\n },\n },\n _currentRenderer2: {\n get() {\n return null;\n },\n set() {\n /* no-op */\n },\n },\n });\n } catch (_) {\n return context;\n }\n}\n\n// eslint-disable-next-line react-refresh/only-export-components\nconst FiberContext = /* @__PURE__ */ wrapContext(\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n /* @__PURE__ */ React.createContext<Fiber>(null!)\n);\nFiberContext.displayName = 'FiberContext';\n\n/**\n * A react-internal {@link Fiber} provider. This component binds React children to the React Fiber tree. Call its-fine hooks within this.\n */\nexport class FiberProvider extends React.Component<{\n children?: React.ReactNode;\n}> {\n private _reactInternals!: Fiber;\n\n render(): JSX.Element {\n const { children } = this.props;\n return (\n // eslint-disable-next-line no-underscore-dangle\n <FiberContext.Provider value={this._reactInternals}>\n {children}\n </FiberContext.Provider>\n );\n }\n}\n\n/**\n * Returns the current react-internal {@link Fiber}. This is an implementation detail of [react-reconciler](https://github.com/facebook/react/tree/main/packages/react-reconciler).\n */\nexport function useFiber(): Fiber<null> | undefined {\n const root = React.useContext(FiberContext);\n if (root === null) {\n throw new Error('useFiber must be called within a <FiberProvider />!');\n }\n\n const [id] = React.useState(() => nanoid());\n const actualFiber = React.useMemo(() => {\n // eslint-disable-next-line no-restricted-syntax\n for (const maybeFiber of [root, root?.alternate].filter(r => r != null)) {\n const fiber = traverseFiber<null>(maybeFiber, false, node => {\n let state = node.memoizedState;\n while (state != null) {\n if (state.memoizedState === id) {\n return true;\n }\n state = state.next;\n }\n });\n\n if (fiber) {\n return fiber;\n }\n }\n }, [root, id]);\n\n return actualFiber;\n}\n"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,QAAQ;AAC/B,OAAO,KAAKC,KAAK,MAAM,OAAO;;AAG9B;AACA;AACA;;AAKA;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AAQA;AACA;AACA;AACA,SAASC,aAAaA,CACpB;AACAC,KAAwB,EACxB;AACAC,SAAkB,EAClB;AACAC,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