From f13853258035ea35dd83d2051428dddce07a4244 Mon Sep 17 00:00:00 2001 From: vim-sroberge Date: Thu, 30 May 2024 16:58:34 -0400 Subject: [PATCH] fixes --- package.json | 2 +- src/bim/bimPanel.tsx | 43 ++++++++++++++++++++++--------------------- src/bim/bimTree.tsx | 4 ++-- src/component.tsx | 4 ++-- src/helpers/utils.ts | 10 +++++++++- src/panels/icons.tsx | 4 ++-- 6 files changed, 38 insertions(+), 29 deletions(-) diff --git a/package.json b/package.json index 6a9ff1d9..0607e470 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vim-webgl-component", - "version": "0.3.5", + "version": "0.3.7", "description": "A demonstration app built on top of the vim-webgl-viewer", "files": [ "dist" diff --git a/src/bim/bimPanel.tsx b/src/bim/bimPanel.tsx index c05dd151..35a487c6 100644 --- a/src/bim/bimPanel.tsx +++ b/src/bim/bimPanel.tsx @@ -13,10 +13,13 @@ import { Grouping, toTreeData } from './bimTreeData' import { ViewerState } from '../viewerState' import { AugmentedElement } from '../helpers/element' import { ComponentSettings, isFalse } from '../settings/settings' -import { whenAllTrue, whenTrue } from '../helpers/utils' +import { whenAllTrue, whenSomeTrue, whenTrue } from '../helpers/utils' import { BimInfoPanel } from './bimInfoPanel' import { BimInfoPanelRef } from './bimInfoData' +// Not sure why I need this, +// when I inline this method in component.tsx it causes an error. +// The error appears only in JSFiddle when the module is directly imported in a script tag. export function OptionalBimPanel (props: { viewer: VIM.Viewer camera: ComponentCamera @@ -27,13 +30,10 @@ export function OptionalBimPanel (props: { treeRef: React.MutableRefObject bimInfoRef: BimInfoPanelRef }) { - if ( - (isFalse(props.settings.ui.bimTreePanel) && - isFalse(props.settings.ui.bimInfoPanel)) - ) { - return null - } - return React.createElement(BimPanel, props) + return whenSomeTrue([ + props.settings.ui.bimTreePanel, + props.settings.ui.bimInfoPanel], + React.createElement(BimPanel, props)) } /** @@ -105,13 +105,15 @@ export function BimPanel (props: { const last = props.viewerState.selection[props.viewerState.selection.length - 1] - const full = isFalse(props.settings.ui.bimInfoPanel) + const fullTree = isFalse(props.settings.ui.bimInfoPanel) + const fullInfo = isFalse(props.settings.ui.bimTreePanel) + return ( -
+
{isFalse(props.settings.ui.bimTreePanel) ? null : ( -
0 ? '' : 'vc-hidden'}`}> +
0 ? '' : 'vc-hidden'}`}>

Project Inspector @@ -141,17 +143,16 @@ export function BimPanel (props: { ], divider()) } - {whenTrue(props.settings.ui.bimInfoPanel, -
- -
)} +
+ +
)}

) } diff --git a/src/bim/bimTree.tsx b/src/bim/bimTree.tsx index f5200e1d..299eb5ab 100644 --- a/src/bim/bimTree.tsx +++ b/src/bim/bimTree.tsx @@ -89,7 +89,7 @@ export function BimTree (props: { // Scroll view so that element is visible, if needed. useEffect(() => { - if (props.treeData && objects.length === 1) { + if (props.treeData && objects.length === 1 && div.current) { scrollToSelection(div.current) const [first] = props.viewer.selection.objects focus.current = props.treeData.getNodeFromElement(first.element) @@ -143,7 +143,7 @@ export function BimTree (props: { onBlur={() => (props.viewer.inputs.keyboard.arrowsEnabled = true)} > (item as VimTreeNode).title} diff --git a/src/component.tsx b/src/component.tsx index c7fece01..92cbfa9c 100644 --- a/src/component.tsx +++ b/src/component.tsx @@ -160,7 +160,7 @@ export function VimComponent (props: { const sidePanel = () => ( <> - + />} +