diff --git a/src/PropertiesPanel.js b/src/PropertiesPanel.js index 9bb6950c..7ee53d5b 100644 --- a/src/PropertiesPanel.js +++ b/src/PropertiesPanel.js @@ -24,7 +24,8 @@ import { ErrorsContext, EventContext, LayoutContext, - PropertiesPanelContext + PropertiesPanelContext, + TooltipContext } from './context'; import { useEvent } from './hooks'; @@ -33,6 +34,8 @@ const DEFAULT_LAYOUT = {}; const DEFAULT_DESCRIPTION = {}; +const DEFAULT_TOOLTIP = {}; + /** * @typedef { { @@ -112,6 +115,8 @@ export default function PropertiesPanel(props) { layoutChanged, descriptionConfig, descriptionLoaded, + tooltipConfig, + tooltipLoaded, eventBus } = props; @@ -167,6 +172,24 @@ export default function PropertiesPanel(props) { getDescriptionForId }; + // set-up tooltip context + const tooltip = useMemo(() => createTooltipContext(tooltipConfig), [ tooltipConfig ]); + + useEffect(() => { + if (typeof tooltipLoaded === 'function') { + tooltipLoaded(tooltip); + } + }, [ tooltip, tooltipLoaded ]); + + const getTooltipForId = (id, element) => { + return tooltip[id] && tooltip[id](element); + }; + + const tooltipContext = { + tooltip, + getTooltipForId + }; + const [ errors, setErrors ] = useState({}); const onSetErrors = ({ errors }) => setErrors(errors); @@ -199,32 +222,34 @@ export default function PropertiesPanel(props) { - - -
-
-
- { - groups.map(group => { - const { - component: Component = Group, - id - } = group; - - return ( - - ); - }) - } + + + +
+
+
+ { + groups.map(group => { + const { + component: Component = Group, + id + } = group; + + return ( + + ); + }) + } +
-
- - + + + @@ -248,6 +273,13 @@ function createDescriptionContext(overrides = {}) { }; } +function createTooltipContext(overrides = {}) { + return { + ...DEFAULT_TOOLTIP, + ...overrides + }; +} + // hooks ////////////////// /** diff --git a/src/components/entries/Checkbox.js b/src/components/entries/Checkbox.js index 9a50d2ab..a30ce614 100644 --- a/src/components/entries/Checkbox.js +++ b/src/components/entries/Checkbox.js @@ -58,7 +58,7 @@ function Checkbox(props) { checked={ localValue } disabled={ disabled } /> @@ -109,7 +109,8 @@ export default function CheckboxEntry(props) { onFocus={ onFocus } onBlur={ onBlur } value={ value } - tooltip={ tooltip } /> + tooltip={ tooltip } + element={ element } /> { error &&
{ error }
}
diff --git a/src/components/entries/FEEL/Feel.js b/src/components/entries/FEEL/Feel.js index 9ce9c2b4..aa24af19 100644 --- a/src/components/entries/FEEL/Feel.js +++ b/src/components/entries/FEEL/Feel.js @@ -188,7 +188,7 @@ function FeelTextfield(props) { { 'feel-active': feelActive } ) }>