bj-web-components 0.2.28 → 0.2.29

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,301 +1,253 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useState, useRef, useCallback, useLayoutEffect, useEffect } from "react";
3
- import { createPortal } from "react-dom";
1
+ import { jsxs as T, jsx as r } from "react/jsx-runtime";
2
+ import { useState as E, useRef as L, useCallback as Q, useLayoutEffect as $, useEffect as U } from "react";
3
+ import { createPortal as Z } from "react-dom";
4
4
  /* empty css */
5
5
  /* empty css */
6
- import BTooltip from "../Tooltip/ContentTooltip.mjs";
7
- import TooltipWrapper from "../Tooltip/TooltipWrapper.mjs";
8
- function TruncatedTooltip({
9
- text,
10
- spanClassName,
11
- wrapperStyle,
12
- placement = "top",
13
- getPopupContainer,
14
- trailing
6
+ import X from "../Tooltip/ContentTooltip.mjs";
7
+ import Y from "../Tooltip/TooltipWrapper.mjs";
8
+ function A({
9
+ text: a,
10
+ spanClassName: p,
11
+ wrapperStyle: d,
12
+ placement: h = "top",
13
+ getPopupContainer: f,
14
+ trailing: u
15
15
  }) {
16
- const [visible, setVisible] = useState(false);
17
- const wrapperRef = useRef(null);
18
- const spanRef = useRef(null);
19
- const [anchorRect, setAnchorRect] = useState(null);
20
- function handleMouseEnter() {
21
- var _a;
22
- const el = spanRef.current;
23
- if (el && el.scrollWidth > el.offsetWidth) {
24
- setAnchorRect(((_a = wrapperRef.current) == null ? void 0 : _a.getBoundingClientRect()) ?? null);
25
- setVisible(true);
26
- }
16
+ const [i, m] = E(!1), N = L(null), x = L(null), [o, w] = E(null);
17
+ function b() {
18
+ var g;
19
+ const y = x.current;
20
+ y && y.scrollWidth > y.offsetWidth && (w(((g = N.current) == null ? void 0 : g.getBoundingClientRect()) ?? null), m(!0));
27
21
  }
28
- return /* @__PURE__ */ jsxs(TooltipWrapper, { ref: wrapperRef, style: wrapperStyle, children: [
29
- /* @__PURE__ */ jsx(
22
+ return /* @__PURE__ */ T(Y, { ref: N, style: d, children: [
23
+ /* @__PURE__ */ r(
30
24
  "span",
31
25
  {
32
- ref: spanRef,
33
- className: spanClassName,
34
- onMouseEnter: handleMouseEnter,
35
- onMouseLeave: () => setVisible(false),
36
- children: text
26
+ ref: x,
27
+ className: p,
28
+ onMouseEnter: b,
29
+ onMouseLeave: () => m(!1),
30
+ children: a
37
31
  }
38
32
  ),
39
- trailing,
40
- visible && anchorRect && createPortal(
41
- /* @__PURE__ */ jsx(
33
+ u,
34
+ i && o && Z(
35
+ /* @__PURE__ */ r(
42
36
  "span",
43
37
  {
44
38
  style: {
45
39
  position: "fixed",
46
- top: anchorRect.top,
47
- left: anchorRect.left,
48
- width: anchorRect.width,
49
- height: anchorRect.height,
40
+ top: o.top,
41
+ left: o.left,
42
+ width: o.width,
43
+ height: o.height,
50
44
  display: "block",
51
45
  pointerEvents: "none",
52
46
  zIndex: 9999999999
53
47
  },
54
- children: /* @__PURE__ */ jsx(BTooltip, { content: text, placement, className: "bu-category-dropdown__tooltip" })
48
+ children: /* @__PURE__ */ r(X, { content: a, placement: h, className: "bu-category-dropdown__tooltip" })
55
49
  }
56
50
  ),
57
- (getPopupContainer == null ? void 0 : getPopupContainer()) ?? document.body
51
+ (f == null ? void 0 : f()) ?? document.body
58
52
  )
59
53
  ] });
60
54
  }
61
- function ChevronDown() {
62
- return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("path", { d: "M5.57345 8.828C5.41074 8.66528 5.41074 8.40152 5.57345 8.2388C5.73617 8.07608 5.99993 8.07608 6.16265 8.2388L10.0323 12.1084L13.8349 8.24124C13.9963 8.0772 14.26 8.07503 14.4241 8.23636C14.5881 8.39771 14.5903 8.66149 14.429 8.82555L10.5282 12.7924C10.2576 13.0675 9.81477 13.0694 9.54196 12.7966L5.57345 8.828Z", fill: "#333333" }) });
55
+ function P() {
56
+ return /* @__PURE__ */ r("svg", { viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ r("path", { d: "M5.57345 8.828C5.41074 8.66528 5.41074 8.40152 5.57345 8.2388C5.73617 8.07608 5.99993 8.07608 6.16265 8.2388L10.0323 12.1084L13.8349 8.24124C13.9963 8.0772 14.26 8.07503 14.4241 8.23636C14.5881 8.39771 14.5903 8.66149 14.429 8.82555L10.5282 12.7924C10.2576 13.0675 9.81477 13.0694 9.54196 12.7966L5.57345 8.828Z", fill: "#333333" }) });
63
57
  }
64
- function ChevronRight() {
58
+ function ee() {
65
59
  return (
66
60
  // <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
67
61
  // <path d="M6 3.5L10.5 8L6 12.5" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
68
62
  // </svg>
69
- /* @__PURE__ */ jsx("svg", { class: "icon", viewBox: "0 0 1024 1024", version: "1.1", xmlns: "http://www.w3.org/2000/svg", "p-id": "55697", children: /* @__PURE__ */ jsx("path", { d: "M451.854222 285.361778A21.333333 21.333333 0 1 0 421.688889 315.52l198.115555 198.122667-197.994666 194.702222a21.333333 21.333333 0 0 0 29.916444 30.414222l203.107556-199.722667a35.555556 35.555556 0 0 0 0.213333-50.488888L451.854222 285.354667z", "p-id": "55698" }) })
63
+ /* @__PURE__ */ r("svg", { class: "icon", viewBox: "0 0 1024 1024", version: "1.1", xmlns: "http://www.w3.org/2000/svg", "p-id": "55697", children: /* @__PURE__ */ r("path", { d: "M451.854222 285.361778A21.333333 21.333333 0 1 0 421.688889 315.52l198.115555 198.122667-197.994666 194.702222a21.333333 21.333333 0 0 0 29.916444 30.414222l203.107556-199.722667a35.555556 35.555556 0 0 0 0.213333-50.488888L451.854222 285.354667z", "p-id": "55698" }) })
70
64
  );
71
65
  }
72
- function buildColumns(data, value) {
73
- var _a;
74
- const cols = [data];
75
- let current = data;
76
- for (let i = 0; i < value.length; i++) {
77
- const selected = current.find((item) => item.value === value[i]);
78
- if ((_a = selected == null ? void 0 : selected.children) == null ? void 0 : _a.length) {
79
- cols.push(selected.children);
80
- current = selected.children;
81
- } else {
66
+ function te(a, p) {
67
+ var f;
68
+ const d = [a];
69
+ let h = a;
70
+ for (let u = 0; u < p.length; u++) {
71
+ const i = h.find((m) => m.value === p[u]);
72
+ if ((f = i == null ? void 0 : i.children) != null && f.length)
73
+ d.push(i.children), h = i.children;
74
+ else
82
75
  break;
83
- }
84
76
  }
85
- return cols;
77
+ return d;
86
78
  }
87
- function buildPath(data, value) {
88
- const path = [];
89
- let items = data;
90
- for (const v of value) {
91
- const found = items.find((x) => x.value === v);
92
- if (!found) break;
93
- path.push(found);
94
- items = found.children ?? [];
79
+ function H(a, p) {
80
+ const d = [];
81
+ let h = a;
82
+ for (const f of p) {
83
+ const u = h.find((i) => i.value === f);
84
+ if (!u) break;
85
+ d.push(u), h = u.children ?? [];
95
86
  }
96
- return path;
87
+ return d;
97
88
  }
98
- function BuCategoryDropdown({
99
- data,
100
- value = [],
101
- onChange,
102
- placeholder = "请选择分类",
103
- disabled = false,
104
- maxVisible = 6,
105
- className,
106
- style,
107
- getPopupContainer,
108
- dropdownStyle: customDropdownStyle
89
+ function ae({
90
+ data: a,
91
+ value: p = [],
92
+ onChange: d,
93
+ placeholder: h = "请选择分类",
94
+ disabled: f = !1,
95
+ maxVisible: u = 6,
96
+ className: i,
97
+ style: m,
98
+ getPopupContainer: N,
99
+ dropdownStyle: x
109
100
  }) {
110
- const [open, setOpen] = useState(false);
111
- const [navValue, setNavValue] = useState(value);
112
- const rootRef = useRef(null);
113
- const dropdownRef = useRef(null);
114
- const panelRef = useRef(null);
115
- const wasOpenRef = useRef(false);
116
- const [dropdownStyle, setDropdownStyle] = useState({});
117
- const [colWidth, setColWidth] = useState();
118
- const updatePosition = useCallback(() => {
119
- var _a;
120
- if (!rootRef.current) return;
121
- const rect = rootRef.current.getBoundingClientRect();
122
- let maxZ = 0;
123
- let el = rootRef.current.parentElement;
124
- while (el && el !== document.documentElement) {
125
- const selfZ = parseInt(window.getComputedStyle(el).zIndex, 10);
126
- if (!isNaN(selfZ) && selfZ > maxZ) maxZ = selfZ;
127
- if (el.parentElement) {
128
- for (const sibling of el.parentElement.children) {
129
- if (sibling === el || !(sibling instanceof HTMLElement)) continue;
130
- const sibZ = parseInt(window.getComputedStyle(sibling).zIndex, 10);
131
- if (!isNaN(sibZ) && sibZ > maxZ) maxZ = sibZ;
101
+ const [o, w] = E(!1), [b, y] = E(p), g = L(null), j = L(null), S = L(null), z = L(!1), [D, q] = E({}), [B, F] = E(), C = Q(() => {
102
+ var _;
103
+ if (!g.current) return;
104
+ const n = g.current.getBoundingClientRect();
105
+ let e = 0, t = g.current.parentElement;
106
+ for (; t && t !== document.documentElement; ) {
107
+ const R = parseInt(window.getComputedStyle(t).zIndex, 10);
108
+ if (!isNaN(R) && R > e && (e = R), t.parentElement)
109
+ for (const v of t.parentElement.children) {
110
+ if (v === t || !(v instanceof HTMLElement)) continue;
111
+ const k = parseInt(window.getComputedStyle(v).zIndex, 10);
112
+ !isNaN(k) && k > e && (e = k);
132
113
  }
133
- }
134
- el = el.parentElement;
114
+ t = t.parentElement;
135
115
  }
136
- const panelHeight = ((_a = panelRef.current) == null ? void 0 : _a.offsetHeight) ?? 0;
137
- const spaceBelow = window.innerHeight - rect.bottom;
138
- const spaceAbove = rect.top;
139
- const flipToTop = panelHeight > 0 && spaceBelow < panelHeight + 4 && spaceAbove > spaceBelow;
140
- setDropdownStyle({
116
+ const l = ((_ = S.current) == null ? void 0 : _.offsetHeight) ?? 0, s = window.innerHeight - n.bottom, c = n.top, M = l > 0 && s < l + 4 && c > s;
117
+ q({
141
118
  position: "fixed",
142
- top: flipToTop ? rect.top - panelHeight - 4 : rect.bottom + 4,
143
- left: rect.left,
144
- zIndex: maxZ > 0 ? maxZ + 10 : 1100,
145
- ...customDropdownStyle
119
+ top: M ? n.top - l - 4 : n.bottom + 4,
120
+ left: n.left,
121
+ zIndex: e > 0 ? e + 10 : 1100,
122
+ ...x
146
123
  });
147
- }, [customDropdownStyle]);
148
- useLayoutEffect(() => {
149
- if (open) {
150
- updatePosition();
151
- }
152
- }, [open, navValue, updatePosition]);
153
- useLayoutEffect(() => {
154
- const justOpened = open && !wasOpenRef.current;
155
- wasOpenRef.current = open;
156
- if (!open || !panelRef.current) return;
157
- const cols = panelRef.current.querySelectorAll(".bu-category-dropdown__col");
158
- cols.forEach((col) => {
159
- col.style.width = "";
160
- });
161
- let max = 0;
162
- cols.forEach((col) => {
163
- if (col.offsetWidth > max) max = col.offsetWidth;
124
+ }, [x]);
125
+ $(() => {
126
+ o && C();
127
+ }, [o, b, C]), $(() => {
128
+ const n = o && !z.current;
129
+ if (z.current = o, !o || !S.current) return;
130
+ const e = S.current.querySelectorAll(".bu-category-dropdown__col");
131
+ e.forEach((s) => {
132
+ s.style.width = "";
164
133
  });
165
- const next = justOpened ? max : Math.max(colWidth ?? 0, max);
166
- cols.forEach((col) => {
167
- col.style.width = next ? `${next}px` : "";
134
+ let t = 0;
135
+ e.forEach((s) => {
136
+ s.offsetWidth > t && (t = s.offsetWidth);
168
137
  });
169
- if (next !== colWidth) setColWidth(next || void 0);
170
- }, [open, navValue]);
171
- useEffect(() => {
172
- if (!open) return;
173
- function handleClickOutside(e) {
174
- var _a, _b;
175
- const target = e.target;
176
- if (((_a = rootRef.current) == null ? void 0 : _a.contains(target)) || ((_b = dropdownRef.current) == null ? void 0 : _b.contains(target))) {
177
- return;
178
- }
179
- setOpen(false);
138
+ const l = n ? t : Math.max(B ?? 0, t);
139
+ e.forEach((s) => {
140
+ s.style.width = l ? `${l}px` : "";
141
+ }), l !== B && F(l || void 0);
142
+ }, [o, b]), U(() => {
143
+ if (!o) return;
144
+ function n(t) {
145
+ var s, c;
146
+ const l = t.target;
147
+ (s = g.current) != null && s.contains(l) || (c = j.current) != null && c.contains(l) || w(!1);
180
148
  }
181
- function handleScroll() {
182
- setOpen(false);
149
+ function e() {
150
+ w(!1);
183
151
  }
184
- document.addEventListener("mousedown", handleClickOutside);
185
- document.addEventListener("scroll", handleScroll, true);
186
- window.addEventListener("resize", updatePosition);
187
- return () => {
188
- document.removeEventListener("mousedown", handleClickOutside);
189
- document.removeEventListener("scroll", handleScroll, true);
190
- window.removeEventListener("resize", updatePosition);
152
+ return document.addEventListener("mousedown", n), document.addEventListener("scroll", e, !0), window.addEventListener("resize", C), () => {
153
+ document.removeEventListener("mousedown", n), document.removeEventListener("scroll", e, !0), window.removeEventListener("resize", C);
191
154
  };
192
- }, [open, updatePosition]);
193
- const path = buildPath(data, value);
194
- const hasValue = path.length > 0;
195
- const triggerLabel = hasValue ? path.map((item) => item.label).join(" / ") : null;
196
- const columns = buildColumns(data, navValue);
197
- function handleSelect(colIndex, item) {
198
- var _a;
199
- if (item.disabled) return;
200
- const newNavValue = navValue.slice(0, colIndex + 1);
201
- newNavValue[colIndex] = item.value;
202
- setNavValue(newNavValue);
203
- if (!((_a = item.children) == null ? void 0 : _a.length)) {
204
- const newPath = buildPath(data, newNavValue);
205
- onChange == null ? void 0 : onChange(newNavValue, newPath);
206
- setOpen(false);
155
+ }, [o, C]);
156
+ const O = H(a, p), W = O.length > 0, G = W ? O.map((n) => n.label).join(" / ") : null, V = te(a, b);
157
+ function I(n, e) {
158
+ var l;
159
+ if (e.disabled) return;
160
+ const t = b.slice(0, n + 1);
161
+ if (t[n] = e.value, y(t), !((l = e.children) != null && l.length)) {
162
+ const s = H(a, t);
163
+ d == null || d(t, s), w(!1);
207
164
  }
208
165
  }
209
- function handleOpen() {
210
- setNavValue(value);
211
- setOpen(true);
166
+ function J() {
167
+ y(p), w(!0);
212
168
  }
213
- const triggerClass = [
169
+ const K = [
214
170
  "bu-category-dropdown__trigger",
215
- open ? "bu-category-dropdown__trigger--open" : "",
216
- hasValue ? "bu-category-dropdown__trigger--has-value" : ""
171
+ o ? "bu-category-dropdown__trigger--open" : "",
172
+ W ? "bu-category-dropdown__trigger--has-value" : ""
217
173
  ].filter(Boolean).join(" ");
218
- return /* @__PURE__ */ jsxs(
174
+ return /* @__PURE__ */ T(
219
175
  "div",
220
176
  {
221
- ref: rootRef,
222
- className: `bu-category-dropdown${className ? ` ${className}` : ""}`,
223
- style,
177
+ ref: g,
178
+ className: `bu-category-dropdown${i ? ` ${i}` : ""}`,
179
+ style: m,
224
180
  children: [
225
- /* @__PURE__ */ jsx(
181
+ /* @__PURE__ */ r(
226
182
  "button",
227
183
  {
228
184
  type: "button",
229
- className: triggerClass,
230
- disabled,
231
- onClick: () => open ? setOpen(false) : handleOpen(),
232
- children: /* @__PURE__ */ jsx(
233
- TruncatedTooltip,
185
+ className: K,
186
+ disabled: f,
187
+ onClick: () => o ? w(!1) : J(),
188
+ children: /* @__PURE__ */ r(
189
+ A,
234
190
  {
235
- text: triggerLabel ?? placeholder,
236
- spanClassName: `bu-category-dropdown__trigger-label${!hasValue ? " bu-category-dropdown__trigger-label--placeholder" : ""}`,
191
+ text: G ?? h,
192
+ spanClassName: `bu-category-dropdown__trigger-label${W ? "" : " bu-category-dropdown__trigger-label--placeholder"}`,
237
193
  wrapperStyle: { flex: 1, minWidth: 0, display: "flex", alignItems: "center", gap: 8 },
238
- getPopupContainer,
239
- trailing: /* @__PURE__ */ jsx("span", { className: `bu-category-dropdown__trigger-chevron${open ? " bu-category-dropdown__trigger-chevron--open" : ""}`, children: /* @__PURE__ */ jsx(ChevronDown, {}) })
194
+ getPopupContainer: N,
195
+ trailing: /* @__PURE__ */ r("span", { className: `bu-category-dropdown__trigger-chevron${o ? " bu-category-dropdown__trigger-chevron--open" : ""}`, children: /* @__PURE__ */ r(P, {}) })
240
196
  }
241
197
  )
242
198
  }
243
199
  ),
244
- open && createPortal(
245
- /* @__PURE__ */ jsx("div", { ref: dropdownRef, style: dropdownStyle, className: "bu-category-dropdown__portal", children: /* @__PURE__ */ jsx("div", { className: "bu-category-dropdown__panel", ref: panelRef, children: columns.map((col, colIndex) => {
246
- const isScrollable = col.length > maxVisible;
247
- const isLast = colIndex === columns.length - 1;
248
- const colClass = [
200
+ o && Z(
201
+ /* @__PURE__ */ r("div", { ref: j, style: D, className: "bu-category-dropdown__portal", children: /* @__PURE__ */ r("div", { className: "bu-category-dropdown__panel", ref: S, children: V.map((n, e) => {
202
+ const t = n.length > u, l = e === V.length - 1, s = [
249
203
  "bu-category-dropdown__col",
250
- colIndex > 0 ? "bu-category-dropdown__col--indent" : "",
251
- isScrollable ? "bu-category-dropdown__col--scrollable" : "",
252
- isLast && colIndex > 0 ? "bu-category-dropdown__col--last" : ""
204
+ e > 0 ? "bu-category-dropdown__col--indent" : "",
205
+ t ? "bu-category-dropdown__col--scrollable" : "",
206
+ l && e > 0 ? "bu-category-dropdown__col--last" : ""
253
207
  ].filter(Boolean).join(" ");
254
- return /* @__PURE__ */ jsxs("div", { style: { display: "contents" }, children: [
255
- colIndex > 0 && /* @__PURE__ */ jsx("div", { className: "bu-category-dropdown__divider" }),
256
- /* @__PURE__ */ jsx(
208
+ return /* @__PURE__ */ T("div", { style: { display: "contents" }, children: [
209
+ e > 0 && /* @__PURE__ */ r("div", { className: "bu-category-dropdown__divider" }),
210
+ /* @__PURE__ */ r(
257
211
  "div",
258
212
  {
259
- className: colClass,
260
- style: colWidth ? { width: colWidth } : void 0,
261
- onMouseEnter: isScrollable ? (e) => e.currentTarget.classList.add("bu-category-dropdown__col--scrollbar-visible") : void 0,
262
- onMouseLeave: isScrollable ? (e) => e.currentTarget.classList.remove("bu-category-dropdown__col--scrollbar-visible") : void 0,
263
- children: col.map((item) => {
264
- var _a;
265
- const isSelected = navValue[colIndex] === item.value;
266
- const hasBranch = !!((_a = item.children) == null ? void 0 : _a.length);
267
- const itemClass = [
213
+ className: s,
214
+ style: B ? { width: B } : void 0,
215
+ onMouseEnter: t ? (c) => c.currentTarget.classList.add("bu-category-dropdown__col--scrollbar-visible") : void 0,
216
+ onMouseLeave: t ? (c) => c.currentTarget.classList.remove("bu-category-dropdown__col--scrollbar-visible") : void 0,
217
+ children: n.map((c) => {
218
+ var v;
219
+ const M = b[e] === c.value, _ = !!((v = c.children) != null && v.length), R = [
268
220
  "bu-category-dropdown__item",
269
- isSelected && hasBranch ? "bu-category-dropdown__item--selected-branch" : "",
270
- isSelected && !hasBranch ? "bu-category-dropdown__item--selected-leaf" : "",
271
- item.disabled ? "bu-category-dropdown__item--disabled" : ""
221
+ M && _ ? "bu-category-dropdown__item--selected-branch" : "",
222
+ M && !_ ? "bu-category-dropdown__item--selected-leaf" : "",
223
+ c.disabled ? "bu-category-dropdown__item--disabled" : ""
272
224
  ].filter(Boolean).join(" ");
273
- return /* @__PURE__ */ jsxs(
225
+ return /* @__PURE__ */ T(
274
226
  "button",
275
227
  {
276
228
  type: "button",
277
- className: itemClass,
278
- disabled: item.disabled,
279
- onClick: () => handleSelect(colIndex, item),
229
+ className: R,
230
+ disabled: c.disabled,
231
+ onClick: () => I(e, c),
280
232
  children: [
281
- /* @__PURE__ */ jsx(
282
- TruncatedTooltip,
233
+ /* @__PURE__ */ r(
234
+ A,
283
235
  {
284
- text: item.label,
236
+ text: c.label,
285
237
  spanClassName: "bu-category-dropdown__item-label",
286
238
  wrapperStyle: { flex: 1, minWidth: 0, display: "block" },
287
- getPopupContainer
239
+ getPopupContainer: N
288
240
  }
289
241
  ),
290
- hasBranch && /* @__PURE__ */ jsx("span", { className: "bu-category-dropdown__item-arrow", children: /* @__PURE__ */ jsx(ChevronRight, {}) })
242
+ _ && /* @__PURE__ */ r("span", { className: "bu-category-dropdown__item-arrow", children: /* @__PURE__ */ r(ee, {}) })
291
243
  ]
292
244
  },
293
- item.value
245
+ c.value
294
246
  );
295
247
  })
296
248
  }
297
249
  )
298
- ] }, colIndex);
250
+ ] }, e);
299
251
  }) }) }),
300
252
  document.body
301
253
  )
@@ -304,5 +256,5 @@ function BuCategoryDropdown({
304
256
  );
305
257
  }
306
258
  export {
307
- BuCategoryDropdown as default
259
+ ae as default
308
260
  };
@@ -1,116 +1 @@
1
- "use strict";
2
- const jsxRuntime = require("react/jsx-runtime");
3
- const react = require("react");
4
- const Icon = require("../Icon/Icon.js");
5
- const context = require("./context.js");
6
- ;/* empty css */
7
- function classNames(...values) {
8
- return values.filter(Boolean).join(" ");
9
- }
10
- const BCheckBox = react.forwardRef((props, forwardedRef) => {
11
- const {
12
- checked: controlledChecked,
13
- defaultChecked = false,
14
- disabled,
15
- indeterminate = false,
16
- children,
17
- className,
18
- style,
19
- onChange,
20
- onMouseEnter,
21
- onMouseLeave,
22
- value,
23
- skipGroup = false,
24
- direction = "ltr",
25
- name,
26
- variant = "dark",
27
- ...inputProps
28
- } = props;
29
- const group = react.useContext(context.CheckBoxGroupContext);
30
- const [internalChecked, setInternalChecked] = react.useState(defaultChecked);
31
- const previousValue = react.useRef(value);
32
- const inGroup = Boolean(group && !skipGroup);
33
- const mergedChecked = inGroup ? group.value.includes(value) : controlledChecked ?? internalChecked;
34
- const mergedDisabled = (group == null ? void 0 : group.disabled) || disabled;
35
- const mergedName = inGroup ? group == null ? void 0 : group.name : name;
36
- const mergedVariant = inGroup ? (group == null ? void 0 : group.variant) ?? variant : variant;
37
- react.useEffect(() => {
38
- if (!inGroup || value === void 0) return;
39
- group == null ? void 0 : group.registerValue(value);
40
- return () => group == null ? void 0 : group.cancelValue(value);
41
- }, [group, inGroup, value]);
42
- react.useEffect(() => {
43
- if (!inGroup || previousValue.current === value) return;
44
- if (previousValue.current !== void 0) group == null ? void 0 : group.cancelValue(previousValue.current);
45
- if (value !== void 0) group == null ? void 0 : group.registerValue(value);
46
- previousValue.current = value;
47
- }, [group, inGroup, value]);
48
- const handleChange = (event) => {
49
- if (mergedDisabled) return;
50
- const nextChecked = event.target.checked;
51
- if (!inGroup && controlledChecked === void 0) setInternalChecked(nextChecked);
52
- const changeEvent = {
53
- target: { ...props, checked: nextChecked },
54
- stopPropagation: () => event.stopPropagation(),
55
- preventDefault: () => event.preventDefault(),
56
- nativeEvent: event.nativeEvent
57
- };
58
- onChange == null ? void 0 : onChange(changeEvent);
59
- if (inGroup && value !== void 0) {
60
- group == null ? void 0 : group.toggleOption({ label: children, value, disabled: mergedDisabled, onChange });
61
- }
62
- };
63
- return /* @__PURE__ */ jsxRuntime.jsxs(
64
- "label",
65
- {
66
- className: classNames(
67
- "bj-checkbox-wrapper",
68
- mergedChecked && "bj-checkbox-wrapper--checked",
69
- mergedDisabled && "bj-checkbox-wrapper--disabled",
70
- direction === "rtl" && "bj-checkbox-wrapper--rtl",
71
- className
72
- ),
73
- onMouseEnter,
74
- onMouseLeave,
75
- style,
76
- children: [
77
- /* @__PURE__ */ jsxRuntime.jsxs(
78
- "span",
79
- {
80
- className: classNames(
81
- "bj-checkbox",
82
- mergedChecked && "bj-checkbox--checked",
83
- mergedDisabled && "bj-checkbox--disabled",
84
- indeterminate && "bj-checkbox--indeterminate",
85
- `bj-checkbox--${mergedVariant}`
86
- ),
87
- children: [
88
- /* @__PURE__ */ jsxRuntime.jsx(
89
- "input",
90
- {
91
- ...inputProps,
92
- "aria-checked": indeterminate ? "mixed" : mergedChecked,
93
- checked: mergedChecked,
94
- className: "bj-checkbox__input",
95
- disabled: mergedDisabled,
96
- name: mergedName,
97
- onChange: handleChange,
98
- ref: forwardedRef,
99
- type: "checkbox",
100
- value: typeof value === "boolean" ? String(value) : value
101
- }
102
- ),
103
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "bj-checkbox__inner", children: [
104
- mergedChecked && !indeterminate && /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "bj-checkbox__check-icon", type: "icon-a-dagouxi" }),
105
- indeterminate && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bj-checkbox__indeterminate-mark" })
106
- ] })
107
- ]
108
- }
109
- ),
110
- children !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bj-checkbox__label", children })
111
- ]
112
- }
113
- );
114
- });
115
- BCheckBox.displayName = "BCheckBox";
116
- module.exports = BCheckBox;
1
+ "use strict";const n=require("react/jsx-runtime"),t=require("react"),M=require("../Icon/Icon.js"),S=require("./context.js");;/* empty css */function f(...i){return i.filter(Boolean).join(" ")}const m=t.forwardRef((i,j)=>{const{checked:k,defaultChecked:v=!1,disabled:p,indeterminate:o=!1,children:h,className:C,style:N,onChange:l,onMouseEnter:_,onMouseLeave:B,value:c,skipGroup:E=!1,direction:V="ltr",name:q,variant:x="dark",...w}=i,e=t.useContext(S.CheckBoxGroupContext),[y,D]=t.useState(v),d=t.useRef(c),a=!!(e&&!E),s=a?e.value.includes(c):k??y,r=(e==null?void 0:e.disabled)||p,G=a?e==null?void 0:e.name:q,P=a?(e==null?void 0:e.variant)??x:x;t.useEffect(()=>{if(!(!a||c===void 0))return e==null||e.registerValue(c),()=>e==null?void 0:e.cancelValue(c)},[e,a,c]),t.useEffect(()=>{!a||d.current===c||(d.current!==void 0&&(e==null||e.cancelValue(d.current)),c!==void 0&&(e==null||e.registerValue(c)),d.current=c)},[e,a,c]);const R=b=>{if(r)return;const u=b.target.checked;!a&&k===void 0&&D(u);const I={target:{...i,checked:u},stopPropagation:()=>b.stopPropagation(),preventDefault:()=>b.preventDefault(),nativeEvent:b.nativeEvent};l==null||l(I),a&&c!==void 0&&(e==null||e.toggleOption({label:h,value:c,disabled:r,onChange:l}))};return n.jsxs("label",{className:f("bj-checkbox-wrapper",s&&"bj-checkbox-wrapper--checked",r&&"bj-checkbox-wrapper--disabled",V==="rtl"&&"bj-checkbox-wrapper--rtl",C),onMouseEnter:_,onMouseLeave:B,style:N,children:[n.jsxs("span",{className:f("bj-checkbox",s&&"bj-checkbox--checked",r&&"bj-checkbox--disabled",o&&"bj-checkbox--indeterminate",`bj-checkbox--${P}`),children:[n.jsx("input",{...w,"aria-checked":o?"mixed":s,checked:s,className:"bj-checkbox__input",disabled:r,name:G,onChange:R,ref:j,type:"checkbox",value:typeof c=="boolean"?String(c):c}),n.jsxs("span",{className:"bj-checkbox__inner",children:[s&&!o&&n.jsx(M,{className:"bj-checkbox__check-icon",type:"icon-a-dagouxi"}),o&&n.jsx("span",{className:"bj-checkbox__indeterminate-mark"})]})]}),h!==void 0&&n.jsx("span",{className:"bj-checkbox__label",children:h})]})});m.displayName="BCheckBox";module.exports=m;