fui-material 2.1.4 → 2.1.5

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.
@@ -4030,6 +4030,7 @@ const FTooltip = ({
4030
4030
  disableFocusListener = false,
4031
4031
  disableTouchListener = false,
4032
4032
  enterDelay = 0,
4033
+ disableOnDisabled = false,
4033
4034
  className = "",
4034
4035
  style
4035
4036
  }) => {
@@ -4149,23 +4150,35 @@ const FTooltip = ({
4149
4150
  cancelAnimationFrame(animationFrame.current);
4150
4151
  }
4151
4152
  };
4152
- }, [isVisible]);
4153
+ }, [isVisible, updatePosition]);
4154
+ const isChildDisabled = children.props.disabled;
4155
+ if (isChildDisabled && disableOnDisabled) {
4156
+ return cloneElement(children, { ref: childRef });
4157
+ }
4153
4158
  const childProps = {
4154
4159
  ref: childRef
4155
4160
  };
4161
+ const wrapperProps = {};
4156
4162
  if (!disableHoverListener) {
4157
- childProps.onMouseEnter = (e) => {
4163
+ const mouseEnterHandler = (e) => {
4158
4164
  var _a, _b;
4159
4165
  handleOpen();
4160
4166
  (_b = (_a = children.props).onMouseEnter) == null ? void 0 : _b.call(_a, e);
4161
4167
  };
4162
- childProps.onMouseLeave = (e) => {
4168
+ const mouseLeaveHandler = (e) => {
4163
4169
  var _a, _b;
4164
4170
  handleClose();
4165
4171
  (_b = (_a = children.props).onMouseLeave) == null ? void 0 : _b.call(_a, e);
4166
4172
  };
4173
+ if (isChildDisabled) {
4174
+ wrapperProps.onMouseEnter = mouseEnterHandler;
4175
+ wrapperProps.onMouseLeave = mouseLeaveHandler;
4176
+ } else {
4177
+ childProps.onMouseEnter = mouseEnterHandler;
4178
+ childProps.onMouseLeave = mouseLeaveHandler;
4179
+ }
4167
4180
  }
4168
- if (!disableFocusListener) {
4181
+ if (!disableFocusListener && !isChildDisabled) {
4169
4182
  childProps.onFocus = (e) => {
4170
4183
  var _a, _b;
4171
4184
  handleOpen();
@@ -4178,18 +4191,33 @@ const FTooltip = ({
4178
4191
  };
4179
4192
  }
4180
4193
  if (!disableTouchListener) {
4181
- childProps.onTouchStart = (e) => {
4194
+ const touchStartHandler = (e) => {
4182
4195
  var _a, _b;
4183
4196
  handleOpen();
4184
4197
  (_b = (_a = children.props).onTouchStart) == null ? void 0 : _b.call(_a, e);
4185
4198
  };
4186
- childProps.onTouchEnd = (e) => {
4199
+ const touchEndHandler = (e) => {
4187
4200
  var _a, _b;
4188
4201
  handleClose();
4189
4202
  (_b = (_a = children.props).onTouchEnd) == null ? void 0 : _b.call(_a, e);
4190
4203
  };
4204
+ if (isChildDisabled) {
4205
+ wrapperProps.onTouchStart = touchStartHandler;
4206
+ wrapperProps.onTouchEnd = touchEndHandler;
4207
+ } else {
4208
+ childProps.onTouchStart = touchStartHandler;
4209
+ childProps.onTouchEnd = touchEndHandler;
4210
+ }
4191
4211
  }
4192
4212
  const clonedChild = cloneElement(children, childProps);
4213
+ const childElement = isChildDisabled ? /* @__PURE__ */ jsxRuntimeExports.jsx(
4214
+ "div",
4215
+ {
4216
+ style: { display: "inline-block", cursor: "not-allowed" },
4217
+ ...wrapperProps,
4218
+ children: clonedChild
4219
+ }
4220
+ ) : clonedChild;
4193
4221
  const tooltipClasses = [
4194
4222
  styles$5["f-tooltip"],
4195
4223
  styles$5[`f-tooltip--${placement}`],
@@ -4212,7 +4240,7 @@ const FTooltip = ({
4212
4240
  }
4213
4241
  ) : null;
4214
4242
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4215
- clonedChild,
4243
+ childElement,
4216
4244
  tooltipElement && createPortal(tooltipElement, document.body)
4217
4245
  ] });
4218
4246
  };