fui-material 2.1.3 → 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.
package/dist/f-ui-kit.es.js
CHANGED
|
@@ -3566,7 +3566,7 @@ const styles$b = {
|
|
|
3566
3566
|
"f-dropdown__content-link": "_f-dropdown__content-link_d5i2z_28",
|
|
3567
3567
|
"f-dropdown__content--open": "_f-dropdown__content--open_d5i2z_43"
|
|
3568
3568
|
};
|
|
3569
|
-
const FDropdown = ({
|
|
3569
|
+
const FDropdown = forwardRef(({
|
|
3570
3570
|
label,
|
|
3571
3571
|
variant = "contained",
|
|
3572
3572
|
color = "primary",
|
|
@@ -3575,20 +3575,23 @@ const FDropdown = ({
|
|
|
3575
3575
|
st: st2,
|
|
3576
3576
|
className,
|
|
3577
3577
|
id,
|
|
3578
|
-
children
|
|
3579
|
-
|
|
3578
|
+
children,
|
|
3579
|
+
...props
|
|
3580
|
+
}, forwardedRef) => {
|
|
3580
3581
|
const [isOpen, setIsOpen] = useState(false);
|
|
3581
|
-
const
|
|
3582
|
+
const internalRef = useRef(null);
|
|
3583
|
+
const ref = forwardedRef || internalRef;
|
|
3582
3584
|
useEffect(() => {
|
|
3583
3585
|
if (!isOpen) return;
|
|
3584
3586
|
const handleClick = (e) => {
|
|
3585
|
-
|
|
3587
|
+
const currentRef = typeof ref === "function" ? null : ref == null ? void 0 : ref.current;
|
|
3588
|
+
if (currentRef && !currentRef.contains(e.target)) {
|
|
3586
3589
|
setIsOpen(false);
|
|
3587
3590
|
}
|
|
3588
3591
|
};
|
|
3589
3592
|
document.addEventListener("mousedown", handleClick);
|
|
3590
3593
|
return () => document.removeEventListener("mousedown", handleClick);
|
|
3591
|
-
}, [isOpen]);
|
|
3594
|
+
}, [isOpen, ref]);
|
|
3592
3595
|
const handleItemClick = (child) => (e) => {
|
|
3593
3596
|
if (child.props && typeof child.props.onClick === "function") {
|
|
3594
3597
|
child.props.onClick(e);
|
|
@@ -3605,7 +3608,7 @@ const FDropdown = ({
|
|
|
3605
3608
|
return child;
|
|
3606
3609
|
});
|
|
3607
3610
|
};
|
|
3608
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$b["f-dropdown"], ref, children: [
|
|
3611
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$b["f-dropdown"], ref, ...props, children: [
|
|
3609
3612
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3610
3613
|
FButton,
|
|
3611
3614
|
{
|
|
@@ -3634,7 +3637,7 @@ const FDropdown = ({
|
|
|
3634
3637
|
}
|
|
3635
3638
|
)
|
|
3636
3639
|
] });
|
|
3637
|
-
};
|
|
3640
|
+
});
|
|
3638
3641
|
FDropdown.displayName = "FDropdown";
|
|
3639
3642
|
const FDropdownItem = ({
|
|
3640
3643
|
disabled: disabled2,
|
|
@@ -4027,6 +4030,7 @@ const FTooltip = ({
|
|
|
4027
4030
|
disableFocusListener = false,
|
|
4028
4031
|
disableTouchListener = false,
|
|
4029
4032
|
enterDelay = 0,
|
|
4033
|
+
disableOnDisabled = false,
|
|
4030
4034
|
className = "",
|
|
4031
4035
|
style
|
|
4032
4036
|
}) => {
|
|
@@ -4146,23 +4150,35 @@ const FTooltip = ({
|
|
|
4146
4150
|
cancelAnimationFrame(animationFrame.current);
|
|
4147
4151
|
}
|
|
4148
4152
|
};
|
|
4149
|
-
}, [isVisible]);
|
|
4153
|
+
}, [isVisible, updatePosition]);
|
|
4154
|
+
const isChildDisabled = children.props.disabled;
|
|
4155
|
+
if (isChildDisabled && disableOnDisabled) {
|
|
4156
|
+
return cloneElement(children, { ref: childRef });
|
|
4157
|
+
}
|
|
4150
4158
|
const childProps = {
|
|
4151
4159
|
ref: childRef
|
|
4152
4160
|
};
|
|
4161
|
+
const wrapperProps = {};
|
|
4153
4162
|
if (!disableHoverListener) {
|
|
4154
|
-
|
|
4163
|
+
const mouseEnterHandler = (e) => {
|
|
4155
4164
|
var _a, _b;
|
|
4156
4165
|
handleOpen();
|
|
4157
4166
|
(_b = (_a = children.props).onMouseEnter) == null ? void 0 : _b.call(_a, e);
|
|
4158
4167
|
};
|
|
4159
|
-
|
|
4168
|
+
const mouseLeaveHandler = (e) => {
|
|
4160
4169
|
var _a, _b;
|
|
4161
4170
|
handleClose();
|
|
4162
4171
|
(_b = (_a = children.props).onMouseLeave) == null ? void 0 : _b.call(_a, e);
|
|
4163
4172
|
};
|
|
4173
|
+
if (isChildDisabled) {
|
|
4174
|
+
wrapperProps.onMouseEnter = mouseEnterHandler;
|
|
4175
|
+
wrapperProps.onMouseLeave = mouseLeaveHandler;
|
|
4176
|
+
} else {
|
|
4177
|
+
childProps.onMouseEnter = mouseEnterHandler;
|
|
4178
|
+
childProps.onMouseLeave = mouseLeaveHandler;
|
|
4179
|
+
}
|
|
4164
4180
|
}
|
|
4165
|
-
if (!disableFocusListener) {
|
|
4181
|
+
if (!disableFocusListener && !isChildDisabled) {
|
|
4166
4182
|
childProps.onFocus = (e) => {
|
|
4167
4183
|
var _a, _b;
|
|
4168
4184
|
handleOpen();
|
|
@@ -4175,18 +4191,33 @@ const FTooltip = ({
|
|
|
4175
4191
|
};
|
|
4176
4192
|
}
|
|
4177
4193
|
if (!disableTouchListener) {
|
|
4178
|
-
|
|
4194
|
+
const touchStartHandler = (e) => {
|
|
4179
4195
|
var _a, _b;
|
|
4180
4196
|
handleOpen();
|
|
4181
4197
|
(_b = (_a = children.props).onTouchStart) == null ? void 0 : _b.call(_a, e);
|
|
4182
4198
|
};
|
|
4183
|
-
|
|
4199
|
+
const touchEndHandler = (e) => {
|
|
4184
4200
|
var _a, _b;
|
|
4185
4201
|
handleClose();
|
|
4186
4202
|
(_b = (_a = children.props).onTouchEnd) == null ? void 0 : _b.call(_a, e);
|
|
4187
4203
|
};
|
|
4204
|
+
if (isChildDisabled) {
|
|
4205
|
+
wrapperProps.onTouchStart = touchStartHandler;
|
|
4206
|
+
wrapperProps.onTouchEnd = touchEndHandler;
|
|
4207
|
+
} else {
|
|
4208
|
+
childProps.onTouchStart = touchStartHandler;
|
|
4209
|
+
childProps.onTouchEnd = touchEndHandler;
|
|
4210
|
+
}
|
|
4188
4211
|
}
|
|
4189
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;
|
|
4190
4221
|
const tooltipClasses = [
|
|
4191
4222
|
styles$5["f-tooltip"],
|
|
4192
4223
|
styles$5[`f-tooltip--${placement}`],
|
|
@@ -4209,7 +4240,7 @@ const FTooltip = ({
|
|
|
4209
4240
|
}
|
|
4210
4241
|
) : null;
|
|
4211
4242
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
4212
|
-
|
|
4243
|
+
childElement,
|
|
4213
4244
|
tooltipElement && createPortal(tooltipElement, document.body)
|
|
4214
4245
|
] });
|
|
4215
4246
|
};
|