bj-web-components 0.2.34 → 0.2.36

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 (111) hide show
  1. package/README.md +10 -1
  2. package/dist/index.js +58 -1
  3. package/dist/index.mjs +1 -29
  4. package/dist/miniapp.js +1 -1
  5. package/dist/miniapp.mjs +0 -1
  6. package/dist/mobile.js +1 -1
  7. package/dist/mobile.mjs +0 -1
  8. package/dist/react.js +1 -1
  9. package/dist/react.mjs +0 -1
  10. package/dist/shared.js +1 -1
  11. package/dist/shared.mjs +0 -1
  12. package/dist/style.css +1 -1
  13. package/dist/web/BasicInput/BInput.js +278 -1
  14. package/dist/web/BasicInput/BInput.mjs +263 -164
  15. package/dist/web/BasicInput/utils.js +47 -1
  16. package/dist/web/BasicInput/utils.mjs +22 -20
  17. package/dist/web/CategoryDropdown/CategoryDropdown.js +376 -1
  18. package/dist/web/CategoryDropdown/CategoryDropdown.mjs +355 -235
  19. package/dist/web/CheckBox/BCheckBox.js +176 -1
  20. package/dist/web/CheckBox/BCheckBox.mjs +169 -98
  21. package/dist/web/CheckBox/Group.js +111 -1
  22. package/dist/web/CheckBox/Group.mjs +104 -64
  23. package/dist/web/CheckBox/context.js +8 -1
  24. package/dist/web/CheckBox/context.mjs +2 -4
  25. package/dist/web/CheckBox/index.js +11 -1
  26. package/dist/web/CheckBox/index.mjs +2 -4
  27. package/dist/web/Dropdown/BDropdown.js +265 -1
  28. package/dist/web/Dropdown/BDropdown.mjs +233 -133
  29. package/dist/web/EmptyInputBox/EmptyInputBox.js +89 -1
  30. package/dist/web/EmptyInputBox/EmptyInputBox.mjs +85 -72
  31. package/dist/web/FileCard/FileCard.js +414 -1
  32. package/dist/web/FileCard/FileCard.mjs +400 -116
  33. package/dist/web/Icon/Icon.js +82 -1
  34. package/dist/web/Icon/Icon.mjs +78 -8
  35. package/dist/web/Input/Input.js +230 -1
  36. package/dist/web/Input/Input.mjs +219 -164
  37. package/dist/web/InputNumber/BInputNumber.js +271 -1
  38. package/dist/web/InputNumber/BInputNumber.mjs +254 -189
  39. package/dist/web/InputNumber/StepHandler.js +112 -1
  40. package/dist/web/InputNumber/StepHandler.mjs +102 -50
  41. package/dist/web/InputNumber/hooks/useCursor.js +38 -1
  42. package/dist/web/InputNumber/hooks/useCursor.mjs +31 -34
  43. package/dist/web/InputNumber/hooks/useFrame.js +15 -1
  44. package/dist/web/InputNumber/hooks/useFrame.mjs +8 -5
  45. package/dist/web/InputNumber/utils/decimal.js +163 -1
  46. package/dist/web/InputNumber/utils/decimal.mjs +114 -79
  47. package/dist/web/MobileDrawer/BMobileDrawer.js +238 -1
  48. package/dist/web/MobileDrawer/BMobileDrawer.mjs +221 -139
  49. package/dist/web/Modal/Modal.js +148 -1
  50. package/dist/web/Modal/Modal.mjs +143 -79
  51. package/dist/web/OverlayScrollbar/BOverlayScrollbar.js +273 -1
  52. package/dist/web/OverlayScrollbar/BOverlayScrollbar.mjs +262 -143
  53. package/dist/web/Pagination/Pagination.js +352 -1
  54. package/dist/web/Pagination/Pagination.mjs +342 -247
  55. package/dist/web/ProductField/ProductField.js +443 -1
  56. package/dist/web/ProductField/ProductField.mjs +423 -208
  57. package/dist/web/ProductField/arrow-up.svg.js +4 -1
  58. package/dist/web/ProductField/arrow-up.svg.mjs +2 -4
  59. package/dist/web/ProductField/checkbox-no.svg.js +4 -1
  60. package/dist/web/ProductField/checkbox-no.svg.mjs +2 -4
  61. package/dist/web/ProductField/checkbox-ok.svg.js +4 -1
  62. package/dist/web/ProductField/checkbox-ok.svg.mjs +2 -4
  63. package/dist/web/ProductField/no_data_light.svg.js +4 -1
  64. package/dist/web/ProductField/no_data_light.svg.mjs +2 -4
  65. package/dist/web/ProductField/search.svg.js +4 -1
  66. package/dist/web/ProductField/search.svg.mjs +2 -4
  67. package/dist/web/ProductField/sort.svg.js +4 -1
  68. package/dist/web/ProductField/sort.svg.mjs +2 -4
  69. package/dist/web/Radio/BRadio.js +151 -1
  70. package/dist/web/Radio/BRadio.mjs +147 -75
  71. package/dist/web/Radio/Button.js +54 -1
  72. package/dist/web/Radio/Button.mjs +51 -8
  73. package/dist/web/Radio/Group.js +97 -1
  74. package/dist/web/Radio/Group.mjs +92 -76
  75. package/dist/web/Radio/context.js +10 -1
  76. package/dist/web/Radio/context.mjs +3 -5
  77. package/dist/web/Radio/index.js +13 -1
  78. package/dist/web/Radio/index.mjs +2 -4
  79. package/dist/web/SkuInputCard/SkuInputCard.js +427 -1
  80. package/dist/web/SkuInputCard/SkuInputCard.mjs +414 -219
  81. package/dist/web/SkuInputCard/spin_loading_red.gif.js +4 -1
  82. package/dist/web/SkuInputCard/spin_loading_red.gif.mjs +2 -4
  83. package/dist/web/Switch/Switch.js +114 -1
  84. package/dist/web/Switch/Switch.mjs +109 -58
  85. package/dist/web/Table/BTable.js +1049 -1
  86. package/dist/web/Table/BTable.mjs +1011 -667
  87. package/dist/web/Table/Column.js +6 -1
  88. package/dist/web/Table/Column.mjs +1 -3
  89. package/dist/web/Table/ColumnGroup.js +6 -1
  90. package/dist/web/Table/ColumnGroup.mjs +1 -3
  91. package/dist/web/Table/utils/columns.js +116 -1
  92. package/dist/web/Table/utils/columns.mjs +103 -37
  93. package/dist/web/Table/utils/sortFilter.js +145 -1
  94. package/dist/web/Table/utils/sortFilter.mjs +129 -57
  95. package/dist/web/Tabs/BTabs.js +260 -1
  96. package/dist/web/Tabs/BTabs.mjs +239 -122
  97. package/dist/web/Tabs/TabPane.js +19 -1
  98. package/dist/web/Tabs/TabPane.mjs +1 -4
  99. package/dist/web/Tooltip/ConfirmTooltip.js +53 -1
  100. package/dist/web/Tooltip/ConfirmTooltip.mjs +47 -22
  101. package/dist/web/Tooltip/ContentTooltip.js +156 -1
  102. package/dist/web/Tooltip/ContentTooltip.mjs +145 -76
  103. package/dist/web/Tooltip/ProgressTooltip.js +56 -1
  104. package/dist/web/Tooltip/ProgressTooltip.mjs +50 -31
  105. package/dist/web/Tooltip/TooltipWrapper.js +19 -1
  106. package/dist/web/Tooltip/TooltipWrapper.mjs +13 -9
  107. package/dist/web/Tooltip/useAutoPlacement.js +65 -1
  108. package/dist/web/Tooltip/useAutoPlacement.mjs +52 -24
  109. package/dist/web.js +58 -1
  110. package/dist/web.mjs +1 -29
  111. package/package.json +3 -1
@@ -1,82 +1,146 @@
1
- import { jsx as l, jsxs as i } from "react/jsx-runtime";
1
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
2
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
3
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
4
+ import { jsx as t, jsxs as n } from "react/jsx-runtime";
2
5
  /* empty css */
3
- function j({
4
- open: _ = !1,
5
- title: r = "标题",
6
- mode: n = "standard",
7
- children: b,
8
- okText: m = "确认",
9
- cancelText: p = "取消",
10
- onOk: N,
11
- onCancel: h,
12
- onClose: a,
13
- activeLang: c = "zh",
14
- onLangChange: t,
15
- labels: o,
16
- hint: d,
17
- confirmLoading: e = !1,
18
- width: s,
19
- className: v,
20
- style: u
21
- }) {
22
- const k = (o == null ? void 0 : o.zh) ?? "中文", f = (o == null ? void 0 : o.en) ?? "EN";
23
- if (!_) return null;
24
- const y = n === "bilingual", w = n === "single", x = s != null ? { width: s, ...u } : u;
25
- return /* @__PURE__ */ l("div", { className: ["bu-modal__overlay", v].filter(Boolean).join(" "), onClick: a, children: /* @__PURE__ */ i(
26
- "div",
27
- {
28
- className: "bu-modal__container",
29
- style: x,
30
- onClick: (z) => z.stopPropagation(),
31
- children: [
32
- /* @__PURE__ */ i("div", { className: "bu-modal__header", children: [
33
- /* @__PURE__ */ l("p", { className: "bu-modal__title", children: r }),
34
- y && /* @__PURE__ */ i("div", { className: "bu-modal__lang-toggle", children: [
35
- /* @__PURE__ */ l(
36
- "button",
37
- {
38
- type: "button",
39
- className: `bu-modal__lang-btn${c === "zh" ? " bu-modal__lang-btn--active" : ""}`,
40
- onClick: () => t == null ? void 0 : t("zh"),
41
- children: k
42
- }
43
- ),
44
- /* @__PURE__ */ l(
45
- "button",
46
- {
47
- type: "button",
48
- className: `bu-modal__lang-btn${c === "en" ? " bu-modal__lang-btn--active" : ""}`,
49
- onClick: () => t == null ? void 0 : t("en"),
50
- children: f
51
- }
52
- )
53
- ] }),
54
- /* @__PURE__ */ l("button", { type: "button", className: "bu-modal__close", onClick: a, children: /* @__PURE__ */ l("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ l("path", { d: "M16.5613 6.73027C16.7558 6.53571 17.0723 6.53442 17.2684 6.72736C17.4644 6.92032 17.4657 7.23444 17.2713 7.42901L12.7036 12.0002L17.2713 16.5714C17.4657 16.766 17.4644 17.0801 17.2684 17.273C17.0723 17.4659 16.7558 17.4646 16.5613 17.2701L11.9996 12.7047L7.43794 17.2701C7.24352 17.4647 6.92699 17.4659 6.73091 17.273C6.53485 17.0801 6.53355 16.7659 6.72798 16.5714L11.2955 12.0002L6.72798 7.42901C6.53355 7.23442 6.53485 6.92032 6.73091 6.72736C6.92698 6.53442 7.2435 6.53571 7.43794 6.73027L11.9996 11.2955L16.5613 6.73027Z", fill: "currentColor" }) }) })
55
- ] }),
56
- /* @__PURE__ */ l("div", { className: "bu-modal__body", children: b }),
57
- /* @__PURE__ */ i("div", { className: "bu-modal__footer", children: [
58
- d && /* @__PURE__ */ l("p", { className: "bu-modal__hint", children: d }),
59
- /* @__PURE__ */ i("div", { className: "bu-modal__btn-row", children: [
60
- !w && /* @__PURE__ */ l("button", { type: "button", className: "bu-modal__btn-cancel", onClick: h ?? a, children: p }),
61
- /* @__PURE__ */ i(
62
- "button",
63
- {
64
- type: "button",
65
- className: ["bu-modal__btn-ok", e ? "bu-modal__btn-ok--loading" : ""].filter(Boolean).join(" "),
66
- disabled: e,
67
- onClick: e ? void 0 : N,
68
- children: [
69
- e && /* @__PURE__ */ l("span", { className: "bu-modal__btn-ok-spinner" }),
70
- m
71
- ]
72
- }
73
- )
74
- ] })
75
- ] })
76
- ]
6
+ var z = Object.defineProperty,
7
+ v = Object.getOwnPropertySymbols,
8
+ B = Object.prototype.hasOwnProperty,
9
+ S = Object.prototype.propertyIsEnumerable,
10
+ h = function h(a, l, e) {
11
+ return l in a ? z(a, l, {
12
+ enumerable: !0,
13
+ configurable: !0,
14
+ writable: !0,
15
+ value: e
16
+ }) : a[l] = e;
17
+ },
18
+ E = function E(a, l) {
19
+ for (var e in l || (l = {})) B.call(l, e) && h(a, e, l[e]);
20
+ if (v) {
21
+ var _iterator = _createForOfIteratorHelper(v(l)),
22
+ _step;
23
+ try {
24
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
25
+ var e = _step.value;
26
+ S.call(l, e) && h(a, e, l[e]);
27
+ }
28
+ } catch (err) {
29
+ _iterator.e(err);
30
+ } finally {
31
+ _iterator.f();
32
+ }
77
33
  }
78
- ) });
34
+ return a;
35
+ };
36
+ function M(_ref) {
37
+ var _ref$open = _ref.open,
38
+ a = _ref$open === void 0 ? !1 : _ref$open,
39
+ _ref$title = _ref.title,
40
+ l = _ref$title === void 0 ? "标题" : _ref$title,
41
+ _ref$mode = _ref.mode,
42
+ e = _ref$mode === void 0 ? "standard" : _ref$mode,
43
+ f = _ref.children,
44
+ _ref$okText = _ref.okText,
45
+ N = _ref$okText === void 0 ? "确认" : _ref$okText,
46
+ _ref$cancelText = _ref.cancelText,
47
+ y = _ref$cancelText === void 0 ? "取消" : _ref$cancelText,
48
+ w = _ref.onOk,
49
+ d = _ref.onCancel,
50
+ s = _ref.onClose,
51
+ _ref$activeLang = _ref.activeLang,
52
+ u = _ref$activeLang === void 0 ? "zh" : _ref$activeLang,
53
+ o = _ref.onLangChange,
54
+ r = _ref.labels,
55
+ c = _ref.hint,
56
+ _ref$confirmLoading = _ref.confirmLoading,
57
+ i = _ref$confirmLoading === void 0 ? !1 : _ref$confirmLoading,
58
+ _ = _ref.width,
59
+ g = _ref.className,
60
+ b = _ref.style;
61
+ var m, p;
62
+ var C = (m = r == null ? void 0 : r.zh) != null ? m : "中文",
63
+ k = (p = r == null ? void 0 : r.en) != null ? p : "EN";
64
+ if (!a) return null;
65
+ var O = e === "bilingual",
66
+ P = e === "single",
67
+ j = _ != null ? E({
68
+ width: _
69
+ }, b) : b;
70
+ return /* @__PURE__ */t("div", {
71
+ className: ["bu-modal__overlay", g].filter(Boolean).join(" "),
72
+ onClick: s,
73
+ children: /* @__PURE__ */n("div", {
74
+ className: "bu-modal__container",
75
+ style: j,
76
+ onClick: function onClick(x) {
77
+ return x.stopPropagation();
78
+ },
79
+ children: [/* @__PURE__ */n("div", {
80
+ className: "bu-modal__header",
81
+ children: [/* @__PURE__ */t("p", {
82
+ className: "bu-modal__title",
83
+ children: l
84
+ }), O && /* @__PURE__ */n("div", {
85
+ className: "bu-modal__lang-toggle",
86
+ children: [/* @__PURE__ */t("button", {
87
+ type: "button",
88
+ className: "bu-modal__lang-btn".concat(u === "zh" ? " bu-modal__lang-btn--active" : ""),
89
+ onClick: function onClick() {
90
+ return o == null ? void 0 : o("zh");
91
+ },
92
+ children: C
93
+ }), /* @__PURE__ */t("button", {
94
+ type: "button",
95
+ className: "bu-modal__lang-btn".concat(u === "en" ? " bu-modal__lang-btn--active" : ""),
96
+ onClick: function onClick() {
97
+ return o == null ? void 0 : o("en");
98
+ },
99
+ children: k
100
+ })]
101
+ }), /* @__PURE__ */t("button", {
102
+ type: "button",
103
+ className: "bu-modal__close",
104
+ onClick: s,
105
+ children: /* @__PURE__ */t("svg", {
106
+ width: "24",
107
+ height: "24",
108
+ viewBox: "0 0 24 24",
109
+ fill: "none",
110
+ xmlns: "http://www.w3.org/2000/svg",
111
+ children: /* @__PURE__ */t("path", {
112
+ d: "M16.5613 6.73027C16.7558 6.53571 17.0723 6.53442 17.2684 6.72736C17.4644 6.92032 17.4657 7.23444 17.2713 7.42901L12.7036 12.0002L17.2713 16.5714C17.4657 16.766 17.4644 17.0801 17.2684 17.273C17.0723 17.4659 16.7558 17.4646 16.5613 17.2701L11.9996 12.7047L7.43794 17.2701C7.24352 17.4647 6.92699 17.4659 6.73091 17.273C6.53485 17.0801 6.53355 16.7659 6.72798 16.5714L11.2955 12.0002L6.72798 7.42901C6.53355 7.23442 6.53485 6.92032 6.73091 6.72736C6.92698 6.53442 7.2435 6.53571 7.43794 6.73027L11.9996 11.2955L16.5613 6.73027Z",
113
+ fill: "currentColor"
114
+ })
115
+ })
116
+ })]
117
+ }), /* @__PURE__ */t("div", {
118
+ className: "bu-modal__body",
119
+ children: f
120
+ }), /* @__PURE__ */n("div", {
121
+ className: "bu-modal__footer",
122
+ children: [c && /* @__PURE__ */t("p", {
123
+ className: "bu-modal__hint",
124
+ children: c
125
+ }), /* @__PURE__ */n("div", {
126
+ className: "bu-modal__btn-row",
127
+ children: [!P && /* @__PURE__ */t("button", {
128
+ type: "button",
129
+ className: "bu-modal__btn-cancel",
130
+ onClick: d != null ? d : s,
131
+ children: y
132
+ }), /* @__PURE__ */n("button", {
133
+ type: "button",
134
+ className: ["bu-modal__btn-ok", i ? "bu-modal__btn-ok--loading" : ""].filter(Boolean).join(" "),
135
+ disabled: i,
136
+ onClick: i ? void 0 : w,
137
+ children: [i && /* @__PURE__ */t("span", {
138
+ className: "bu-modal__btn-ok-spinner"
139
+ }), N]
140
+ })]
141
+ })]
142
+ })]
143
+ })
144
+ });
79
145
  }
80
- export {
81
- j as default
82
- };
146
+ export { M as default };
@@ -1 +1,273 @@
1
- "use strict";const Y=require("react/jsx-runtime"),s=require("react");;/* empty css */const $=24,re=800,H={visible:!1,offset:0,length:0,cross:0};function se({containerRef:_,targetRef:j,selector:U,direction:S="vertical",size:E=4,gap:w=0,background:F,showOnHover:l=!0,showOnScroll:Z=!0,hoverSelector:A,horizontalInsetStart:p=0,horizontalInsetEnd:D=0,horizontalThumbLength:R,className:te=""}){const P=S==="vertical"||S==="both",V=S==="horizontal"||S==="both",m=s.useRef(null),f=s.useRef(null),y=s.useRef(null),L=s.useRef(!1),M=s.useRef(!1),[k,G]=s.useState(H),[B,J]=s.useState(H),[ne,v]=s.useState(!l);s.useEffect(()=>{l||v(!0)},[l]);const g=s.useCallback(()=>{const e=m.current,n=_.current;if(!e||!n)return;const{scrollTop:t,scrollHeight:o,clientHeight:c,scrollLeft:d,scrollWidth:u,clientWidth:i}=e,h=e.getBoundingClientRect(),r=n.getBoundingClientRect(),b=h.top-r.top,x=h.left-r.left;if(P){const C=o-c;if(C<=1)G(a=>a.visible?H:a);else{const a=Math.max(c/o*c,$);G({visible:!0,offset:b+t/C*(c-a),length:a,cross:x+i-E-w})}}if(V){const C=u-i,a=Math.max(i-p-D,0);if(C<=1||a<=0)J(W=>W.visible?H:W);else{const W=i/u*a,ee=Math.min(a,Math.max(R??W,$));J({visible:!0,offset:x+p+d/C*(a-ee),length:ee,cross:b+c-E-w})}}},[_,w,D,p,R,V,P,E]),q=s.useCallback(()=>{if(!l)return;const e=L.current||M.current||f.current;if(!Z&&!e){v(!1);return}v(!0),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{!f.current&&!L.current&&!M.current&&v(!1)},re)},[l,Z]),X=s.useCallback(()=>{g(),q()},[g,q]);s.useEffect(()=>{const e=_.current;if(!e)return;window.getComputedStyle(e).position==="static"&&(e.style.position="relative");let n,t=null;const o=()=>{const r=(j==null?void 0:j.current)??(U?e.querySelector(U):e.firstElementChild);if(!r||r===m.current)return;n==null||n(),m.current=r,r.addEventListener("scroll",X,{passive:!0});const b=new ResizeObserver(g);b.observe(r),r.firstElementChild&&b.observe(r.firstElementChild),n=()=>{r.removeEventListener("scroll",X),b.disconnect()},g()},c=()=>{L.current=!0,l&&v(!0)},d=()=>{L.current=!1,l&&!M.current&&!f.current&&v(!1)},u=()=>{t==null||t.removeEventListener("mouseenter",c),t==null||t.removeEventListener("mouseleave",d),t=null,L.current=!1},i=()=>{const r=A?e.querySelector(A):e;!r||r===t||(u(),t=r,t.addEventListener("mouseenter",c),t.addEventListener("mouseleave",d))};o(),i();const h=new MutationObserver(()=>{(!m.current||!e.contains(m.current))&&o(),t&&!e.contains(t)&&u(),t||i(),g()});return h.observe(e,{childList:!0,subtree:!0}),()=>{h.disconnect(),n==null||n(),u(),m.current=null,y.current&&clearTimeout(y.current)}},[_,A,X,U,l,g,j]);const T=s.useCallback(e=>{const n=m.current,t=f.current;if(!n||!t)return;const o=t.axis==="vertical",c=o?n.clientHeight:n.clientWidth,d=o?n.scrollHeight:n.scrollWidth,u=o?c:Math.max(c-p-D,0),i=c/d*u,h=Math.min(u,Math.max(o?i:R??i,$)),r=u-h;if(r<=0)return;const b=(o?e.clientY:e.clientX)-t.client,x=t.scroll+b*((d-c)/r);o?n.scrollTop=x:n.scrollLeft=x},[D,p,R]),N=s.useCallback(()=>{const e=!!f.current;f.current=null,document.body.style.userSelect="",document.removeEventListener("mousemove",T),document.removeEventListener("mouseup",N),e&&q()},[T,q]),K=e=>n=>{const t=m.current;t&&(n.preventDefault(),n.stopPropagation(),f.current={axis:e,client:e==="vertical"?n.clientY:n.clientX,scroll:e==="vertical"?t.scrollTop:t.scrollLeft},document.body.style.userSelect="none",document.addEventListener("mousemove",T),document.addEventListener("mouseup",N))};s.useEffect(()=>()=>{f.current=null,document.body.style.userSelect="",document.removeEventListener("mousemove",T),document.removeEventListener("mouseup",N)},[N,T]);const Q=["bj-overlay-scrollbar__thumb",ne&&"bj-overlay-scrollbar__thumb--active",te].filter(Boolean).join(" "),I=F?{"--bj-overlay-scrollbar-bg":F}:void 0,z=()=>{M.current=!0,l&&v(!0)},O=()=>{M.current=!1,l&&!L.current&&!f.current&&v(!1)};return Y.jsxs(Y.Fragment,{children:[P&&k.visible&&Y.jsx("div",{className:`${Q} bj-overlay-scrollbar__thumb--vertical`,onMouseDown:K("vertical"),onMouseEnter:z,onMouseLeave:O,style:{...I,top:k.offset,left:k.cross,height:k.length,width:E}}),V&&B.visible&&Y.jsx("div",{className:`${Q} bj-overlay-scrollbar__thumb--horizontal`,onMouseDown:K("horizontal"),onMouseEnter:z,onMouseLeave:O,style:{...I,left:B.offset,top:B.cross,width:B.length,height:E}})]})}module.exports=se;
1
+ "use strict";
2
+
3
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
4
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
7
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
8
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
9
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
10
+ var O = require("react/jsx-runtime"),
11
+ s = require("react");
12
+ ; /* empty css */
13
+ var le = Object.defineProperty,
14
+ ue = Object.defineProperties,
15
+ ie = Object.getOwnPropertyDescriptors,
16
+ te = Object.getOwnPropertySymbols,
17
+ ae = Object.prototype.hasOwnProperty,
18
+ fe = Object.prototype.propertyIsEnumerable,
19
+ re = function re(c, n, o) {
20
+ return n in c ? le(c, n, {
21
+ enumerable: !0,
22
+ configurable: !0,
23
+ writable: !0,
24
+ value: o
25
+ }) : c[n] = o;
26
+ },
27
+ ne = function ne(c, n) {
28
+ for (var o in n || (n = {})) ae.call(n, o) && re(c, o, n[o]);
29
+ if (te) {
30
+ var _iterator = _createForOfIteratorHelper(te(n)),
31
+ _step;
32
+ try {
33
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
34
+ var o = _step.value;
35
+ fe.call(n, o) && re(c, o, n[o]);
36
+ }
37
+ } catch (err) {
38
+ _iterator.e(err);
39
+ } finally {
40
+ _iterator.f();
41
+ }
42
+ }
43
+ return c;
44
+ },
45
+ se = function se(c, n) {
46
+ return ue(c, ie(n));
47
+ };
48
+ var X = 24,
49
+ me = 800,
50
+ W = {
51
+ visible: !1,
52
+ offset: 0,
53
+ length: 0,
54
+ cross: 0
55
+ };
56
+ function ve(_ref) {
57
+ var c = _ref.containerRef,
58
+ n = _ref.targetRef,
59
+ o = _ref.selector,
60
+ _ref$direction = _ref.direction,
61
+ S = _ref$direction === void 0 ? "vertical" : _ref$direction,
62
+ _ref$size = _ref.size,
63
+ j = _ref$size === void 0 ? 4 : _ref$size,
64
+ _ref$gap = _ref.gap,
65
+ Y = _ref$gap === void 0 ? 0 : _ref$gap,
66
+ $ = _ref.background,
67
+ _ref$showOnHover = _ref.showOnHover,
68
+ f = _ref$showOnHover === void 0 ? !0 : _ref$showOnHover,
69
+ _ref$showOnScroll = _ref.showOnScroll,
70
+ F = _ref$showOnScroll === void 0 ? !0 : _ref$showOnScroll,
71
+ H = _ref.hoverSelector,
72
+ _ref$horizontalInsetS = _ref.horizontalInsetStart,
73
+ P = _ref$horizontalInsetS === void 0 ? 0 : _ref$horizontalInsetS,
74
+ _ref$horizontalInsetE = _ref.horizontalInsetEnd,
75
+ D = _ref$horizontalInsetE === void 0 ? 0 : _ref$horizontalInsetE,
76
+ y = _ref.horizontalThumbLength,
77
+ _ref$className = _ref.className,
78
+ ce = _ref$className === void 0 ? "" : _ref$className;
79
+ var U = S === "vertical" || S === "both",
80
+ V = S === "horizontal" || S === "both",
81
+ h = s.useRef(null),
82
+ b = s.useRef(null),
83
+ T = s.useRef(null),
84
+ L = s.useRef(!1),
85
+ x = s.useRef(!1),
86
+ _s$useState = s.useState(W),
87
+ _s$useState2 = _slicedToArray(_s$useState, 2),
88
+ w = _s$useState2[0],
89
+ Z = _s$useState2[1],
90
+ _s$useState3 = s.useState(W),
91
+ _s$useState4 = _slicedToArray(_s$useState3, 2),
92
+ B = _s$useState4[0],
93
+ G = _s$useState4[1],
94
+ _s$useState5 = s.useState(!f),
95
+ _s$useState6 = _slicedToArray(_s$useState5, 2),
96
+ oe = _s$useState6[0],
97
+ _ = _s$useState6[1];
98
+ s.useEffect(function () {
99
+ f || _(!0);
100
+ }, [f]);
101
+ var M = s.useCallback(function () {
102
+ var e = h.current,
103
+ r = c.current;
104
+ if (!e || !r) return;
105
+ var t = e.scrollTop,
106
+ i = e.scrollHeight,
107
+ l = e.clientHeight,
108
+ g = e.scrollLeft,
109
+ m = e.scrollWidth,
110
+ v = e.clientWidth,
111
+ E = e.getBoundingClientRect(),
112
+ a = r.getBoundingClientRect(),
113
+ u = E.top - a.top,
114
+ p = E.left - a.left;
115
+ if (U) {
116
+ var R = i - l;
117
+ if (R <= 1) Z(function (d) {
118
+ return d.visible ? W : d;
119
+ });else {
120
+ var d = Math.max(l / i * l, X);
121
+ Z({
122
+ visible: !0,
123
+ offset: u + t / R * (l - d),
124
+ length: d,
125
+ cross: p + v - j - Y
126
+ });
127
+ }
128
+ }
129
+ if (V) {
130
+ var _R = m - v,
131
+ _d = Math.max(v - P - D, 0);
132
+ if (_R <= 1 || _d <= 0) G(function (N) {
133
+ return N.visible ? W : N;
134
+ });else {
135
+ var N = v / m * _d,
136
+ ee = Math.min(_d, Math.max(y != null ? y : N, X));
137
+ G({
138
+ visible: !0,
139
+ offset: p + P + g / _R * (_d - ee),
140
+ length: ee,
141
+ cross: u + l - j - Y
142
+ });
143
+ }
144
+ }
145
+ }, [c, Y, D, P, y, V, U, j]),
146
+ k = s.useCallback(function () {
147
+ if (!f) return;
148
+ var e = L.current || x.current || b.current;
149
+ if (!F && !e) {
150
+ _(!1);
151
+ return;
152
+ }
153
+ _(!0), T.current && clearTimeout(T.current), T.current = setTimeout(function () {
154
+ !b.current && !L.current && !x.current && _(!1);
155
+ }, me);
156
+ }, [f, F]),
157
+ A = s.useCallback(function () {
158
+ M(), k();
159
+ }, [M, k]);
160
+ s.useEffect(function () {
161
+ var e = c.current;
162
+ if (!e) return;
163
+ window.getComputedStyle(e).position === "static" && (e.style.position = "relative");
164
+ var r,
165
+ t = null;
166
+ var i = function i() {
167
+ var a;
168
+ var u = (a = n == null ? void 0 : n.current) != null ? a : o ? e.querySelector(o) : e.firstElementChild;
169
+ if (!u || u === h.current) return;
170
+ r == null || r(), h.current = u, u.addEventListener("scroll", A, {
171
+ passive: !0
172
+ });
173
+ var p = new ResizeObserver(M);
174
+ p.observe(u), u.firstElementChild && p.observe(u.firstElementChild), r = function r() {
175
+ u.removeEventListener("scroll", A), p.disconnect();
176
+ }, M();
177
+ },
178
+ l = function l() {
179
+ L.current = !0, f && _(!0);
180
+ },
181
+ g = function g() {
182
+ L.current = !1, f && !x.current && !b.current && _(!1);
183
+ },
184
+ m = function m() {
185
+ t == null || t.removeEventListener("mouseenter", l), t == null || t.removeEventListener("mouseleave", g), t = null, L.current = !1;
186
+ },
187
+ v = function v() {
188
+ var a = H ? e.querySelector(H) : e;
189
+ !a || a === t || (m(), t = a, t.addEventListener("mouseenter", l), t.addEventListener("mouseleave", g));
190
+ };
191
+ i(), v();
192
+ var E = new MutationObserver(function () {
193
+ (!h.current || !e.contains(h.current)) && i(), t && !e.contains(t) && m(), t || v(), M();
194
+ });
195
+ return E.observe(e, {
196
+ childList: !0,
197
+ subtree: !0
198
+ }), function () {
199
+ E.disconnect(), r == null || r(), m(), h.current = null, T.current && clearTimeout(T.current);
200
+ };
201
+ }, [c, H, A, o, f, M, n]);
202
+ var C = s.useCallback(function (e) {
203
+ var r = h.current,
204
+ t = b.current;
205
+ if (!r || !t) return;
206
+ var i = t.axis === "vertical",
207
+ l = i ? r.clientHeight : r.clientWidth,
208
+ g = i ? r.scrollHeight : r.scrollWidth,
209
+ m = i ? l : Math.max(l - P - D, 0),
210
+ v = l / g * m,
211
+ E = Math.min(m, Math.max(i ? v : y != null ? y : v, X)),
212
+ a = m - E;
213
+ if (a <= 0) return;
214
+ var u = (i ? e.clientY : e.clientX) - t.client,
215
+ p = t.scroll + u * ((g - l) / a);
216
+ i ? r.scrollTop = p : r.scrollLeft = p;
217
+ }, [D, P, y]),
218
+ q = s.useCallback(function () {
219
+ var e = !!b.current;
220
+ b.current = null, document.body.style.userSelect = "", document.removeEventListener("mousemove", C), document.removeEventListener("mouseup", q), e && k();
221
+ }, [C, k]),
222
+ J = function J(e) {
223
+ return function (r) {
224
+ var t = h.current;
225
+ t && (r.preventDefault(), r.stopPropagation(), b.current = {
226
+ axis: e,
227
+ client: e === "vertical" ? r.clientY : r.clientX,
228
+ scroll: e === "vertical" ? t.scrollTop : t.scrollLeft
229
+ }, document.body.style.userSelect = "none", document.addEventListener("mousemove", C), document.addEventListener("mouseup", q));
230
+ };
231
+ };
232
+ s.useEffect(function () {
233
+ return function () {
234
+ b.current = null, document.body.style.userSelect = "", document.removeEventListener("mousemove", C), document.removeEventListener("mouseup", q);
235
+ };
236
+ }, [q, C]);
237
+ var K = ["bj-overlay-scrollbar__thumb", oe && "bj-overlay-scrollbar__thumb--active", ce].filter(Boolean).join(" "),
238
+ Q = $ ? {
239
+ "--bj-overlay-scrollbar-bg": $
240
+ } : void 0,
241
+ I = function I() {
242
+ x.current = !0, f && _(!0);
243
+ },
244
+ z = function z() {
245
+ x.current = !1, f && !L.current && !b.current && _(!1);
246
+ };
247
+ return O.jsxs(O.Fragment, {
248
+ children: [U && w.visible && O.jsx("div", {
249
+ className: "".concat(K, " bj-overlay-scrollbar__thumb--vertical"),
250
+ onMouseDown: J("vertical"),
251
+ onMouseEnter: I,
252
+ onMouseLeave: z,
253
+ style: se(ne({}, Q), {
254
+ top: w.offset,
255
+ left: w.cross,
256
+ height: w.length,
257
+ width: j
258
+ })
259
+ }), V && B.visible && O.jsx("div", {
260
+ className: "".concat(K, " bj-overlay-scrollbar__thumb--horizontal"),
261
+ onMouseDown: J("horizontal"),
262
+ onMouseEnter: I,
263
+ onMouseLeave: z,
264
+ style: se(ne({}, Q), {
265
+ left: B.offset,
266
+ top: B.cross,
267
+ width: B.length,
268
+ height: j
269
+ })
270
+ })]
271
+ });
272
+ }
273
+ module.exports = ve;