oolib 2.224.0 → 2.225.1
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/components/SimpleTable/comps/rowColActionMenus/RowActionsMenu/index.d.ts +2 -1
- package/dist/components/SimpleTable/comps/rowColActionMenus/RowActionsMenu/index.js +4 -4
- package/dist/components/SimpleTable/handlers/handleRowActions.d.ts +6 -3
- package/dist/components/SimpleTable/handlers/handleRowActions.js +13 -12
- package/dist/components/SimpleTable/index.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/stories/v2/components/Tooltip.stories.d.ts +215 -0
- package/dist/stories/v2/components/Tooltip.stories.js +197 -0
- package/dist/utils/customHooks/useFloatingPosition.d.ts +99 -0
- package/dist/utils/customHooks/useFloatingPosition.js +102 -0
- package/dist/v2/components/TextInputs/index.styled.js +1 -1
- package/dist/v2/components/Tooltip/Layout/TooltipHeading.d.ts +10 -0
- package/dist/v2/components/Tooltip/Layout/TooltipHeading.js +29 -0
- package/dist/v2/components/Tooltip/Layout/TooltipText.d.ts +8 -0
- package/dist/v2/components/Tooltip/Layout/TooltipText.js +28 -0
- package/dist/v2/components/Tooltip/Layout/index.d.ts +2 -0
- package/dist/v2/components/Tooltip/Layout/index.js +10 -0
- package/dist/v2/components/Tooltip/index.d.ts +21 -0
- package/dist/v2/components/Tooltip/index.js +216 -0
- package/dist/v2/components/Tooltip/styled.d.ts +24 -0
- package/dist/v2/components/Tooltip/styled.js +81 -0
- package/dist/v2/components/Tooltip/utils/autoSafeFlip.d.ts +4 -0
- package/dist/v2/components/Tooltip/utils/autoSafeFlip.js +63 -0
- package/dist/v2/components/Tooltip/utils/index.d.ts +26 -0
- package/dist/v2/components/Tooltip/utils/index.js +66 -0
- package/package.json +7 -2
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { type UseFloatingOptions, type OpenChangeReason, type UseHoverProps, type UseClickProps, type UseDismissProps, type UseFocusProps, type UseRoleProps, type ArrowOptions, type OffsetOptions, type ShiftOptions, type FlipOptions, type AutoPlacementOptions, type HideOptions, type UseTransitionStylesProps, type Middleware } from "@floating-ui/react";
|
|
2
|
+
import { type CSSProperties } from "react";
|
|
3
|
+
interface UseFloatingPositionPropsBase {
|
|
4
|
+
placement?: UseFloatingOptions["placement"];
|
|
5
|
+
strategy?: UseFloatingOptions["strategy"];
|
|
6
|
+
transform?: UseFloatingOptions["transform"];
|
|
7
|
+
open?: boolean;
|
|
8
|
+
onOpenChange?(open: boolean, event?: Event, reason?: OpenChangeReason): void;
|
|
9
|
+
dismissOptions?: UseDismissProps;
|
|
10
|
+
focusOptions?: UseFocusProps;
|
|
11
|
+
roleOptions?: UseRoleProps;
|
|
12
|
+
showArrow?: boolean;
|
|
13
|
+
arrowRef?: ArrowOptions["element"];
|
|
14
|
+
arrowPadding?: number;
|
|
15
|
+
enableDelayGroups?: boolean;
|
|
16
|
+
transitionOptions?: UseTransitionStylesProps;
|
|
17
|
+
customMiddleware?: Middleware[];
|
|
18
|
+
disableAutoUpdate?: boolean;
|
|
19
|
+
middlewareOptions?: {
|
|
20
|
+
offset?: {
|
|
21
|
+
enabled?: boolean;
|
|
22
|
+
config?: OffsetOptions;
|
|
23
|
+
};
|
|
24
|
+
shift?: {
|
|
25
|
+
enabled?: boolean;
|
|
26
|
+
config?: ShiftOptions;
|
|
27
|
+
};
|
|
28
|
+
flip?: {
|
|
29
|
+
enabled?: boolean;
|
|
30
|
+
config?: FlipOptions;
|
|
31
|
+
};
|
|
32
|
+
autoPlacement?: {
|
|
33
|
+
enabled?: boolean;
|
|
34
|
+
config?: AutoPlacementOptions;
|
|
35
|
+
};
|
|
36
|
+
hide?: {
|
|
37
|
+
enabled?: boolean;
|
|
38
|
+
config?: HideOptions;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
interface UseFloatingPositionPropsHover extends UseFloatingPositionPropsBase {
|
|
43
|
+
enableTriggerOnClick?: false;
|
|
44
|
+
enableHover?: boolean;
|
|
45
|
+
hoverOptions?: Omit<UseHoverProps, "enabled">;
|
|
46
|
+
}
|
|
47
|
+
interface UseFloatingPositionPropsClick extends UseFloatingPositionPropsBase {
|
|
48
|
+
enableTriggerOnClick: true;
|
|
49
|
+
clickOptions?: Omit<UseClickProps, "enabled">;
|
|
50
|
+
}
|
|
51
|
+
export type UseFloatingPositionProps = UseFloatingPositionPropsHover | UseFloatingPositionPropsClick;
|
|
52
|
+
export declare const useFloatingPosition: ({ placement, strategy, transform, open, onOpenChange, enableTriggerOnClick, dismissOptions, focusOptions, roleOptions, showArrow, arrowRef, arrowPadding, enableDelayGroups, transitionOptions, customMiddleware, disableAutoUpdate, middlewareOptions, ...options }: UseFloatingPositionProps) => {
|
|
53
|
+
getReferenceProps: (userProps?: React.HTMLProps<Element>) => Record<string, unknown>;
|
|
54
|
+
getFloatingProps: (userProps?: React.HTMLProps<HTMLElement>) => Record<string, unknown>;
|
|
55
|
+
getItemProps: (userProps?: Omit<React.HTMLProps<HTMLElement>, "selected" | "active"> & {
|
|
56
|
+
active?: boolean;
|
|
57
|
+
selected?: boolean;
|
|
58
|
+
}) => Record<string, unknown>;
|
|
59
|
+
strategy: import("@floating-ui/utils").Strategy;
|
|
60
|
+
y: number;
|
|
61
|
+
x: number;
|
|
62
|
+
floatingStyles: React.CSSProperties;
|
|
63
|
+
refs: {
|
|
64
|
+
reference: import("react").MutableRefObject<import("@floating-ui/react-dom").ReferenceType>;
|
|
65
|
+
floating: React.MutableRefObject<HTMLElement | null>;
|
|
66
|
+
setReference: (node: import("@floating-ui/react-dom").ReferenceType) => void;
|
|
67
|
+
setFloating: (node: HTMLElement | null) => void;
|
|
68
|
+
} & import("@floating-ui/react").ExtendedRefs<import("@floating-ui/react").ReferenceType>;
|
|
69
|
+
elements: {
|
|
70
|
+
reference: import("@floating-ui/react-dom").ReferenceType;
|
|
71
|
+
floating: HTMLElement | null;
|
|
72
|
+
} & import("@floating-ui/react").ExtendedElements<import("@floating-ui/react").ReferenceType>;
|
|
73
|
+
state: "initial" | "unmounted" | "positioned";
|
|
74
|
+
middlewareData: import("@floating-ui/core").MiddlewareData;
|
|
75
|
+
context: {
|
|
76
|
+
y: number;
|
|
77
|
+
x: number;
|
|
78
|
+
placement: import("@floating-ui/utils").Placement;
|
|
79
|
+
strategy: import("@floating-ui/utils").Strategy;
|
|
80
|
+
middlewareData: import("@floating-ui/core").MiddlewareData;
|
|
81
|
+
isPositioned: boolean;
|
|
82
|
+
update: () => void;
|
|
83
|
+
floatingStyles: React.CSSProperties;
|
|
84
|
+
open: boolean;
|
|
85
|
+
onOpenChange: (open: boolean, event?: Event, reason?: OpenChangeReason) => void;
|
|
86
|
+
events: import("@floating-ui/react").FloatingEvents;
|
|
87
|
+
dataRef: React.MutableRefObject<import("@floating-ui/react").ContextData>;
|
|
88
|
+
nodeId: string | undefined;
|
|
89
|
+
floatingId: string | undefined;
|
|
90
|
+
refs: import("@floating-ui/react").ExtendedRefs<import("@floating-ui/react").ReferenceType>;
|
|
91
|
+
elements: import("@floating-ui/react").ExtendedElements<import("@floating-ui/react").ReferenceType>;
|
|
92
|
+
};
|
|
93
|
+
computedPlacement: import("@floating-ui/utils").Placement;
|
|
94
|
+
isPositioned: boolean;
|
|
95
|
+
isMounted: boolean;
|
|
96
|
+
transitionStyles: CSSProperties;
|
|
97
|
+
update: () => void;
|
|
98
|
+
};
|
|
99
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.useFloatingPosition = void 0;
|
|
26
|
+
var react_1 = require("@floating-ui/react");
|
|
27
|
+
var react_2 = require("react");
|
|
28
|
+
var useFloatingPosition = function (_a) {
|
|
29
|
+
var placement = _a.placement, strategy = _a.strategy, transform = _a.transform, open = _a.open, onOpenChange = _a.onOpenChange, _b = _a.enableTriggerOnClick, enableTriggerOnClick = _b === void 0 ? false : _b, dismissOptions = _a.dismissOptions, focusOptions = _a.focusOptions, roleOptions = _a.roleOptions, _c = _a.showArrow, showArrow = _c === void 0 ? false : _c, arrowRef = _a.arrowRef, arrowPadding = _a.arrowPadding, _d = _a.enableDelayGroups, enableDelayGroups = _d === void 0 ? true : _d, transitionOptions = _a.transitionOptions, customMiddleware = _a.customMiddleware, _e = _a.disableAutoUpdate, disableAutoUpdate = _e === void 0 ? false : _e, _f = _a.middlewareOptions, middlewareOptions = _f === void 0 ? {} : _f, options = __rest(_a, ["placement", "strategy", "transform", "open", "onOpenChange", "enableTriggerOnClick", "dismissOptions", "focusOptions", "roleOptions", "showArrow", "arrowRef", "arrowPadding", "enableDelayGroups", "transitionOptions", "customMiddleware", "disableAutoUpdate", "middlewareOptions"]);
|
|
30
|
+
var _g = (0, react_2.useState)("unmounted"), state = _g[0], setState = _g[1];
|
|
31
|
+
var middlewares = [];
|
|
32
|
+
var offsetConfig = middlewareOptions.offset;
|
|
33
|
+
if ((offsetConfig === null || offsetConfig === void 0 ? void 0 : offsetConfig.enabled) !== false) {
|
|
34
|
+
middlewares.push((0, react_1.offset)((offsetConfig === null || offsetConfig === void 0 ? void 0 : offsetConfig.config) || 5));
|
|
35
|
+
}
|
|
36
|
+
var shiftConfig = middlewareOptions.shift;
|
|
37
|
+
if ((shiftConfig === null || shiftConfig === void 0 ? void 0 : shiftConfig.enabled) === true) {
|
|
38
|
+
middlewares.push((0, react_1.shift)(shiftConfig === null || shiftConfig === void 0 ? void 0 : shiftConfig.config));
|
|
39
|
+
}
|
|
40
|
+
// flip and autoPlacement are mutually exclusive
|
|
41
|
+
var flipConfig = middlewareOptions.flip;
|
|
42
|
+
var autoPlacementConfig = middlewareOptions.autoPlacement;
|
|
43
|
+
if ((flipConfig === null || flipConfig === void 0 ? void 0 : flipConfig.enabled) !== false && (autoPlacementConfig === null || autoPlacementConfig === void 0 ? void 0 : autoPlacementConfig.enabled) !== true) {
|
|
44
|
+
middlewares.push((0, react_1.flip)(flipConfig === null || flipConfig === void 0 ? void 0 : flipConfig.config));
|
|
45
|
+
}
|
|
46
|
+
else if ((autoPlacementConfig === null || autoPlacementConfig === void 0 ? void 0 : autoPlacementConfig.enabled) === true &&
|
|
47
|
+
(flipConfig === null || flipConfig === void 0 ? void 0 : flipConfig.enabled) !== true) {
|
|
48
|
+
middlewares.push((0, react_1.autoPlacement)(autoPlacementConfig === null || autoPlacementConfig === void 0 ? void 0 : autoPlacementConfig.config));
|
|
49
|
+
}
|
|
50
|
+
if (customMiddleware && customMiddleware.length > 0) {
|
|
51
|
+
middlewares.push.apply(middlewares, customMiddleware);
|
|
52
|
+
}
|
|
53
|
+
if (showArrow && arrowRef) {
|
|
54
|
+
middlewares.push((0, react_1.arrow)({ element: arrowRef, padding: arrowPadding }));
|
|
55
|
+
}
|
|
56
|
+
var hideConfig = middlewareOptions.hide;
|
|
57
|
+
if ((hideConfig === null || hideConfig === void 0 ? void 0 : hideConfig.enabled) === true) {
|
|
58
|
+
middlewares.push((0, react_1.hide)(hideConfig === null || hideConfig === void 0 ? void 0 : hideConfig.config));
|
|
59
|
+
}
|
|
60
|
+
var _h = (0, react_1.useFloating)({
|
|
61
|
+
placement: placement,
|
|
62
|
+
strategy: strategy,
|
|
63
|
+
transform: transform,
|
|
64
|
+
open: open,
|
|
65
|
+
onOpenChange: function (open) {
|
|
66
|
+
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(open);
|
|
67
|
+
if (open) {
|
|
68
|
+
if (state === "unmounted")
|
|
69
|
+
setState("initial");
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
whileElementsMounted: disableAutoUpdate ? undefined : react_1.autoUpdate,
|
|
73
|
+
middleware: middlewares,
|
|
74
|
+
}), context = _h.context, middlewareData = _h.middlewareData, isPositioned = _h.isPositioned, computedPlacement = _h.placement, update = _h.update, rest = __rest(_h, ["context", "middlewareData", "isPositioned", "placement", "update"]);
|
|
75
|
+
var delayGroupContext = (0, react_1.useDelayGroup)(context, {
|
|
76
|
+
enabled: enableDelayGroups,
|
|
77
|
+
});
|
|
78
|
+
var delayGroupDelay = enableDelayGroups && delayGroupContext
|
|
79
|
+
? delayGroupContext.delay
|
|
80
|
+
: undefined;
|
|
81
|
+
var enableHover = "enableHover" in options ? options.enableHover : true;
|
|
82
|
+
var hover = (0, react_1.useHover)(context, __assign(__assign({}, ("hoverOptions" in options ? options.hoverOptions : {})), { enabled: !enableTriggerOnClick && enableHover !== false, delay: enableDelayGroups ? delayGroupDelay : undefined }));
|
|
83
|
+
var click = (0, react_1.useClick)(context, __assign(__assign({}, ("clickOptions" in options ? options.clickOptions : {})), { enabled: enableTriggerOnClick }));
|
|
84
|
+
var focus = (0, react_1.useFocus)(context, focusOptions);
|
|
85
|
+
var role = (0, react_1.useRole)(context, roleOptions);
|
|
86
|
+
var dismiss = (0, react_1.useDismiss)(context, dismissOptions);
|
|
87
|
+
var interactionProps = (0, react_1.useInteractions)([
|
|
88
|
+
hover,
|
|
89
|
+
click,
|
|
90
|
+
focus,
|
|
91
|
+
role,
|
|
92
|
+
dismiss,
|
|
93
|
+
]);
|
|
94
|
+
var _j = (0, react_1.useTransitionStyles)(context, transitionOptions), isMounted = _j.isMounted, transitionStyles = _j.styles;
|
|
95
|
+
(0, react_2.useLayoutEffect)(function () {
|
|
96
|
+
if (isPositioned && state !== "positioned") {
|
|
97
|
+
setState("positioned");
|
|
98
|
+
}
|
|
99
|
+
}, [isPositioned, state]);
|
|
100
|
+
return __assign(__assign({ state: state, middlewareData: middlewareData, context: context, computedPlacement: computedPlacement, isPositioned: isPositioned, isMounted: isMounted, transitionStyles: transitionStyles, update: update }, rest), interactionProps);
|
|
101
|
+
};
|
|
102
|
+
exports.useFloatingPosition = useFloatingPosition;
|
|
@@ -61,7 +61,7 @@ exports.InputContainerStyled = styled_components_1.default.div(templateObject_5
|
|
|
61
61
|
var readOnly = _a.readOnly;
|
|
62
62
|
return readOnly && (0, styled_components_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n pointer-events: none;\n "], ["\n pointer-events: none;\n "])));
|
|
63
63
|
});
|
|
64
|
-
exports.InputStyled = styled_components_1.default.input(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n height: ", ";\n border: none;\n outline: none;\n flex-grow: 1;\n background: transparent;\n color: inherit;\n\n &:-webkit-autofill {\n transition-delay: 9999s;\n }\n\n ::placeholder {\n ", ";\n opacity: 1;\n }\n"], ["\n height: ", ";\n border: none;\n outline: none;\n flex-grow: 1;\n background: transparent;\n color: inherit;\n\n &:-webkit-autofill {\n transition-delay: 9999s;\n }\n\n ::placeholder {\n ", ";\n opacity: 1;\n }\n"])), function (_a) {
|
|
64
|
+
exports.InputStyled = styled_components_1.default.input(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n height: ", ";\n border: none;\n outline: none;\n flex-grow: 1;\n min-width: 0; /* Allow input to shrink below its default size */\n background: transparent;\n color: inherit;\n\n &:-webkit-autofill {\n transition-delay: 9999s;\n }\n\n ::placeholder {\n ", ";\n opacity: 1;\n }\n"], ["\n height: ", ";\n border: none;\n outline: none;\n flex-grow: 1;\n min-width: 0; /* Allow input to shrink below its default size */\n background: transparent;\n color: inherit;\n\n &:-webkit-autofill {\n transition-delay: 9999s;\n }\n\n ::placeholder {\n ", ";\n opacity: 1;\n }\n"])), function (_a) {
|
|
65
65
|
var size = _a.size;
|
|
66
66
|
return size === "S" ? "36px" : "45px";
|
|
67
67
|
}, globalStyles_1.globalInputElemPlaceholderColor);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface TooltipHeadingProps {
|
|
3
|
+
heading: string;
|
|
4
|
+
text: string;
|
|
5
|
+
containerStyle?: React.CSSProperties;
|
|
6
|
+
headingStyle?: React.CSSProperties;
|
|
7
|
+
textStyle?: React.CSSProperties;
|
|
8
|
+
}
|
|
9
|
+
export default function TooltipHeading({ heading, text, containerStyle, headingStyle, textStyle }: TooltipHeadingProps): React.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.default = TooltipHeading;
|
|
18
|
+
var react_1 = __importDefault(require("react"));
|
|
19
|
+
var Typo2_1 = require("../../Typo2");
|
|
20
|
+
var defaultContainerStyle = {
|
|
21
|
+
padding: '0.8rem',
|
|
22
|
+
maxWidth: '30rem',
|
|
23
|
+
};
|
|
24
|
+
function TooltipHeading(_a) {
|
|
25
|
+
var heading = _a.heading, text = _a.text, containerStyle = _a.containerStyle, headingStyle = _a.headingStyle, textStyle = _a.textStyle;
|
|
26
|
+
return (react_1.default.createElement("div", { style: __assign(__assign({}, defaultContainerStyle), containerStyle) },
|
|
27
|
+
react_1.default.createElement(Typo2_1.UI_CAPTION_SEMIBOLD, { style: headingStyle }, heading),
|
|
28
|
+
react_1.default.createElement(Typo2_1.UI_CAPTION, { style: textStyle }, text)));
|
|
29
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface TooltipTextProps {
|
|
3
|
+
text: string;
|
|
4
|
+
containerStyle?: React.CSSProperties;
|
|
5
|
+
textStyle?: React.CSSProperties;
|
|
6
|
+
}
|
|
7
|
+
export default function TooltipText({ text, containerStyle, textStyle }: TooltipTextProps): React.JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.default = TooltipText;
|
|
18
|
+
var react_1 = __importDefault(require("react"));
|
|
19
|
+
var Typo2_1 = require("../../Typo2");
|
|
20
|
+
var defaultContainerStyle = {
|
|
21
|
+
padding: '0.8rem',
|
|
22
|
+
maxWidth: '30rem',
|
|
23
|
+
};
|
|
24
|
+
function TooltipText(_a) {
|
|
25
|
+
var text = _a.text, containerStyle = _a.containerStyle, textStyle = _a.textStyle;
|
|
26
|
+
return (react_1.default.createElement("div", { style: __assign(__assign({}, defaultContainerStyle), containerStyle) },
|
|
27
|
+
react_1.default.createElement(Typo2_1.UI_CAPTION, { style: textStyle }, text)));
|
|
28
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TooltipHeading = exports.TooltipText = void 0;
|
|
7
|
+
var TooltipText_1 = require("./TooltipText");
|
|
8
|
+
Object.defineProperty(exports, "TooltipText", { enumerable: true, get: function () { return __importDefault(TooltipText_1).default; } });
|
|
9
|
+
var TooltipHeading_1 = require("./TooltipHeading");
|
|
10
|
+
Object.defineProperty(exports, "TooltipHeading", { enumerable: true, get: function () { return __importDefault(TooltipHeading_1).default; } });
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ContentConfig } from './utils';
|
|
3
|
+
interface TooltipProps {
|
|
4
|
+
text?: string;
|
|
5
|
+
heading?: string;
|
|
6
|
+
primaryContent?: ContentConfig;
|
|
7
|
+
secondaryContent?: ContentConfig;
|
|
8
|
+
progressiveDelay?: number;
|
|
9
|
+
progressiveGap?: number;
|
|
10
|
+
children: React.ReactElement;
|
|
11
|
+
placement?: 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end';
|
|
12
|
+
showPointer?: boolean;
|
|
13
|
+
showDelay?: number;
|
|
14
|
+
hideDelay?: number;
|
|
15
|
+
animation?: 'fade' | 'none';
|
|
16
|
+
followCursor?: boolean;
|
|
17
|
+
cursorOffset?: number;
|
|
18
|
+
invert?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export default function Tooltip({ text, heading, primaryContent, secondaryContent, progressiveDelay, progressiveGap, children, placement, showPointer, showDelay, hideDelay, animation, followCursor, cursorOffset, invert, }: TooltipProps): React.JSX.Element;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
46
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
+
exports.default = Tooltip;
|
|
48
|
+
var react_1 = __importStar(require("react"));
|
|
49
|
+
var react_2 = require("@floating-ui/react");
|
|
50
|
+
var __1 = require("../../..");
|
|
51
|
+
var useFloatingPosition_1 = require("../../../utils/customHooks/useFloatingPosition");
|
|
52
|
+
var utils_1 = require("./utils");
|
|
53
|
+
var styled_1 = require("./styled");
|
|
54
|
+
var CURSOR_HEIGHT = 20;
|
|
55
|
+
function Tooltip(_a) {
|
|
56
|
+
var text = _a.text, heading = _a.heading, primaryContent = _a.primaryContent, secondaryContent = _a.secondaryContent, _b = _a.progressiveDelay, progressiveDelay = _b === void 0 ? 1000 : _b, _c = _a.progressiveGap, progressiveGap = _c === void 0 ? 8 : _c, children = _a.children, _d = _a.placement, placement = _d === void 0 ? 'top' : _d, _e = _a.showPointer, showPointer = _e === void 0 ? true : _e, _f = _a.showDelay, showDelay = _f === void 0 ? 0 : _f, _g = _a.hideDelay, hideDelay = _g === void 0 ? 0 : _g, _h = _a.animation, animation = _h === void 0 ? 'none' : _h, _j = _a.followCursor, followCursor = _j === void 0 ? false : _j, _k = _a.cursorOffset, cursorOffset = _k === void 0 ? 10 : _k, _l = _a.invert, invert = _l === void 0 ? false : _l;
|
|
57
|
+
var bgColor = invert ? __1.colors2.white : __1.colors2.black;
|
|
58
|
+
var textColor = invert ? __1.colors2.black : __1.colors2.white;
|
|
59
|
+
var resolvedPrimaryContent = (0, utils_1.resolvePrimaryContent)(text, heading, primaryContent);
|
|
60
|
+
var _m = (0, react_1.useState)(false), isOpen = _m[0], setIsOpen = _m[1];
|
|
61
|
+
var _o = (0, react_1.useState)(false), showSecondary = _o[0], setShowSecondary = _o[1];
|
|
62
|
+
var _p = (0, react_1.useState)(false), isPinned = _p[0], setIsPinned = _p[1];
|
|
63
|
+
var _q = (0, react_1.useState)({ x: 0, y: 0 }), mousePos = _q[0], setMousePos = _q[1];
|
|
64
|
+
var _r = (0, react_1.useState)({}), cursorTooltipStyle = _r[0], setCursorTooltipStyle = _r[1];
|
|
65
|
+
var progressiveTimerRef = (0, react_1.useRef)(null);
|
|
66
|
+
var containerRef = (0, react_1.useRef)(null);
|
|
67
|
+
var arrowRef = (0, react_1.useRef)(null);
|
|
68
|
+
var tooltipRef = (0, react_1.useRef)(null);
|
|
69
|
+
// Progressive tooltip logic
|
|
70
|
+
(0, react_1.useEffect)(function () {
|
|
71
|
+
if (isOpen && secondaryContent) {
|
|
72
|
+
progressiveTimerRef.current = setTimeout(function () { return setShowSecondary(true); }, progressiveDelay);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
setShowSecondary(false);
|
|
76
|
+
if (progressiveTimerRef.current)
|
|
77
|
+
clearTimeout(progressiveTimerRef.current);
|
|
78
|
+
}
|
|
79
|
+
return function () {
|
|
80
|
+
if (progressiveTimerRef.current)
|
|
81
|
+
clearTimeout(progressiveTimerRef.current);
|
|
82
|
+
};
|
|
83
|
+
}, [isOpen, progressiveDelay, secondaryContent]);
|
|
84
|
+
var hasFadeAnimation = animation === 'fade';
|
|
85
|
+
var transitionOptions = hasFadeAnimation ? {
|
|
86
|
+
duration: 150,
|
|
87
|
+
initial: { opacity: 0 },
|
|
88
|
+
open: { opacity: 1 },
|
|
89
|
+
close: { opacity: 0 },
|
|
90
|
+
} : undefined;
|
|
91
|
+
var _s = (0, useFloatingPosition_1.useFloatingPosition)({
|
|
92
|
+
open: isOpen,
|
|
93
|
+
onOpenChange: function (open) {
|
|
94
|
+
if (followCursor)
|
|
95
|
+
return;
|
|
96
|
+
if (isPinned) {
|
|
97
|
+
if (!open) {
|
|
98
|
+
setIsPinned(false);
|
|
99
|
+
setIsOpen(false);
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
setIsOpen(open);
|
|
104
|
+
},
|
|
105
|
+
placement: followCursor ? 'bottom-start' : placement,
|
|
106
|
+
showArrow: showPointer && !followCursor,
|
|
107
|
+
arrowRef: arrowRef,
|
|
108
|
+
arrowPadding: utils_1.ARROW_PADDING,
|
|
109
|
+
customMiddleware: followCursor ? undefined : [utils_1.autoSafeFlip],
|
|
110
|
+
disableAutoUpdate: followCursor,
|
|
111
|
+
enableDelayGroups: false,
|
|
112
|
+
enableHover: !isPinned && !followCursor,
|
|
113
|
+
hoverOptions: {
|
|
114
|
+
delay: { open: showDelay, close: hideDelay },
|
|
115
|
+
},
|
|
116
|
+
focusOptions: { enabled: !followCursor },
|
|
117
|
+
dismissOptions: { enabled: !followCursor },
|
|
118
|
+
roleOptions: { role: 'tooltip' },
|
|
119
|
+
transitionOptions: transitionOptions,
|
|
120
|
+
middlewareOptions: {
|
|
121
|
+
offset: { config: followCursor ? cursorOffset : 10 },
|
|
122
|
+
shift: { enabled: true, config: { padding: 8 } },
|
|
123
|
+
flip: { enabled: followCursor, config: { fallbackPlacements: ['top-start'] } },
|
|
124
|
+
},
|
|
125
|
+
}), refs = _s.refs, floatingStyles = _s.floatingStyles, context = _s.context, getReferenceProps = _s.getReferenceProps, getFloatingProps = _s.getFloatingProps, isMounted = _s.isMounted, transitionStyles = _s.transitionStyles;
|
|
126
|
+
var handleMouseMove = (0, react_1.useCallback)(function (e) {
|
|
127
|
+
if (followCursor) {
|
|
128
|
+
setMousePos({ x: e.clientX, y: e.clientY });
|
|
129
|
+
}
|
|
130
|
+
}, [followCursor]);
|
|
131
|
+
var handleMouseEnter = (0, react_1.useCallback)(function (e) {
|
|
132
|
+
if (followCursor) {
|
|
133
|
+
setMousePos({ x: e.clientX, y: e.clientY });
|
|
134
|
+
setIsOpen(true);
|
|
135
|
+
}
|
|
136
|
+
}, [followCursor]);
|
|
137
|
+
var handleMouseLeave = (0, react_1.useCallback)(function () {
|
|
138
|
+
if (followCursor) {
|
|
139
|
+
setIsOpen(false);
|
|
140
|
+
}
|
|
141
|
+
}, [followCursor]);
|
|
142
|
+
var handleClick = function (e) {
|
|
143
|
+
if (followCursor)
|
|
144
|
+
return;
|
|
145
|
+
e.stopPropagation();
|
|
146
|
+
if (isOpen) {
|
|
147
|
+
setIsPinned(false);
|
|
148
|
+
setIsOpen(false);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
setIsPinned(true);
|
|
152
|
+
setIsOpen(true);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
// Calculate cursor tooltip position
|
|
156
|
+
(0, react_1.useEffect)(function () {
|
|
157
|
+
if (followCursor && isOpen && tooltipRef.current) {
|
|
158
|
+
var tooltipRect = tooltipRef.current.getBoundingClientRect();
|
|
159
|
+
var viewportHeight = window.innerHeight;
|
|
160
|
+
var viewportWidth = window.innerWidth;
|
|
161
|
+
var top_1 = mousePos.y + CURSOR_HEIGHT + cursorOffset;
|
|
162
|
+
var left = mousePos.x;
|
|
163
|
+
if (top_1 + tooltipRect.height > viewportHeight - 8) {
|
|
164
|
+
top_1 = mousePos.y - tooltipRect.height - cursorOffset;
|
|
165
|
+
}
|
|
166
|
+
if (left + tooltipRect.width > viewportWidth - 8) {
|
|
167
|
+
left = viewportWidth - tooltipRect.width - 8;
|
|
168
|
+
}
|
|
169
|
+
if (left < 8) {
|
|
170
|
+
left = 8;
|
|
171
|
+
}
|
|
172
|
+
setCursorTooltipStyle({
|
|
173
|
+
position: 'fixed',
|
|
174
|
+
top: "".concat(top_1, "px"),
|
|
175
|
+
left: "".concat(left, "px"),
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}, [followCursor, isOpen, mousePos, cursorOffset]);
|
|
179
|
+
// Render cursor-following mode
|
|
180
|
+
if (followCursor) {
|
|
181
|
+
var cursorBorderRadius = secondaryContent && showSecondary && progressiveGap === 0
|
|
182
|
+
? "".concat(utils_1.BORDER_RADIUS, " ").concat(utils_1.BORDER_RADIUS, " 0 0")
|
|
183
|
+
: utils_1.BORDER_RADIUS;
|
|
184
|
+
var cursorSecondaryBorderRadius = progressiveGap === 0
|
|
185
|
+
? "0 0 ".concat(utils_1.BORDER_RADIUS, " ").concat(utils_1.BORDER_RADIUS)
|
|
186
|
+
: utils_1.BORDER_RADIUS;
|
|
187
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
188
|
+
react_1.default.createElement(styled_1.StyledInlineWrapper, { ref: containerRef, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onMouseMove: handleMouseMove }, children),
|
|
189
|
+
isOpen && (react_1.default.createElement(react_2.FloatingPortal, null,
|
|
190
|
+
react_1.default.createElement(styled_1.StyledCursorTooltipWrapper, { ref: tooltipRef, style: cursorTooltipStyle, "$gap": progressiveGap },
|
|
191
|
+
react_1.default.createElement(styled_1.StyledTooltipContent, { "$bgColor": bgColor, "$textColor": textColor, "$borderRadius": cursorBorderRadius }, resolvedPrimaryContent && (0, utils_1.renderContent)(resolvedPrimaryContent)),
|
|
192
|
+
secondaryContent && showSecondary && (react_1.default.createElement(styled_1.StyledTooltipContent, { "$bgColor": bgColor, "$textColor": textColor, "$borderRadius": cursorSecondaryBorderRadius }, (0, utils_1.renderContent)(secondaryContent))))))));
|
|
193
|
+
}
|
|
194
|
+
var isVertical = placement.startsWith('top') || placement.startsWith('bottom');
|
|
195
|
+
var secondaryFirst = placement.startsWith('top') || placement.startsWith('left');
|
|
196
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
197
|
+
react_1.default.cloneElement(children, __assign({ ref: refs.setReference }, getReferenceProps({ onClick: handleClick }))),
|
|
198
|
+
(hasFadeAnimation ? isMounted : isOpen) && (react_1.default.createElement(react_2.FloatingPortal, null,
|
|
199
|
+
react_1.default.createElement(styled_1.StyledTooltipWrapper, __assign({ ref: refs.setFloating, style: __assign(__assign({}, floatingStyles), (hasFadeAnimation ? transitionStyles : {})), "$isVertical": isVertical, "$gap": progressiveGap }, getFloatingProps()),
|
|
200
|
+
react_1.default.createElement(styled_1.StyledTooltipContent, { "$bgColor": bgColor, "$textColor": textColor, "$borderRadius": (0, utils_1.getBorderRadius)({
|
|
201
|
+
isPrimary: true,
|
|
202
|
+
progressiveGap: progressiveGap,
|
|
203
|
+
secondaryContent: !!secondaryContent,
|
|
204
|
+
showSecondary: showSecondary,
|
|
205
|
+
placement: placement,
|
|
206
|
+
}), "$order": 1 },
|
|
207
|
+
resolvedPrimaryContent && (0, utils_1.renderContent)(resolvedPrimaryContent),
|
|
208
|
+
showPointer && react_1.default.createElement(react_2.FloatingArrow, { ref: arrowRef, context: context, fill: bgColor, tipRadius: 2 })),
|
|
209
|
+
secondaryContent && showSecondary && (react_1.default.createElement(styled_1.StyledTooltipContent, { "$bgColor": bgColor, "$textColor": textColor, "$borderRadius": (0, utils_1.getBorderRadius)({
|
|
210
|
+
isPrimary: false,
|
|
211
|
+
progressiveGap: progressiveGap,
|
|
212
|
+
secondaryContent: !!secondaryContent,
|
|
213
|
+
showSecondary: showSecondary,
|
|
214
|
+
placement: placement,
|
|
215
|
+
}), "$order": secondaryFirst ? 0 : 2 }, (0, utils_1.renderContent)(secondaryContent))))))));
|
|
216
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const tooltipFadeIn: import("styled-components").Keyframes;
|
|
2
|
+
export declare const fadeSlideIn: import("styled-components").Keyframes;
|
|
3
|
+
export declare const fadeAnimation: import("styled-components").FlattenSimpleInterpolation;
|
|
4
|
+
export declare const slideAnimation: import("styled-components").FlattenSimpleInterpolation;
|
|
5
|
+
export declare const StyledTooltipContainer: import("styled-components").StyledComponent<"div", any, {
|
|
6
|
+
$animate?: boolean;
|
|
7
|
+
}, never>;
|
|
8
|
+
export declare const StyledSecondaryContentWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
9
|
+
$animate?: boolean;
|
|
10
|
+
}, never>;
|
|
11
|
+
export declare const StyledTooltipWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
12
|
+
$isVertical?: boolean;
|
|
13
|
+
$gap?: number;
|
|
14
|
+
}, never>;
|
|
15
|
+
export declare const StyledCursorTooltipWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
16
|
+
$gap?: number;
|
|
17
|
+
}, never>;
|
|
18
|
+
export declare const StyledTooltipContent: import("styled-components").StyledComponent<"div", any, {
|
|
19
|
+
$bgColor: string;
|
|
20
|
+
$textColor: string;
|
|
21
|
+
$borderRadius?: string;
|
|
22
|
+
$order?: number;
|
|
23
|
+
}, never>;
|
|
24
|
+
export declare const StyledInlineWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|