Skip to content

Commit 240ee68

Browse files
authored
Inspector v2: Add exports for inspector and shared ui components needed for extending inspector features (#17174)
This PR is mostly about adding the needed exports to extend the inspector with new features. This includes: 1. Exports from the inspector package itself - these I did selectively from the root index.ts, because what should be part of the public API is only a subset of what is used internally within the inspector itself and future internal tool usage. 2. Exports from the shared ui package - these I did with an index.ts hierarchy as the intention is that 95% of the Fluent directory should be exported, so I thought this made more sense for this case. I also included a small change in this PR where Scene Explorer now hides empty sections (e.g. if there are no post proesses, the "Post Processes" section won't be displayed). This is to minimize the noise/cognitive load when you are only using a subset of the Babylon features.
1 parent ca70334 commit 240ee68

File tree

5 files changed

+84
-17
lines changed

5 files changed

+84
-17
lines changed

packages/dev/inspector-v2/src/components/scene/sceneExplorer.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,12 @@ export const SceneExplorer: FunctionComponent<{
560560
visibleItems.add(sceneTreeItem);
561561

562562
for (const sectionTreeItem of sectionTreeItems) {
563+
const children = sectionTreeItem.children;
563564
traversedItems.push(sectionTreeItem);
565+
if (!children.length) {
566+
continue;
567+
}
568+
564569
// Section tree items are always visible when not filtering.
565570
if (!filter) {
566571
visibleItems.add(sectionTreeItem);
@@ -569,7 +574,7 @@ export const SceneExplorer: FunctionComponent<{
569574
// When an item filter is present, always traverse the full scene graph (e.g. ignore the open item state).
570575
if (filter || openItems.has(sectionTreeItem.sectionName)) {
571576
TraverseGraph(
572-
sectionTreeItem.children,
577+
children,
573578
// Get children
574579
(treeItem) => {
575580
if (filter || openItems.has(treeItem.entity.uniqueId)) {
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,61 @@
1+
// Export the parts of inspector that are intended to be part of the public API.
2+
export * from "./components/properties/boundProperty";
3+
export * from "./components/properties/linkToEntityPropertyLine";
4+
export { EntityBase, EntityDisplayInfo, SceneExplorerCommand, SceneExplorerCommandProvider, SceneExplorerSection } from "./components/scene/sceneExplorer";
5+
export * from "./components/extensibleAccordion";
6+
export { Pane as PaneContainer } from "./components/pane";
7+
export * from "./components/teachingMoment";
8+
export * from "./extensibility/extensionFeed";
9+
export * from "./hooks/compoundPropertyHooks";
10+
export * from "./hooks/instrumentationHooks";
11+
export * from "./hooks/observableHooks";
12+
export * from "./hooks/pollingHooks";
13+
export * from "./hooks/resourceHooks";
14+
export * from "./hooks/settingsHooks";
15+
export * from "./hooks/teachingMomentHooks";
16+
export * from "./instrumentation/functionInstrumentation";
17+
export * from "./instrumentation/propertyInstrumentation";
18+
export * from "./modularity/serviceDefinition";
19+
export { IPropertiesService, PropertiesServiceIdentity } from "./services/panes/properties/propertiesService";
20+
export { ISceneExplorerService, SceneExplorerServiceIdentity } from "./services/panes/scene/sceneExplorerService";
21+
export { IDebugService, DebugServiceIdentity } from "./services/panes/debugService";
22+
export { ISettingsService, SettingsServiceIdentity } from "./services/panes/settingsService";
23+
export { IStatsService, StatsServiceIdentity } from "./services/panes/statsService";
24+
export { IToolsService, ToolsServiceIdentity } from "./services/panes/toolsService";
25+
export * from "./services/sceneContext";
26+
export * from "./services/selectionService";
27+
export * from "./services/settingsContext";
28+
export { IShellService, ToolbarItem, SidePane, CentralContent, ShellServiceIdentity } from "./services/shellService";
129
export * from "./inspector";
30+
31+
// Export the shared primitive UI controls that can be used for extending the inspector.
32+
export * from "shared-ui-components/fluent/primitives/accordion";
33+
export * from "shared-ui-components/fluent/primitives/button";
34+
export * from "shared-ui-components/fluent/primitives/checkbox";
35+
export * from "shared-ui-components/fluent/primitives/collapse";
36+
export * from "shared-ui-components/fluent/primitives/colorPicker";
37+
export * from "shared-ui-components/fluent/primitives/comboBox";
38+
export * from "shared-ui-components/fluent/primitives/draggable";
39+
export * from "shared-ui-components/fluent/primitives/dropdown";
40+
export * from "shared-ui-components/fluent/primitives/gradient";
41+
export * from "shared-ui-components/fluent/primitives/infoLabel";
42+
export * from "shared-ui-components/fluent/primitives/lazyComponent";
43+
export * from "shared-ui-components/fluent/primitives/link";
44+
export * from "shared-ui-components/fluent/primitives/list";
45+
export * from "shared-ui-components/fluent/primitives/messageBar";
46+
export * from "shared-ui-components/fluent/primitives/positionedPopover";
47+
export * from "shared-ui-components/fluent/primitives/primitive";
48+
export * from "shared-ui-components/fluent/primitives/searchBar";
49+
export * from "shared-ui-components/fluent/primitives/searchBox";
50+
export * from "shared-ui-components/fluent/primitives/spinButton";
51+
export * from "shared-ui-components/fluent/primitives/switch";
52+
export * from "shared-ui-components/fluent/primitives/syncedSlider";
53+
export * from "shared-ui-components/fluent/primitives/textarea";
54+
export * from "shared-ui-components/fluent/primitives/textInput";
55+
export * from "shared-ui-components/fluent/primitives/toggleButton";
56+
57+
// Export the shared hoc UI controls that can be used for extending the inspector.
58+
export * from "shared-ui-components/fluent/hoc/buttonLine";
59+
export * from "shared-ui-components/fluent/hoc/fileUploadLine";
60+
export * from "shared-ui-components/fluent/hoc/gradientList";
61+
export * from "shared-ui-components/fluent/hoc/pane";

packages/dev/sharedUiComponents/src/fluent/primitives/spinButton.tsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { makeStyles, SpinButton as FluentSpinButton, useId, tokens } from "@fluentui/react-components";
22
import type { SpinButtonOnChangeData, SpinButtonChangeEvent } from "@fluentui/react-components";
3-
import type { FunctionComponent, KeyboardEvent, FocusEvent } from "react";
3+
import type { FunctionComponent, KeyboardEvent } from "react";
44
import { useEffect, useState, useRef } from "react";
55
import type { PrimitiveProps } from "./primitive";
66
import { InfoLabel } from "./infoLabel";
7+
import { HandleKeyDown, HandleOnBlur } from "./utils";
78

89
const useSpinStyles = makeStyles({
910
base: {
@@ -140,17 +141,3 @@ function PrecisionRound(value: number, precision: number) {
140141
const exp = Math.pow(10, precision);
141142
return Math.round(value * exp) / exp;
142143
}
143-
144-
export function HandleOnBlur(event: FocusEvent<HTMLInputElement>) {
145-
event.stopPropagation();
146-
event.preventDefault();
147-
}
148-
149-
export function HandleKeyDown(event: KeyboardEvent<HTMLInputElement>) {
150-
event.stopPropagation(); // Prevent event propagation
151-
152-
// Prevent Enter key from causing form submission or value reversion
153-
if (event.key === "Enter") {
154-
event.preventDefault();
155-
}
156-
}

packages/dev/sharedUiComponents/src/fluent/primitives/textInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { InputOnChangeData } from "@fluentui/react-components";
44
import { Input as FluentInput, makeStyles, tokens, useId } from "@fluentui/react-components";
55
import type { PrimitiveProps } from "./primitive";
66
import { InfoLabel } from "./infoLabel";
7-
import { HandleOnBlur, HandleKeyDown } from "./spinButton";
7+
import { HandleOnBlur, HandleKeyDown } from "./utils";
88

99
const useInputStyles = makeStyles({
1010
base: {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type { KeyboardEvent, FocusEvent } from "react";
2+
3+
export function HandleOnBlur(event: FocusEvent<HTMLInputElement>) {
4+
event.stopPropagation();
5+
event.preventDefault();
6+
}
7+
8+
export function HandleKeyDown(event: KeyboardEvent<HTMLInputElement>) {
9+
event.stopPropagation(); // Prevent event propagation
10+
11+
// Prevent Enter key from causing form submission or value reversion
12+
if (event.key === "Enter") {
13+
event.preventDefault();
14+
}
15+
}

0 commit comments

Comments
 (0)