Skip to content

Commit 7ca6a34

Browse files
committed
WIP: UI dashboard
1 parent fc84ae7 commit 7ca6a34

20 files changed

Lines changed: 499 additions & 70 deletions

plugins/ui/src/deephaven/ui/components/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
from .panel import panel
66
from .spectrum import *
77
from .table import table
8+
from .row import row
9+
from .column import column
10+
from .stack import stack
11+
from .dashboard import dashboard
812
from . import html
913

1014

@@ -13,9 +17,11 @@
1317
"button",
1418
"button_group",
1519
"checkbox",
20+
"column",
1621
"component",
1722
"content",
1823
"contextual_help",
24+
"dashboard",
1925
"flex",
2026
"form",
2127
"fragment",
@@ -30,8 +36,10 @@
3036
"object_view",
3137
"panel",
3238
"range_slider",
39+
"row",
3340
"slider",
3441
"spectrum_element",
42+
"stack",
3543
"switch",
3644
"table",
3745
"tab_list",
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from __future__ import annotations
2+
3+
from typing import Any
4+
from ..elements import BaseElement
5+
6+
7+
def column(*children: Any, width: float | None = None, **kwargs: Any):
8+
"""
9+
A column is a container that can be used to group elements.
10+
Each element will be placed below its prior sibling.
11+
12+
Args:
13+
children: Elements to render in the column.
14+
width: The percent width of the column relative to other children of its parent. If not provided, the column will be sized automatically.
15+
"""
16+
return BaseElement(
17+
"deephaven.ui.components.Column", *children, width=width, **kwargs
18+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from __future__ import annotations
2+
3+
from typing import Any
4+
from ..elements import BaseElement
5+
6+
7+
def dashboard(*children: Any, **kwargs: Any):
8+
"""
9+
A dashboard is the container for an entire layout.
10+
11+
Args:
12+
children: Elements to render in the dashboard. Must have only 1 root element.
13+
"""
14+
return BaseElement("deephaven.ui.components.Dashboard", *children, **kwargs)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from __future__ import annotations
2+
3+
from typing import Any
4+
from ..elements import BaseElement
5+
6+
7+
def row(*children: Any, height: float | None = None, **kwargs: Any):
8+
"""
9+
A row is a container that can be used to group elements.
10+
Each element will be placed to the right of its prior sibling.
11+
12+
Args:
13+
children: Elements to render in the row.
14+
height: The percent height of the row relative to other children of its parent. If not provided, the row will be sized automatically.
15+
"""
16+
return BaseElement(
17+
"deephaven.ui.components.Row", *children, height=height, **kwargs
18+
)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from __future__ import annotations
2+
3+
from typing import Any
4+
from ..elements import BaseElement
5+
6+
7+
def stack(
8+
*children: Any,
9+
height: float | None = None,
10+
width: float | None = None,
11+
activeItemIndex: int | None = None,
12+
**kwargs: Any,
13+
):
14+
"""
15+
A stack is a container that can be used to group elements which creates a set of tabs.
16+
Each element will get a tab and only one element can be visible at a time.
17+
18+
Args:
19+
children: Elements to render in the row.
20+
height: The percent height of the stack relative to other children of its parent. If not provided, the stack will be sized automatically.
21+
width: The percent width of the stack relative to other children of its parent. If not provided, the stack will be sized automatically.
22+
"""
23+
return BaseElement(
24+
"deephaven.ui.components.Stack",
25+
*children,
26+
height=height,
27+
width=width,
28+
activeItemIndex=activeItemIndex,
29+
**kwargs,
30+
)

plugins/ui/src/js/src/DocumentHandler.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { WidgetDefinition } from '@deephaven/dashboard';
33
import { TestUtils } from '@deephaven/utils';
44
import { render } from '@testing-library/react';
55
import DocumentHandler, { DocumentHandlerProps } from './DocumentHandler';
6-
import { PANEL_ELEMENT_NAME, ReactPanelProps } from './PanelUtils';
6+
import { PANEL_ELEMENT_NAME, ReactPanelProps } from './layout/LayoutUtils';
77
import { MixedPanelsError, NoChildrenError } from './errors';
88
import { getComponentForElement } from './WidgetUtils';
99

plugins/ui/src/js/src/DocumentUtils.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ export function getRootChildren(
3131
throw new MixedPanelsError('Cannot mix panel and non-panel elements');
3232
}
3333

34-
if (childPanelCount === 0) {
35-
// Just wrap it in a panel
36-
return (
37-
<ReactPanel
38-
key="root"
39-
title={definition.title ?? definition.id ?? definition.type}
40-
>
41-
{children}
42-
</ReactPanel>
43-
);
44-
}
34+
// if (childPanelCount === 0) {
35+
// // Just wrap it in a panel
36+
// return (
37+
// <ReactPanel
38+
// key="root"
39+
// title={definition.title ?? definition.id ?? definition.type}
40+
// >
41+
// {children}
42+
// </ReactPanel>
43+
// );
44+
// }
4545

4646
// It's already got panels defined, just return it
4747
return children;

plugins/ui/src/js/src/ElementUtils.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { WidgetExportedObject } from '@deephaven/jsapi-types';
2-
import { ReactNode } from 'react';
32

43
export const CALLABLE_KEY = '__dhCbid';
54
export const OBJECT_KEY = '__dhObid';
@@ -32,15 +31,6 @@ export type ElementNode<
3231
props?: P;
3332
};
3433

35-
export type ElementNodeWithChildren<
36-
K extends string = string,
37-
P extends Record<string, unknown> = Record<string, unknown>
38-
> = ElementNode<K, P> & {
39-
props: P & {
40-
children: ReactNode;
41-
};
42-
};
43-
4434
export function isObjectNode(obj: unknown): obj is ObjectNode {
4535
return obj != null && typeof obj === 'object' && OBJECT_KEY in obj;
4636
}

plugins/ui/src/js/src/PanelUtils.test.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

plugins/ui/src/js/src/PanelUtils.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)