fui-material 2.1.5 → 2.1.7
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/f-ui-kit.es.js
CHANGED
|
@@ -4030,9 +4030,9 @@ const FTooltip = ({
|
|
|
4030
4030
|
disableFocusListener = false,
|
|
4031
4031
|
disableTouchListener = false,
|
|
4032
4032
|
enterDelay = 0,
|
|
4033
|
-
disableOnDisabled = false,
|
|
4034
4033
|
className = "",
|
|
4035
|
-
style
|
|
4034
|
+
style,
|
|
4035
|
+
allowTooltipOnDisabled = false
|
|
4036
4036
|
}) => {
|
|
4037
4037
|
const [open, setOpen] = useState(false);
|
|
4038
4038
|
const [mountTooltip, setMountTooltip] = useState(false);
|
|
@@ -4046,12 +4046,8 @@ const FTooltip = ({
|
|
|
4046
4046
|
const animationFrame = useRef(null);
|
|
4047
4047
|
const isOpen = openProp !== void 0 ? openProp : open;
|
|
4048
4048
|
const handleOpen = () => {
|
|
4049
|
-
if (enterTimer.current)
|
|
4050
|
-
|
|
4051
|
-
}
|
|
4052
|
-
if (leaveTimer.current) {
|
|
4053
|
-
clearTimeout(leaveTimer.current);
|
|
4054
|
-
}
|
|
4049
|
+
if (enterTimer.current) clearTimeout(enterTimer.current);
|
|
4050
|
+
if (leaveTimer.current) clearTimeout(leaveTimer.current);
|
|
4055
4051
|
enterTimer.current = setTimeout(() => {
|
|
4056
4052
|
if (openProp === void 0) {
|
|
4057
4053
|
setOpen(true);
|
|
@@ -4095,7 +4091,7 @@ const FTooltip = ({
|
|
|
4095
4091
|
}
|
|
4096
4092
|
}
|
|
4097
4093
|
};
|
|
4098
|
-
const updatePosition = () => {
|
|
4094
|
+
const updatePosition = useCallback(() => {
|
|
4099
4095
|
if (!childRef.current || !tooltipRef.current) return;
|
|
4100
4096
|
const childRect = childRef.current.getBoundingClientRect();
|
|
4101
4097
|
const tooltipRect = tooltipRef.current.getBoundingClientRect();
|
|
@@ -4121,64 +4117,44 @@ const FTooltip = ({
|
|
|
4121
4117
|
left2 = childRect.right + scrollX + (arrow2 ? 8 : 0);
|
|
4122
4118
|
break;
|
|
4123
4119
|
}
|
|
4124
|
-
setTooltipStyles({
|
|
4125
|
-
|
|
4126
|
-
left: `${left2}px`
|
|
4127
|
-
});
|
|
4128
|
-
};
|
|
4120
|
+
setTooltipStyles({ top: `${top}px`, left: `${left2}px` });
|
|
4121
|
+
}, [placement, arrow2]);
|
|
4129
4122
|
useEffect(() => {
|
|
4130
4123
|
if (isVisible) {
|
|
4131
4124
|
updatePosition();
|
|
4132
4125
|
}
|
|
4133
|
-
}, [isVisible,
|
|
4126
|
+
}, [isVisible, updatePosition]);
|
|
4134
4127
|
useEffect(() => {
|
|
4135
4128
|
const handleResize = () => {
|
|
4136
|
-
if (isVisible)
|
|
4137
|
-
updatePosition();
|
|
4138
|
-
}
|
|
4129
|
+
if (isVisible) updatePosition();
|
|
4139
4130
|
};
|
|
4140
4131
|
window.addEventListener("resize", handleResize);
|
|
4132
|
+
const currentEnterTimer = enterTimer.current;
|
|
4133
|
+
const currentLeaveTimer = leaveTimer.current;
|
|
4134
|
+
const currentAnimationFrame = animationFrame.current;
|
|
4141
4135
|
return () => {
|
|
4142
4136
|
window.removeEventListener("resize", handleResize);
|
|
4143
|
-
if (
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
if (leaveTimer.current) {
|
|
4147
|
-
clearTimeout(leaveTimer.current);
|
|
4148
|
-
}
|
|
4149
|
-
if (animationFrame.current) {
|
|
4150
|
-
cancelAnimationFrame(animationFrame.current);
|
|
4151
|
-
}
|
|
4137
|
+
if (currentEnterTimer) clearTimeout(currentEnterTimer);
|
|
4138
|
+
if (currentLeaveTimer) clearTimeout(currentLeaveTimer);
|
|
4139
|
+
if (currentAnimationFrame) cancelAnimationFrame(currentAnimationFrame);
|
|
4152
4140
|
};
|
|
4153
4141
|
}, [isVisible, updatePosition]);
|
|
4154
|
-
const isChildDisabled = children.props.disabled;
|
|
4155
|
-
if (isChildDisabled && disableOnDisabled) {
|
|
4156
|
-
return cloneElement(children, { ref: childRef });
|
|
4157
|
-
}
|
|
4158
4142
|
const childProps = {
|
|
4159
4143
|
ref: childRef
|
|
4160
4144
|
};
|
|
4161
|
-
const wrapperProps = {};
|
|
4162
4145
|
if (!disableHoverListener) {
|
|
4163
|
-
|
|
4146
|
+
childProps.onMouseEnter = (e) => {
|
|
4164
4147
|
var _a, _b;
|
|
4165
4148
|
handleOpen();
|
|
4166
4149
|
(_b = (_a = children.props).onMouseEnter) == null ? void 0 : _b.call(_a, e);
|
|
4167
4150
|
};
|
|
4168
|
-
|
|
4151
|
+
childProps.onMouseLeave = (e) => {
|
|
4169
4152
|
var _a, _b;
|
|
4170
4153
|
handleClose();
|
|
4171
4154
|
(_b = (_a = children.props).onMouseLeave) == null ? void 0 : _b.call(_a, e);
|
|
4172
4155
|
};
|
|
4173
|
-
if (isChildDisabled) {
|
|
4174
|
-
wrapperProps.onMouseEnter = mouseEnterHandler;
|
|
4175
|
-
wrapperProps.onMouseLeave = mouseLeaveHandler;
|
|
4176
|
-
} else {
|
|
4177
|
-
childProps.onMouseEnter = mouseEnterHandler;
|
|
4178
|
-
childProps.onMouseLeave = mouseLeaveHandler;
|
|
4179
|
-
}
|
|
4180
4156
|
}
|
|
4181
|
-
if (!disableFocusListener
|
|
4157
|
+
if (!disableFocusListener) {
|
|
4182
4158
|
childProps.onFocus = (e) => {
|
|
4183
4159
|
var _a, _b;
|
|
4184
4160
|
handleOpen();
|
|
@@ -4191,33 +4167,32 @@ const FTooltip = ({
|
|
|
4191
4167
|
};
|
|
4192
4168
|
}
|
|
4193
4169
|
if (!disableTouchListener) {
|
|
4194
|
-
|
|
4170
|
+
childProps.onTouchStart = (e) => {
|
|
4195
4171
|
var _a, _b;
|
|
4196
4172
|
handleOpen();
|
|
4197
4173
|
(_b = (_a = children.props).onTouchStart) == null ? void 0 : _b.call(_a, e);
|
|
4198
4174
|
};
|
|
4199
|
-
|
|
4175
|
+
childProps.onTouchEnd = (e) => {
|
|
4200
4176
|
var _a, _b;
|
|
4201
4177
|
handleClose();
|
|
4202
4178
|
(_b = (_a = children.props).onTouchEnd) == null ? void 0 : _b.call(_a, e);
|
|
4203
4179
|
};
|
|
4204
|
-
if (isChildDisabled) {
|
|
4205
|
-
wrapperProps.onTouchStart = touchStartHandler;
|
|
4206
|
-
wrapperProps.onTouchEnd = touchEndHandler;
|
|
4207
|
-
} else {
|
|
4208
|
-
childProps.onTouchStart = touchStartHandler;
|
|
4209
|
-
childProps.onTouchEnd = touchEndHandler;
|
|
4210
|
-
}
|
|
4211
4180
|
}
|
|
4212
|
-
|
|
4213
|
-
const
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4181
|
+
let wrappedChild;
|
|
4182
|
+
const childPropsTyped = children.props;
|
|
4183
|
+
if (allowTooltipOnDisabled && React.isValidElement(children) && (childPropsTyped.disabled || childPropsTyped["aria-disabled"])) {
|
|
4184
|
+
wrappedChild = /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4185
|
+
"span",
|
|
4186
|
+
{
|
|
4187
|
+
ref: childRef,
|
|
4188
|
+
...childProps,
|
|
4189
|
+
style: { display: "inline-block", cursor: "not-allowed" },
|
|
4190
|
+
children
|
|
4191
|
+
}
|
|
4192
|
+
);
|
|
4193
|
+
} else {
|
|
4194
|
+
wrappedChild = cloneElement(children, childProps);
|
|
4195
|
+
}
|
|
4221
4196
|
const tooltipClasses = [
|
|
4222
4197
|
styles$5["f-tooltip"],
|
|
4223
4198
|
styles$5[`f-tooltip--${placement}`],
|
|
@@ -4240,7 +4215,7 @@ const FTooltip = ({
|
|
|
4240
4215
|
}
|
|
4241
4216
|
) : null;
|
|
4242
4217
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
4243
|
-
|
|
4218
|
+
wrappedChild,
|
|
4244
4219
|
tooltipElement && createPortal(tooltipElement, document.body)
|
|
4245
4220
|
] });
|
|
4246
4221
|
};
|