fui-material 2.1.4 → 2.1.6

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.
@@ -4031,7 +4031,8 @@ const FTooltip = ({
4031
4031
  disableTouchListener = false,
4032
4032
  enterDelay = 0,
4033
4033
  className = "",
4034
- style
4034
+ style,
4035
+ allowTooltipOnDisabled = false
4035
4036
  }) => {
4036
4037
  const [open, setOpen] = useState(false);
4037
4038
  const [mountTooltip, setMountTooltip] = useState(false);
@@ -4045,12 +4046,8 @@ const FTooltip = ({
4045
4046
  const animationFrame = useRef(null);
4046
4047
  const isOpen = openProp !== void 0 ? openProp : open;
4047
4048
  const handleOpen = () => {
4048
- if (enterTimer.current) {
4049
- clearTimeout(enterTimer.current);
4050
- }
4051
- if (leaveTimer.current) {
4052
- clearTimeout(leaveTimer.current);
4053
- }
4049
+ if (enterTimer.current) clearTimeout(enterTimer.current);
4050
+ if (leaveTimer.current) clearTimeout(leaveTimer.current);
4054
4051
  enterTimer.current = setTimeout(() => {
4055
4052
  if (openProp === void 0) {
4056
4053
  setOpen(true);
@@ -4094,7 +4091,7 @@ const FTooltip = ({
4094
4091
  }
4095
4092
  }
4096
4093
  };
4097
- const updatePosition = () => {
4094
+ const updatePosition = useCallback(() => {
4098
4095
  if (!childRef.current || !tooltipRef.current) return;
4099
4096
  const childRect = childRef.current.getBoundingClientRect();
4100
4097
  const tooltipRect = tooltipRef.current.getBoundingClientRect();
@@ -4120,36 +4117,28 @@ const FTooltip = ({
4120
4117
  left2 = childRect.right + scrollX + (arrow2 ? 8 : 0);
4121
4118
  break;
4122
4119
  }
4123
- setTooltipStyles({
4124
- top: `${top}px`,
4125
- left: `${left2}px`
4126
- });
4127
- };
4120
+ setTooltipStyles({ top: `${top}px`, left: `${left2}px` });
4121
+ }, [placement, arrow2]);
4128
4122
  useEffect(() => {
4129
4123
  if (isVisible) {
4130
4124
  updatePosition();
4131
4125
  }
4132
- }, [isVisible, placement]);
4126
+ }, [isVisible, updatePosition]);
4133
4127
  useEffect(() => {
4134
4128
  const handleResize = () => {
4135
- if (isVisible) {
4136
- updatePosition();
4137
- }
4129
+ if (isVisible) updatePosition();
4138
4130
  };
4139
4131
  window.addEventListener("resize", handleResize);
4132
+ const currentEnterTimer = enterTimer.current;
4133
+ const currentLeaveTimer = leaveTimer.current;
4134
+ const currentAnimationFrame = animationFrame.current;
4140
4135
  return () => {
4141
4136
  window.removeEventListener("resize", handleResize);
4142
- if (enterTimer.current) {
4143
- clearTimeout(enterTimer.current);
4144
- }
4145
- if (leaveTimer.current) {
4146
- clearTimeout(leaveTimer.current);
4147
- }
4148
- if (animationFrame.current) {
4149
- cancelAnimationFrame(animationFrame.current);
4150
- }
4137
+ if (currentEnterTimer) clearTimeout(currentEnterTimer);
4138
+ if (currentLeaveTimer) clearTimeout(currentLeaveTimer);
4139
+ if (currentAnimationFrame) cancelAnimationFrame(currentAnimationFrame);
4151
4140
  };
4152
- }, [isVisible]);
4141
+ }, [isVisible, updatePosition]);
4153
4142
  const childProps = {
4154
4143
  ref: childRef
4155
4144
  };
@@ -4189,7 +4178,21 @@ const FTooltip = ({
4189
4178
  (_b = (_a = children.props).onTouchEnd) == null ? void 0 : _b.call(_a, e);
4190
4179
  };
4191
4180
  }
4192
- const clonedChild = cloneElement(children, childProps);
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
+ }
4193
4196
  const tooltipClasses = [
4194
4197
  styles$5["f-tooltip"],
4195
4198
  styles$5[`f-tooltip--${placement}`],
@@ -4212,7 +4215,7 @@ const FTooltip = ({
4212
4215
  }
4213
4216
  ) : null;
4214
4217
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4215
- clonedChild,
4218
+ wrappedChild,
4216
4219
  tooltipElement && createPortal(tooltipElement, document.body)
4217
4220
  ] });
4218
4221
  };