Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structure updates and internal documentation improvements #256

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
39665e0
Add notes from architecture dive meeting
nstrayer Dec 1, 2023
c3397ce
Merge BSLIb definitions
nstrayer Dec 1, 2023
c1e770f
Update gridlayout nodes
nstrayer Dec 1, 2023
3b5c791
Finish merging directory structure
nstrayer Dec 1, 2023
19c1c74
Better organize new unified node definition folder
nstrayer Dec 1, 2023
3187a4d
Add (currently optional) slot for ui component into the nodeInfoFacto…
nstrayer Dec 1, 2023
e792d8e
Add icon field to nodeInfoFactory
nstrayer Dec 1, 2023
119ba0f
Add support for custom settings form renderer in nodeInfoFactory() as…
nstrayer Dec 1, 2023
467a387
Add final component of the editor info object bundle to the nodeInfoF…
nstrayer Dec 1, 2023
5b84067
Switch ui_component field to be non-optional (lots of typescript errors)
nstrayer Dec 1, 2023
256b43b
Start fixing errors from the requirement of the ui component needing …
nstrayer Dec 1, 2023
3f2bc85
temporarily make the ui component not required again
nstrayer Dec 4, 2023
2c0659c
Update typescript version
nstrayer Dec 4, 2023
c2c9def
Merged all the node info to single blob setup
nstrayer Dec 4, 2023
13d2054
Start fixing errors by moving things to use the main info store
nstrayer Dec 4, 2023
966b59e
Fix bug with typescript type checking for component definitions
nstrayer Dec 4, 2023
a337264
Cleanup some typings
nstrayer Dec 4, 2023
ffa9cb4
Fix left-over debugging styles
nstrayer Dec 4, 2023
1f9c2fa
Upgrade vite version
nstrayer Dec 5, 2023
d2ca656
Remove duplicate nodes in registery
nstrayer Dec 5, 2023
e793bcc
Fix tab style bugs after switch and start moving more styles to tailwind
nstrayer Dec 5, 2023
556cb19
Remove string-array type from input types as it's never used and is c…
nstrayer Dec 12, 2023
7dd7fa3
Switch action button to tailwind styles
nstrayer Dec 12, 2023
82acd40
Remove external styles for numeric input
nstrayer Dec 12, 2023
e9e5cf2
Add docs for the settingsRenderer function
nstrayer Dec 12, 2023
7c0a16a
Add readme describing the structure of a node's definition
nstrayer Dec 12, 2023
d97ec53
Update snapshots on mac to reflect new order of elements palette
nstrayer Dec 12, 2023
34a6976
Commit build assets
nstrayer Dec 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion inst/communication-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dependencies": {
"editor": "*",
"shared-configs": "*",
"typescript": "^5.0.4"
"typescript": "^5.3.0"
},
"scripts": {
"type-check": "tsc -p ./ --noEmit",
Expand Down
4 changes: 2 additions & 2 deletions inst/editor-component-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"tailwindcss": "^3.3.3",
"shared-configs": "*",
"tsx": "^3.12.1",
"typescript": "^5.0.4",
"vite": "^4.2.1",
"typescript": "^5.3.0",
"vite": "^5.0.4",
"vite-tsconfig-paths": "^4.0.5"
}
}
3 changes: 3 additions & 0 deletions inst/editor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
How to get running with editor

TODO: Add info on getting development going on editor

Large diffs are not rendered by default.

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions inst/editor/build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Shiny UI Editor</title>
<script type="module" crossorigin src="./assets/index-f1413a39.js"></script>
<link rel="stylesheet" href="./assets/index-faf2b339.css">
<script type="module" crossorigin src="./assets/index-UWa3tAPI.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-R-rzO2Tn.css">
</head>

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root" style="height: 100vh; display: relative"></div>

</body>
</html>
4 changes: 2 additions & 2 deletions inst/editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@
"storybook": "^7.0.0-beta.47",
"tailwindcss": "^3.3.3",
"tsx": "^3.11.0",
"typescript": "^5.0.4",
"typescript": "^5.3.0",
"typescript-plugin-css-modules": "^5.0.1",
"vite": "^4.4.8",
"vite": "^5.0.4",
"vite-tsconfig-paths": "^4.2.0",
"vitest": "^0.30.1",
"yarn": "^1.22.19"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from "@playwright/experimental-ct-react";

import { IconSelector } from "../../src/Shiny-Ui-Elements/Bslib/ValueBox/IconSelector";
import { IconSelector } from "../../src/ui-node-definitions/Bslib/ValueBox/IconSelector";

test("Can choose icons with search", async ({ mount, page }) => {
let chosen_icon: string | null = null;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion inst/editor/src/DragAndDropHelpers/DropWatcherPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
import UiNode from "../components/UiNode/UiNode";
import { usePlaceNode } from "../state/usePlaceNode";
import type { PathElement, NodePath } from "../ui-node-definitions/NodePath";
import { makeChildPath } from "../ui-node-definitions/nodePathUtils";
import type { ShinyUiNode } from "../ui-node-definitions/ShinyUiNode";
import { getIsValidMove } from "../ui-node-definitions/TreeManipulation/getIsValidMove";
import type { WrappingNode } from "../ui-node-definitions/TreeManipulation/wrapInNode";
Expand All @@ -18,6 +17,7 @@ import {
getUiNodeTitle,
getUiNodeInfo,
} from "../ui-node-definitions/uiNodeTypes";
import { makeChildPath } from "../ui-node-definitions/utils/nodePathUtils";
import { mergeClasses } from "../utils/mergeClasses";

import type { DraggedNodeInfo } from "./DragAndDropHelpers";
Expand Down
6 changes: 5 additions & 1 deletion inst/editor/src/DragAndDropHelpers/useFilteredDrop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ function useDropHighlights({
// the layout shift from the drop mode can cause the mouse to leave the
// dragged item and thus prematurely terminate the drag event
setTimeout(() => {
watcherRef.current?.classList.add(canAcceptDropClass);
if (!watcherRef.current) return;

watcherRef.current.classList.add(canAcceptDropClass);
watcherRef.current.dataset.canAcceptDrop = "true";
}, 1);
}, [canAcceptDropClass, watcherRef]);

Expand All @@ -165,6 +168,7 @@ function useDropHighlights({

watcherRef.current.classList.remove(hoveringOverClass);
watcherRef.current.classList.remove(canAcceptDropClass);
watcherRef.current.dataset.canAcceptDrop = "false";
}, [canAcceptDropClass, hoveringOverClass, watcherRef]);

return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ShinyUiNode } from "../ui-node-definitions/ShinyUiNode";
import { walkUiNode } from "../ui-node-definitions/walkUiNode";
import { walkUiNode } from "../ui-node-definitions/utils/walkUiNode";

export function getAllInputOutputIdsInApp(ui_tree: ShinyUiNode): string[] {
const ids: string[] = [];
Expand Down
11 changes: 10 additions & 1 deletion inst/editor/src/ElementsPalette/UiElementIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
} from "../components/PopoverEl/FloatingPopover";
import { useMakeDraggable } from "../DragAndDropHelpers/useMakeDraggable";
import { getDefaultSettings } from "../SettingsPanel/buildStaticSettingsInfo";
import { getUiNodeIcon } from "../Shiny-Ui-Elements/registered_ui_nodes";
import type { ShinyUiNode } from "../ui-node-definitions/ShinyUiNode";
import type { ShinyUiNodeIds } from "../ui-node-definitions/uiNodeTypes";
import { getUiNodeInfo } from "../ui-node-definitions/uiNodeTypes";
Expand Down Expand Up @@ -52,3 +51,13 @@ export function UiElementIcon({ id }: { id: ShinyUiNodeIds }) {
</Tooltip>
);
}

/**
*
* @param id Name of ui node to look up
* @returns icon source for node or undefined if that icon doesn't exist
* @throws Error if node doesn't exist
*/
function getUiNodeIcon(id: string): string | undefined {
return getUiNodeInfo(id).iconSrc;
}
6 changes: 3 additions & 3 deletions inst/editor/src/ElementsPalette/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { LanguageMode } from "communication-types/src/AppInfo";

import { PanelHeader } from "../EditorLayout/PanelHeader";
import { registered_ui_nodes } from "../Shiny-Ui-Elements/registered_ui_nodes";
import { useLanguageMode } from "../state/languageMode";
import type { ShinyUiNodeInfo } from "../ui-node-definitions/uiNodeTypes";
import { all_node_info } from "../ui-node-definitions/uiNodeTypes";

import classes from "./styles.module.css";
import { UiElementIcon } from "./UiElementIcon";
Expand All @@ -23,7 +23,7 @@ const categoryOrder = Object.keys({
Uncategorized: 1,
} satisfies Record<Exclude<ShinyUiNodeInfo["category"], "TESTING">, 1>);

type NodeInfo = (typeof registered_ui_nodes)[number];
type NodeInfo = (typeof all_node_info)[number];

function sortByCategory(info_a: NodeInfo, info_b: NodeInfo): number {
const cat_a = categoryOrder.indexOf(info_a.category);
Expand All @@ -44,7 +44,7 @@ function filterToLanguage(info: NodeInfo, language: LanguageMode): boolean {
export default function ElementsPalette() {
const languageMode = useLanguageMode();

const ui_node_names = registered_ui_nodes
const ui_node_names = all_node_info
.filter((info) => filterToLanguage(info, languageMode))
.sort(sortByCategory)
.map((info) => info.id);
Expand Down
17 changes: 17 additions & 0 deletions inst/editor/src/SettingsPanel/FormBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,26 @@ import { UnknownArgumentsRender } from "./UnknownArgumentsRender";

type SettingsObj = Record<string, unknown>;

/**
* A function that can be used to render a custom form for a node.
*/
export type CustomFormRenderFn<Settings extends SettingsObj> = (x: {
/**
* A map keyed by the name of an argument with values that are react elements rendering the appropriate settings input for adjusting that argument.
*/
inputs: Record<StringKeys<Settings>, JSX.Element>;
/**
* The current values of the settings/ arugments for a node
*/
settings: Settings;

/**
* Callback that can be used to update an argument's value if more complex
* logic is needed than is provided in the component provided by the arguments `inputs` component.
* @param name Name of the argument to update
* @param action How to update the argument. Is an object with either `type: "UPDATE"` or `type: "REMOVE"` and a `value` property if the type is `UPDATE`
* @returns void
*/
onSettingsChange?: (name: string, action: SettingsUpdateAction) => void;
}) => JSX.Element;

Expand Down
6 changes: 1 addition & 5 deletions inst/editor/src/SettingsPanel/SettingsInput/valueIsType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
KnownInputFieldTypes,
InputTypeNames,
} from "../../ui-node-definitions/inputFieldTypes";
import { isShinyUiNode } from "../../ui-node-definitions/isShinyUiNode";
import { isShinyUiNode } from "../../ui-node-definitions/utils/isShinyUiNode";

// import type { InputTypeNames, KnownInputFieldTypes } from "../inputFieldTypes";

Expand Down Expand Up @@ -48,10 +48,6 @@ export function valueIsType(
return typeof value === "string";
}

if (type === "string-array") {
return Array.isArray(value) && typeof value[0] === "string";
}

if (type === "ui-node") {
return isShinyUiNode(value);
}
Expand Down
11 changes: 10 additions & 1 deletion inst/editor/src/SettingsPanel/SettingsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { ErrorBoundary } from "react-error-boundary";

import { GeneralErrorView } from "../components/ErrorCatcher/GeneralErrorView";
import { PanelHeader } from "../EditorLayout/PanelHeader";
import { getUiNodeSettingsRenderer } from "../Shiny-Ui-Elements/registered_ui_nodes";
import type { ShinyUiNode } from "../ui-node-definitions/ShinyUiNode";
import { getUiNodeInfo } from "../ui-node-definitions/uiNodeTypes";
import {
Expand All @@ -23,6 +22,16 @@ import PathBreadcrumb from "./PathBreadcrumb";
import { useGetNodeServerBindingInfo } from "./useGetNodeServerBindingInfo";
import { useUpdateSettings } from "./useUpdateSettings";

/**
*
* @param id Name of ui node to look up
* @returns Component used to render that node
* @throws Error if node doesn't exist
*/
function getUiNodeSettingsRenderer(id: string) {
return getUiNodeInfo(id).settingsFormRender;
}

export function SettingsPanel({ app_tree }: { app_tree: ShinyUiNode }) {
const {
currentNode,
Expand Down
4 changes: 2 additions & 2 deletions inst/editor/src/SettingsPanel/UnknownArgumentsRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
TooltipTrigger,
TooltipContent,
} from "../components/PopoverEl/FloatingPopover";
import type { UnknownUiNode } from "../ui-node-definitions/internal/unknown_code";
import { isKnownShinyUiNode } from "../ui-node-definitions/isShinyUiNode";
import type { UnknownUiNode } from "../ui-node-definitions/internal/UnknownUiFunction/unknown_code";
import { isKnownShinyUiNode } from "../ui-node-definitions/utils/isShinyUiNode";

import type { FormBuilderProps } from "./FormBuilder";

Expand Down
17 changes: 0 additions & 17 deletions inst/editor/src/Shiny-Ui-Elements/Bslib/BslibCard.tsx

This file was deleted.

20 changes: 0 additions & 20 deletions inst/editor/src/Shiny-Ui-Elements/Bslib/BslibCardBodyFill.tsx

This file was deleted.

20 changes: 0 additions & 20 deletions inst/editor/src/Shiny-Ui-Elements/Bslib/BslibCardFooter.tsx

This file was deleted.

41 changes: 0 additions & 41 deletions inst/editor/src/Shiny-Ui-Elements/Bslib/NavPanel.tsx

This file was deleted.

4 changes: 0 additions & 4 deletions inst/editor/src/Shiny-Ui-Elements/Bslib/index.tsx

This file was deleted.

44 changes: 0 additions & 44 deletions inst/editor/src/Shiny-Ui-Elements/DtDtOutput/index.tsx

This file was deleted.

Loading