bianic-ui 2.2.0-beta.1 → 2.2.0
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/cjs/index.js +14 -12
- package/dist/cjs/lib.css +1 -1
- package/dist/cjs/types/components/Popover/index.d.ts +10 -2
- package/dist/cjs/types/components/Tooltip/PropsInterface.d.ts +2 -6
- package/dist/esm/index.js +14 -12
- package/dist/esm/lib.css +1 -1
- package/dist/esm/types/components/Popover/index.d.ts +10 -2
- package/dist/esm/types/components/Tooltip/PropsInterface.d.ts +2 -6
- package/dist/index.d.ts +5 -10
- package/package.json +45 -7
- package/dist/cjs/types/components/Popover/PropInterface.d.ts +0 -21
- package/dist/esm/types/components/Popover/PropInterface.d.ts +0 -21
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
interface PopoverProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
content: string;
|
|
5
|
+
delay?: number;
|
|
6
|
+
direction?: 'top' | 'right' | 'bottom' | 'left' | 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
7
|
+
title?: string;
|
|
8
|
+
maxWidth?: string;
|
|
9
|
+
}
|
|
10
|
+
declare function Popover({ children, content, delay, direction, title, maxWidth, }: PopoverProps): React.JSX.Element;
|
|
4
11
|
declare namespace Popover {
|
|
5
12
|
var defaultProps: {
|
|
13
|
+
delay: number;
|
|
6
14
|
direction: string;
|
|
7
15
|
title: string;
|
|
8
16
|
};
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import { ComponentPropsWithoutRef,
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode, RefObject } from 'react';
|
|
2
2
|
interface TooltipProps extends Omit<ComponentPropsWithoutRef<'div'>, 'content'> {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
content: ReactNode | string;
|
|
5
5
|
delay?: number;
|
|
6
6
|
maxWidth?: string;
|
|
7
|
-
zIndex?: number;
|
|
8
7
|
direction?: 'top' | 'right' | 'bottom' | 'left' | 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
9
8
|
}
|
|
10
9
|
interface TooltipItemProps {
|
|
11
10
|
anchorRef: RefObject<HTMLDivElement>;
|
|
12
|
-
|
|
11
|
+
direction?: 'top' | 'right' | 'bottom' | 'left' | 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
13
12
|
content: ReactNode | string;
|
|
14
13
|
tooltipContainerRef: React.RefObject<HTMLDivElement>;
|
|
15
14
|
tooltipContainerStyle: React.CSSProperties;
|
|
16
|
-
style?: ComponentPropsWithRef<'div'>['style'];
|
|
17
|
-
zIndex: number;
|
|
18
|
-
direction?: 'top' | 'right' | 'bottom' | 'left' | 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
19
15
|
}
|
|
20
16
|
export { TooltipProps, TooltipItemProps };
|
package/dist/esm/index.js
CHANGED
|
@@ -1987,15 +1987,15 @@ MenuItem.defaultProps = {
|
|
|
1987
1987
|
};
|
|
1988
1988
|
|
|
1989
1989
|
function Tooltip(props) {
|
|
1990
|
-
var children = props.children, content = props.content, delay = props.delay, _a = props.direction, direction = _a === void 0 ? 'top' : _a, _b = props.maxWidth, maxWidth = _b === void 0 ? undefined : _b
|
|
1990
|
+
var children = props.children, content = props.content, delay = props.delay, _a = props.direction, direction = _a === void 0 ? 'top' : _a, _b = props.maxWidth, maxWidth = _b === void 0 ? undefined : _b;
|
|
1991
1991
|
var timeout;
|
|
1992
|
-
var
|
|
1992
|
+
var _c = useState(false), active = _c[0], setActive = _c[1];
|
|
1993
1993
|
var anchorRef = useRef(null);
|
|
1994
1994
|
var tooltipContainerRef = useRef(null);
|
|
1995
|
-
var
|
|
1995
|
+
var _d = useState({
|
|
1996
1996
|
maxWidth: maxWidth + 'px',
|
|
1997
1997
|
whiteSpace: 'nowrap',
|
|
1998
|
-
}), tooltipContainerStyle =
|
|
1998
|
+
}), tooltipContainerStyle = _d[0], setTooltipContainerStyle = _d[1];
|
|
1999
1999
|
var showTip = function () {
|
|
2000
2000
|
timeout = setTimeout(function () {
|
|
2001
2001
|
setActive(true);
|
|
@@ -2039,12 +2039,12 @@ function Tooltip(props) {
|
|
|
2039
2039
|
}, [content, maxWidth, scrollWidth, offsetHeight]);
|
|
2040
2040
|
return (React.createElement("div", { className: "tooltip-wrapper relative inline-flex h-fit w-fit flex-col", onMouseEnter: showTip, onMouseLeave: hideTip, ref: anchorRef },
|
|
2041
2041
|
children,
|
|
2042
|
-
active && (React.createElement(TooltipItem, { anchorRef: anchorRef, direction: direction, content: content, tooltipContainerRef: tooltipContainerRef, tooltipContainerStyle: tooltipContainerStyle
|
|
2042
|
+
active && (React.createElement(TooltipItem, { anchorRef: anchorRef, direction: direction, content: content, tooltipContainerRef: tooltipContainerRef, tooltipContainerStyle: tooltipContainerStyle }))));
|
|
2043
2043
|
}
|
|
2044
2044
|
var TooltipItem = function (_a) {
|
|
2045
|
-
var anchorRef = _a.anchorRef,
|
|
2045
|
+
var anchorRef = _a.anchorRef, direction = _a.direction, content = _a.content, tooltipContainerRef = _a.tooltipContainerRef, tooltipContainerStyle = _a.tooltipContainerStyle;
|
|
2046
2046
|
var positionStyle = usePopupPosition(anchorRef, tooltipContainerRef, direction)[0];
|
|
2047
|
-
return createPortal(React.createElement("div", { className: "tooltip-container break-word absolute inline-block break-all rounded-[4px] bg-primary-black px-[7px] py-[4px] text-size-sm text-primary-white
|
|
2047
|
+
return createPortal(React.createElement("div", { className: "tooltip-container break-word absolute z-50 inline-block break-all rounded-[4px] bg-primary-black px-[7px] py-[4px] text-size-sm text-primary-white", style: __assign(__assign({}, positionStyle), tooltipContainerStyle), ref: tooltipContainerRef }, content), document.body);
|
|
2048
2048
|
};
|
|
2049
2049
|
Tooltip.defaultProps = {
|
|
2050
2050
|
delay: 400,
|
|
@@ -3707,19 +3707,20 @@ var classConfig = {
|
|
|
3707
3707
|
};
|
|
3708
3708
|
|
|
3709
3709
|
function Popover(_a) {
|
|
3710
|
-
var
|
|
3710
|
+
var children = _a.children, content = _a.content; _a.delay; var _c = _a.direction, direction = _c === void 0 ? 'bottom' : _c, _d = _a.title, title = _d === void 0 ? '' : _d; _a.maxWidth;
|
|
3711
3711
|
var wrapperRef = useRef(null);
|
|
3712
|
-
|
|
3712
|
+
useRef(null);
|
|
3713
|
+
var _e = useDetectOutsideClick(wrapperRef, false), isOpen = _e[0], setIsOpen = _e[1];
|
|
3713
3714
|
return (React.createElement("div", { className: "Bianic-popover-Wrapper relative block h-fit w-fit", role: "button", ref: wrapperRef, onClick: function () { return setIsOpen(true); } },
|
|
3714
3715
|
children,
|
|
3715
|
-
isOpen && (React.createElement(PopoverItem, { title: title, content: content, anchorRef: wrapperRef, direction: direction
|
|
3716
|
+
isOpen && (React.createElement(PopoverItem, { title: title, content: content, anchorRef: wrapperRef, direction: direction }))));
|
|
3716
3717
|
}
|
|
3717
3718
|
var PopoverItem = function (_a) {
|
|
3718
|
-
var title = _a.title, content = _a.content, anchorRef = _a.anchorRef, direction = _a.direction
|
|
3719
|
+
var title = _a.title, content = _a.content, anchorRef = _a.anchorRef, direction = _a.direction;
|
|
3719
3720
|
var popoverRef = useRef(null);
|
|
3720
3721
|
var positionStyle = usePopupPosition(anchorRef, popoverRef, direction)[0];
|
|
3721
3722
|
var _b = classConfig[direction], triangleContainer = _b.triangleContainer, triangleShape = _b.triangleShape;
|
|
3722
|
-
return createPortal(React.createElement("div", { ref: popoverRef, style:
|
|
3723
|
+
return createPortal(React.createElement("div", { ref: popoverRef, style: positionStyle, className: "Bianic-popover-Tip text-bia-sm absolute z-50 w-[245px] space-y-[5px] rounded-[4px] bg-primary-black px-[20px] py-[17.5px] text-primary-white" },
|
|
3723
3724
|
React.createElement("div", { className: "flex flex-col" },
|
|
3724
3725
|
React.createElement("div", { className: "mb-[5px] font-humnst777 text-[16px] font-bold leading-[19.42px]" }, title),
|
|
3725
3726
|
React.createElement("div", { className: "break-words font-segoe text-[12px] font-normal" }, content)),
|
|
@@ -3727,6 +3728,7 @@ var PopoverItem = function (_a) {
|
|
|
3727
3728
|
React.createElement("div", { className: "h-0 w-0 ".concat(triangleShape) }))), document.body);
|
|
3728
3729
|
};
|
|
3729
3730
|
Popover.defaultProps = {
|
|
3731
|
+
delay: 400,
|
|
3730
3732
|
direction: 'top',
|
|
3731
3733
|
title: '',
|
|
3732
3734
|
};
|