diff --git a/CHANGELOG.md b/CHANGELOG.md index 7101c14eb..a4e26fedb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ## [Unreleased] +### Added + +- `` + - `noDrag` parameter: Add the `nodrag` class to the Switch element. Default: `true` + +### Deprecated + +- `preventReactFlowActionsClasses`: use `ClassNames.ReactFlow.preventAllActions` + ## [26.1.0] - 2026-08-20 ### Added diff --git a/src/cmem/react-flow/ReactFlow/ReactFlow.tsx b/src/cmem/react-flow/ReactFlow/ReactFlow.tsx index 5b1cb79be..2839a0828 100644 --- a/src/cmem/react-flow/ReactFlow/ReactFlow.tsx +++ b/src/cmem/react-flow/ReactFlow/ReactFlow.tsx @@ -207,6 +207,3 @@ const ReactFlowExtendedPlain = ( export const ReactFlowExtended = React.forwardRef(ReactFlowExtendedPlain) as ( p: T & { ref?: Ref }, ) => ReactElement; - -/** Classes that when set for an element, prevent that they trigger react-flow dragging, wheel and panning actions. */ -export const preventReactFlowActionsClasses = "nodrag nopan nowheel"; diff --git a/src/cmem/react-flow/ReactFlow/constants.ts b/src/cmem/react-flow/ReactFlow/constants.ts new file mode 100644 index 000000000..33f52b9a5 --- /dev/null +++ b/src/cmem/react-flow/ReactFlow/constants.ts @@ -0,0 +1,17 @@ +/* + Classes that when set for an element, prevent that they trigger react-flow dragging, wheel and panning actions. + + This module must stay free of imports, so that basic components can use these class names without pulling the + react-flow packages into their dependency chain. +*/ +export const preventReactFlowDragClass = "nodrag"; +export const preventReactFlowPanClass = "nopan"; +export const preventReactFlowWheelClass = "nowheel"; +export const preventReactFlowActionsClasses = `${preventReactFlowDragClass} ${preventReactFlowPanClass} ${preventReactFlowWheelClass}`; + +export const helperClasses = { + preventDrag: preventReactFlowDragClass, + preventPan: preventReactFlowPanClass, + preventWheel: preventReactFlowWheelClass, + preventAllActions: preventReactFlowActionsClasses, +}; diff --git a/src/components/AutocompleteField/AutoCompleteField.tsx b/src/components/AutocompleteField/AutoCompleteField.tsx index 2b8949461..770fc222e 100644 --- a/src/components/AutocompleteField/AutoCompleteField.tsx +++ b/src/components/AutocompleteField/AutoCompleteField.tsx @@ -5,6 +5,7 @@ import { } from "@blueprintjs/core"; import { Suggest as BlueprintSuggest } from "@blueprintjs/select"; +import { preventReactFlowDragClass } from "../../cmem/react-flow/ReactFlow/constants"; import { CLASSPREFIX as eccgui } from "../../configuration/constants"; import { ContextOverlayProps, @@ -485,7 +486,7 @@ export function SuggestField(props: SuggestFieldProps { * class names */ className?: string; + + /** Adds the 'nodrag' class to the element, preventing dragging via the Switch element. Default: true */ + noDrag?: boolean; } -export const Switch = ({ onChange, className, label, ...otherProps }: SwitchProps) => { +export const Switch = ({ onChange, className, label, noDrag = true, ...otherProps }: SwitchProps) => { const handleChange = (e: React.ChangeEvent) => { if (onChange) { onChange(!!e.target?.checked); } }; + const noDragClass = noDrag ? `${preventReactFlowDragClass} ` : ""; + return ( >({ )} {(menuButtons || (showExecutionButtons && executionButtons)) && ( -
+
{showExecutionButtons && typeof executionButtons === "function" ? executionButtons(adjustedContentProps, setAdjustedContentProps) : null} @@ -782,7 +783,7 @@ export function NodeContent>({ (resizeDirections!.right ? ` ${eccgui}-graphviz__node__resizer--right` : "") + (resizeDirections!.bottom ? ` ${eccgui}-graphviz__node__resizer--bottom` : "") } - handleWrapperClass={`${eccgui}-graphviz__node__resizer--cursorhandles` + " nodrag"} + handleWrapperClass={`${eccgui}-graphviz__node__resizer--cursorhandles ${preventReactFlowDragClass}`} size={resizableSize} maxHeight={resizeMaxDimensions?.height ?? undefined} maxWidth={resizeMaxDimensions?.width ?? undefined} diff --git a/src/index.ts b/src/index.ts index b6b9e8c56..c89288a26 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,6 @@ import { Classes as BlueprintClasses } from "@blueprintjs/core"; +import {helperClasses as reactFlowHelperClasses } from "./cmem/react-flow/ReactFlow/constants"; import { ClassNames as IntentClassNames } from "./common/Intent"; import * as Skeleton from "./components/Skeleton/classnames"; import * as TypographyClassNames from "./components/Typography/classnames"; @@ -9,12 +10,16 @@ const ClassNames = { Intent: IntentClassNames, Skeleton, Typography: TypographyClassNames, + ReactFlow: reactFlowHelperClasses, }; +/** @deprecated (v27) use `ClassNames.ReactFlow.preventAllActions` */ +const preventReactFlowActionsClasses = reactFlowHelperClasses.preventAllActions; + export * from "./configuration/constants"; export * from "./common"; export * from "./components"; export * from "./extensions"; export * from "./cmem"; -export { ClassNames }; +export { ClassNames, preventReactFlowActionsClasses };