diff --git a/examples/react-workspace-example/build.js b/examples/react-workspace-example/build.js new file mode 100644 index 0000000000..44be9a5f78 --- /dev/null +++ b/examples/react-workspace-example/build.js @@ -0,0 +1,38 @@ +// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ +// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃ +// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃ +// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃ +// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃ +// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ +// ┃ Copyright (c) 2017, the Perspective Authors. ┃ +// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃ +// ┃ This file is part of the Perspective library, distributed under the terms ┃ +// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃ +// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ + +import esbuild from "esbuild"; +import fs from "fs"; +import path from "path"; +import { fileURLToPath } from "url"; +import { dirname } from "path"; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +await esbuild.build({ + entryPoints: ["src/index.tsx"], + outdir: "dist", + format: "esm", + bundle: true, + sourcemap: "linked", + target: "es2022", + loader: { + ".arrow": "file", + ".wasm": "file", + }, + assetNames: "[name]", +}); + +fs.writeFileSync( + path.join(__dirname, "dist/index.html"), + fs.readFileSync(path.join(__dirname, "src/index.html")).toString() +); diff --git a/examples/react-workspace-example/globals.d.ts b/examples/react-workspace-example/globals.d.ts new file mode 100644 index 0000000000..26ce93c67f --- /dev/null +++ b/examples/react-workspace-example/globals.d.ts @@ -0,0 +1,21 @@ +// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ +// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃ +// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃ +// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃ +// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃ +// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ +// ┃ Copyright (c) 2017, the Perspective Authors. ┃ +// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃ +// ┃ This file is part of the Perspective library, distributed under the terms ┃ +// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃ +// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ + +declare module "*.wasm" { + const content: string; + export default content; +} + +declare module "*.arrow" { + const content: string; + export default content; +} diff --git a/examples/react-workspace-example/package.json b/examples/react-workspace-example/package.json new file mode 100644 index 0000000000..cc649f4a37 --- /dev/null +++ b/examples/react-workspace-example/package.json @@ -0,0 +1,29 @@ +{ + "name": "react-workspace-example", + "private": true, + "version": "3.7.4", + "description": "An example app using @finos/perspective-react and its workspace component", + "type": "module", + "scripts": { + "build": "node build.js", + "start": "node build.js && http-server dist" + }, + "keywords": [], + "license": "Apache-2.0", + "dependencies": { + "@finos/perspective": "workspace:^", + "@finos/perspective-viewer": "workspace:^", + "@finos/perspective-viewer-d3fc": "workspace:^", + "@finos/perspective-viewer-datagrid": "workspace:^", + "@finos/perspective-react": "workspace:^", + "react": "^18.0.0", + "react-dom": "^18.0.0", + "superstore-arrow": "^3.0.0" + }, + "devDependencies": { + "esbuild": "^0.25.5", + "http-server": "^14.1.1", + "@types/react": "^18", + "@types/react-dom": "^18" + } +} diff --git a/examples/react-workspace-example/src/index.css b/examples/react-workspace-example/src/index.css new file mode 100644 index 0000000000..dd60379436 --- /dev/null +++ b/examples/react-workspace-example/src/index.css @@ -0,0 +1,68 @@ +/* ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ + * ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃ + * ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃ + * ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃ + * ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃ + * ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ + * ┃ Copyright (c) 2017, the Perspective Authors. ┃ + * ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃ + * ┃ This file is part of the Perspective library, distributed under the terms ┃ + * ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃ + * ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ + */ + +body { + margin: 0; + background-color: #f0f0f0; + font-family: "ui-monospace", "SFMono-Regular", "SF Mono", "Menlo", + "Consolas", "Liberation Mono", monospace; +} + +.container { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + + display: grid; + gap: 8px; + grid-template-columns: 1fr 1fr; + grid-template-rows: 45px 1fr; +} + +perspective-viewer { + grid-row: 2; +} + +.toolbar { + grid-row: 1; + grid-column-start: 1; + grid-column-end: 3; + + display: flex; + flex-direction: row; + gap: 10px; + padding: 10px; + justify-content: stretch; + border-bottom: 1px solid #666; +} + +button { + font-family: "ui-monospace", "SFMono-Regular", "SF Mono", "Menlo", + "Consolas", "Liberation Mono", monospace; +} + +.workspace-container { + display: flex; + flex-direction: column; + + .workspace-toolbar { + display: flex; + flex-direction: row; + } + + perspective-workspace { + height: 100vh; + } +} \ No newline at end of file diff --git a/examples/react-workspace-example/src/index.html b/examples/react-workspace-example/src/index.html new file mode 100644 index 0000000000..d06e153a60 --- /dev/null +++ b/examples/react-workspace-example/src/index.html @@ -0,0 +1,19 @@ + + + +
+ +