@bpmn-io/properties-panel 3.6.0 → 3.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1329,6 +1329,11 @@ const FEEL_POPUP_HEIGHT = 250;
1329
1329
  function FEELPopupRoot(props) {
1330
1330
  const {
1331
1331
  element,
1332
+ eventBus = {
1333
+ fire() {},
1334
+ on() {},
1335
+ off() {}
1336
+ },
1332
1337
  popupContainer
1333
1338
  } = props;
1334
1339
  const prevElement = usePrevious(element);
@@ -1336,15 +1341,23 @@ function FEELPopupRoot(props) {
1336
1341
  const [open, setOpen] = useState(false);
1337
1342
  const [source, setSource] = useState(null);
1338
1343
  const [sourceElement, setSourceElement] = useState(null);
1339
- const handleOpen = (key, config, _sourceElement) => {
1340
- setSource(key);
1344
+ const emit = (type, context) => {
1345
+ eventBus.fire('feelPopup.' + type, context);
1346
+ };
1347
+ const isOpen = useCallback(() => {
1348
+ return !!open;
1349
+ }, [open]);
1350
+ const handleOpen = (entryId, config, _sourceElement) => {
1351
+ setSource(entryId);
1341
1352
  setPopupConfig(config);
1342
1353
  setOpen(true);
1343
1354
  setSourceElement(_sourceElement);
1355
+ emit('opened');
1344
1356
  };
1345
1357
  const handleClose = () => {
1346
1358
  setOpen(false);
1347
1359
  setSource(null);
1360
+ emit('closed');
1348
1361
  };
1349
1362
  const feelPopupContext = {
1350
1363
  open: handleOpen,
@@ -1354,10 +1367,33 @@ function FEELPopupRoot(props) {
1354
1367
 
1355
1368
  // close popup on element change, cf. https://github.com/bpmn-io/properties-panel/issues/270
1356
1369
  useEffect(() => {
1357
- if (element && element !== prevElement) {
1370
+ if (element && prevElement && element !== prevElement) {
1358
1371
  handleClose();
1359
1372
  }
1360
1373
  }, [element]);
1374
+
1375
+ // allow close and open via events
1376
+ useEffect(() => {
1377
+ const handlePopupOpen = context => {
1378
+ const {
1379
+ entryId,
1380
+ popupConfig,
1381
+ sourceElement
1382
+ } = context;
1383
+ handleOpen(entryId, popupConfig, sourceElement);
1384
+ };
1385
+ const handleIsOpen = () => {
1386
+ return isOpen();
1387
+ };
1388
+ eventBus.on('feelPopup._close', handleClose);
1389
+ eventBus.on('feelPopup._open', handlePopupOpen);
1390
+ eventBus.on('feelPopup._isOpen', handleIsOpen);
1391
+ return () => {
1392
+ eventBus.off('feelPopup._close', handleClose);
1393
+ eventBus.off('feelPopup._open', handleOpen);
1394
+ eventBus.off('feelPopup._isOpen', handleIsOpen);
1395
+ };
1396
+ }, [eventBus, isOpen]);
1361
1397
  return jsxs(FeelPopupContext.Provider, {
1362
1398
  value: feelPopupContext,
1363
1399
  children: [open && jsx(FeelPopupComponent, {
@@ -2425,7 +2461,7 @@ function calculatePopupPosition(element) {
2425
2461
 
2426
2462
  // todo(pinussilvestrus): make this configurable in the future
2427
2463
  function getPopupTitle(element, label) {
2428
- let popupTitle;
2464
+ let popupTitle = '';
2429
2465
  if (element && element.type) {
2430
2466
  popupTitle = `${element.type} / `;
2431
2467
  }
@@ -2631,6 +2667,7 @@ function PropertiesPanel(props) {
2631
2667
  value: eventContext,
2632
2668
  children: jsx(FEELPopupRoot, {
2633
2669
  element: element,
2670
+ eventBus: eventBus,
2634
2671
  popupContainer: feelPopupContainer,
2635
2672
  children: jsxs("div", {
2636
2673
  class: "bio-properties-panel",
@@ -4096,9 +4133,50 @@ function debounceInput(debounceDelay) {
4096
4133
  }
4097
4134
  debounceInput.$inject = ['config.debounceInput'];
4098
4135
 
4099
- var index = {
4136
+ var index$1 = {
4100
4137
  debounceInput: ['factory', debounceInput]
4101
4138
  };
4102
4139
 
4103
- export { ArrowIcon, CheckboxEntry, CollapsibleEntry, CreateIcon, index as DebounceInputModule, DeleteIcon, DescriptionContext, Description as DescriptionEntry, DragIcon, DropdownButton, ErrorsContext, EventContext, ExternalLinkIcon, FeelCheckboxEntry, FeelEntry, FeelIcon$1 as FeelIcon, FeelNumberEntry, FeelTemplatingEntry, FeelTextAreaEntry, FeelToggleSwitchEntry, Group, Header, HeaderButton, LayoutContext, List as ListEntry, ListGroup, ListItem, NumberFieldEntry, Placeholder, Popup, PropertiesPanel, LayoutContext as PropertiesPanelContext, SelectEntry, Simple as SimpleEntry, TemplatingEntry, TextAreaEntry, TextfieldEntry as TextFieldEntry, ToggleSwitchEntry, TooltipContext, isEdited$5 as isCheckboxEntryEdited, isEdited$6 as isFeelEntryEdited, isEdited$7 as isNumberFieldEntryEdited, isEdited$3 as isSelectEntryEdited, isEdited$2 as isSimpleEntryEdited, isEdited$4 as isTemplatingEntryEdited, isEdited$1 as isTextAreaEntryEdited, isEdited as isTextFieldEntryEdited, isEdited$8 as isToggleSwitchEntryEdited, useDescriptionContext, useError, useErrors, useEvent, useKeyFactory, useLayoutState, usePrevious, useShowEntryEvent, useStaticCallback, useStickyIntersectionObserver, useTooltipContext };
4140
+ class FeelPopupModule {
4141
+ constructor(eventBus) {
4142
+ this._eventBus = eventBus;
4143
+ }
4144
+
4145
+ /**
4146
+ * Check if the FEEL popup is open.
4147
+ * @return {Boolean}
4148
+ */
4149
+ isOpen() {
4150
+ return this._eventBus.fire('feelPopup._isOpen');
4151
+ }
4152
+
4153
+ /**
4154
+ * Open the FEEL popup.
4155
+ *
4156
+ * @param {String} entryId
4157
+ * @param {Object} popupConfig
4158
+ * @param {HTMLElement} sourceElement
4159
+ */
4160
+ open(entryId, popupConfig, sourceElement) {
4161
+ return this._eventBus.fire('feelPopup._open', {
4162
+ entryId,
4163
+ popupConfig,
4164
+ sourceElement
4165
+ });
4166
+ }
4167
+
4168
+ /**
4169
+ * Close the FEEL popup.
4170
+ */
4171
+ close() {
4172
+ return this._eventBus.fire('feelPopup._close');
4173
+ }
4174
+ }
4175
+ FeelPopupModule.$inject = ['eventBus'];
4176
+
4177
+ var index = {
4178
+ feelPopup: ['type', FeelPopupModule]
4179
+ };
4180
+
4181
+ export { ArrowIcon, CheckboxEntry, CollapsibleEntry, CreateIcon, index$1 as DebounceInputModule, DeleteIcon, DescriptionContext, Description as DescriptionEntry, DragIcon, DropdownButton, ErrorsContext, EventContext, ExternalLinkIcon, FeelCheckboxEntry, FeelEntry, FeelIcon$1 as FeelIcon, FeelNumberEntry, index as FeelPopupModule, FeelTemplatingEntry, FeelTextAreaEntry, FeelToggleSwitchEntry, Group, Header, HeaderButton, LayoutContext, List as ListEntry, ListGroup, ListItem, NumberFieldEntry, Placeholder, Popup, PropertiesPanel, LayoutContext as PropertiesPanelContext, SelectEntry, Simple as SimpleEntry, TemplatingEntry, TextAreaEntry, TextfieldEntry as TextFieldEntry, ToggleSwitchEntry, TooltipContext, isEdited$5 as isCheckboxEntryEdited, isEdited$6 as isFeelEntryEdited, isEdited$7 as isNumberFieldEntryEdited, isEdited$3 as isSelectEntryEdited, isEdited$2 as isSimpleEntryEdited, isEdited$4 as isTemplatingEntryEdited, isEdited$1 as isTextAreaEntryEdited, isEdited as isTextFieldEntryEdited, isEdited$8 as isToggleSwitchEntryEdited, useDescriptionContext, useError, useErrors, useEvent, useKeyFactory, useLayoutState, usePrevious, useShowEntryEvent, useStaticCallback, useStickyIntersectionObserver, useTooltipContext };
4104
4182
  //# sourceMappingURL=index.esm.js.map