bj-web-components 0.2.26 → 0.2.28
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/favicon.ico +0 -0
- package/dist/file.svg +1 -0
- package/dist/globe.svg +1 -0
- package/dist/index.d.ts +1141 -0
- package/dist/index.js +51 -0
- package/dist/index.mjs +51 -0
- package/dist/miniapp.d.ts +1 -0
- package/dist/miniapp.js +1 -0
- package/dist/miniapp.mjs +1 -0
- package/dist/mobile.d.ts +1 -0
- package/dist/mobile.js +1 -0
- package/dist/mobile.mjs +1 -0
- package/dist/next.svg +1 -0
- package/dist/react.d.ts +1 -0
- package/dist/react.js +1 -0
- package/dist/react.mjs +1 -0
- package/dist/shared.d.ts +1 -0
- package/dist/shared.js +1 -0
- package/dist/shared.mjs +1 -0
- package/dist/style.css +3744 -0
- package/dist/vercel.svg +1 -0
- package/dist/web/BasicInput/BInput.js +208 -0
- package/dist/web/BasicInput/BInput.mjs +209 -0
- package/dist/web/BasicInput/utils.js +47 -0
- package/dist/web/BasicInput/utils.mjs +47 -0
- package/dist/web/CategoryDropdown/CategoryDropdown.js +307 -0
- package/dist/web/CategoryDropdown/CategoryDropdown.mjs +308 -0
- package/dist/web/CheckBox/BCheckBox.js +116 -0
- package/dist/web/CheckBox/BCheckBox.mjs +117 -0
- package/dist/web/CheckBox/Group.js +73 -0
- package/dist/web/CheckBox/Group.mjs +74 -0
- package/dist/web/CheckBox/context.js +5 -0
- package/dist/web/CheckBox/context.mjs +5 -0
- package/dist/web/CheckBox/index.js +8 -0
- package/dist/web/CheckBox/index.mjs +8 -0
- package/dist/web/Dropdown/BDropdown.js +186 -0
- package/dist/web/Dropdown/BDropdown.mjs +186 -0
- package/dist/web/EmptyInputBox/EmptyInputBox.js +77 -0
- package/dist/web/EmptyInputBox/EmptyInputBox.mjs +78 -0
- package/dist/web/FileCard/FileCard.js +157 -0
- package/dist/web/FileCard/FileCard.mjs +158 -0
- package/dist/web/Icon/Icon.js +9 -0
- package/dist/web/Icon/Icon.mjs +10 -0
- package/dist/web/Input/Input.js +181 -0
- package/dist/web/Input/Input.mjs +182 -0
- package/dist/web/InputNumber/BInputNumber.js +311 -0
- package/dist/web/InputNumber/BInputNumber.mjs +312 -0
- package/dist/web/InputNumber/StepHandler.js +69 -0
- package/dist/web/InputNumber/StepHandler.mjs +70 -0
- package/dist/web/InputNumber/hooks/useCursor.js +40 -0
- package/dist/web/InputNumber/hooks/useCursor.mjs +41 -0
- package/dist/web/InputNumber/hooks/useFrame.js +12 -0
- package/dist/web/InputNumber/hooks/useFrame.mjs +13 -0
- package/dist/web/InputNumber/utils/decimal.js +147 -0
- package/dist/web/InputNumber/utils/decimal.mjs +147 -0
- package/dist/web/Modal/Modal.js +84 -0
- package/dist/web/Modal/Modal.mjs +85 -0
- package/dist/web/OverlayScrollbar/BOverlayScrollbar.js +232 -0
- package/dist/web/OverlayScrollbar/BOverlayScrollbar.mjs +233 -0
- package/dist/web/Pagination/Pagination.js +328 -0
- package/dist/web/Pagination/Pagination.mjs +329 -0
- package/dist/web/ProductField/ProductField.js +272 -0
- package/dist/web/ProductField/ProductField.mjs +273 -0
- package/dist/web/ProductField/arrow-up.svg.js +3 -0
- package/dist/web/ProductField/arrow-up.svg.mjs +4 -0
- package/dist/web/ProductField/checkbox-no.svg.js +3 -0
- package/dist/web/ProductField/checkbox-no.svg.mjs +4 -0
- package/dist/web/ProductField/checkbox-ok.svg.js +3 -0
- package/dist/web/ProductField/checkbox-ok.svg.mjs +4 -0
- package/dist/web/ProductField/no_data_light.svg.js +3 -0
- package/dist/web/ProductField/no_data_light.svg.mjs +4 -0
- package/dist/web/ProductField/search.svg.js +3 -0
- package/dist/web/ProductField/search.svg.mjs +4 -0
- package/dist/web/ProductField/sort.svg.js +3 -0
- package/dist/web/ProductField/sort.svg.mjs +4 -0
- package/dist/web/SkuInputCard/SkuInputCard.js +276 -0
- package/dist/web/SkuInputCard/SkuInputCard.mjs +277 -0
- package/dist/web/SkuInputCard/spin_loading_red.gif.js +3 -0
- package/dist/web/SkuInputCard/spin_loading_red.gif.mjs +4 -0
- package/dist/web/Switch/Switch.js +70 -0
- package/dist/web/Switch/Switch.mjs +71 -0
- package/dist/web/Table/BTable.js +950 -0
- package/dist/web/Table/BTable.mjs +950 -0
- package/dist/web/Table/Column.js +5 -0
- package/dist/web/Table/Column.mjs +6 -0
- package/dist/web/Table/ColumnGroup.js +5 -0
- package/dist/web/Table/ColumnGroup.mjs +6 -0
- package/dist/web/Table/utils/columns.js +48 -0
- package/dist/web/Table/utils/columns.mjs +48 -0
- package/dist/web/Table/utils/sortFilter.js +84 -0
- package/dist/web/Table/utils/sortFilter.mjs +84 -0
- package/dist/web/Tabs/BTabs.js +150 -0
- package/dist/web/Tabs/BTabs.mjs +150 -0
- package/dist/web/Tabs/TabPane.js +8 -0
- package/dist/web/Tabs/TabPane.mjs +8 -0
- package/dist/web/Tooltip/ConfirmTooltip.js +26 -0
- package/dist/web/Tooltip/ConfirmTooltip.mjs +27 -0
- package/dist/web/Tooltip/ContentTooltip.js +94 -0
- package/dist/web/Tooltip/ContentTooltip.mjs +95 -0
- package/dist/web/Tooltip/ProgressTooltip.js +36 -0
- package/dist/web/Tooltip/ProgressTooltip.mjs +37 -0
- package/dist/web/Tooltip/TooltipWrapper.js +12 -0
- package/dist/web/Tooltip/TooltipWrapper.mjs +13 -0
- package/dist/web/Tooltip/useAutoPlacement.js +41 -0
- package/dist/web/Tooltip/useAutoPlacement.mjs +41 -0
- package/dist/web.d.ts +1141 -0
- package/dist/web.js +51 -0
- package/dist/web.mjs +51 -0
- package/package.json +1 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const react = require("react");
|
|
4
|
+
const reactDom = require("react-dom");
|
|
5
|
+
const antd = require("antd");
|
|
6
|
+
;/* empty css */
|
|
7
|
+
const useAutoPlacement = require("./useAutoPlacement.js");
|
|
8
|
+
function BTooltip({
|
|
9
|
+
children,
|
|
10
|
+
placement = "top",
|
|
11
|
+
content = "这里是提示内容,可以包含更多详细信息。",
|
|
12
|
+
variant = "default",
|
|
13
|
+
className,
|
|
14
|
+
style,
|
|
15
|
+
getPopupContainer,
|
|
16
|
+
getAnchorElement,
|
|
17
|
+
color,
|
|
18
|
+
fontColor,
|
|
19
|
+
autoAdjustOverflow = true
|
|
20
|
+
}) {
|
|
21
|
+
const [activePlacement, popupRef] = useAutoPlacement.useAutoPlacement(placement);
|
|
22
|
+
const anchorRef = react.useRef(null);
|
|
23
|
+
const [portalStyle, setPortalStyle] = react.useState();
|
|
24
|
+
const popupCls = [
|
|
25
|
+
"tooltip-popup",
|
|
26
|
+
"tooltip-popup--content",
|
|
27
|
+
`tooltip-popup--${activePlacement}`,
|
|
28
|
+
variant !== "default" ? `tooltip-popup--${variant}` : "",
|
|
29
|
+
className
|
|
30
|
+
].filter(Boolean).join(" ");
|
|
31
|
+
const arrowCls = [
|
|
32
|
+
"tooltip-arrow",
|
|
33
|
+
`tooltip-arrow--${activePlacement}`,
|
|
34
|
+
variant === "tinted" ? "tooltip-arrow--tinted-bg" : ""
|
|
35
|
+
].filter(Boolean).join(" ");
|
|
36
|
+
const mergedPopupStyle = {
|
|
37
|
+
...style,
|
|
38
|
+
...color ? { backgroundColor: color } : {},
|
|
39
|
+
...fontColor ? { color: fontColor } : {}
|
|
40
|
+
};
|
|
41
|
+
const arrowStyle = color ? { backgroundColor: color, borderColor: color } : void 0;
|
|
42
|
+
const contentStyle = fontColor ? { color: fontColor } : void 0;
|
|
43
|
+
const customContent = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${popupCls} tooltip-popup--antd`, style: mergedPopupStyle, children: [
|
|
44
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: arrowCls, style: arrowStyle }),
|
|
45
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bu-tooltip-content__text", style: contentStyle, children: content })
|
|
46
|
+
] });
|
|
47
|
+
if (children) {
|
|
48
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
49
|
+
antd.Tooltip,
|
|
50
|
+
{
|
|
51
|
+
title: customContent,
|
|
52
|
+
placement: placement === "auto" ? "top" : placement,
|
|
53
|
+
arrowPointAtCenter: true,
|
|
54
|
+
autoAdjustOverflow,
|
|
55
|
+
getPopupContainer,
|
|
56
|
+
overlayClassName: "bu-content-tooltip",
|
|
57
|
+
children
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
const popup = /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: popupRef, className: popupCls, style: mergedPopupStyle, children: [
|
|
62
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: arrowCls, style: arrowStyle }),
|
|
63
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bu-tooltip-content__text", style: contentStyle, children: content })
|
|
64
|
+
] });
|
|
65
|
+
react.useLayoutEffect(() => {
|
|
66
|
+
if (!getPopupContainer || !anchorRef.current) return;
|
|
67
|
+
const anchor = (getAnchorElement == null ? void 0 : getAnchorElement()) ?? anchorRef.current.parentElement;
|
|
68
|
+
if (!anchor) return;
|
|
69
|
+
const rect = anchor.getBoundingClientRect();
|
|
70
|
+
setPortalStyle({
|
|
71
|
+
position: "fixed",
|
|
72
|
+
left: rect.left + rect.width / 2,
|
|
73
|
+
top: rect.top,
|
|
74
|
+
right: "auto",
|
|
75
|
+
bottom: "auto",
|
|
76
|
+
transform: "translate(-50%, calc(-100% - 16px))"
|
|
77
|
+
});
|
|
78
|
+
}, [getAnchorElement, getPopupContainer]);
|
|
79
|
+
if (getPopupContainer && typeof document !== "undefined") {
|
|
80
|
+
const container = getPopupContainer();
|
|
81
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
82
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { ref: anchorRef, className: "tooltip-portal-anchor" }),
|
|
83
|
+
portalStyle && reactDom.createPortal(
|
|
84
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { ref: popupRef, className: popupCls, style: { ...mergedPopupStyle, ...portalStyle }, children: [
|
|
85
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: arrowCls, style: arrowStyle }),
|
|
86
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bu-tooltip-content__text", style: contentStyle, children: content })
|
|
87
|
+
] }),
|
|
88
|
+
container
|
|
89
|
+
)
|
|
90
|
+
] });
|
|
91
|
+
}
|
|
92
|
+
return popup;
|
|
93
|
+
}
|
|
94
|
+
module.exports = BTooltip;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState, useLayoutEffect } from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
|
+
import { Tooltip } from "antd";
|
|
5
|
+
/* empty css */
|
|
6
|
+
import { useAutoPlacement } from "./useAutoPlacement.mjs";
|
|
7
|
+
function BTooltip({
|
|
8
|
+
children,
|
|
9
|
+
placement = "top",
|
|
10
|
+
content = "这里是提示内容,可以包含更多详细信息。",
|
|
11
|
+
variant = "default",
|
|
12
|
+
className,
|
|
13
|
+
style,
|
|
14
|
+
getPopupContainer,
|
|
15
|
+
getAnchorElement,
|
|
16
|
+
color,
|
|
17
|
+
fontColor,
|
|
18
|
+
autoAdjustOverflow = true
|
|
19
|
+
}) {
|
|
20
|
+
const [activePlacement, popupRef] = useAutoPlacement(placement);
|
|
21
|
+
const anchorRef = useRef(null);
|
|
22
|
+
const [portalStyle, setPortalStyle] = useState();
|
|
23
|
+
const popupCls = [
|
|
24
|
+
"tooltip-popup",
|
|
25
|
+
"tooltip-popup--content",
|
|
26
|
+
`tooltip-popup--${activePlacement}`,
|
|
27
|
+
variant !== "default" ? `tooltip-popup--${variant}` : "",
|
|
28
|
+
className
|
|
29
|
+
].filter(Boolean).join(" ");
|
|
30
|
+
const arrowCls = [
|
|
31
|
+
"tooltip-arrow",
|
|
32
|
+
`tooltip-arrow--${activePlacement}`,
|
|
33
|
+
variant === "tinted" ? "tooltip-arrow--tinted-bg" : ""
|
|
34
|
+
].filter(Boolean).join(" ");
|
|
35
|
+
const mergedPopupStyle = {
|
|
36
|
+
...style,
|
|
37
|
+
...color ? { backgroundColor: color } : {},
|
|
38
|
+
...fontColor ? { color: fontColor } : {}
|
|
39
|
+
};
|
|
40
|
+
const arrowStyle = color ? { backgroundColor: color, borderColor: color } : void 0;
|
|
41
|
+
const contentStyle = fontColor ? { color: fontColor } : void 0;
|
|
42
|
+
const customContent = /* @__PURE__ */ jsxs("div", { className: `${popupCls} tooltip-popup--antd`, style: mergedPopupStyle, children: [
|
|
43
|
+
/* @__PURE__ */ jsx("div", { className: arrowCls, style: arrowStyle }),
|
|
44
|
+
/* @__PURE__ */ jsx("div", { className: "bu-tooltip-content__text", style: contentStyle, children: content })
|
|
45
|
+
] });
|
|
46
|
+
if (children) {
|
|
47
|
+
return /* @__PURE__ */ jsx(
|
|
48
|
+
Tooltip,
|
|
49
|
+
{
|
|
50
|
+
title: customContent,
|
|
51
|
+
placement: placement === "auto" ? "top" : placement,
|
|
52
|
+
arrowPointAtCenter: true,
|
|
53
|
+
autoAdjustOverflow,
|
|
54
|
+
getPopupContainer,
|
|
55
|
+
overlayClassName: "bu-content-tooltip",
|
|
56
|
+
children
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
const popup = /* @__PURE__ */ jsxs("div", { ref: popupRef, className: popupCls, style: mergedPopupStyle, children: [
|
|
61
|
+
/* @__PURE__ */ jsx("div", { className: arrowCls, style: arrowStyle }),
|
|
62
|
+
/* @__PURE__ */ jsx("div", { className: "bu-tooltip-content__text", style: contentStyle, children: content })
|
|
63
|
+
] });
|
|
64
|
+
useLayoutEffect(() => {
|
|
65
|
+
if (!getPopupContainer || !anchorRef.current) return;
|
|
66
|
+
const anchor = (getAnchorElement == null ? void 0 : getAnchorElement()) ?? anchorRef.current.parentElement;
|
|
67
|
+
if (!anchor) return;
|
|
68
|
+
const rect = anchor.getBoundingClientRect();
|
|
69
|
+
setPortalStyle({
|
|
70
|
+
position: "fixed",
|
|
71
|
+
left: rect.left + rect.width / 2,
|
|
72
|
+
top: rect.top,
|
|
73
|
+
right: "auto",
|
|
74
|
+
bottom: "auto",
|
|
75
|
+
transform: "translate(-50%, calc(-100% - 16px))"
|
|
76
|
+
});
|
|
77
|
+
}, [getAnchorElement, getPopupContainer]);
|
|
78
|
+
if (getPopupContainer && typeof document !== "undefined") {
|
|
79
|
+
const container = getPopupContainer();
|
|
80
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
81
|
+
/* @__PURE__ */ jsx("span", { ref: anchorRef, className: "tooltip-portal-anchor" }),
|
|
82
|
+
portalStyle && createPortal(
|
|
83
|
+
/* @__PURE__ */ jsxs("div", { ref: popupRef, className: popupCls, style: { ...mergedPopupStyle, ...portalStyle }, children: [
|
|
84
|
+
/* @__PURE__ */ jsx("div", { className: arrowCls, style: arrowStyle }),
|
|
85
|
+
/* @__PURE__ */ jsx("div", { className: "bu-tooltip-content__text", style: contentStyle, children: content })
|
|
86
|
+
] }),
|
|
87
|
+
container
|
|
88
|
+
)
|
|
89
|
+
] });
|
|
90
|
+
}
|
|
91
|
+
return popup;
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
BTooltip as default
|
|
95
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
;/* empty css */
|
|
4
|
+
const useAutoPlacement = require("./useAutoPlacement.js");
|
|
5
|
+
function ProgressTooltip({
|
|
6
|
+
placement = "top",
|
|
7
|
+
title = "正在翻译私域数据...",
|
|
8
|
+
progress = 0,
|
|
9
|
+
className,
|
|
10
|
+
style
|
|
11
|
+
}) {
|
|
12
|
+
const [activePlacement, popupRef] = useAutoPlacement.useAutoPlacement(placement);
|
|
13
|
+
const pct = Math.min(100, Math.max(0, Math.round(progress)));
|
|
14
|
+
const popupCls = ["tooltip-popup", `tooltip-popup--${activePlacement}`, className].filter(Boolean).join(" ");
|
|
15
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: popupRef, className: popupCls, style, children: [
|
|
16
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: `tooltip-arrow tooltip-arrow--${activePlacement}` }),
|
|
17
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tooltip-progress", children: [
|
|
18
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tooltip-progress__header", children: [
|
|
19
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "tooltip-progress__title", children: title }),
|
|
20
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "tooltip-progress__percent", children: [
|
|
21
|
+
pct,
|
|
22
|
+
"%"
|
|
23
|
+
] })
|
|
24
|
+
] }),
|
|
25
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
26
|
+
"div",
|
|
27
|
+
{
|
|
28
|
+
className: "tooltip-progress__track",
|
|
29
|
+
style: { "--tooltip-progress": `${pct}%` },
|
|
30
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tooltip-progress__fill" })
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
] })
|
|
34
|
+
] });
|
|
35
|
+
}
|
|
36
|
+
module.exports = ProgressTooltip;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { useAutoPlacement } from "./useAutoPlacement.mjs";
|
|
4
|
+
function ProgressTooltip({
|
|
5
|
+
placement = "top",
|
|
6
|
+
title = "正在翻译私域数据...",
|
|
7
|
+
progress = 0,
|
|
8
|
+
className,
|
|
9
|
+
style
|
|
10
|
+
}) {
|
|
11
|
+
const [activePlacement, popupRef] = useAutoPlacement(placement);
|
|
12
|
+
const pct = Math.min(100, Math.max(0, Math.round(progress)));
|
|
13
|
+
const popupCls = ["tooltip-popup", `tooltip-popup--${activePlacement}`, className].filter(Boolean).join(" ");
|
|
14
|
+
return /* @__PURE__ */ jsxs("div", { ref: popupRef, className: popupCls, style, children: [
|
|
15
|
+
/* @__PURE__ */ jsx("div", { className: `tooltip-arrow tooltip-arrow--${activePlacement}` }),
|
|
16
|
+
/* @__PURE__ */ jsxs("div", { className: "tooltip-progress", children: [
|
|
17
|
+
/* @__PURE__ */ jsxs("div", { className: "tooltip-progress__header", children: [
|
|
18
|
+
/* @__PURE__ */ jsx("span", { className: "tooltip-progress__title", children: title }),
|
|
19
|
+
/* @__PURE__ */ jsxs("span", { className: "tooltip-progress__percent", children: [
|
|
20
|
+
pct,
|
|
21
|
+
"%"
|
|
22
|
+
] })
|
|
23
|
+
] }),
|
|
24
|
+
/* @__PURE__ */ jsx(
|
|
25
|
+
"div",
|
|
26
|
+
{
|
|
27
|
+
className: "tooltip-progress__track",
|
|
28
|
+
style: { "--tooltip-progress": `${pct}%` },
|
|
29
|
+
children: /* @__PURE__ */ jsx("div", { className: "tooltip-progress__fill" })
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
] })
|
|
33
|
+
] });
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
ProgressTooltip as default
|
|
37
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const react = require("react");
|
|
4
|
+
;/* empty css */
|
|
5
|
+
const TooltipWrapper = react.forwardRef(
|
|
6
|
+
({ children, style, className }, ref) => {
|
|
7
|
+
const cls = ["tooltip-wrapper", className].filter(Boolean).join(" ");
|
|
8
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cls, style, children });
|
|
9
|
+
}
|
|
10
|
+
);
|
|
11
|
+
TooltipWrapper.displayName = "TooltipWrapper";
|
|
12
|
+
module.exports = TooltipWrapper;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
/* empty css */
|
|
4
|
+
const TooltipWrapper = forwardRef(
|
|
5
|
+
({ children, style, className }, ref) => {
|
|
6
|
+
const cls = ["tooltip-wrapper", className].filter(Boolean).join(" ");
|
|
7
|
+
return /* @__PURE__ */ jsx("div", { ref, className: cls, style, children });
|
|
8
|
+
}
|
|
9
|
+
);
|
|
10
|
+
TooltipWrapper.displayName = "TooltipWrapper";
|
|
11
|
+
export {
|
|
12
|
+
TooltipWrapper as default
|
|
13
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const react = require("react");
|
|
4
|
+
const CLOCKWISE = ["top", "right", "bottom", "left"];
|
|
5
|
+
function useAutoPlacement(placement) {
|
|
6
|
+
const [resolved, setResolved] = react.useState("top");
|
|
7
|
+
const [popupEl, setPopupEl] = react.useState(null);
|
|
8
|
+
const popupRef = react.useCallback((el) => {
|
|
9
|
+
setPopupEl(el);
|
|
10
|
+
}, []);
|
|
11
|
+
react.useLayoutEffect(() => {
|
|
12
|
+
if (placement !== "auto" || !popupEl) return;
|
|
13
|
+
const parent = popupEl.parentElement;
|
|
14
|
+
if (!parent) return;
|
|
15
|
+
const pr = parent.getBoundingClientRect();
|
|
16
|
+
const pw = popupEl.offsetWidth;
|
|
17
|
+
const ph = popupEl.offsetHeight;
|
|
18
|
+
const gap = 12;
|
|
19
|
+
const space = {
|
|
20
|
+
top: pr.top,
|
|
21
|
+
right: window.innerWidth - pr.right,
|
|
22
|
+
bottom: window.innerHeight - pr.bottom,
|
|
23
|
+
left: pr.left
|
|
24
|
+
};
|
|
25
|
+
const required = {
|
|
26
|
+
top: ph + gap,
|
|
27
|
+
right: pw + gap,
|
|
28
|
+
bottom: ph + gap,
|
|
29
|
+
left: pw + gap
|
|
30
|
+
};
|
|
31
|
+
for (const dir of CLOCKWISE) {
|
|
32
|
+
if (space[dir] >= required[dir]) {
|
|
33
|
+
setResolved(dir);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
setResolved("top");
|
|
38
|
+
}, [placement, popupEl]);
|
|
39
|
+
return [placement === "auto" ? resolved : placement, popupRef];
|
|
40
|
+
}
|
|
41
|
+
exports.useAutoPlacement = useAutoPlacement;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useState, useCallback, useLayoutEffect } from "react";
|
|
2
|
+
const CLOCKWISE = ["top", "right", "bottom", "left"];
|
|
3
|
+
function useAutoPlacement(placement) {
|
|
4
|
+
const [resolved, setResolved] = useState("top");
|
|
5
|
+
const [popupEl, setPopupEl] = useState(null);
|
|
6
|
+
const popupRef = useCallback((el) => {
|
|
7
|
+
setPopupEl(el);
|
|
8
|
+
}, []);
|
|
9
|
+
useLayoutEffect(() => {
|
|
10
|
+
if (placement !== "auto" || !popupEl) return;
|
|
11
|
+
const parent = popupEl.parentElement;
|
|
12
|
+
if (!parent) return;
|
|
13
|
+
const pr = parent.getBoundingClientRect();
|
|
14
|
+
const pw = popupEl.offsetWidth;
|
|
15
|
+
const ph = popupEl.offsetHeight;
|
|
16
|
+
const gap = 12;
|
|
17
|
+
const space = {
|
|
18
|
+
top: pr.top,
|
|
19
|
+
right: window.innerWidth - pr.right,
|
|
20
|
+
bottom: window.innerHeight - pr.bottom,
|
|
21
|
+
left: pr.left
|
|
22
|
+
};
|
|
23
|
+
const required = {
|
|
24
|
+
top: ph + gap,
|
|
25
|
+
right: pw + gap,
|
|
26
|
+
bottom: ph + gap,
|
|
27
|
+
left: pw + gap
|
|
28
|
+
};
|
|
29
|
+
for (const dir of CLOCKWISE) {
|
|
30
|
+
if (space[dir] >= required[dir]) {
|
|
31
|
+
setResolved(dir);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
setResolved("top");
|
|
36
|
+
}, [placement, popupEl]);
|
|
37
|
+
return [placement === "auto" ? resolved : placement, popupRef];
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
useAutoPlacement
|
|
41
|
+
};
|