diff --git a/package-lock.json b/package-lock.json index 5cc66a1e..15501e3a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "MIT", "dependencies": { "@supabase/supabase-js": "^2.31.0", + "file-saver": "^2.0.5", "mathjs": "^11.9.1", "monaco-editor": "^0.40.0", "solid-js": "^1.7.8", @@ -19,6 +20,7 @@ "devDependencies": { "@storybook/html-vite": "^7.1.1", "@tweakpane/core": "^2.0.1", + "@types/file-saver": "^2.0.7", "@types/jest": "^29.5.3", "@types/three": "^0.154.0", "autoprefixer": "^10.4.14", @@ -69,11 +71,13 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.22.5", + "version": "7.23.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.23.5.tgz", + "integrity": "sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA==", "dev": true, - "license": "MIT", "dependencies": { - "@babel/highlight": "^7.22.5" + "@babel/highlight": "^7.23.4", + "chalk": "^2.4.2" }, "engines": { "node": ">=6.9.0" @@ -119,12 +123,12 @@ } }, "node_modules/@babel/generator": { - "version": "7.22.9", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.22.9.tgz", - "integrity": "sha512-KtLMbmicyuK2Ak/FTCJVbDnkN1SlT8/kceFTiuDiiRUUSMnHMidxSCdG4ndkTOHHpoomWe/4xkvHkEOncwjYIw==", + "version": "7.23.5", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.5.tgz", + "integrity": "sha512-BPssCHrBD+0YrxviOa3QzpqwhNIXKEtOa2jQrm4FlmkC2apYgRnQcmPWiGZDlGxiNtltnUFolMe8497Esry+jA==", "dev": true, "dependencies": { - "@babel/types": "^7.22.5", + "@babel/types": "^7.23.5", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -231,20 +235,22 @@ } }, "node_modules/@babel/helper-environment-visitor": { - "version": "7.22.5", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", "dev": true, - "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-function-name": { - "version": "7.22.5", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz", + "integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==", "dev": true, - "license": "MIT", "dependencies": { - "@babel/template": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/template": "^7.22.15", + "@babel/types": "^7.23.0" }, "engines": { "node": ">=6.9.0" @@ -388,17 +394,19 @@ } }, "node_modules/@babel/helper-string-parser": { - "version": "7.22.5", + "version": "7.23.4", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.23.4.tgz", + "integrity": "sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ==", "dev": true, - "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.22.5", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", + "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", "dev": true, - "license": "MIT", "engines": { "node": ">=6.9.0" } @@ -440,12 +448,13 @@ } }, "node_modules/@babel/highlight": { - "version": "7.22.5", + "version": "7.23.4", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.23.4.tgz", + "integrity": "sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A==", "dev": true, - "license": "MIT", "dependencies": { - "@babel/helper-validator-identifier": "^7.22.5", - "chalk": "^2.0.0", + "@babel/helper-validator-identifier": "^7.22.20", + "chalk": "^2.4.2", "js-tokens": "^4.0.0" }, "engines": { @@ -453,9 +462,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.22.7", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.7.tgz", - "integrity": "sha512-7NF8pOkHP5o2vpmGgNGcfAeCvOYhGLyA3Z4eBQkT1RJlWu47n63bCs93QfJ2hIAFCil7L5P2IWhs1oToVgrL0Q==", + "version": "7.23.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.5.tgz", + "integrity": "sha512-hOOqoiNXrmGdFbhgCzu6GiURxUgM27Xwd/aPuu8RfHEZPBzL1Z54okAHAQjXfcQNwvrlkAmAp4SlRTZ45vlthQ==", "dev": true, "bin": { "parser": "bin/babel-parser.js" @@ -1955,32 +1964,33 @@ } }, "node_modules/@babel/template": { - "version": "7.22.5", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", + "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", "dev": true, - "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.22.5", - "@babel/parser": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/code-frame": "^7.22.13", + "@babel/parser": "^7.22.15", + "@babel/types": "^7.22.15" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.22.8", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.8.tgz", - "integrity": "sha512-y6LPR+wpM2I3qJrsheCTwhIinzkETbplIgPBbwvqPKc+uljeA5gP+3nP8irdYt1mjQaDnlIcG+dw8OjAco4GXw==", + "version": "7.23.5", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.5.tgz", + "integrity": "sha512-czx7Xy5a6sapWWRx61m1Ke1Ra4vczu1mCTtJam5zRTBOonfdJ+S/B6HYmGYu3fJtr8GGET3si6IhgWVBhJ/m8w==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.22.5", - "@babel/generator": "^7.22.7", - "@babel/helper-environment-visitor": "^7.22.5", - "@babel/helper-function-name": "^7.22.5", + "@babel/code-frame": "^7.23.5", + "@babel/generator": "^7.23.5", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-function-name": "^7.23.0", "@babel/helper-hoist-variables": "^7.22.5", "@babel/helper-split-export-declaration": "^7.22.6", - "@babel/parser": "^7.22.7", - "@babel/types": "^7.22.5", + "@babel/parser": "^7.23.5", + "@babel/types": "^7.23.5", "debug": "^4.1.0", "globals": "^11.1.0" }, @@ -1989,12 +1999,13 @@ } }, "node_modules/@babel/types": { - "version": "7.22.5", + "version": "7.23.5", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.5.tgz", + "integrity": "sha512-ON5kSOJwVO6xXVRTvOI0eOnWe7VdUcIpsovGo9U/Br4Ie4UVFQTboO2cYnDhAGU6Fp+UxSiT+pMft0SMHfuq6w==", "dev": true, - "license": "MIT", "dependencies": { - "@babel/helper-string-parser": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.5", + "@babel/helper-string-parser": "^7.23.4", + "@babel/helper-validator-identifier": "^7.22.20", "to-fast-properties": "^2.0.0" }, "engines": { @@ -4193,6 +4204,12 @@ "@types/send": "*" } }, + "node_modules/@types/file-saver": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/@types/file-saver/-/file-saver-2.0.7.tgz", + "integrity": "sha512-dNKVfHd/jk0SkR/exKGj2ggkB45MAkzvWCaqLUUgkyjITkGNzH8H+yUwr+BLJUBjZOe9w8X3wgmXhZDRg1ED6A==", + "dev": true + }, "node_modules/@types/find-cache-dir": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/@types/find-cache-dir/-/find-cache-dir-3.2.1.tgz", @@ -4526,8 +4543,9 @@ }, "node_modules/ansi-styles": { "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, - "license": "MIT", "dependencies": { "color-convert": "^1.9.0" }, @@ -5248,8 +5266,9 @@ }, "node_modules/chalk": { "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "dev": true, - "license": "MIT", "dependencies": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", @@ -5432,16 +5451,18 @@ }, "node_modules/color-convert": { "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "dev": true, - "license": "MIT", "dependencies": { "color-name": "1.1.3" } }, "node_modules/color-name": { "version": "1.1.3", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true }, "node_modules/colord": { "version": "2.9.3", @@ -6303,8 +6324,9 @@ }, "node_modules/escape-string-regexp": { "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "dev": true, - "license": "MIT", "engines": { "node": ">=0.8.0" } @@ -6584,6 +6606,11 @@ "dev": true, "license": "MIT" }, + "node_modules/file-saver": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.5.tgz", + "integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA==" + }, "node_modules/file-system-cache": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/file-system-cache/-/file-system-cache-2.3.0.tgz", @@ -7147,8 +7174,9 @@ }, "node_modules/has-flag": { "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true, - "license": "MIT", "engines": { "node": ">=4" } @@ -10230,7 +10258,9 @@ } }, "node_modules/nanoid": { - "version": "3.3.6", + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", + "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", "dev": true, "funding": [ { @@ -10238,7 +10268,6 @@ "url": "https://github.com/sponsors/ai" } ], - "license": "MIT", "bin": { "nanoid": "bin/nanoid.cjs" }, @@ -10819,9 +10848,9 @@ } }, "node_modules/postcss": { - "version": "8.4.27", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.27.tgz", - "integrity": "sha512-gY/ACJtJPSmUFPDCHtX78+01fHa64FaU4zaaWfuh1MhGJISufJAH4cun6k/8fwsHYeK4UQmENQK+tRLCFJE8JQ==", + "version": "8.4.32", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.32.tgz", + "integrity": "sha512-D/kj5JNu6oo2EIy+XL/26JEDTlIbB8hw85G8StOE6L74RQAVVP5rej6wxCNqyMbR4RkPfqvezVbPw81Ngd6Kcw==", "dev": true, "funding": [ { @@ -10838,7 +10867,7 @@ } ], "dependencies": { - "nanoid": "^3.3.6", + "nanoid": "^3.3.7", "picocolors": "^1.0.0", "source-map-js": "^1.0.2" }, @@ -11645,9 +11674,10 @@ } }, "node_modules/rollup": { - "version": "3.26.2", + "version": "3.29.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.29.4.tgz", + "integrity": "sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw==", "dev": true, - "license": "MIT", "bin": { "rollup": "dist/bin/rollup" }, @@ -12243,8 +12273,9 @@ }, "node_modules/supports-color": { "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "dev": true, - "license": "MIT", "dependencies": { "has-flag": "^3.0.0" }, @@ -13084,14 +13115,14 @@ } }, "node_modules/vite": { - "version": "4.4.7", - "resolved": "https://registry.npmjs.org/vite/-/vite-4.4.7.tgz", - "integrity": "sha512-6pYf9QJ1mHylfVh39HpuSfMPojPSKVxZvnclX1K1FyZ1PXDOcLBibdq5t1qxJSnL63ca8Wf4zts6mD8u8oc9Fw==", + "version": "4.5.1", + "resolved": "https://registry.npmjs.org/vite/-/vite-4.5.1.tgz", + "integrity": "sha512-AXXFaAJ8yebyqzoNB9fu2pHoo/nWX+xZlaRwoeYUxEqBO+Zj4msE5G+BhGBll9lYEKv9Hfks52PAF2X7qDYXQA==", "dev": true, "dependencies": { "esbuild": "^0.18.10", - "postcss": "^8.4.26", - "rollup": "^3.25.2" + "postcss": "^8.4.27", + "rollup": "^3.27.1" }, "bin": { "vite": "bin/vite.js" diff --git a/package.json b/package.json index 25edb1cb..811969b1 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "devDependencies": { "@storybook/html-vite": "^7.1.1", "@tweakpane/core": "^2.0.1", + "@types/file-saver": "^2.0.7", "@types/jest": "^29.5.3", "@types/three": "^0.154.0", "autoprefixer": "^10.4.14", @@ -49,6 +50,7 @@ }, "dependencies": { "@supabase/supabase-js": "^2.31.0", + "file-saver": "^2.0.5", "mathjs": "^11.9.1", "monaco-editor": "^0.40.0", "solid-js": "^1.7.8", diff --git a/src/App/App.tsx b/src/App/App.tsx index ce402946..4de0e1b7 100644 --- a/src/App/App.tsx +++ b/src/App/App.tsx @@ -24,6 +24,7 @@ import { EditorBar } from "../EditorBar/EditorBar"; import { Parameters, ParametersType } from "../Parameters/Parameters"; import { Login, supabase } from "../Login/Login"; import { Axes } from "../Viewer/objects/Axes"; +import { Export } from "../Export/Export"; export const staging = localStorage.getItem("staging") ? true : false; @@ -78,7 +79,6 @@ export const analysisResults = analyzing(nodes, elements, assignments);`; deformedShape: true, elementResults: "none", nodeResults: "none", - hideEditor: false, }; const settings = createMutable(defaultSettings); const [script, setScript] = createSignal(""); @@ -87,6 +87,7 @@ export const analysisResults = analyzing(nodes, elements, assignments);`; const [undeformedNodes, setUndeformedNodes] = createSignal([]); const [deformedNodes, setDeformedNodes] = createSignal([]); const [elements, setElements] = createSignal([]); + const [assignments, setAssignments] = createSignal([]); const [nodeSupports, setNodeSupports] = createSignal([]); const [nodeLoads, setNodeLoads] = createSignal([]); const [elementResults, setElementResults] = createSignal([]); @@ -183,19 +184,6 @@ export const analysisResults = analyzing(nodes, elements, assignments);`; ) ); - // on settings.hideEditor change: hide the editor based on both settings and project-user ownership - createEffect( - on([() => settings.hideEditor], async () => { - const projectUserID = new URL(window.location.href).searchParams.get( - "user_id" - ); - const currentUserID = (await supabase.auth.getSession()).data.session - ?.user?.id; - settings.hideEditor = - settings.hideEditor && projectUserID != currentUserID; - }) - ); - // on undeformed node change: compute deformed nodes createEffect( on(undeformedNodes, () => { @@ -244,6 +232,7 @@ export const analysisResults = analyzing(nodes, elements, assignments);`; setError(undefined); setUndeformedNodes(e.data.nodes); setElements(e.data.elements); + setAssignments(e.data.assignments); setNodeSupports(e.data.nodeSupports); setNodeLoads(e.data.nodeLoads); setNodeResults(e.data.nodeResults); @@ -260,7 +249,7 @@ export const analysisResults = analyzing(nodes, elements, assignments);`; } return ( - + + + ); } diff --git a/src/App/solveWorker.ts b/src/App/solveWorker.ts index 8c25422f..59142e8b 100644 --- a/src/App/solveWorker.ts +++ b/src/App/solveWorker.ts @@ -66,6 +66,7 @@ self.onmessage = async (e) => { nodeLoads, nodeResults, elementResults, + assignments, settings: module?.settings || {}, }); }; diff --git a/src/Export/CheckBoxWithLabel.tsx b/src/Export/CheckBoxWithLabel.tsx new file mode 100644 index 00000000..d6737e0c --- /dev/null +++ b/src/Export/CheckBoxWithLabel.tsx @@ -0,0 +1,21 @@ +import { ExportOptionsEnum } from "./export.types"; + +type checkBoxProps = { + Label: string; + OnChange: Function; + Property: boolean; +}; + +export function CheckBoxWithLabel(props: checkBoxProps) { + return ( + + ); +} diff --git a/src/Export/Export.tsx b/src/Export/Export.tsx new file mode 100644 index 00000000..387983b6 --- /dev/null +++ b/src/Export/Export.tsx @@ -0,0 +1,169 @@ +import { For, createSignal } from "solid-js"; +import { createStore } from "solid-js/store"; +import { exportToJSON } from "./exportToJSON"; +import FileSaver from "file-saver"; +import { + ExportOptions, + ExportOptionsEnum, + FileType, + exportProps, +} from "./export.types"; +import { CheckBoxWithLabel } from "./CheckBoxWithLabel"; + +export function Export(props: exportProps) { + const [fileType, setFileType] = createSignal(FileType.JSON); + const [exportOptions, SetExportOptions] = createStore({ + nodes: true, + elements: true, + supports: true, + loads: false, + properties: false, + analysisResults: false, + }); + + async function onExport(event: any) { + let jsonObject = exportToJSON( + props.nodes, + props.elements, + props.assignments, + props.analysisResults, + exportOptions + ); + + var blob = new Blob([jsonObject], { type: "text/plain;charset=utf-8" }); + FileSaver.saveAs(blob, `awatif-model.${fileType()}`); + + document?.getElementById("ExportModal_closeButton")?.click(); + } + + function fileTypeChange(event: Event) { + const target = event.target as HTMLSelectElement; + setFileType(target.value as FileType); + } + + function setOptions(event: Event, option: ExportOptionsEnum) { + const target = event.target as HTMLInputElement; + + switch (option) { + case ExportOptionsEnum.Loads: + SetExportOptions("loads", target.checked); + break; + case ExportOptionsEnum.Nodes: + SetExportOptions("nodes", target.checked); + break; + case ExportOptionsEnum.AnalysisResults: + SetExportOptions("analysisResults", target.checked); + break; + case ExportOptionsEnum.Elements: + SetExportOptions("elements", target.checked); + break; + case ExportOptionsEnum.Properties: + SetExportOptions("properties", target.checked); + break; + case ExportOptionsEnum.Supports: + SetExportOptions("supports", target.checked); + break; + default: + break; + } + } + + return ( + <> + + + + + + + + ); +} diff --git a/src/Export/export.types.ts b/src/Export/export.types.ts new file mode 100644 index 00000000..0af4e99f --- /dev/null +++ b/src/Export/export.types.ts @@ -0,0 +1,26 @@ +export enum FileType { + JSON = "JSON", +} +export type exportProps = { + nodes: any; + elements: any; + assignments: any[]; + analysisResults: any; +}; +export enum ExportOptionsEnum { + Nodes = "Nodes", + Elements = "Elements", + Supports = "Supports", + Loads = "Loads", + Properties = "Properties", + AnalysisResults = "Analysis Results", +} + +export type ExportOptions = { + nodes: boolean; + elements: boolean; + supports: boolean; + loads: boolean; + properties: boolean; + analysisResults: boolean; +}; diff --git a/src/Export/exportToJSON.test.ts b/src/Export/exportToJSON.test.ts index 0a9fb39d..702878be 100644 --- a/src/Export/exportToJSON.test.ts +++ b/src/Export/exportToJSON.test.ts @@ -1,4 +1,5 @@ -import { exportToJSON, ExportOptions } from "./exportToJSON"; +import { exportToJSON } from "./exportToJSON"; +import { ExportOptions } from "./export.types"; describe("exportToJson", () => { const nodes = [ diff --git a/src/Export/exportToJSON.ts b/src/Export/exportToJSON.ts index 089eceb5..d97fa9e4 100644 --- a/src/Export/exportToJSON.ts +++ b/src/Export/exportToJSON.ts @@ -1,11 +1,4 @@ -export type ExportOptions = { - nodes: boolean; - elements: boolean; - supports: boolean; - loads: boolean; - properties: boolean; - analysisResults: boolean; -}; +import { ExportOptions } from "./export.types"; export function exportToJSON( nodes: any, diff --git a/src/Layouter/Layouter.stories-dev.tsx b/src/Layouter/Layouter.stories-dev.tsx index f3ff219b..5c48a973 100644 --- a/src/Layouter/Layouter.stories-dev.tsx +++ b/src/Layouter/Layouter.stories-dev.tsx @@ -6,13 +6,15 @@ export const Default: StoryObj = {}; export default { title: "Layouter", render: () => ( - +
EditorBar
Editor
Login
+
Viewer
Setting
Parameters
+
Export
), } as Meta; diff --git a/src/Layouter/Layouter.tsx b/src/Layouter/Layouter.tsx index 8f094e15..d3991fb9 100644 --- a/src/Layouter/Layouter.tsx +++ b/src/Layouter/Layouter.tsx @@ -1,8 +1,7 @@ -import { children, onMount, ParentComponent, Show } from "solid-js"; +import { children, onMount } from "solid-js"; type LayouterProps = { children: any; - hideEditor: boolean; }; export function Layouter(props: LayouterProps) { @@ -13,75 +12,51 @@ export function Layouter(props: LayouterProps) { const c = children(() => props.children).toArray(); onMount(() => { - if (!props.hideEditor) { - let x = 0; - let dx = 0; - let leftViewWidth = 0; - - // on pointer down - resizerHorizontal.addEventListener("pointerdown", (e) => { - x = e.clientX; - leftViewWidth = leftView.getBoundingClientRect().width; - - document.addEventListener("pointermove", pointerMoveHandlerHorizontal); - }); - - // on pointer move - const pointerMoveHandlerHorizontal = (e: PointerEvent): void => { - dx = e.clientX - x; - leftView.style.width = `${leftViewWidth + dx}px`; - document.body.style.cursor = "col-resize"; - resizerHorizontal.style.cursor = "col-resize"; - - container.style.userSelect = "none"; - container.style.pointerEvents = "none"; - }; - - // on pointer up - document.addEventListener("pointerup", () => { - document.body.style.removeProperty("cursor"); - document.removeEventListener( - "pointermove", - pointerMoveHandlerHorizontal - ); - container.style.removeProperty("user-select"); - container.style.removeProperty("pointer-events"); - }); - } + let x = 0; + let dx = 0; + let leftViewWidth = 0; + + // on pointer down + resizerHorizontal.addEventListener("pointerdown", (e) => { + x = e.clientX; + leftViewWidth = leftView.getBoundingClientRect().width; + + document.addEventListener("pointermove", pointerMoveHandlerHorizontal); + }); + + // on pointer move + const pointerMoveHandlerHorizontal = (e: PointerEvent): void => { + dx = e.clientX - x; + leftView.style.width = `${leftViewWidth + dx}px`; + document.body.style.cursor = "col-resize"; + resizerHorizontal.style.cursor = "col-resize"; + + container.style.userSelect = "none"; + container.style.pointerEvents = "none"; + }; + + // on pointer up + document.addEventListener("pointerup", () => { + document.body.style.removeProperty("cursor"); + document.removeEventListener("pointermove", pointerMoveHandlerHorizontal); + container.style.removeProperty("user-select"); + container.style.removeProperty("pointer-events"); + }); }); return (
- -
- {c[0]} - {c[1]} - {c[2]} -
-
-
- {c[3]} - {c[4]} - {c[5]} -
- - } +
-
- {c[3]} - {c[4]} - {c[5]} -
- + {c.slice(0, 2)} +
+
+
{c.slice(3)}
); } diff --git a/src/Settings/Settings.tsx b/src/Settings/Settings.tsx index 259c857e..b653288a 100644 --- a/src/Settings/Settings.tsx +++ b/src/Settings/Settings.tsx @@ -13,7 +13,6 @@ export type SettingsType = { deformedShape: boolean; elementResults: string; nodeResults: string; - hideEditor: boolean; }; export type SettingsProps = {