bj-web-components 0.2.25 → 0.2.27

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/index.d.ts CHANGED
@@ -290,7 +290,7 @@ export declare interface BTabsTabPaneProps extends Omit<BTabsItem, 'key' | 'labe
290
290
 
291
291
  export declare type BTabsType = 'line' | 'card';
292
292
 
293
- declare function BTooltip({ children, placement, content, variant, className, style, getPopupContainer, getAnchorElement, color, fontColor, }: ContentTooltipProps): JSX.Element;
293
+ declare function BTooltip({ children, placement, content, variant, className, style, getPopupContainer, getAnchorElement, color, fontColor, autoAdjustOverflow, }: ContentTooltipProps): JSX.Element;
294
294
  export { BTooltip }
295
295
  export { BTooltip as ContentTooltip }
296
296
 
@@ -698,6 +698,8 @@ declare interface ContentTooltipProps extends BaseTooltipProps {
698
698
  children?: React.ReactElement;
699
699
  content?: ReactNode;
700
700
  variant?: TooltipVariant;
701
+ /** 空间不足时是否允许 antd 自动翻转弹层方向;置 false 时严格按 placement 渲染(可能溢出视口)。默认 true */
702
+ autoAdjustOverflow?: boolean;
701
703
  /** Tooltip background color, including the arrow. */
702
704
  color?: string;
703
705
  /** Tooltip content text color. */
@@ -1 +1 @@
1
- "use strict";const t=require("react/jsx-runtime"),y=require("react"),R=require("react-dom"),B=require("antd");;/* empty css */const $=require("./useAutoPlacement.js");function P({children:j,placement:i="top",content:a="这里是提示内容,可以包含更多详细信息。",variant:c="default",className:w,style:h,getPopupContainer:e,getAnchorElement:s,color:o,fontColor:r}){const[v,N]=$.useAutoPlacement(i),n=y.useRef(null),[b,q]=y.useState(),u=["tooltip-popup","tooltip-popup--content",`tooltip-popup--${v}`,c!=="default"?`tooltip-popup--${c}`:"",w].filter(Boolean).join(" "),p=["tooltip-arrow",`tooltip-arrow--${v}`,c==="tinted"?"tooltip-arrow--tinted-bg":""].filter(Boolean).join(" "),d={...h,...o?{backgroundColor:o}:{},...r?{color:r}:{}},f=o?{backgroundColor:o,borderColor:o}:void 0,x=r?{color:r}:void 0,S=t.jsxs("div",{className:`${u} tooltip-popup--antd`,style:d,children:[t.jsx("div",{className:p,style:f}),t.jsx("div",{className:"bu-tooltip-content__text",style:x,children:a})]});if(j)return t.jsx(B.Tooltip,{title:S,placement:i==="auto"?"top":i,arrowPointAtCenter:!0,getPopupContainer:e,overlayClassName:"bu-content-tooltip",children:j});const _=t.jsxs("div",{ref:N,className:u,style:d,children:[t.jsx("div",{className:p,style:f}),t.jsx("div",{className:"bu-tooltip-content__text",style:x,children:a})]});if(y.useLayoutEffect(()=>{if(!e||!n.current)return;const l=(s==null?void 0:s())??n.current.parentElement;if(!l)return;const m=l.getBoundingClientRect();q({position:"fixed",left:m.left+m.width/2,top:m.top,right:"auto",bottom:"auto",transform:"translate(-50%, calc(-100% - 16px))"})},[s,e]),e&&typeof document<"u"){const l=e();return t.jsxs(t.Fragment,{children:[t.jsx("span",{ref:n,className:"tooltip-portal-anchor"}),b&&R.createPortal(t.jsxs("div",{ref:N,className:u,style:{...d,...b},children:[t.jsx("div",{className:p,style:f}),t.jsx("div",{className:"bu-tooltip-content__text",style:x,children:a})]}),l)]})}return _}module.exports=P;
1
+ "use strict";const t=require("react/jsx-runtime"),y=require("react"),B=require("react-dom"),$=require("antd");;/* empty css */const P=require("./useAutoPlacement.js");function k({children:j,placement:i="top",content:a="这里是提示内容,可以包含更多详细信息。",variant:c="default",className:w,style:h,getPopupContainer:e,getAnchorElement:s,color:o,fontColor:r,autoAdjustOverflow:q=!0}){const[v,N]=P.useAutoPlacement(i),n=y.useRef(null),[b,S]=y.useState(),u=["tooltip-popup","tooltip-popup--content",`tooltip-popup--${v}`,c!=="default"?`tooltip-popup--${c}`:"",w].filter(Boolean).join(" "),p=["tooltip-arrow",`tooltip-arrow--${v}`,c==="tinted"?"tooltip-arrow--tinted-bg":""].filter(Boolean).join(" "),d={...h,...o?{backgroundColor:o}:{},...r?{color:r}:{}},f=o?{backgroundColor:o,borderColor:o}:void 0,x=r?{color:r}:void 0,_=t.jsxs("div",{className:`${u} tooltip-popup--antd`,style:d,children:[t.jsx("div",{className:p,style:f}),t.jsx("div",{className:"bu-tooltip-content__text",style:x,children:a})]});if(j)return t.jsx($.Tooltip,{title:_,placement:i==="auto"?"top":i,arrowPointAtCenter:!0,autoAdjustOverflow:q,getPopupContainer:e,overlayClassName:"bu-content-tooltip",children:j});const R=t.jsxs("div",{ref:N,className:u,style:d,children:[t.jsx("div",{className:p,style:f}),t.jsx("div",{className:"bu-tooltip-content__text",style:x,children:a})]});if(y.useLayoutEffect(()=>{if(!e||!n.current)return;const l=(s==null?void 0:s())??n.current.parentElement;if(!l)return;const m=l.getBoundingClientRect();S({position:"fixed",left:m.left+m.width/2,top:m.top,right:"auto",bottom:"auto",transform:"translate(-50%, calc(-100% - 16px))"})},[s,e]),e&&typeof document<"u"){const l=e();return t.jsxs(t.Fragment,{children:[t.jsx("span",{ref:n,className:"tooltip-portal-anchor"}),b&&B.createPortal(t.jsxs("div",{ref:N,className:u,style:{...d,...b},children:[t.jsx("div",{className:p,style:f}),t.jsx("div",{className:"bu-tooltip-content__text",style:x,children:a})]}),l)]})}return R}module.exports=k;
@@ -1,10 +1,10 @@
1
- import { jsx as t, jsxs as i, Fragment as R } from "react/jsx-runtime";
2
- import { useRef as $, useState as k, useLayoutEffect as C } from "react";
3
- import { createPortal as P } from "react-dom";
4
- import { Tooltip as T } from "antd";
1
+ import { jsx as t, jsxs as i, Fragment as $ } from "react/jsx-runtime";
2
+ import { useRef as k, useState as C, useLayoutEffect as P } from "react";
3
+ import { createPortal as T } from "react-dom";
4
+ import { Tooltip as F } from "antd";
5
5
  /* empty css */
6
- import { useAutoPlacement as F } from "./useAutoPlacement.mjs";
7
- function I({
6
+ import { useAutoPlacement as L } from "./useAutoPlacement.mjs";
7
+ function J({
8
8
  children: N,
9
9
  placement: a = "top",
10
10
  content: p = "这里是提示内容,可以包含更多详细信息。",
@@ -14,9 +14,10 @@ function I({
14
14
  getPopupContainer: o,
15
15
  getAnchorElement: l,
16
16
  color: e,
17
- fontColor: r
17
+ fontColor: r,
18
+ autoAdjustOverflow: _ = !0
18
19
  }) {
19
- const [b, x] = F(a), c = $(null), [w, _] = k(), u = [
20
+ const [b, x] = L(a), c = k(null), [w, j] = C(), u = [
20
21
  "tooltip-popup",
21
22
  "tooltip-popup--content",
22
23
  `tooltip-popup--${b}`,
@@ -30,32 +31,33 @@ function I({
30
31
  ...S,
31
32
  ...e ? { backgroundColor: e } : {},
32
33
  ...r ? { color: r } : {}
33
- }, m = e ? { backgroundColor: e, borderColor: e } : void 0, y = r ? { color: r } : void 0, j = /* @__PURE__ */ i("div", { className: `${u} tooltip-popup--antd`, style: f, children: [
34
+ }, m = e ? { backgroundColor: e, borderColor: e } : void 0, y = r ? { color: r } : void 0, B = /* @__PURE__ */ i("div", { className: `${u} tooltip-popup--antd`, style: f, children: [
34
35
  /* @__PURE__ */ t("div", { className: d, style: m }),
35
36
  /* @__PURE__ */ t("div", { className: "bu-tooltip-content__text", style: y, children: p })
36
37
  ] });
37
38
  if (N)
38
39
  return /* @__PURE__ */ t(
39
- T,
40
+ F,
40
41
  {
41
- title: j,
42
+ title: B,
42
43
  placement: a === "auto" ? "top" : a,
43
44
  arrowPointAtCenter: !0,
45
+ autoAdjustOverflow: _,
44
46
  getPopupContainer: o,
45
47
  overlayClassName: "bu-content-tooltip",
46
48
  children: N
47
49
  }
48
50
  );
49
- const B = /* @__PURE__ */ i("div", { ref: x, className: u, style: f, children: [
51
+ const R = /* @__PURE__ */ i("div", { ref: x, className: u, style: f, children: [
50
52
  /* @__PURE__ */ t("div", { className: d, style: m }),
51
53
  /* @__PURE__ */ t("div", { className: "bu-tooltip-content__text", style: y, children: p })
52
54
  ] });
53
- if (C(() => {
55
+ if (P(() => {
54
56
  if (!o || !c.current) return;
55
57
  const s = (l == null ? void 0 : l()) ?? c.current.parentElement;
56
58
  if (!s) return;
57
59
  const v = s.getBoundingClientRect();
58
- _({
60
+ j({
59
61
  position: "fixed",
60
62
  left: v.left + v.width / 2,
61
63
  top: v.top,
@@ -65,9 +67,9 @@ function I({
65
67
  });
66
68
  }, [l, o]), o && typeof document < "u") {
67
69
  const s = o();
68
- return /* @__PURE__ */ i(R, { children: [
70
+ return /* @__PURE__ */ i($, { children: [
69
71
  /* @__PURE__ */ t("span", { ref: c, className: "tooltip-portal-anchor" }),
70
- w && P(
72
+ w && T(
71
73
  /* @__PURE__ */ i("div", { ref: x, className: u, style: { ...f, ...w }, children: [
72
74
  /* @__PURE__ */ t("div", { className: d, style: m }),
73
75
  /* @__PURE__ */ t("div", { className: "bu-tooltip-content__text", style: y, children: p })
@@ -76,8 +78,8 @@ function I({
76
78
  )
77
79
  ] });
78
80
  }
79
- return B;
81
+ return R;
80
82
  }
81
83
  export {
82
- I as default
84
+ J as default
83
85
  };
package/dist/web.d.ts CHANGED
@@ -290,7 +290,7 @@ export declare interface BTabsTabPaneProps extends Omit<BTabsItem, 'key' | 'labe
290
290
 
291
291
  export declare type BTabsType = 'line' | 'card';
292
292
 
293
- declare function BTooltip({ children, placement, content, variant, className, style, getPopupContainer, getAnchorElement, color, fontColor, }: ContentTooltipProps): JSX.Element;
293
+ declare function BTooltip({ children, placement, content, variant, className, style, getPopupContainer, getAnchorElement, color, fontColor, autoAdjustOverflow, }: ContentTooltipProps): JSX.Element;
294
294
  export { BTooltip }
295
295
  export { BTooltip as ContentTooltip }
296
296
 
@@ -698,6 +698,8 @@ declare interface ContentTooltipProps extends BaseTooltipProps {
698
698
  children?: React.ReactElement;
699
699
  content?: ReactNode;
700
700
  variant?: TooltipVariant;
701
+ /** 空间不足时是否允许 antd 自动翻转弹层方向;置 false 时严格按 placement 渲染(可能溢出视口)。默认 true */
702
+ autoAdjustOverflow?: boolean;
701
703
  /** Tooltip background color, including the arrow. */
702
704
  color?: string;
703
705
  /** Tooltip content text color. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bj-web-components",
3
- "version": "0.2.25",
3
+ "version": "0.2.27",
4
4
  "description": "Enterprise UI component library for Web, Mobile, and Mini-app platforms",
5
5
  "keywords": [
6
6
  "react",