2020
2121import perspective from "@perspective-dev/client" ;
2222import perspective_viewer from "@perspective-dev/viewer" ;
23+ import perspective_workspace from "@perspective-dev/workspace" ;
24+ import "@perspective-dev/workspace" ;
2325import "@perspective-dev/viewer-datagrid" ;
2426import "@perspective-dev/viewer-d3fc" ;
2527
28+ import * as React from "react" ;
29+ import { createRoot } from "react-dom/client" ;
30+ import {
31+ PerspectiveViewer ,
32+ PerspectiveWorkspace ,
33+ } from "@perspective-dev/react" ;
34+
35+ import "@perspective-dev/viewer/dist/css/themes.css" ;
36+ import "@perspective-dev/workspace/dist/css/pro.css" ;
37+ import "./index.css" ;
38+
39+ import type * as psp from "@perspective-dev/client" ;
40+ import type * as pspViewer from "@perspective-dev/viewer" ;
41+
42+ import SUPERSTORE_ARROW from "superstore-arrow/superstore.lz4.arrow" ;
43+
2644import SERVER_WASM from "@perspective-dev/server/dist/wasm/perspective-server.wasm" ;
2745import CLIENT_WASM from "@perspective-dev/viewer/dist/wasm/perspective-viewer.wasm" ;
2846
@@ -37,11 +55,6 @@ await Promise.all([
3755// table creation function which both downloads data and loads it into the
3856// engine.
3957
40- import type * as psp from "@perspective-dev/client" ;
41- import type * as pspViewer from "@perspective-dev/viewer" ;
42-
43- import SUPERSTORE_ARROW from "superstore-arrow/superstore.lz4.arrow" ;
44-
4558const WORKER = await perspective . worker ( ) ;
4659
4760async function createNewSuperstoreTable ( ) : Promise < psp . Table > {
@@ -60,23 +73,22 @@ const CONFIG: pspViewer.ViewerConfigUpdate = {
6073
6174// The React application itself
6275
63- import * as React from "react" ;
64- import { createRoot } from "react-dom/client" ;
65- import { PerspectiveViewer } from "@perspective-dev/react" ;
66-
67- import "@perspective-dev/viewer/dist/css/themes.css" ;
68- import "./index.css" ;
69-
7076interface ToolbarState {
7177 mounted : boolean ;
7278 table ?: Promise < psp . Table > ;
7379 config : pspViewer . ViewerConfigUpdate ;
80+ layout : perspective_workspace . PerspectiveWorkspaceConfig ;
7481}
7582
7683const App : React . FC = ( ) => {
7784 const [ state , setState ] = React . useState < ToolbarState > ( ( ) => ( {
7885 mounted : true ,
7986 table : createNewSuperstoreTable ( ) ,
87+ layout : {
88+ detail : { main : null } ,
89+ sizes : [ ] ,
90+ viewers : { } ,
91+ } ,
8092 config : { ...CONFIG } ,
8193 } ) ) ;
8294
@@ -102,9 +114,19 @@ const App: React.FC = () => {
102114
103115 const onConfigUpdate = ( config : pspViewer . ViewerConfigUpdate ) => {
104116 console . log ( "Config Update Event" , config ) ;
117+ delete config . table ;
105118 setState ( { ...state , config } ) ;
106119 } ;
107120
121+ const onLayoutUpdate = (
122+ layout : perspective_workspace . PerspectiveWorkspaceConfig ,
123+ ) => {
124+ console . log ( "Layout Update Event" , layout ) ;
125+
126+ // delete config.table;
127+ setState ( { ...state , layout } ) ;
128+ } ;
129+
108130 const onClick = ( detail : pspViewer . PerspectiveClickEventDetail ) => {
109131 console . log ( "Click Event," , detail ) ;
110132 } ;
@@ -122,14 +144,19 @@ const App: React.FC = () => {
122144 </ div >
123145 { state . mounted && (
124146 < >
125- < PerspectiveViewer table = { state . table } />
147+ < PerspectiveViewer client = { state . table } />
126148 < PerspectiveViewer
127149 className = "my-perspective-viewer"
128- table = { state . table }
150+ client = { state . table }
129151 config = { state . config }
130152 onClick = { onClick }
131- onSelect = { onSelect }
132153 onConfigUpdate = { onConfigUpdate }
154+ onSelect = { onSelect }
155+ />
156+ < PerspectiveWorkspace
157+ client = { WORKER }
158+ layout = { state . layout }
159+ onLayoutUpdate = { onLayoutUpdate }
133160 />
134161 </ >
135162 ) }
0 commit comments