Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
289cf54
Remove DisabledTooltip wrapper and inline tooltip logic
kube Jan 22, 2026
9c737c2
Fix Switch tooltip by wrapping with ark.span for proper event forwarding
kube Jan 22, 2026
180d288
Add disabled and tooltip props to SegmentGroup component
kube Jan 22, 2026
16e658e
Use ID composition for SegmentGroup tooltip to avoid layout-breaking …
kube Jan 22, 2026
39448b5
Use display:contents wrapper for SegmentGroup tooltip
kube Jan 22, 2026
958fb41
Fix SegmentGroup tooltip using ArkTooltip.Trigger with asChild
kube Jan 22, 2026
1a70954
Disable delete buttons in properties panels during simulation
kube Jan 22, 2026
57f8d65
Add tooltip to Dynamics switch when no type is selected
kube Jan 22, 2026
d13cd43
Disable Visualizer toggle during simulation
kube Jan 22, 2026
303c763
Keep editor read-only when simulation is complete
kube Jan 22, 2026
2d7a53f
Prevent Delete/Backspace keyboard deletion in read-only mode
kube Jan 22, 2026
07273d1
Use useIsReadOnly hook in SDCPN canvas view
kube Jan 23, 2026
060eed5
Disable add/delete buttons in sidebar lists during read-only mode
kube Jan 23, 2026
6108b91
Add changeset for read-only tooltips fix
kube Jan 23, 2026
e8c28b7
Fix CodeEditor overlay blocking scroll in read-only mode
kube Jan 23, 2026
1b95fc3
Fix SegmentGroup tooltip nesting structure
kube Jan 23, 2026
4b5d663
Fix Tooltip to work on disabled elements
kube Jan 23, 2026
5d3dd19
Fix Tooltip wrapper to use flex instead of inline-flex
kube Jan 23, 2026
24e3357
Add width: 100% to Tooltip wrapper for block elements
kube Jan 23, 2026
e0e8032
Use div instead of span for Tooltip wrapper
kube Jan 23, 2026
83b22c8
Fix Tooltip wrapper to preserve input dimensions
kube Jan 24, 2026
3620c95
Refactor Tooltip component with display variants and fix readonly guards
kube Jan 26, 2026
401ea89
Remove unused `mode` variable from SDCPNView
kube Jan 26, 2026
1cc91a8
Add withTooltip HoC to reduce tooltip boilerplate in components
kube Jan 26, 2026
1cc11b2
Add reusable form components and refactor properties panels
kube Jan 26, 2026
9b44186
Replace interface with type in form component props
kube Jan 26, 2026
68ef34f
Fix CodeEditor tooltip and listener issues from AI review
kube Jan 26, 2026
1f85b90
Fix duplicate listener registration and add arc tooltips
kube Jan 27, 2026
99fdc4d
Improve type dropdown UX and simplify CodeEditor tooltip
kube Jan 28, 2026
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
5 changes: 5 additions & 0 deletions .changeset/fix-readonly-tooltips.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hashintel/petrinaut": patch
---

Fix read-only tooltips to always show during simulation mode
82 changes: 82 additions & 0 deletions libs/@hashintel/petrinaut/src/components/button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { cva } from "@hashintel/ds-helpers/css";

import { withTooltip } from "./hoc/with-tooltip";

const buttonStyle = cva({
base: {
display: "inline-flex",
alignItems: "center",
justifyContent: "center",
gap: "[6px]",
fontSize: "[12px]",
padding: "[4px 8px]",
border: "[1px solid rgba(0, 0, 0, 0.2)]",
borderRadius: "[4px]",
backgroundColor: "[white]",
color: "[#333]",
cursor: "pointer",
transition: "[all 0.15s ease]",
_hover: {
backgroundColor: "[rgba(0, 0, 0, 0.05)]",
},
_active: {
backgroundColor: "[rgba(0, 0, 0, 0.1)]",
},
},
variants: {
isDisabled: {
true: {
opacity: "[0.5]",
cursor: "not-allowed",
_hover: {
backgroundColor: "[white]",
},
},
false: {},
},
variant: {
default: {},
ghost: {
border: "none",
backgroundColor: "[transparent]",
_hover: {
backgroundColor: "[rgba(0, 0, 0, 0.05)]",
},
},
},
},
defaultVariants: {
isDisabled: false,
variant: "default",
},
});

type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
/** Button variant */
variant?: "default" | "ghost";
/** Button content */
children: React.ReactNode;
/** Ref to the button element */
ref?: React.Ref<HTMLButtonElement>;
};

const ButtonBase: React.FC<ButtonProps> = ({
variant = "default",
disabled,
className,
children,
ref,
...props
}) => (
<button
ref={ref}
type="button"
disabled={disabled}
className={`${buttonStyle({ isDisabled: disabled, variant })}${className ? ` ${className}` : ""}`}
{...props}
>
{children}
</button>
);
Comment thread
kube marked this conversation as resolved.

export const Button = withTooltip(ButtonBase, "block");
98 changes: 98 additions & 0 deletions libs/@hashintel/petrinaut/src/components/code-editor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { css, cva } from "@hashintel/ds-helpers/css";
import type { EditorProps, Monaco } from "@monaco-editor/react";
import MonacoEditor from "@monaco-editor/react";
import type { editor } from "monaco-editor";
import { useCallback, useRef } from "react";

import { Tooltip } from "./tooltip";

const containerStyle = cva({
base: {
position: "relative",
border: "[1px solid rgba(0, 0, 0, 0.1)]",
borderRadius: "[4px]",
overflow: "hidden",
},
variants: {
isReadOnly: {
true: {
filter: "[grayscale(20%) brightness(98%)]",
cursor: "not-allowed",
},
false: {},
},
},
});
Comment thread
kube marked this conversation as resolved.

type CodeEditorProps = Omit<EditorProps, "theme"> & {
tooltip?: string;
};

/**
* Code editor component that wraps Monaco Editor.
*
* @param tooltip - Optional tooltip to show when hovering over the editor.
* In read-only mode, the tooltip also appears when attempting to edit.
*/
export const CodeEditor: React.FC<CodeEditorProps> = ({
tooltip,
options,
height,
onMount,
...props
}) => {
const isReadOnly = options?.readOnly === true;
const editorRef = useRef<editor.IStandaloneCodeEditor | null>(null);

const handleMount = useCallback(
(editorInstance: editor.IStandaloneCodeEditor, monaco: Monaco) => {
editorRef.current = editorInstance;
// Call the original onMount if provided
onMount?.(editorInstance, monaco);
},
[onMount],
);
Comment thread
cursor[bot] marked this conversation as resolved.

const editorOptions: EditorProps["options"] = {
minimap: { enabled: false },
scrollBeyondLastLine: false,
fontSize: 12,
lineNumbers: "off",
folding: true,
glyphMargin: false,
lineDecorationsWidth: 0,
lineNumbersMinChars: 3,
padding: { top: 8, bottom: 8 },
fixedOverflowWidgets: true,
...options,
};

const editorElement = (
<div className={containerStyle({ isReadOnly })} style={{ height }}>
<MonacoEditor
theme="vs-light"
height="100%"
options={editorOptions}
onMount={handleMount}
{...props}
/>
</div>
);

// Regular tooltip for non-read-only mode (if tooltip is provided)
if (tooltip) {
return (
<Tooltip
content={tooltip}
display="block"
className={css({
flex: "1",
})}
>
{editorElement}
</Tooltip>
);
Comment thread
cursor[bot] marked this conversation as resolved.
}

return editorElement;
};
43 changes: 0 additions & 43 deletions libs/@hashintel/petrinaut/src/components/disabled-tooltip.tsx

This file was deleted.

63 changes: 63 additions & 0 deletions libs/@hashintel/petrinaut/src/components/hoc/with-tooltip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import type { ComponentType } from "react";

import { Tooltip } from "../tooltip";

type WithTooltipProps = {
/** Tooltip to show when hovering (useful for explaining disabled state). */
tooltip?: string;
/**
* Display mode for the tooltip wrapper element.
* - "block": For full-width elements like inputs/selects (default)
* - "inline": For inline elements like buttons in flex containers
*/
tooltipDisplay?: "block" | "inline";
};

/**
* Higher-Order Component that adds tooltip support to any component.
*
* When `tooltip` prop is provided, the component is wrapped with a Tooltip.
* When `tooltip` is undefined/empty, the component renders unwrapped.
*
* @param Component - The component to wrap
* @param defaultDisplay - Default display mode for the tooltip wrapper ("block" | "inline")
*
* @example
* ```tsx
* const MyButtonBase: React.FC<{ onClick: () => void }> = ({ onClick }) => (
* <button onClick={onClick}>Click me</button>
* );
*
* export const MyButton = withTooltip(MyButtonBase, "inline");
*
* // Usage:
* <MyButton onClick={handleClick} tooltip="Click to submit" />
* ```
*/
export function withTooltip<P extends object>(
Component: ComponentType<P>,
defaultDisplay: "block" | "inline" = "block",
): ComponentType<P & WithTooltipProps> {
const WrappedComponent: React.FC<P & WithTooltipProps> = ({
tooltip,
tooltipDisplay = defaultDisplay,
...props
}) => {
const element = <Component {...(props as P)} />;

if (!tooltip) {
return element;
}

return (
<Tooltip content={tooltip} display={tooltipDisplay}>
{element}
</Tooltip>
);
};

// Set display name for debugging
WrappedComponent.displayName = `withTooltip(${Component.displayName ?? Component.name})`;

return WrappedComponent;
}
Loading
Loading