@bpmn-io/properties-panel 3.40.0 → 3.40.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/assets/properties-panel.css +1 -1
- package/dist/index.esm.js +61 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +60 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1176,7 +1176,7 @@ textarea.bio-properties-panel-input {
|
|
|
1176
1176
|
display: flex;
|
|
1177
1177
|
color: var(--color-white, white);
|
|
1178
1178
|
position: fixed;
|
|
1179
|
-
z-index:
|
|
1179
|
+
z-index: 1001;
|
|
1180
1180
|
max-width: 300px;
|
|
1181
1181
|
font-size: var(--text-size-small);
|
|
1182
1182
|
font-family: var(--font-family);
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useContext, useState, useRef, useEffect, useCallback, useMemo
|
|
1
|
+
import { useContext, useState, useRef, useEffect, useLayoutEffect, useCallback, useMemo } from '../preact/hooks';
|
|
2
2
|
import { isFunction, isArray, get, assign, set, isString, isNumber, debounce } from 'min-dash';
|
|
3
3
|
import { createPortal, forwardRef } from '../preact/compat';
|
|
4
4
|
import { jsx, jsxs, Fragment } from '../preact/jsx-runtime';
|
|
@@ -343,6 +343,8 @@ function Tooltip(props) {
|
|
|
343
343
|
hideDelay = 250
|
|
344
344
|
} = props;
|
|
345
345
|
const [visible, setVisible] = useState(false);
|
|
346
|
+
const [tooltipPosition, setTooltipPosition] = useState(null);
|
|
347
|
+
const [arrowOffset, setArrowOffset] = useState(null);
|
|
346
348
|
const showTimeoutRef = useRef(null);
|
|
347
349
|
const hideTimeoutRef = useRef(null);
|
|
348
350
|
const wrapperRef = useRef(null);
|
|
@@ -396,6 +398,20 @@ function Tooltip(props) {
|
|
|
396
398
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
397
399
|
};
|
|
398
400
|
}, [visible, hide]);
|
|
401
|
+
useLayoutEffect(() => {
|
|
402
|
+
if (!visible || position) {
|
|
403
|
+
setTooltipPosition(null);
|
|
404
|
+
setArrowOffset(null);
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
if (!wrapperRef.current || !tooltipRef.current) return;
|
|
408
|
+
const {
|
|
409
|
+
tooltipPosition: newPosition,
|
|
410
|
+
arrowOffset: newArrowOffset
|
|
411
|
+
} = getTooltipPosition(wrapperRef.current, tooltipRef.current, direction);
|
|
412
|
+
setTooltipPosition(newPosition);
|
|
413
|
+
setArrowOffset(newArrowOffset);
|
|
414
|
+
}, [visible, position]);
|
|
399
415
|
const handleMouseLeave = ({
|
|
400
416
|
relatedTarget
|
|
401
417
|
}) => {
|
|
@@ -431,12 +447,14 @@ function Tooltip(props) {
|
|
|
431
447
|
e.code === 'Escape' && hide(false);
|
|
432
448
|
};
|
|
433
449
|
const renderTooltip = () => {
|
|
450
|
+
const tooltipStyle = position || (tooltipPosition ? `right: ${tooltipPosition.right}; top: ${tooltipPosition.top}px;` : undefined);
|
|
451
|
+
const arrowStyle = arrowOffset != null ? `margin-top: ${arrowOffset}px;` : undefined;
|
|
434
452
|
return jsxs("div", {
|
|
435
453
|
class: `bio-properties-panel-tooltip ${direction}`,
|
|
436
454
|
role: "tooltip",
|
|
437
455
|
id: "bio-properties-panel-tooltip",
|
|
438
456
|
"aria-labelledby": forId,
|
|
439
|
-
style:
|
|
457
|
+
style: tooltipStyle,
|
|
440
458
|
ref: tooltipRef,
|
|
441
459
|
onClick: e => e.stopPropagation(),
|
|
442
460
|
onMouseEnter: handleTooltipMouseEnter,
|
|
@@ -445,7 +463,8 @@ function Tooltip(props) {
|
|
|
445
463
|
class: "bio-properties-panel-tooltip-content",
|
|
446
464
|
children: value
|
|
447
465
|
}), jsx("div", {
|
|
448
|
-
class: "bio-properties-panel-tooltip-arrow"
|
|
466
|
+
class: "bio-properties-panel-tooltip-arrow",
|
|
467
|
+
style: arrowStyle
|
|
449
468
|
})]
|
|
450
469
|
});
|
|
451
470
|
};
|
|
@@ -464,11 +483,47 @@ function Tooltip(props) {
|
|
|
464
483
|
|
|
465
484
|
// helper
|
|
466
485
|
|
|
467
|
-
function getTooltipPosition(refElement) {
|
|
486
|
+
function getTooltipPosition(refElement, tooltipElement, direction) {
|
|
487
|
+
if (!refElement) {
|
|
488
|
+
return {
|
|
489
|
+
tooltipPosition: null,
|
|
490
|
+
arrowOffset: null
|
|
491
|
+
};
|
|
492
|
+
}
|
|
468
493
|
const refPosition = refElement.getBoundingClientRect();
|
|
469
494
|
const right = `calc(100% - ${refPosition.x}px)`;
|
|
470
|
-
|
|
471
|
-
|
|
495
|
+
let top = refPosition.top - 10;
|
|
496
|
+
let arrowOffset = null;
|
|
497
|
+
|
|
498
|
+
// Ensure that the tooltip is within the viewport, adjust the top position if needed.
|
|
499
|
+
// This is only relevant for the 'right' direction for now
|
|
500
|
+
if (tooltipElement && direction === 'right') {
|
|
501
|
+
const tooltipRect = tooltipElement.getBoundingClientRect();
|
|
502
|
+
const viewportHeight = window.innerHeight;
|
|
503
|
+
const minTop = 0;
|
|
504
|
+
const maxTop = viewportHeight - tooltipRect.height;
|
|
505
|
+
const originalTop = top;
|
|
506
|
+
if (top > maxTop) {
|
|
507
|
+
top = maxTop;
|
|
508
|
+
}
|
|
509
|
+
if (top < minTop) {
|
|
510
|
+
top = minTop;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// Adjust the arrow position if the tooltip had to be moved to stay within viewport
|
|
514
|
+
if (top !== originalTop) {
|
|
515
|
+
const defaultMarginTop = 16;
|
|
516
|
+
const topDiff = top - originalTop;
|
|
517
|
+
arrowOffset = defaultMarginTop - topDiff;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
return {
|
|
521
|
+
tooltipPosition: {
|
|
522
|
+
right,
|
|
523
|
+
top
|
|
524
|
+
},
|
|
525
|
+
arrowOffset
|
|
526
|
+
};
|
|
472
527
|
}
|
|
473
528
|
|
|
474
529
|
/**
|