bj-web-components 0.2.27 → 0.2.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +51 -1
- package/dist/index.mjs +49 -49
- package/dist/style.css +3744 -1
- package/dist/web/BasicInput/BInput.js +208 -1
- package/dist/web/BasicInput/BInput.mjs +164 -132
- package/dist/web/BasicInput/utils.js +47 -1
- package/dist/web/BasicInput/utils.mjs +38 -28
- package/dist/web/CategoryDropdown/CategoryDropdown.js +307 -1
- package/dist/web/CategoryDropdown/CategoryDropdown.mjs +218 -170
- package/dist/web/CheckBox/BCheckBox.js +116 -1
- package/dist/web/CheckBox/BCheckBox.mjs +86 -70
- package/dist/web/CheckBox/Group.js +73 -1
- package/dist/web/CheckBox/Group.mjs +63 -56
- package/dist/web/CheckBox/context.js +5 -1
- package/dist/web/CheckBox/context.mjs +3 -3
- package/dist/web/CheckBox/index.js +8 -1
- package/dist/web/CheckBox/index.mjs +6 -6
- package/dist/web/Dropdown/BDropdown.js +186 -1
- package/dist/web/Dropdown/BDropdown.mjs +132 -106
- package/dist/web/EmptyInputBox/EmptyInputBox.js +77 -1
- package/dist/web/EmptyInputBox/EmptyInputBox.mjs +52 -48
- package/dist/web/FileCard/FileCard.js +157 -1
- package/dist/web/FileCard/FileCard.mjs +112 -82
- package/dist/web/Icon/Icon.js +9 -1
- package/dist/web/Icon/Icon.mjs +6 -6
- package/dist/web/Input/Input.js +181 -1
- package/dist/web/Input/Input.mjs +122 -113
- package/dist/web/InputNumber/BInputNumber.js +311 -1
- package/dist/web/InputNumber/BInputNumber.mjs +275 -167
- package/dist/web/InputNumber/StepHandler.js +69 -1
- package/dist/web/InputNumber/StepHandler.mjs +38 -32
- package/dist/web/InputNumber/hooks/useCursor.js +40 -1
- package/dist/web/InputNumber/hooks/useCursor.mjs +35 -33
- package/dist/web/InputNumber/hooks/useFrame.js +12 -1
- package/dist/web/InputNumber/hooks/useFrame.mjs +9 -6
- package/dist/web/InputNumber/utils/decimal.js +147 -1
- package/dist/web/InputNumber/utils/decimal.mjs +109 -81
- package/dist/web/Modal/Modal.js +84 -1
- package/dist/web/Modal/Modal.mjs +52 -49
- package/dist/web/OverlayScrollbar/BOverlayScrollbar.js +232 -1
- package/dist/web/OverlayScrollbar/BOverlayScrollbar.mjs +206 -125
- package/dist/web/Pagination/Pagination.js +328 -1
- package/dist/web/Pagination/Pagination.mjs +254 -178
- package/dist/web/ProductField/ProductField.js +272 -1
- package/dist/web/ProductField/ProductField.mjs +190 -143
- package/dist/web/ProductField/arrow-up.svg.js +3 -1
- package/dist/web/ProductField/arrow-up.svg.mjs +2 -2
- package/dist/web/ProductField/checkbox-no.svg.js +3 -1
- package/dist/web/ProductField/checkbox-no.svg.mjs +2 -2
- package/dist/web/ProductField/checkbox-ok.svg.js +3 -1
- package/dist/web/ProductField/checkbox-ok.svg.mjs +2 -2
- package/dist/web/ProductField/no_data_light.svg.js +3 -1
- package/dist/web/ProductField/no_data_light.svg.mjs +2 -2
- package/dist/web/ProductField/search.svg.js +3 -1
- package/dist/web/ProductField/search.svg.mjs +2 -2
- package/dist/web/ProductField/sort.svg.js +3 -1
- package/dist/web/ProductField/sort.svg.mjs +2 -2
- package/dist/web/SkuInputCard/SkuInputCard.js +276 -1
- package/dist/web/SkuInputCard/SkuInputCard.mjs +188 -149
- package/dist/web/SkuInputCard/spin_loading_red.gif.js +3 -1
- package/dist/web/SkuInputCard/spin_loading_red.gif.mjs +2 -2
- package/dist/web/Switch/Switch.js +70 -1
- package/dist/web/Switch/Switch.mjs +47 -37
- package/dist/web/Table/BTable.js +950 -1
- package/dist/web/Table/BTable.mjs +771 -519
- package/dist/web/Table/Column.js +5 -1
- package/dist/web/Table/Column.mjs +2 -2
- package/dist/web/Table/ColumnGroup.js +5 -1
- package/dist/web/Table/ColumnGroup.mjs +2 -2
- package/dist/web/Table/utils/columns.js +48 -1
- package/dist/web/Table/utils/columns.mjs +35 -30
- package/dist/web/Table/utils/sortFilter.js +84 -1
- package/dist/web/Table/utils/sortFilter.mjs +73 -52
- package/dist/web/Tabs/BTabs.js +150 -1
- package/dist/web/Tabs/BTabs.mjs +118 -98
- package/dist/web/Tabs/TabPane.js +8 -1
- package/dist/web/Tabs/TabPane.mjs +4 -4
- package/dist/web/Tooltip/ConfirmTooltip.js +26 -1
- package/dist/web/Tooltip/ConfirmTooltip.mjs +20 -19
- package/dist/web/Tooltip/ContentTooltip.js +94 -1
- package/dist/web/Tooltip/ContentTooltip.mjs +72 -62
- package/dist/web/Tooltip/ProgressTooltip.js +36 -1
- package/dist/web/Tooltip/ProgressTooltip.mjs +22 -20
- package/dist/web/Tooltip/TooltipWrapper.js +12 -1
- package/dist/web/Tooltip/TooltipWrapper.mjs +8 -8
- package/dist/web/Tooltip/useAutoPlacement.js +41 -1
- package/dist/web/Tooltip/useAutoPlacement.mjs +34 -25
- package/dist/web.js +51 -1
- package/dist/web.mjs +49 -49
- package/package.json +1 -1
|
@@ -1,253 +1,301 @@
|
|
|
1
|
-
import { jsxs
|
|
2
|
-
import { useState
|
|
3
|
-
import { createPortal
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useCallback, useLayoutEffect, useEffect } from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
4
|
/* empty css */
|
|
5
5
|
/* empty css */
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
function
|
|
9
|
-
text
|
|
10
|
-
spanClassName
|
|
11
|
-
wrapperStyle
|
|
12
|
-
placement
|
|
13
|
-
getPopupContainer
|
|
14
|
-
trailing
|
|
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
|
|
15
15
|
}) {
|
|
16
|
-
const [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
+
}
|
|
21
27
|
}
|
|
22
|
-
return /* @__PURE__ */
|
|
23
|
-
/* @__PURE__ */
|
|
28
|
+
return /* @__PURE__ */ jsxs(TooltipWrapper, { ref: wrapperRef, style: wrapperStyle, children: [
|
|
29
|
+
/* @__PURE__ */ jsx(
|
|
24
30
|
"span",
|
|
25
31
|
{
|
|
26
|
-
ref:
|
|
27
|
-
className:
|
|
28
|
-
onMouseEnter:
|
|
29
|
-
onMouseLeave: () =>
|
|
30
|
-
children:
|
|
32
|
+
ref: spanRef,
|
|
33
|
+
className: spanClassName,
|
|
34
|
+
onMouseEnter: handleMouseEnter,
|
|
35
|
+
onMouseLeave: () => setVisible(false),
|
|
36
|
+
children: text
|
|
31
37
|
}
|
|
32
38
|
),
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/* @__PURE__ */
|
|
39
|
+
trailing,
|
|
40
|
+
visible && anchorRect && createPortal(
|
|
41
|
+
/* @__PURE__ */ jsx(
|
|
36
42
|
"span",
|
|
37
43
|
{
|
|
38
44
|
style: {
|
|
39
45
|
position: "fixed",
|
|
40
|
-
top:
|
|
41
|
-
left:
|
|
42
|
-
width:
|
|
43
|
-
height:
|
|
46
|
+
top: anchorRect.top,
|
|
47
|
+
left: anchorRect.left,
|
|
48
|
+
width: anchorRect.width,
|
|
49
|
+
height: anchorRect.height,
|
|
44
50
|
display: "block",
|
|
45
51
|
pointerEvents: "none",
|
|
46
52
|
zIndex: 9999999999
|
|
47
53
|
},
|
|
48
|
-
children: /* @__PURE__ */
|
|
54
|
+
children: /* @__PURE__ */ jsx(BTooltip, { content: text, placement, className: "bu-category-dropdown__tooltip" })
|
|
49
55
|
}
|
|
50
56
|
),
|
|
51
|
-
(
|
|
57
|
+
(getPopupContainer == null ? void 0 : getPopupContainer()) ?? document.body
|
|
52
58
|
)
|
|
53
59
|
] });
|
|
54
60
|
}
|
|
55
|
-
function
|
|
56
|
-
return /* @__PURE__ */
|
|
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" }) });
|
|
57
63
|
}
|
|
58
|
-
function
|
|
64
|
+
function ChevronRight() {
|
|
59
65
|
return (
|
|
60
66
|
// <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
61
67
|
// <path d="M6 3.5L10.5 8L6 12.5" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
|
|
62
68
|
// </svg>
|
|
63
|
-
/* @__PURE__ */
|
|
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" }) })
|
|
64
70
|
);
|
|
65
71
|
}
|
|
66
|
-
function
|
|
67
|
-
var
|
|
68
|
-
const
|
|
69
|
-
let
|
|
70
|
-
for (let
|
|
71
|
-
const
|
|
72
|
-
if ((
|
|
73
|
-
|
|
74
|
-
|
|
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 {
|
|
75
82
|
break;
|
|
83
|
+
}
|
|
76
84
|
}
|
|
77
|
-
return
|
|
85
|
+
return cols;
|
|
78
86
|
}
|
|
79
|
-
function
|
|
80
|
-
const
|
|
81
|
-
let
|
|
82
|
-
for (const
|
|
83
|
-
const
|
|
84
|
-
if (!
|
|
85
|
-
|
|
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 ?? [];
|
|
86
95
|
}
|
|
87
|
-
return
|
|
96
|
+
return path;
|
|
88
97
|
}
|
|
89
|
-
function
|
|
90
|
-
data
|
|
91
|
-
value
|
|
92
|
-
onChange
|
|
93
|
-
placeholder
|
|
94
|
-
disabled
|
|
95
|
-
maxVisible
|
|
96
|
-
className
|
|
97
|
-
style
|
|
98
|
-
getPopupContainer
|
|
99
|
-
dropdownStyle:
|
|
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
|
|
100
109
|
}) {
|
|
101
|
-
const [
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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;
|
|
113
132
|
}
|
|
114
|
-
|
|
133
|
+
}
|
|
134
|
+
el = el.parentElement;
|
|
115
135
|
}
|
|
116
|
-
const
|
|
117
|
-
|
|
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({
|
|
118
141
|
position: "fixed",
|
|
119
|
-
top:
|
|
120
|
-
left:
|
|
121
|
-
zIndex:
|
|
122
|
-
...
|
|
142
|
+
top: flipToTop ? rect.top - panelHeight - 4 : rect.bottom + 4,
|
|
143
|
+
left: rect.left,
|
|
144
|
+
zIndex: maxZ > 0 ? maxZ + 10 : 1100,
|
|
145
|
+
...customDropdownStyle
|
|
123
146
|
});
|
|
124
|
-
}, [
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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;
|
|
133
164
|
});
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
165
|
+
const next = justOpened ? max : Math.max(colWidth ?? 0, max);
|
|
166
|
+
cols.forEach((col) => {
|
|
167
|
+
col.style.width = next ? `${next}px` : "";
|
|
137
168
|
});
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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);
|
|
148
180
|
}
|
|
149
|
-
function
|
|
150
|
-
|
|
181
|
+
function handleScroll() {
|
|
182
|
+
setOpen(false);
|
|
151
183
|
}
|
|
152
|
-
|
|
153
|
-
|
|
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);
|
|
154
191
|
};
|
|
155
|
-
}, [
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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);
|
|
164
207
|
}
|
|
165
208
|
}
|
|
166
|
-
function
|
|
167
|
-
|
|
209
|
+
function handleOpen() {
|
|
210
|
+
setNavValue(value);
|
|
211
|
+
setOpen(true);
|
|
168
212
|
}
|
|
169
|
-
const
|
|
213
|
+
const triggerClass = [
|
|
170
214
|
"bu-category-dropdown__trigger",
|
|
171
|
-
|
|
172
|
-
|
|
215
|
+
open ? "bu-category-dropdown__trigger--open" : "",
|
|
216
|
+
hasValue ? "bu-category-dropdown__trigger--has-value" : ""
|
|
173
217
|
].filter(Boolean).join(" ");
|
|
174
|
-
return /* @__PURE__ */
|
|
218
|
+
return /* @__PURE__ */ jsxs(
|
|
175
219
|
"div",
|
|
176
220
|
{
|
|
177
|
-
ref:
|
|
178
|
-
className: `bu-category-dropdown${
|
|
179
|
-
style
|
|
221
|
+
ref: rootRef,
|
|
222
|
+
className: `bu-category-dropdown${className ? ` ${className}` : ""}`,
|
|
223
|
+
style,
|
|
180
224
|
children: [
|
|
181
|
-
/* @__PURE__ */
|
|
225
|
+
/* @__PURE__ */ jsx(
|
|
182
226
|
"button",
|
|
183
227
|
{
|
|
184
228
|
type: "button",
|
|
185
|
-
className:
|
|
186
|
-
disabled
|
|
187
|
-
onClick: () =>
|
|
188
|
-
children: /* @__PURE__ */
|
|
189
|
-
|
|
229
|
+
className: triggerClass,
|
|
230
|
+
disabled,
|
|
231
|
+
onClick: () => open ? setOpen(false) : handleOpen(),
|
|
232
|
+
children: /* @__PURE__ */ jsx(
|
|
233
|
+
TruncatedTooltip,
|
|
190
234
|
{
|
|
191
|
-
text:
|
|
192
|
-
spanClassName: `bu-category-dropdown__trigger-label${
|
|
235
|
+
text: triggerLabel ?? placeholder,
|
|
236
|
+
spanClassName: `bu-category-dropdown__trigger-label${!hasValue ? " bu-category-dropdown__trigger-label--placeholder" : ""}`,
|
|
193
237
|
wrapperStyle: { flex: 1, minWidth: 0, display: "flex", alignItems: "center", gap: 8 },
|
|
194
|
-
getPopupContainer
|
|
195
|
-
trailing: /* @__PURE__ */
|
|
238
|
+
getPopupContainer,
|
|
239
|
+
trailing: /* @__PURE__ */ jsx("span", { className: `bu-category-dropdown__trigger-chevron${open ? " bu-category-dropdown__trigger-chevron--open" : ""}`, children: /* @__PURE__ */ jsx(ChevronDown, {}) })
|
|
196
240
|
}
|
|
197
241
|
)
|
|
198
242
|
}
|
|
199
243
|
),
|
|
200
|
-
|
|
201
|
-
/* @__PURE__ */
|
|
202
|
-
const
|
|
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 = [
|
|
203
249
|
"bu-category-dropdown__col",
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
250
|
+
colIndex > 0 ? "bu-category-dropdown__col--indent" : "",
|
|
251
|
+
isScrollable ? "bu-category-dropdown__col--scrollable" : "",
|
|
252
|
+
isLast && colIndex > 0 ? "bu-category-dropdown__col--last" : ""
|
|
207
253
|
].filter(Boolean).join(" ");
|
|
208
|
-
return /* @__PURE__ */
|
|
209
|
-
|
|
210
|
-
/* @__PURE__ */
|
|
254
|
+
return /* @__PURE__ */ jsxs("div", { style: { display: "contents" }, children: [
|
|
255
|
+
colIndex > 0 && /* @__PURE__ */ jsx("div", { className: "bu-category-dropdown__divider" }),
|
|
256
|
+
/* @__PURE__ */ jsx(
|
|
211
257
|
"div",
|
|
212
258
|
{
|
|
213
|
-
className:
|
|
214
|
-
style:
|
|
215
|
-
onMouseEnter:
|
|
216
|
-
onMouseLeave:
|
|
217
|
-
children:
|
|
218
|
-
var
|
|
219
|
-
const
|
|
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 = [
|
|
220
268
|
"bu-category-dropdown__item",
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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" : ""
|
|
224
272
|
].filter(Boolean).join(" ");
|
|
225
|
-
return /* @__PURE__ */
|
|
273
|
+
return /* @__PURE__ */ jsxs(
|
|
226
274
|
"button",
|
|
227
275
|
{
|
|
228
276
|
type: "button",
|
|
229
|
-
className:
|
|
230
|
-
disabled:
|
|
231
|
-
onClick: () =>
|
|
277
|
+
className: itemClass,
|
|
278
|
+
disabled: item.disabled,
|
|
279
|
+
onClick: () => handleSelect(colIndex, item),
|
|
232
280
|
children: [
|
|
233
|
-
/* @__PURE__ */
|
|
234
|
-
|
|
281
|
+
/* @__PURE__ */ jsx(
|
|
282
|
+
TruncatedTooltip,
|
|
235
283
|
{
|
|
236
|
-
text:
|
|
284
|
+
text: item.label,
|
|
237
285
|
spanClassName: "bu-category-dropdown__item-label",
|
|
238
286
|
wrapperStyle: { flex: 1, minWidth: 0, display: "block" },
|
|
239
|
-
getPopupContainer
|
|
287
|
+
getPopupContainer
|
|
240
288
|
}
|
|
241
289
|
),
|
|
242
|
-
|
|
290
|
+
hasBranch && /* @__PURE__ */ jsx("span", { className: "bu-category-dropdown__item-arrow", children: /* @__PURE__ */ jsx(ChevronRight, {}) })
|
|
243
291
|
]
|
|
244
292
|
},
|
|
245
|
-
|
|
293
|
+
item.value
|
|
246
294
|
);
|
|
247
295
|
})
|
|
248
296
|
}
|
|
249
297
|
)
|
|
250
|
-
] },
|
|
298
|
+
] }, colIndex);
|
|
251
299
|
}) }) }),
|
|
252
300
|
document.body
|
|
253
301
|
)
|
|
@@ -256,5 +304,5 @@ function ae({
|
|
|
256
304
|
);
|
|
257
305
|
}
|
|
258
306
|
export {
|
|
259
|
-
|
|
307
|
+
BuCategoryDropdown as default
|
|
260
308
|
};
|
|
@@ -1 +1,116 @@
|
|
|
1
|
-
"use strict";
|
|
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;
|