diagram-js
Advanced tools
Comparing version 11.4.4 to 11.5.0
@@ -94,13 +94,9 @@ import { | ||
const entriesArray = [ | ||
...Object.entries(entries).map( | ||
([ key, value ]) => ({ id: key, ...value }) | ||
) | ||
]; | ||
const entriesArray = Object.entries(entries).map( | ||
([ key, value ]) => ({ id: key, ...value }) | ||
); | ||
const headerEntriesArray = [ | ||
...Object.entries(headerEntries).map( | ||
([ key, value ]) => ({ id: key, ...value }) | ||
) | ||
]; | ||
const headerEntriesArray = Object.entries(headerEntries).map( | ||
([ key, value ]) => ({ id: key, ...value }) | ||
); | ||
@@ -114,3 +110,3 @@ const position = _position && ( | ||
const onClose = result => this.close(result); | ||
const onSelect = (event, entry) => this.trigger(event, entry); | ||
const onSelect = (event, entry, action) => this.trigger(event, entry, action); | ||
@@ -512,6 +508,7 @@ render( | ||
* @param {Object} entry | ||
* @param {string} [action='click'] the action to trigger | ||
* | ||
* @return the result of the action callback, if any | ||
*/ | ||
PopupMenu.prototype.trigger = function(event, entry) { | ||
PopupMenu.prototype.trigger = function(event, entry, action = 'click') { | ||
@@ -528,4 +525,12 @@ // silence other actions | ||
if (entry.action) { | ||
return entry.action.call(null, event, entry); | ||
const handler = entry.action; | ||
if (isFunction(handler)) { | ||
if (action === 'click') { | ||
return handler(event, entry); | ||
} | ||
} else { | ||
if (handler[action]) { | ||
return handler[action](event, entry); | ||
} | ||
} | ||
@@ -532,0 +537,0 @@ }; |
@@ -235,3 +235,3 @@ import { | ||
setSelectedEntry=${ setSelectedEntry } | ||
onClick=${ onSelect } | ||
onAction=${ onSelect } | ||
/> | ||
@@ -238,0 +238,0 @@ </div> |
@@ -16,3 +16,3 @@ import classNames from 'clsx'; | ||
* @param {function} onMouseLeave | ||
* @param {function} onClick | ||
* @param {function} onAction | ||
*/ | ||
@@ -25,3 +25,3 @@ export default function PopupMenuItem(props) { | ||
onMouseLeave, | ||
onClick | ||
onAction | ||
} = props; | ||
@@ -34,5 +34,7 @@ | ||
title=${ entry.title || entry.label } | ||
onClick=${ onClick } | ||
onClick=${ onAction } | ||
onMouseEnter=${ onMouseEnter } | ||
onMouseLeave=${ onMouseLeave } | ||
onDragStart=${ (event) => onAction(event, entry, 'dragstart') } | ||
draggable=${ true } | ||
> | ||
@@ -39,0 +41,0 @@ <div class="djs-popup-entry-content"> |
@@ -16,3 +16,3 @@ import { | ||
* @param {function} setSelectedEntry | ||
* @param {function} onClick | ||
* @param {function} onAction | ||
* @param {Object} resultsRef | ||
@@ -25,4 +25,4 @@ */ | ||
setSelectedEntry, | ||
onClick, | ||
entries | ||
entries, | ||
...restProps | ||
} = props; | ||
@@ -64,3 +64,3 @@ | ||
onMouseLeave=${ () => setSelectedEntry(null) } | ||
onClick=${ onClick } | ||
...${ restProps } | ||
/> | ||
@@ -67,0 +67,0 @@ `) } |
{ | ||
"name": "diagram-js", | ||
"version": "11.4.4", | ||
"version": "11.5.0", | ||
"description": "A toolbox for displaying and modifying diagrams on the web", | ||
@@ -50,3 +50,3 @@ "main": "index.js", | ||
"eslint": "^8.24.0", | ||
"eslint-plugin-bpmn-io": "^0.16.0", | ||
"eslint-plugin-bpmn-io": "^1.0.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
@@ -53,0 +53,0 @@ "jquery": "^3.5.1", |
673534
22995