bj-web-components 0.2.28 → 0.2.30

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.
Files changed (90) hide show
  1. package/dist/index.js +1 -51
  2. package/dist/index.mjs +49 -49
  3. package/dist/style.css +1 -3744
  4. package/dist/web/BasicInput/BInput.js +1 -208
  5. package/dist/web/BasicInput/BInput.mjs +132 -164
  6. package/dist/web/BasicInput/utils.js +1 -47
  7. package/dist/web/BasicInput/utils.mjs +28 -38
  8. package/dist/web/CategoryDropdown/CategoryDropdown.js +1 -307
  9. package/dist/web/CategoryDropdown/CategoryDropdown.mjs +170 -218
  10. package/dist/web/CheckBox/BCheckBox.js +1 -116
  11. package/dist/web/CheckBox/BCheckBox.mjs +70 -86
  12. package/dist/web/CheckBox/Group.js +1 -73
  13. package/dist/web/CheckBox/Group.mjs +56 -63
  14. package/dist/web/CheckBox/context.js +1 -5
  15. package/dist/web/CheckBox/context.mjs +3 -3
  16. package/dist/web/CheckBox/index.js +1 -8
  17. package/dist/web/CheckBox/index.mjs +6 -6
  18. package/dist/web/Dropdown/BDropdown.js +1 -186
  19. package/dist/web/Dropdown/BDropdown.mjs +106 -132
  20. package/dist/web/EmptyInputBox/EmptyInputBox.js +1 -77
  21. package/dist/web/EmptyInputBox/EmptyInputBox.mjs +48 -52
  22. package/dist/web/FileCard/FileCard.js +1 -157
  23. package/dist/web/FileCard/FileCard.mjs +82 -112
  24. package/dist/web/Icon/Icon.js +1 -9
  25. package/dist/web/Icon/Icon.mjs +6 -6
  26. package/dist/web/Input/Input.js +1 -181
  27. package/dist/web/Input/Input.mjs +113 -122
  28. package/dist/web/InputNumber/BInputNumber.js +1 -311
  29. package/dist/web/InputNumber/BInputNumber.mjs +167 -275
  30. package/dist/web/InputNumber/StepHandler.js +1 -69
  31. package/dist/web/InputNumber/StepHandler.mjs +32 -38
  32. package/dist/web/InputNumber/hooks/useCursor.js +1 -40
  33. package/dist/web/InputNumber/hooks/useCursor.mjs +33 -35
  34. package/dist/web/InputNumber/hooks/useFrame.js +1 -12
  35. package/dist/web/InputNumber/hooks/useFrame.mjs +6 -9
  36. package/dist/web/InputNumber/utils/decimal.js +1 -147
  37. package/dist/web/InputNumber/utils/decimal.mjs +81 -109
  38. package/dist/web/Modal/Modal.js +1 -84
  39. package/dist/web/Modal/Modal.mjs +49 -52
  40. package/dist/web/OverlayScrollbar/BOverlayScrollbar.js +1 -232
  41. package/dist/web/OverlayScrollbar/BOverlayScrollbar.mjs +125 -206
  42. package/dist/web/Pagination/Pagination.js +1 -328
  43. package/dist/web/Pagination/Pagination.mjs +178 -254
  44. package/dist/web/ProductField/ProductField.js +1 -272
  45. package/dist/web/ProductField/ProductField.mjs +143 -190
  46. package/dist/web/ProductField/arrow-up.svg.js +1 -3
  47. package/dist/web/ProductField/arrow-up.svg.mjs +2 -2
  48. package/dist/web/ProductField/checkbox-no.svg.js +1 -3
  49. package/dist/web/ProductField/checkbox-no.svg.mjs +2 -2
  50. package/dist/web/ProductField/checkbox-ok.svg.js +1 -3
  51. package/dist/web/ProductField/checkbox-ok.svg.mjs +2 -2
  52. package/dist/web/ProductField/no_data_light.svg.js +1 -3
  53. package/dist/web/ProductField/no_data_light.svg.mjs +2 -2
  54. package/dist/web/ProductField/search.svg.js +1 -3
  55. package/dist/web/ProductField/search.svg.mjs +2 -2
  56. package/dist/web/ProductField/sort.svg.js +1 -3
  57. package/dist/web/ProductField/sort.svg.mjs +2 -2
  58. package/dist/web/SkuInputCard/SkuInputCard.js +1 -276
  59. package/dist/web/SkuInputCard/SkuInputCard.mjs +149 -188
  60. package/dist/web/SkuInputCard/spin_loading_red.gif.js +1 -3
  61. package/dist/web/SkuInputCard/spin_loading_red.gif.mjs +2 -2
  62. package/dist/web/Switch/Switch.js +1 -70
  63. package/dist/web/Switch/Switch.mjs +37 -47
  64. package/dist/web/Table/BTable.js +1 -950
  65. package/dist/web/Table/BTable.mjs +521 -767
  66. package/dist/web/Table/Column.js +1 -5
  67. package/dist/web/Table/Column.mjs +2 -2
  68. package/dist/web/Table/ColumnGroup.js +1 -5
  69. package/dist/web/Table/ColumnGroup.mjs +2 -2
  70. package/dist/web/Table/utils/columns.js +1 -48
  71. package/dist/web/Table/utils/columns.mjs +30 -35
  72. package/dist/web/Table/utils/sortFilter.js +1 -84
  73. package/dist/web/Table/utils/sortFilter.mjs +52 -73
  74. package/dist/web/Tabs/BTabs.js +1 -150
  75. package/dist/web/Tabs/BTabs.mjs +98 -118
  76. package/dist/web/Tabs/TabPane.js +1 -8
  77. package/dist/web/Tabs/TabPane.mjs +4 -4
  78. package/dist/web/Tooltip/ConfirmTooltip.js +1 -26
  79. package/dist/web/Tooltip/ConfirmTooltip.mjs +19 -20
  80. package/dist/web/Tooltip/ContentTooltip.js +1 -94
  81. package/dist/web/Tooltip/ContentTooltip.mjs +62 -72
  82. package/dist/web/Tooltip/ProgressTooltip.js +1 -36
  83. package/dist/web/Tooltip/ProgressTooltip.mjs +20 -22
  84. package/dist/web/Tooltip/TooltipWrapper.js +1 -12
  85. package/dist/web/Tooltip/TooltipWrapper.mjs +8 -8
  86. package/dist/web/Tooltip/useAutoPlacement.js +1 -41
  87. package/dist/web/Tooltip/useAutoPlacement.mjs +25 -34
  88. package/dist/web.js +1 -51
  89. package/dist/web.mjs +49 -49
  90. package/package.json +1 -1
@@ -1,150 +1,130 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useRef, useState, useEffect, useMemo, Children, isValidElement } from "react";
3
- import { TabPane } from "./TabPane.mjs";
1
+ import { jsxs as g, jsx as b } from "react/jsx-runtime";
2
+ import { useRef as E, useState as A, useEffect as L, useMemo as T, Children as P, isValidElement as F } from "react";
3
+ import { TabPane as G } from "./TabPane.mjs";
4
4
  /* empty css */
5
- function classNames(...values) {
6
- return values.filter(Boolean).join(" ");
5
+ function I(...n) {
6
+ return n.filter(Boolean).join(" ");
7
7
  }
8
- function useMergedState(defaultValue, value) {
9
- const [innerValue, setInnerValue] = useState(defaultValue);
10
- return [value === void 0 ? innerValue : value, setInnerValue];
8
+ function U(n, s) {
9
+ const [t, a] = A(n);
10
+ return [s === void 0 ? t : s, a];
11
11
  }
12
- function useLegacyItems(items, children) {
13
- return useMemo(() => {
14
- if (items) return items.filter((item) => Boolean(item && typeof item === "object" && "key" in item));
15
- return Children.toArray(children).flatMap((child) => {
16
- if (!isValidElement(child)) return [];
17
- const { tab, tabKey, ...restProps } = child.props;
18
- const key = tabKey ?? child.key;
19
- return key === null ? [] : [{ ...restProps, key: String(key), label: tab }];
20
- });
21
- }, [children, items]);
12
+ function q(n, s) {
13
+ return T(() => n ? n.filter((t) => !!(t && typeof t == "object" && "key" in t)) : P.toArray(s).flatMap((t) => {
14
+ if (!F(t)) return [];
15
+ const { tab: a, tabKey: l, ...u } = t.props, c = l ?? t.key;
16
+ return c === null ? [] : [{ ...u, key: String(c), label: a }];
17
+ }), [s, n]);
22
18
  }
23
- function TabNode({
24
- active,
25
- id,
26
- item,
27
- onClick,
28
- onKeyDown,
29
- tabCount,
30
- tabIndex
19
+ function z({
20
+ active: n,
21
+ id: s,
22
+ item: t,
23
+ onClick: a,
24
+ onKeyDown: l,
25
+ tabCount: u,
26
+ tabIndex: c
31
27
  }) {
32
- return /* @__PURE__ */ jsxs(
28
+ return /* @__PURE__ */ g(
33
29
  "button",
34
30
  {
35
- "aria-controls": `${id}-panel-${item.key}`,
36
- "aria-disabled": item.disabled,
37
- "aria-selected": active,
38
- className: classNames("bj-tabs__tab", active && "bj-tabs__tab--active", item.disabled && "bj-tabs__tab--disabled"),
39
- disabled: item.disabled,
40
- id: `${id}-tab-${item.key}`,
41
- onClick,
42
- onKeyDown,
31
+ "aria-controls": `${s}-panel-${t.key}`,
32
+ "aria-disabled": t.disabled,
33
+ "aria-selected": n,
34
+ className: I("bj-tabs__tab", n && "bj-tabs__tab--active", t.disabled && "bj-tabs__tab--disabled"),
35
+ disabled: t.disabled,
36
+ id: `${s}-tab-${t.key}`,
37
+ onClick: a,
38
+ onKeyDown: l,
43
39
  role: "tab",
44
- tabIndex: item.disabled ? -1 : active ? 0 : -1,
40
+ tabIndex: t.disabled ? -1 : n ? 0 : -1,
45
41
  type: "button",
46
42
  children: [
47
- /* @__PURE__ */ jsx("span", { className: "bj-tabs__tab-btn", children: item.label }),
48
- /* @__PURE__ */ jsx("span", { className: "bj-tabs__sr-only", children: `Tab ${tabIndex + 1} of ${tabCount}` })
43
+ /* @__PURE__ */ b("span", { className: "bj-tabs__tab-btn", children: t.label }),
44
+ /* @__PURE__ */ b("span", { className: "bj-tabs__sr-only", children: `Tab ${c + 1} of ${u}` })
49
45
  ]
50
46
  }
51
47
  );
52
48
  }
53
- function TabPanelList({ activeKey, id, items }) {
54
- return /* @__PURE__ */ jsx("div", { className: "bj-tabs__content-holder", children: /* @__PURE__ */ jsx("div", { className: "bj-tabs__content", children: items.map((item) => {
55
- const active = item.key === activeKey;
56
- if (!active && !item.forceRender) return null;
57
- return /* @__PURE__ */ jsx(
49
+ function H({ activeKey: n, id: s, items: t }) {
50
+ return /* @__PURE__ */ b("div", { className: "bj-tabs__content-holder", children: /* @__PURE__ */ b("div", { className: "bj-tabs__content", children: t.map((a) => {
51
+ const l = a.key === n;
52
+ return !l && !a.forceRender ? null : /* @__PURE__ */ b(
58
53
  "div",
59
54
  {
60
- "aria-hidden": !active,
61
- "aria-labelledby": `${id}-tab-${item.key}`,
62
- className: classNames("bj-tabs__tabpane", active && "bj-tabs__tabpane--active", item.className),
63
- id: `${id}-panel-${item.key}`,
55
+ "aria-hidden": !l,
56
+ "aria-labelledby": `${s}-tab-${a.key}`,
57
+ className: I("bj-tabs__tabpane", l && "bj-tabs__tabpane--active", a.className),
58
+ id: `${s}-panel-${a.key}`,
64
59
  role: "tabpanel",
65
- style: item.style,
66
- tabIndex: active ? 0 : -1,
67
- children: item.children
60
+ style: a.style,
61
+ tabIndex: l ? 0 : -1,
62
+ children: a.children
68
63
  },
69
- item.key
64
+ a.key
70
65
  );
71
66
  }) }) });
72
67
  }
73
- function BTabs({
74
- activeKey,
75
- children,
76
- centered,
77
- className,
78
- defaultActiveKey,
79
- id,
80
- items,
81
- onChange,
82
- onTabClick,
83
- style,
84
- tabBarGutter,
85
- tabBarStyle,
86
- tabPosition = "top",
87
- type = "line"
68
+ function J({
69
+ activeKey: n,
70
+ children: s,
71
+ centered: t,
72
+ className: a,
73
+ defaultActiveKey: l,
74
+ id: u,
75
+ items: c,
76
+ onChange: f,
77
+ onTabClick: p,
78
+ style: w,
79
+ tabBarGutter: O,
80
+ tabBarStyle: M,
81
+ tabPosition: _ = "top",
82
+ type: K = "line"
88
83
  }) {
89
- const tabs = useLegacyItems(items, children);
90
- const generatedIdRef = useRef(`bj-tabs-${Math.random().toString(36).slice(2, 10)}`);
91
- const mergedId = id ?? generatedIdRef.current;
92
- const [mergedActiveKey, setMergedActiveKey] = useMergedState(
84
+ const r = q(c, s), B = E(`bj-tabs-${Math.random().toString(36).slice(2, 10)}`), j = u ?? B.current, [o, k] = U(
93
85
  () => {
94
- var _a;
95
- return defaultActiveKey ?? ((_a = tabs[0]) == null ? void 0 : _a.key);
86
+ var e;
87
+ return l ?? ((e = r[0]) == null ? void 0 : e.key);
96
88
  },
97
- activeKey
98
- );
99
- const [activeIndex, setActiveIndex] = useState(() => tabs.findIndex((tab) => tab.key === mergedActiveKey));
100
- useEffect(() => {
101
- var _a;
102
- let nextActiveIndex = tabs.findIndex((tab) => tab.key === mergedActiveKey);
103
- if (nextActiveIndex === -1) {
104
- nextActiveIndex = Math.max(0, Math.min(activeIndex, tabs.length - 1));
105
- setMergedActiveKey((_a = tabs[nextActiveIndex]) == null ? void 0 : _a.key);
106
- }
107
- setActiveIndex(nextActiveIndex);
108
- }, [activeIndex, mergedActiveKey, setMergedActiveKey, tabs]);
109
- const activateTab = (key, event) => {
110
- onTabClick == null ? void 0 : onTabClick(key, event);
111
- if (key === mergedActiveKey) return;
112
- setMergedActiveKey(key);
113
- onChange == null ? void 0 : onChange(key);
114
- };
115
- const moveFocus = (event, index) => {
116
- var _a;
117
- const isVertical = tabPosition === "left" || tabPosition === "right";
118
- const nextKey = isVertical ? event.key === "ArrowDown" ? 1 : event.key === "ArrowUp" ? -1 : 0 : event.key === "ArrowRight" ? 1 : event.key === "ArrowLeft" ? -1 : 0;
119
- if (!nextKey) return;
120
- event.preventDefault();
121
- const enabledTabs = tabs.filter((tab) => !tab.disabled);
122
- const enabledIndex = enabledTabs.findIndex((tab) => {
123
- var _a2;
124
- return tab.key === ((_a2 = tabs[index]) == null ? void 0 : _a2.key);
125
- });
126
- const nextTab = enabledTabs[(enabledIndex + nextKey + enabledTabs.length) % enabledTabs.length];
127
- (_a = document.getElementById(`${mergedId}-tab-${nextTab == null ? void 0 : nextTab.key}`)) == null ? void 0 : _a.focus();
89
+ n
90
+ ), [$, V] = A(() => r.findIndex((e) => e.key === o));
91
+ L(() => {
92
+ var d;
93
+ let e = r.findIndex((i) => i.key === o);
94
+ e === -1 && (e = Math.max(0, Math.min($, r.length - 1)), k((d = r[e]) == null ? void 0 : d.key)), V(e);
95
+ }, [$, o, k, r]);
96
+ const R = (e, d) => {
97
+ p == null || p(e, d), e !== o && (k(e), f == null || f(e));
98
+ }, S = (e, d) => {
99
+ var m;
100
+ const x = _ === "left" || _ === "right" ? e.key === "ArrowDown" ? 1 : e.key === "ArrowUp" ? -1 : 0 : e.key === "ArrowRight" ? 1 : e.key === "ArrowLeft" ? -1 : 0;
101
+ if (!x) return;
102
+ e.preventDefault();
103
+ const y = r.filter((h) => !h.disabled), D = y.findIndex((h) => {
104
+ var N;
105
+ return h.key === ((N = r[d]) == null ? void 0 : N.key);
106
+ }), v = y[(D + x + y.length) % y.length];
107
+ (m = document.getElementById(`${j}-tab-${v == null ? void 0 : v.key}`)) == null || m.focus();
128
108
  };
129
- return /* @__PURE__ */ jsxs("div", { className: classNames("bj-tabs", `bj-tabs--${tabPosition}`, `bj-tabs--${type}`, centered && "bj-tabs--centered", className), style, children: [
130
- /* @__PURE__ */ jsx("div", { className: "bj-tabs__nav", role: "tablist", style: tabBarStyle, children: /* @__PURE__ */ jsx("div", { className: "bj-tabs__nav-wrap", children: /* @__PURE__ */ jsx("div", { className: "bj-tabs__nav-list", children: tabs.map((item, index) => /* @__PURE__ */ jsx(
131
- TabNode,
109
+ return /* @__PURE__ */ g("div", { className: I("bj-tabs", `bj-tabs--${_}`, `bj-tabs--${K}`, t && "bj-tabs--centered", a), style: w, children: [
110
+ /* @__PURE__ */ b("div", { className: "bj-tabs__nav", role: "tablist", style: M, children: /* @__PURE__ */ b("div", { className: "bj-tabs__nav-wrap", children: /* @__PURE__ */ b("div", { className: "bj-tabs__nav-list", children: r.map((e, d) => /* @__PURE__ */ b(
111
+ z,
132
112
  {
133
- active: item.key === mergedActiveKey,
134
- id: mergedId,
135
- item,
136
- onClick: (event) => activateTab(item.key, event),
137
- onKeyDown: (event) => moveFocus(event, index),
138
- tabCount: tabs.length,
139
- tabIndex: index
113
+ active: e.key === o,
114
+ id: j,
115
+ item: e,
116
+ onClick: (i) => R(e.key, i),
117
+ onKeyDown: (i) => S(i, d),
118
+ tabCount: r.length,
119
+ tabIndex: d
140
120
  },
141
- item.key
121
+ e.key
142
122
  )) }) }) }),
143
- /* @__PURE__ */ jsx(TabPanelList, { activeKey: mergedActiveKey, id: mergedId, items: tabs })
123
+ /* @__PURE__ */ b(H, { activeKey: o, id: j, items: r })
144
124
  ] });
145
125
  }
146
- BTabs.TabPane = TabPane;
126
+ J.TabPane = G;
147
127
  export {
148
- TabPane,
149
- BTabs as default
128
+ G as TabPane,
129
+ J as default
150
130
  };
@@ -1,8 +1 @@
1
- "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- function TabPane(_) {
4
- return null;
5
- }
6
- TabPane.displayName = "BTabs.TabPane";
7
- exports.TabPane = TabPane;
8
- exports.default = TabPane;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function e(a){return null}e.displayName="BTabs.TabPane";exports.TabPane=e;exports.default=e;
@@ -1,8 +1,8 @@
1
- function TabPane(_) {
1
+ function a(e) {
2
2
  return null;
3
3
  }
4
- TabPane.displayName = "BTabs.TabPane";
4
+ a.displayName = "BTabs.TabPane";
5
5
  export {
6
- TabPane,
7
- TabPane as default
6
+ a as TabPane,
7
+ a as default
8
8
  };
@@ -1,26 +1 @@
1
- "use strict";
2
- const jsxRuntime = require("react/jsx-runtime");
3
- ;/* empty css */
4
- const useAutoPlacement = require("./useAutoPlacement.js");
5
- function ConfirmTooltip({
6
- placement = "top",
7
- title = "是否使用当前自动翻译的英文?",
8
- okText = "使用",
9
- cancelText = "我去改改",
10
- onOk,
11
- onCancel,
12
- className,
13
- style
14
- }) {
15
- const [activePlacement, popupRef] = useAutoPlacement.useAutoPlacement(placement);
16
- const popupCls = ["tooltip-popup", `tooltip-popup--${activePlacement}`, className].filter(Boolean).join(" ");
17
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: popupRef, className: popupCls, style, children: [
18
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: `tooltip-arrow tooltip-arrow--${activePlacement}` }),
19
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "tooltip-confirm__title", children: title }),
20
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tooltip-confirm__actions", children: [
21
- /* @__PURE__ */ jsxRuntime.jsx("button", { className: "tooltip-confirm__cancel", onClick: onCancel, children: cancelText }),
22
- /* @__PURE__ */ jsxRuntime.jsx("button", { className: "tooltip-confirm__ok", onClick: onOk, children: okText })
23
- ] })
24
- ] });
25
- }
26
- module.exports = ConfirmTooltip;
1
+ "use strict";const o=require("react/jsx-runtime");;/* empty css */const m=require("./useAutoPlacement.js");function f({placement:e="top",title:i="是否使用当前自动翻译的英文?",okText:s="使用",cancelText:c="我去改改",onOk:l,onCancel:n,className:r,style:p}){const[t,a]=m.useAutoPlacement(e),u=["tooltip-popup",`tooltip-popup--${t}`,r].filter(Boolean).join(" ");return o.jsxs("div",{ref:a,className:u,style:p,children:[o.jsx("div",{className:`tooltip-arrow tooltip-arrow--${t}`}),o.jsx("p",{className:"tooltip-confirm__title",children:i}),o.jsxs("div",{className:"tooltip-confirm__actions",children:[o.jsx("button",{className:"tooltip-confirm__cancel",onClick:n,children:c}),o.jsx("button",{className:"tooltip-confirm__ok",onClick:l,children:s})]})]})}module.exports=f;
@@ -1,27 +1,26 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
1
+ import { jsxs as i, jsx as o } from "react/jsx-runtime";
2
2
  /* empty css */
3
- import { useAutoPlacement } from "./useAutoPlacement.mjs";
4
- function ConfirmTooltip({
5
- placement = "top",
6
- title = "是否使用当前自动翻译的英文?",
7
- okText = "使用",
8
- cancelText = "我去改改",
9
- onOk,
10
- onCancel,
11
- className,
12
- style
3
+ import { useAutoPlacement as u } from "./useAutoPlacement.mjs";
4
+ function h({
5
+ placement: l = "top",
6
+ title: p = "是否使用当前自动翻译的英文?",
7
+ okText: c = "使用",
8
+ cancelText: e = "我去改改",
9
+ onOk: n,
10
+ onCancel: r,
11
+ className: a,
12
+ style: s
13
13
  }) {
14
- const [activePlacement, popupRef] = useAutoPlacement(placement);
15
- const popupCls = ["tooltip-popup", `tooltip-popup--${activePlacement}`, className].filter(Boolean).join(" ");
16
- return /* @__PURE__ */ jsxs("div", { ref: popupRef, className: popupCls, style, children: [
17
- /* @__PURE__ */ jsx("div", { className: `tooltip-arrow tooltip-arrow--${activePlacement}` }),
18
- /* @__PURE__ */ jsx("p", { className: "tooltip-confirm__title", children: title }),
19
- /* @__PURE__ */ jsxs("div", { className: "tooltip-confirm__actions", children: [
20
- /* @__PURE__ */ jsx("button", { className: "tooltip-confirm__cancel", onClick: onCancel, children: cancelText }),
21
- /* @__PURE__ */ jsx("button", { className: "tooltip-confirm__ok", onClick: onOk, children: okText })
14
+ const [t, m] = u(l), f = ["tooltip-popup", `tooltip-popup--${t}`, a].filter(Boolean).join(" ");
15
+ return /* @__PURE__ */ i("div", { ref: m, className: f, style: s, children: [
16
+ /* @__PURE__ */ o("div", { className: `tooltip-arrow tooltip-arrow--${t}` }),
17
+ /* @__PURE__ */ o("p", { className: "tooltip-confirm__title", children: p }),
18
+ /* @__PURE__ */ i("div", { className: "tooltip-confirm__actions", children: [
19
+ /* @__PURE__ */ o("button", { className: "tooltip-confirm__cancel", onClick: r, children: e }),
20
+ /* @__PURE__ */ o("button", { className: "tooltip-confirm__ok", onClick: n, children: c })
22
21
  ] })
23
22
  ] });
24
23
  }
25
24
  export {
26
- ConfirmTooltip as default
25
+ h as default
27
26
  };
@@ -1,94 +1 @@
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;
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,95 +1,85 @@
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";
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 } 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
6
+ import { useAutoPlacement as L } from "./useAutoPlacement.mjs";
7
+ function J({
8
+ children: N,
9
+ placement: a = "top",
10
+ content: p = "这里是提示内容,可以包含更多详细信息。",
11
+ variant: n = "default",
12
+ className: h,
13
+ style: S,
14
+ getPopupContainer: o,
15
+ getAnchorElement: l,
16
+ color: e,
17
+ fontColor: r,
18
+ autoAdjustOverflow: _ = !0
19
19
  }) {
20
- const [activePlacement, popupRef] = useAutoPlacement(placement);
21
- const anchorRef = useRef(null);
22
- const [portalStyle, setPortalStyle] = useState();
23
- const popupCls = [
20
+ const [b, x] = L(a), c = k(null), [w, j] = C(), u = [
24
21
  "tooltip-popup",
25
22
  "tooltip-popup--content",
26
- `tooltip-popup--${activePlacement}`,
27
- variant !== "default" ? `tooltip-popup--${variant}` : "",
28
- className
29
- ].filter(Boolean).join(" ");
30
- const arrowCls = [
23
+ `tooltip-popup--${b}`,
24
+ n !== "default" ? `tooltip-popup--${n}` : "",
25
+ h
26
+ ].filter(Boolean).join(" "), d = [
31
27
  "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 })
28
+ `tooltip-arrow--${b}`,
29
+ n === "tinted" ? "tooltip-arrow--tinted-bg" : ""
30
+ ].filter(Boolean).join(" "), f = {
31
+ ...S,
32
+ ...e ? { backgroundColor: e } : {},
33
+ ...r ? { color: r } : {}
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: [
35
+ /* @__PURE__ */ t("div", { className: d, style: m }),
36
+ /* @__PURE__ */ t("div", { className: "bu-tooltip-content__text", style: y, children: p })
45
37
  ] });
46
- if (children) {
47
- return /* @__PURE__ */ jsx(
48
- Tooltip,
38
+ if (N)
39
+ return /* @__PURE__ */ t(
40
+ F,
49
41
  {
50
- title: customContent,
51
- placement: placement === "auto" ? "top" : placement,
52
- arrowPointAtCenter: true,
53
- autoAdjustOverflow,
54
- getPopupContainer,
42
+ title: B,
43
+ placement: a === "auto" ? "top" : a,
44
+ arrowPointAtCenter: !0,
45
+ autoAdjustOverflow: _,
46
+ getPopupContainer: o,
55
47
  overlayClassName: "bu-content-tooltip",
56
- children
48
+ children: N
57
49
  }
58
50
  );
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 })
51
+ const R = /* @__PURE__ */ i("div", { ref: x, className: u, style: f, children: [
52
+ /* @__PURE__ */ t("div", { className: d, style: m }),
53
+ /* @__PURE__ */ t("div", { className: "bu-tooltip-content__text", style: y, children: p })
63
54
  ] });
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({
55
+ if (P(() => {
56
+ if (!o || !c.current) return;
57
+ const s = (l == null ? void 0 : l()) ?? c.current.parentElement;
58
+ if (!s) return;
59
+ const v = s.getBoundingClientRect();
60
+ j({
70
61
  position: "fixed",
71
- left: rect.left + rect.width / 2,
72
- top: rect.top,
62
+ left: v.left + v.width / 2,
63
+ top: v.top,
73
64
  right: "auto",
74
65
  bottom: "auto",
75
66
  transform: "translate(-50%, calc(-100% - 16px))"
76
67
  });
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 })
68
+ }, [l, o]), o && typeof document < "u") {
69
+ const s = o();
70
+ return /* @__PURE__ */ i($, { children: [
71
+ /* @__PURE__ */ t("span", { ref: c, className: "tooltip-portal-anchor" }),
72
+ w && T(
73
+ /* @__PURE__ */ i("div", { ref: x, className: u, style: { ...f, ...w }, children: [
74
+ /* @__PURE__ */ t("div", { className: d, style: m }),
75
+ /* @__PURE__ */ t("div", { className: "bu-tooltip-content__text", style: y, children: p })
86
76
  ] }),
87
- container
77
+ s
88
78
  )
89
79
  ] });
90
80
  }
91
- return popup;
81
+ return R;
92
82
  }
93
83
  export {
94
- BTooltip as default
84
+ J as default
95
85
  };