@conveyorhq/arrow-ds 1.165.0 → 1.167.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/package.json +1 -1
- package/public/components/Button/Button.d.ts +2 -1
- package/public/components/Button/Button.js +6 -2
- package/public/components/Tooltip/Tooltip.d.ts +12 -2
- package/public/components/Tooltip/Tooltip.js +30 -6
- package/public/css/styles.css +2 -8
- package/public/css/styles.min.css +1 -1
- package/public/css/styles.min.css.map +1 -1
- package/src/components/Button/Button.stories.mdx +28 -0
- package/src/components/Button/Button.tsx +25 -9
- package/src/components/Button/index.css +2 -9
- package/src/components/Tooltip/Tooltip.stories.mdx +31 -0
- package/src/components/Tooltip/Tooltip.tsx +56 -7
package/package.json
CHANGED
|
@@ -42,6 +42,7 @@ var BUTTON_VARIANT;
|
|
|
42
42
|
BUTTON_VARIANT["UTILITY"] = "utility";
|
|
43
43
|
BUTTON_VARIANT["DANGER"] = "danger";
|
|
44
44
|
BUTTON_VARIANT["MINIMAL"] = "minimal";
|
|
45
|
+
BUTTON_VARIANT["PLAIN"] = "plain";
|
|
45
46
|
})(BUTTON_VARIANT || (exports.BUTTON_VARIANT = BUTTON_VARIANT = {}));
|
|
46
47
|
var BUTTON_SIZE;
|
|
47
48
|
(function (BUTTON_SIZE) {
|
|
@@ -74,7 +75,7 @@ const Button = (0, react_1.forwardRef)(({ as: Component = "button", children, cl
|
|
|
74
75
|
const themeContext = (0, react_1.useContext)(contexts_1.ThemeContext);
|
|
75
76
|
const theme = themeProp || themeContext;
|
|
76
77
|
const buttonClassNames = (0, classnames_1.default)((0, bem_1.bem)(cn), (0, bem_1.bem)(cn, { m: variant }), (0, bem_1.bem)(cn, { m: theme }), block && (0, bem_1.bem)(cn, { m: "block" }), getButtonSizeClasses(size, icon, children), depressed && (0, bem_1.bem)(cn, { m: "depressed" }), isDisabled && (0, bem_1.bem)(cn, { m: "disabled" }), className);
|
|
77
|
-
const iconClassNames = (0, classnames_1.default)((0, bem_1.bem)(cn, { e: "icon" }),
|
|
78
|
+
const iconClassNames = (0, classnames_1.default)((0, bem_1.bem)(cn, { e: "icon" }), isLoading && (0, bem_1.bem)(cn, { e: "icon", m: "invisible" }));
|
|
78
79
|
const iconProps = icon
|
|
79
80
|
? {
|
|
80
81
|
icon,
|
|
@@ -89,9 +90,12 @@ const Button = (0, react_1.forwardRef)(({ as: Component = "button", children, cl
|
|
|
89
90
|
type = "button";
|
|
90
91
|
}
|
|
91
92
|
const propsIfLink = Component === Link_1.Link ? { noStyles: true } : {};
|
|
93
|
+
if (variant === BUTTON_VARIANT.PLAIN) {
|
|
94
|
+
return (react_1.default.createElement(Component, { type: type, className: className, disabled: disabled, ref: ref, ...rest }, children));
|
|
95
|
+
}
|
|
92
96
|
return (react_1.default.createElement(Component, { type: type, className: buttonClassNames, disabled: isDisabled, ref: ref, ...propsIfLink, ...rest },
|
|
93
97
|
icon && iconProps && iconPosition === BUTTON_ICON_POSITION.LEFT && (react_1.default.createElement(Icon_1.Icon, { ...iconProps })),
|
|
94
|
-
react_1.default.createElement("span", { className: (0, classnames_1.default)((0, bem_1.bem)(cn, { e: "content" }), isLoading && (0, bem_1.bem)(cn, { e: "content", m: "invisible" })) }, children),
|
|
98
|
+
children && (react_1.default.createElement("span", { className: (0, classnames_1.default)((0, bem_1.bem)(cn, { e: "content" }), isLoading && (0, bem_1.bem)(cn, { e: "content", m: "invisible" })) }, children)),
|
|
95
99
|
icon && iconProps && iconPosition === BUTTON_ICON_POSITION.RIGHT && (react_1.default.createElement(Icon_1.Icon, { ...iconProps })),
|
|
96
100
|
isLoading && (react_1.default.createElement(Icon_1.Icon, { className: (0, bem_1.bem)(cn, { e: "loader" }), icon: Icon_1.ICON_TYPE.CIRCLE_NOTCH, spin: true }))));
|
|
97
101
|
});
|
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { ReactElement } from "react";
|
|
2
2
|
import { PopoverTooltipSharedProps } from "../Popover";
|
|
3
3
|
export interface TooltipProps extends PopoverTooltipSharedProps {
|
|
4
|
-
delay?: number
|
|
4
|
+
delay?: number | {
|
|
5
|
+
show?: number;
|
|
6
|
+
hide?: number;
|
|
7
|
+
};
|
|
5
8
|
theme?: "light" | "dark";
|
|
6
9
|
hideArrow?: boolean;
|
|
7
10
|
open?: boolean;
|
|
8
11
|
setOpen?(open: boolean): void;
|
|
9
12
|
}
|
|
13
|
+
type ReferenceRenderFunction = (props: {
|
|
14
|
+
isOpen: boolean;
|
|
15
|
+
}) => ReactElement;
|
|
16
|
+
export declare const TooltipReference: React.ForwardRefExoticComponent<{
|
|
17
|
+
children: ReferenceRenderFunction | ReactElement;
|
|
18
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
10
19
|
export declare const Tooltip: (props: TooltipProps) => React.JSX.Element;
|
|
20
|
+
export {};
|
|
@@ -26,17 +26,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.Tooltip = void 0;
|
|
29
|
+
exports.Tooltip = exports.TooltipReference = void 0;
|
|
30
30
|
const react_1 = __importStar(require("react"));
|
|
31
31
|
const classnames_1 = __importDefault(require("classnames"));
|
|
32
32
|
const bem_1 = require("../../utilities/bem");
|
|
33
33
|
const hooks_1 = require("../../hooks");
|
|
34
|
+
const Box_1 = require("../Box");
|
|
34
35
|
const Popover_1 = require("../Popover");
|
|
35
36
|
const types_1 = require("../../types");
|
|
36
37
|
const context_1 = require("./context");
|
|
38
|
+
const DEFAULT_DELAY = 200;
|
|
37
39
|
const cn = "Tooltip";
|
|
40
|
+
exports.TooltipReference = react_1.default.forwardRef(({ children, ...props }, ref) => {
|
|
41
|
+
const { isOpen } = (0, context_1.useTooltipContext)();
|
|
42
|
+
return (react_1.default.createElement(Box_1.Box, { ref: ref, ...props }, typeof children === "function" ? children({ isOpen }) : children));
|
|
43
|
+
});
|
|
38
44
|
const Tooltip = (props) => {
|
|
39
|
-
const { isVisible: isVisibleInitial = false, open: isOpenControlled, setOpen: setOpenControlled, children, referenceElement, placement = "bottom", className, delay
|
|
45
|
+
const { isVisible: isVisibleInitial = false, open: isOpenControlled, setOpen: setOpenControlled, children, referenceElement, placement = "bottom", className, delay, theme = "dark", hideArrow, style, ...rest } = props;
|
|
40
46
|
const [isOpenUncontrolled, setOpenUncontrolled] = (0, react_1.useState)(isVisibleInitial);
|
|
41
47
|
const open = isOpenControlled !== null && isOpenControlled !== void 0 ? isOpenControlled : isOpenUncontrolled;
|
|
42
48
|
const setOpen = setOpenControlled !== null && setOpenControlled !== void 0 ? setOpenControlled : setOpenUncontrolled;
|
|
@@ -44,6 +50,24 @@ const Tooltip = (props) => {
|
|
|
44
50
|
const isHoveringPopoverRef = (0, react_1.useRef)(false);
|
|
45
51
|
const referenceTimoutRef = (0, react_1.useRef)(null);
|
|
46
52
|
const popoverTimoutRef = (0, react_1.useRef)(null);
|
|
53
|
+
const showDelay = (0, react_1.useMemo)(() => {
|
|
54
|
+
if (typeof delay === "number") {
|
|
55
|
+
return delay;
|
|
56
|
+
}
|
|
57
|
+
if (typeof delay !== "undefined" && typeof delay.show === "number") {
|
|
58
|
+
return delay.show;
|
|
59
|
+
}
|
|
60
|
+
return DEFAULT_DELAY;
|
|
61
|
+
}, [delay]);
|
|
62
|
+
const hideDelay = (0, react_1.useMemo)(() => {
|
|
63
|
+
if (typeof delay === "number") {
|
|
64
|
+
return delay;
|
|
65
|
+
}
|
|
66
|
+
if (typeof delay !== "undefined" && typeof delay.hide === "number") {
|
|
67
|
+
return delay.hide;
|
|
68
|
+
}
|
|
69
|
+
return DEFAULT_DELAY;
|
|
70
|
+
}, [delay]);
|
|
47
71
|
(0, react_1.useEffect)(() => {
|
|
48
72
|
if (isVisibleInitial) {
|
|
49
73
|
setOpen(true);
|
|
@@ -60,7 +84,7 @@ const Tooltip = (props) => {
|
|
|
60
84
|
};
|
|
61
85
|
});
|
|
62
86
|
const close = () => {
|
|
63
|
-
if (!isHoveringPopoverRef.current) {
|
|
87
|
+
if (!isHoveringPopoverRef.current && !isHoveringReferenceRef.current) {
|
|
64
88
|
setOpen(false);
|
|
65
89
|
}
|
|
66
90
|
};
|
|
@@ -71,14 +95,14 @@ const Tooltip = (props) => {
|
|
|
71
95
|
if (isHoveringReferenceRef.current) {
|
|
72
96
|
setOpen(true);
|
|
73
97
|
}
|
|
74
|
-
},
|
|
98
|
+
}, showDelay);
|
|
75
99
|
referenceTimoutRef.current = referenceTimeout;
|
|
76
100
|
}
|
|
77
101
|
};
|
|
78
102
|
const handleMouseLeave = () => {
|
|
79
103
|
isHoveringReferenceRef.current = false;
|
|
80
104
|
if (open) {
|
|
81
|
-
const popoverTimeout = setTimeout(close,
|
|
105
|
+
const popoverTimeout = setTimeout(close, hideDelay);
|
|
82
106
|
popoverTimoutRef.current = popoverTimeout;
|
|
83
107
|
}
|
|
84
108
|
};
|
|
@@ -90,7 +114,7 @@ const Tooltip = (props) => {
|
|
|
90
114
|
const handlePopoverMouseLeave = () => {
|
|
91
115
|
isHoveringPopoverRef.current = false;
|
|
92
116
|
if (open) {
|
|
93
|
-
const popoverTimeout = setTimeout(close,
|
|
117
|
+
const popoverTimeout = setTimeout(close, hideDelay);
|
|
94
118
|
popoverTimoutRef.current = popoverTimeout;
|
|
95
119
|
}
|
|
96
120
|
};
|
package/public/css/styles.css
CHANGED
|
@@ -2069,19 +2069,13 @@ override built-in Image component classes */
|
|
|
2069
2069
|
display: inline-flex;
|
|
2070
2070
|
align-items: center;
|
|
2071
2071
|
justify-content: center;
|
|
2072
|
+
-webkit-column-gap: 8px;
|
|
2073
|
+
column-gap: 8px;
|
|
2072
2074
|
border-width: 1px;
|
|
2073
2075
|
font-weight: 500;
|
|
2074
2076
|
transition-duration: 200ms;
|
|
2075
2077
|
}
|
|
2076
2078
|
|
|
2077
|
-
.ads-Button-icon--left {
|
|
2078
|
-
margin-right: 8px;
|
|
2079
|
-
}
|
|
2080
|
-
|
|
2081
|
-
.ads-Button-icon--right {
|
|
2082
|
-
margin-left: 8px;
|
|
2083
|
-
}
|
|
2084
|
-
|
|
2085
2079
|
.ads-Button-icon--invisible {
|
|
2086
2080
|
visibility: hidden;
|
|
2087
2081
|
}
|