@uxf/ui 11.54.0 → 11.55.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/css/tooltip.css +10 -2
- package/package.json +1 -1
- package/tooltip/tooltip.stories.js +29 -5
- package/tooltip/use-tooltip.d.ts +1 -0
- package/tooltip/use-tooltip.js +11 -7
package/css/tooltip.css
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
.uxf-tooltip {
|
|
2
|
-
|
|
2
|
+
background-color: theme("colors.lightHigh");
|
|
3
|
+
border-radius: theme("borderRadius.lg");
|
|
4
|
+
color: theme("colors.white");
|
|
5
|
+
max-width: calc(100vw - 20px);
|
|
6
|
+
padding: theme("spacing.3");
|
|
7
|
+
width: max-content;
|
|
8
|
+
z-index: theme("zIndex.tooltip");
|
|
3
9
|
|
|
4
10
|
&__arrow {
|
|
5
|
-
|
|
11
|
+
background-color: theme("colors.lightHigh");
|
|
12
|
+
border-radius: theme("borderRadius.sm");
|
|
13
|
+
z-index: theme("zIndex.tooltip");
|
|
6
14
|
}
|
|
7
15
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
4
24
|
};
|
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
26
|
exports.Default = Default;
|
|
7
|
-
const react_1 =
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const checkbox_input_1 = require("../checkbox-input");
|
|
8
29
|
const chip_1 = require("../chip");
|
|
9
30
|
const tooltip_1 = require("./tooltip");
|
|
10
31
|
function Default() {
|
|
11
32
|
const sides = ["top", "bottom", "bottom-start", "left", "right"];
|
|
12
|
-
|
|
13
|
-
|
|
33
|
+
const [isPointingDisabled, setIsPointingDisabled] = (0, react_1.useState)(false);
|
|
34
|
+
return (react_1.default.createElement("div", { className: "grid h-96 place-items-center" },
|
|
35
|
+
react_1.default.createElement(checkbox_input_1.CheckboxInput, { label: "Disable pointing inside tooltip?", name: "isPointingDisabled", onChange: (value) => setIsPointingDisabled(Boolean(value)), value: isPointingDisabled }),
|
|
36
|
+
sides.map((placement) => (react_1.default.createElement(tooltip_1.Tooltip, { content: "My tooltip content", isPointingDisabled: isPointingDisabled, key: placement, placement: placement },
|
|
37
|
+
react_1.default.createElement(chip_1.Chip, { color: "green" }, placement))))));
|
|
14
38
|
}
|
package/tooltip/use-tooltip.d.ts
CHANGED
package/tooltip/use-tooltip.js
CHANGED
|
@@ -5,7 +5,7 @@ const react_1 = require("@floating-ui/react");
|
|
|
5
5
|
const react_2 = require("react");
|
|
6
6
|
function useTooltip(options) {
|
|
7
7
|
var _a, _b;
|
|
8
|
-
const [
|
|
8
|
+
const [isOpen, setIsOpen] = (0, react_2.useState)(false);
|
|
9
9
|
const data = (0, react_1.useFloating)({
|
|
10
10
|
middleware: [
|
|
11
11
|
(0, react_1.offset)((_a = options.offset) !== null && _a !== void 0 ? _a : 16),
|
|
@@ -13,23 +13,27 @@ function useTooltip(options) {
|
|
|
13
13
|
(0, react_1.shift)({ padding: (_b = options.shiftPadding) !== null && _b !== void 0 ? _b : 8 }),
|
|
14
14
|
(0, react_1.arrow)({ element: options.arrowRef }),
|
|
15
15
|
],
|
|
16
|
-
open,
|
|
17
|
-
onOpenChange:
|
|
16
|
+
open: isOpen,
|
|
17
|
+
onOpenChange: setIsOpen,
|
|
18
18
|
placement: options.placement,
|
|
19
19
|
whileElementsMounted: (reference, floating, update) => (0, react_1.autoUpdate)(reference, floating, update, {
|
|
20
20
|
elementResize: typeof ResizeObserver !== "undefined",
|
|
21
21
|
}),
|
|
22
22
|
});
|
|
23
23
|
const context = data.context;
|
|
24
|
-
const hover = (0, react_1.useHover)(context, {
|
|
24
|
+
const hover = (0, react_1.useHover)(context, {
|
|
25
|
+
delay: options.isPointingDisabled ? undefined : 200,
|
|
26
|
+
handleClose: options.isPointingDisabled ? null : (0, react_1.safePolygon)(),
|
|
27
|
+
move: false,
|
|
28
|
+
});
|
|
25
29
|
const focus = (0, react_1.useFocus)(context);
|
|
26
30
|
const role = (0, react_1.useRole)(context, { role: "tooltip" });
|
|
27
31
|
const dismiss = (0, react_1.useDismiss)(context);
|
|
28
32
|
const interactions = (0, react_1.useInteractions)([hover, focus, dismiss, role]);
|
|
29
33
|
return (0, react_2.useMemo)(() => ({
|
|
30
|
-
open,
|
|
31
|
-
setOpen,
|
|
34
|
+
open: isOpen,
|
|
35
|
+
setOpen: setIsOpen,
|
|
32
36
|
...interactions,
|
|
33
37
|
...data,
|
|
34
|
-
}), [
|
|
38
|
+
}), [isOpen, setIsOpen, interactions, data]);
|
|
35
39
|
}
|