bj-web-components 0.2.26 → 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/favicon.ico +0 -0
- package/dist/file.svg +1 -0
- package/dist/globe.svg +1 -0
- package/dist/index.d.ts +1141 -0
- package/dist/index.js +51 -0
- package/dist/index.mjs +51 -0
- package/dist/miniapp.d.ts +1 -0
- package/dist/miniapp.js +1 -0
- package/dist/miniapp.mjs +1 -0
- package/dist/mobile.d.ts +1 -0
- package/dist/mobile.js +1 -0
- package/dist/mobile.mjs +1 -0
- package/dist/next.svg +1 -0
- package/dist/react.d.ts +1 -0
- package/dist/react.js +1 -0
- package/dist/react.mjs +1 -0
- package/dist/shared.d.ts +1 -0
- package/dist/shared.js +1 -0
- package/dist/shared.mjs +1 -0
- package/dist/style.css +3744 -0
- package/dist/vercel.svg +1 -0
- package/dist/web/BasicInput/BInput.js +208 -0
- package/dist/web/BasicInput/BInput.mjs +209 -0
- package/dist/web/BasicInput/utils.js +47 -0
- package/dist/web/BasicInput/utils.mjs +47 -0
- package/dist/web/CategoryDropdown/CategoryDropdown.js +307 -0
- package/dist/web/CategoryDropdown/CategoryDropdown.mjs +308 -0
- package/dist/web/CheckBox/BCheckBox.js +116 -0
- package/dist/web/CheckBox/BCheckBox.mjs +117 -0
- package/dist/web/CheckBox/Group.js +73 -0
- package/dist/web/CheckBox/Group.mjs +74 -0
- package/dist/web/CheckBox/context.js +5 -0
- package/dist/web/CheckBox/context.mjs +5 -0
- package/dist/web/CheckBox/index.js +8 -0
- package/dist/web/CheckBox/index.mjs +8 -0
- package/dist/web/Dropdown/BDropdown.js +186 -0
- package/dist/web/Dropdown/BDropdown.mjs +186 -0
- package/dist/web/EmptyInputBox/EmptyInputBox.js +77 -0
- package/dist/web/EmptyInputBox/EmptyInputBox.mjs +78 -0
- package/dist/web/FileCard/FileCard.js +157 -0
- package/dist/web/FileCard/FileCard.mjs +158 -0
- package/dist/web/Icon/Icon.js +9 -0
- package/dist/web/Icon/Icon.mjs +10 -0
- package/dist/web/Input/Input.js +181 -0
- package/dist/web/Input/Input.mjs +182 -0
- package/dist/web/InputNumber/BInputNumber.js +311 -0
- package/dist/web/InputNumber/BInputNumber.mjs +312 -0
- package/dist/web/InputNumber/StepHandler.js +69 -0
- package/dist/web/InputNumber/StepHandler.mjs +70 -0
- package/dist/web/InputNumber/hooks/useCursor.js +40 -0
- package/dist/web/InputNumber/hooks/useCursor.mjs +41 -0
- package/dist/web/InputNumber/hooks/useFrame.js +12 -0
- package/dist/web/InputNumber/hooks/useFrame.mjs +13 -0
- package/dist/web/InputNumber/utils/decimal.js +147 -0
- package/dist/web/InputNumber/utils/decimal.mjs +147 -0
- package/dist/web/Modal/Modal.js +84 -0
- package/dist/web/Modal/Modal.mjs +85 -0
- package/dist/web/OverlayScrollbar/BOverlayScrollbar.js +232 -0
- package/dist/web/OverlayScrollbar/BOverlayScrollbar.mjs +233 -0
- package/dist/web/Pagination/Pagination.js +328 -0
- package/dist/web/Pagination/Pagination.mjs +329 -0
- package/dist/web/ProductField/ProductField.js +272 -0
- package/dist/web/ProductField/ProductField.mjs +273 -0
- package/dist/web/ProductField/arrow-up.svg.js +3 -0
- package/dist/web/ProductField/arrow-up.svg.mjs +4 -0
- package/dist/web/ProductField/checkbox-no.svg.js +3 -0
- package/dist/web/ProductField/checkbox-no.svg.mjs +4 -0
- package/dist/web/ProductField/checkbox-ok.svg.js +3 -0
- package/dist/web/ProductField/checkbox-ok.svg.mjs +4 -0
- package/dist/web/ProductField/no_data_light.svg.js +3 -0
- package/dist/web/ProductField/no_data_light.svg.mjs +4 -0
- package/dist/web/ProductField/search.svg.js +3 -0
- package/dist/web/ProductField/search.svg.mjs +4 -0
- package/dist/web/ProductField/sort.svg.js +3 -0
- package/dist/web/ProductField/sort.svg.mjs +4 -0
- package/dist/web/SkuInputCard/SkuInputCard.js +276 -0
- package/dist/web/SkuInputCard/SkuInputCard.mjs +277 -0
- package/dist/web/SkuInputCard/spin_loading_red.gif.js +3 -0
- package/dist/web/SkuInputCard/spin_loading_red.gif.mjs +4 -0
- package/dist/web/Switch/Switch.js +70 -0
- package/dist/web/Switch/Switch.mjs +71 -0
- package/dist/web/Table/BTable.js +950 -0
- package/dist/web/Table/BTable.mjs +950 -0
- package/dist/web/Table/Column.js +5 -0
- package/dist/web/Table/Column.mjs +6 -0
- package/dist/web/Table/ColumnGroup.js +5 -0
- package/dist/web/Table/ColumnGroup.mjs +6 -0
- package/dist/web/Table/utils/columns.js +48 -0
- package/dist/web/Table/utils/columns.mjs +48 -0
- package/dist/web/Table/utils/sortFilter.js +84 -0
- package/dist/web/Table/utils/sortFilter.mjs +84 -0
- package/dist/web/Tabs/BTabs.js +150 -0
- package/dist/web/Tabs/BTabs.mjs +150 -0
- package/dist/web/Tabs/TabPane.js +8 -0
- package/dist/web/Tabs/TabPane.mjs +8 -0
- package/dist/web/Tooltip/ConfirmTooltip.js +26 -0
- package/dist/web/Tooltip/ConfirmTooltip.mjs +27 -0
- package/dist/web/Tooltip/ContentTooltip.js +94 -0
- package/dist/web/Tooltip/ContentTooltip.mjs +95 -0
- package/dist/web/Tooltip/ProgressTooltip.js +36 -0
- package/dist/web/Tooltip/ProgressTooltip.mjs +37 -0
- package/dist/web/Tooltip/TooltipWrapper.js +12 -0
- package/dist/web/Tooltip/TooltipWrapper.mjs +13 -0
- package/dist/web/Tooltip/useAutoPlacement.js +41 -0
- package/dist/web/Tooltip/useAutoPlacement.mjs +41 -0
- package/dist/web.d.ts +1141 -0
- package/dist/web.js +51 -0
- package/dist/web.mjs +51 -0
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
;/* empty css */
|
|
4
|
+
const BuIcon = ({ type, style, onClick, className, ...rest }) => {
|
|
5
|
+
const cls = className ? `bu-icon ${className}` : "bu-icon";
|
|
6
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { style, className: cls, "aria-hidden": "true", onClick, ...rest, children: /* @__PURE__ */ jsxRuntime.jsx("use", { xlinkHref: `#${type}` }) });
|
|
7
|
+
};
|
|
8
|
+
BuIcon.displayName = "BuIcon";
|
|
9
|
+
module.exports = BuIcon;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
/* empty css */
|
|
3
|
+
const BuIcon = ({ type, style, onClick, className, ...rest }) => {
|
|
4
|
+
const cls = className ? `bu-icon ${className}` : "bu-icon";
|
|
5
|
+
return /* @__PURE__ */ jsx("svg", { style, className: cls, "aria-hidden": "true", onClick, ...rest, children: /* @__PURE__ */ jsx("use", { xlinkHref: `#${type}` }) });
|
|
6
|
+
};
|
|
7
|
+
BuIcon.displayName = "BuIcon";
|
|
8
|
+
export {
|
|
9
|
+
BuIcon as default
|
|
10
|
+
};
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const react = require("react");
|
|
4
|
+
;/* empty css */
|
|
5
|
+
function ArrowUp() {
|
|
6
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "8", height: "4.5", viewBox: "315 270 365 185", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
7
|
+
"path",
|
|
8
|
+
{
|
|
9
|
+
d: "M661.191111 440.106667c19.100444 0 28.664889-23.096889 15.160889-36.600889l-148.337778-148.337778a21.44 21.44 0 0 0-30.321778 0l-148.337777 148.337778c-13.511111 13.511111-3.946667 36.600889 15.153777 36.600889H661.191111z",
|
|
10
|
+
fill: "currentColor"
|
|
11
|
+
}
|
|
12
|
+
) });
|
|
13
|
+
}
|
|
14
|
+
function ArrowDown() {
|
|
15
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "8", height: "4.5", viewBox: "315 565 365 215", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
16
|
+
"path",
|
|
17
|
+
{
|
|
18
|
+
d: "M659.498667 582.328889c19.100444 0 28.657778 23.089778 15.160889 36.600889l-148.337778 148.337778a21.447111 21.447111 0 0 1-30.321778 0l-148.337778-148.337778c-13.511111-13.511111-3.946667-36.600889 15.146667-36.600889h296.689778z",
|
|
19
|
+
fill: "currentColor"
|
|
20
|
+
}
|
|
21
|
+
) });
|
|
22
|
+
}
|
|
23
|
+
function ErrorIcon() {
|
|
24
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { className: "bu-input__error-icon", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
25
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "8", cy: "8", r: "7", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
26
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 8h6", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
|
|
27
|
+
] });
|
|
28
|
+
}
|
|
29
|
+
const BuInput = react.forwardRef(
|
|
30
|
+
function BuInput2({
|
|
31
|
+
type = "input",
|
|
32
|
+
mode = "single",
|
|
33
|
+
activeLang = "zh",
|
|
34
|
+
onLangChange,
|
|
35
|
+
value = "",
|
|
36
|
+
onChange,
|
|
37
|
+
label,
|
|
38
|
+
required,
|
|
39
|
+
placeholder,
|
|
40
|
+
maxLength,
|
|
41
|
+
showCount,
|
|
42
|
+
error = false,
|
|
43
|
+
errorMessage,
|
|
44
|
+
disabled,
|
|
45
|
+
leftIcon,
|
|
46
|
+
rightIcon,
|
|
47
|
+
langToggle,
|
|
48
|
+
translating = false,
|
|
49
|
+
translated = false,
|
|
50
|
+
onBlur,
|
|
51
|
+
min,
|
|
52
|
+
max,
|
|
53
|
+
step = 1,
|
|
54
|
+
labels,
|
|
55
|
+
id,
|
|
56
|
+
className,
|
|
57
|
+
style
|
|
58
|
+
}, ref) {
|
|
59
|
+
(labels == null ? void 0 : labels.zh) ?? "中文";
|
|
60
|
+
(labels == null ? void 0 : labels.en) ?? "EN";
|
|
61
|
+
function handleStep(delta) {
|
|
62
|
+
const current = parseFloat(value) || 0;
|
|
63
|
+
let next = current + delta;
|
|
64
|
+
if (min !== void 0) next = Math.max(min, next);
|
|
65
|
+
if (max !== void 0) next = Math.min(max, next);
|
|
66
|
+
onChange == null ? void 0 : onChange(String(next));
|
|
67
|
+
}
|
|
68
|
+
const showCharCount = type === "textarea" && !!showCount;
|
|
69
|
+
const showFooter = showCharCount || mode === "bilingual" || translating || translated;
|
|
70
|
+
const countText = maxLength ? `${value.length}/${maxLength}` : `${value.length}`;
|
|
71
|
+
const showErrorMsg = error && !!errorMessage && value.length > 0;
|
|
72
|
+
const boxCls = [
|
|
73
|
+
"bu-input__box",
|
|
74
|
+
(type === "input" || type === "number") && "bu-input__box--single",
|
|
75
|
+
type === "number" && "bu-input__box--number",
|
|
76
|
+
type === "textarea" && "bu-input__box--textarea",
|
|
77
|
+
error && "bu-input__box--error",
|
|
78
|
+
disabled && "bu-input__box--disabled",
|
|
79
|
+
!!leftIcon && "bu-input__box--has-left",
|
|
80
|
+
!!rightIcon && "bu-input__box--has-right"
|
|
81
|
+
].filter(Boolean).join(" ");
|
|
82
|
+
const fieldCls = `bu-input__field bu-input__field--${type}`;
|
|
83
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ["bu-input", className].filter(Boolean).join(" "), style, children: [
|
|
84
|
+
label && /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "bu-input__label", htmlFor: id, children: [
|
|
85
|
+
required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bu-input__required", children: "*" }),
|
|
86
|
+
label
|
|
87
|
+
] }),
|
|
88
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bu-input__row", children: [
|
|
89
|
+
leftIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bu-input__icon bu-input__icon--left", children: leftIcon }),
|
|
90
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: boxCls, children: [
|
|
91
|
+
type === "textarea" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
92
|
+
"textarea",
|
|
93
|
+
{
|
|
94
|
+
ref,
|
|
95
|
+
id,
|
|
96
|
+
className: fieldCls,
|
|
97
|
+
value,
|
|
98
|
+
onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
|
|
99
|
+
onBlur,
|
|
100
|
+
placeholder,
|
|
101
|
+
maxLength,
|
|
102
|
+
disabled
|
|
103
|
+
}
|
|
104
|
+
) : type === "number" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
105
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
106
|
+
"input",
|
|
107
|
+
{
|
|
108
|
+
ref,
|
|
109
|
+
id,
|
|
110
|
+
className: fieldCls,
|
|
111
|
+
value,
|
|
112
|
+
onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
|
|
113
|
+
onBlur,
|
|
114
|
+
placeholder,
|
|
115
|
+
disabled,
|
|
116
|
+
inputMode: "numeric"
|
|
117
|
+
}
|
|
118
|
+
),
|
|
119
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bu-input__stepper", children: [
|
|
120
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
121
|
+
"button",
|
|
122
|
+
{
|
|
123
|
+
type: "button",
|
|
124
|
+
className: "bu-input__stepper-btn bu-input__stepper-btn--up",
|
|
125
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
126
|
+
onClick: () => handleStep(step),
|
|
127
|
+
disabled: disabled || max !== void 0 && parseFloat(value || "0") >= max,
|
|
128
|
+
tabIndex: -1,
|
|
129
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ArrowUp, {})
|
|
130
|
+
}
|
|
131
|
+
),
|
|
132
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
133
|
+
"button",
|
|
134
|
+
{
|
|
135
|
+
type: "button",
|
|
136
|
+
className: "bu-input__stepper-btn bu-input__stepper-btn--down",
|
|
137
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
138
|
+
onClick: () => handleStep(-step),
|
|
139
|
+
disabled: disabled || min !== void 0 && parseFloat(value || "0") <= min,
|
|
140
|
+
tabIndex: -1,
|
|
141
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ArrowDown, {})
|
|
142
|
+
}
|
|
143
|
+
)
|
|
144
|
+
] })
|
|
145
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
146
|
+
"input",
|
|
147
|
+
{
|
|
148
|
+
ref,
|
|
149
|
+
id,
|
|
150
|
+
className: fieldCls,
|
|
151
|
+
value,
|
|
152
|
+
onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
|
|
153
|
+
onBlur,
|
|
154
|
+
placeholder,
|
|
155
|
+
maxLength,
|
|
156
|
+
disabled
|
|
157
|
+
}
|
|
158
|
+
),
|
|
159
|
+
showFooter && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `bu-input__footer${type === "textarea" ? " bu-input__footer--bottom" : ""}`, children: [
|
|
160
|
+
showCharCount && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bu-input__count", children: countText }),
|
|
161
|
+
translating && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "bu-input__translating", children: [
|
|
162
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { className: "bu-input__translating-icon", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "9", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeDasharray: "14 42" }) }),
|
|
163
|
+
"翻译中…"
|
|
164
|
+
] }),
|
|
165
|
+
translated && !translating && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "bu-input__translated", children: [
|
|
166
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3 8l3.5 3.5L13 4.5", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) }),
|
|
167
|
+
"翻译完成"
|
|
168
|
+
] }),
|
|
169
|
+
mode === "bilingual" && !translating && !translated && (langToggle ?? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bu-input__lang-toggle" }))
|
|
170
|
+
] })
|
|
171
|
+
] }),
|
|
172
|
+
rightIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bu-input__icon bu-input__icon--right", children: rightIcon })
|
|
173
|
+
] }),
|
|
174
|
+
showErrorMsg && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bu-input__error-msg", children: [
|
|
175
|
+
/* @__PURE__ */ jsxRuntime.jsx(ErrorIcon, {}),
|
|
176
|
+
errorMessage
|
|
177
|
+
] })
|
|
178
|
+
] });
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
module.exports = BuInput;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
/* empty css */
|
|
4
|
+
function ArrowUp() {
|
|
5
|
+
return /* @__PURE__ */ jsx("svg", { width: "8", height: "4.5", viewBox: "315 270 365 185", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx(
|
|
6
|
+
"path",
|
|
7
|
+
{
|
|
8
|
+
d: "M661.191111 440.106667c19.100444 0 28.664889-23.096889 15.160889-36.600889l-148.337778-148.337778a21.44 21.44 0 0 0-30.321778 0l-148.337777 148.337778c-13.511111 13.511111-3.946667 36.600889 15.153777 36.600889H661.191111z",
|
|
9
|
+
fill: "currentColor"
|
|
10
|
+
}
|
|
11
|
+
) });
|
|
12
|
+
}
|
|
13
|
+
function ArrowDown() {
|
|
14
|
+
return /* @__PURE__ */ jsx("svg", { width: "8", height: "4.5", viewBox: "315 565 365 215", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx(
|
|
15
|
+
"path",
|
|
16
|
+
{
|
|
17
|
+
d: "M659.498667 582.328889c19.100444 0 28.657778 23.089778 15.160889 36.600889l-148.337778 148.337778a21.447111 21.447111 0 0 1-30.321778 0l-148.337778-148.337778c-13.511111-13.511111-3.946667-36.600889 15.146667-36.600889h296.689778z",
|
|
18
|
+
fill: "currentColor"
|
|
19
|
+
}
|
|
20
|
+
) });
|
|
21
|
+
}
|
|
22
|
+
function ErrorIcon() {
|
|
23
|
+
return /* @__PURE__ */ jsxs("svg", { className: "bu-input__error-icon", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
24
|
+
/* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "7", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
25
|
+
/* @__PURE__ */ jsx("path", { d: "M5 8h6", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
|
|
26
|
+
] });
|
|
27
|
+
}
|
|
28
|
+
const BuInput = forwardRef(
|
|
29
|
+
function BuInput2({
|
|
30
|
+
type = "input",
|
|
31
|
+
mode = "single",
|
|
32
|
+
activeLang = "zh",
|
|
33
|
+
onLangChange,
|
|
34
|
+
value = "",
|
|
35
|
+
onChange,
|
|
36
|
+
label,
|
|
37
|
+
required,
|
|
38
|
+
placeholder,
|
|
39
|
+
maxLength,
|
|
40
|
+
showCount,
|
|
41
|
+
error = false,
|
|
42
|
+
errorMessage,
|
|
43
|
+
disabled,
|
|
44
|
+
leftIcon,
|
|
45
|
+
rightIcon,
|
|
46
|
+
langToggle,
|
|
47
|
+
translating = false,
|
|
48
|
+
translated = false,
|
|
49
|
+
onBlur,
|
|
50
|
+
min,
|
|
51
|
+
max,
|
|
52
|
+
step = 1,
|
|
53
|
+
labels,
|
|
54
|
+
id,
|
|
55
|
+
className,
|
|
56
|
+
style
|
|
57
|
+
}, ref) {
|
|
58
|
+
(labels == null ? void 0 : labels.zh) ?? "中文";
|
|
59
|
+
(labels == null ? void 0 : labels.en) ?? "EN";
|
|
60
|
+
function handleStep(delta) {
|
|
61
|
+
const current = parseFloat(value) || 0;
|
|
62
|
+
let next = current + delta;
|
|
63
|
+
if (min !== void 0) next = Math.max(min, next);
|
|
64
|
+
if (max !== void 0) next = Math.min(max, next);
|
|
65
|
+
onChange == null ? void 0 : onChange(String(next));
|
|
66
|
+
}
|
|
67
|
+
const showCharCount = type === "textarea" && !!showCount;
|
|
68
|
+
const showFooter = showCharCount || mode === "bilingual" || translating || translated;
|
|
69
|
+
const countText = maxLength ? `${value.length}/${maxLength}` : `${value.length}`;
|
|
70
|
+
const showErrorMsg = error && !!errorMessage && value.length > 0;
|
|
71
|
+
const boxCls = [
|
|
72
|
+
"bu-input__box",
|
|
73
|
+
(type === "input" || type === "number") && "bu-input__box--single",
|
|
74
|
+
type === "number" && "bu-input__box--number",
|
|
75
|
+
type === "textarea" && "bu-input__box--textarea",
|
|
76
|
+
error && "bu-input__box--error",
|
|
77
|
+
disabled && "bu-input__box--disabled",
|
|
78
|
+
!!leftIcon && "bu-input__box--has-left",
|
|
79
|
+
!!rightIcon && "bu-input__box--has-right"
|
|
80
|
+
].filter(Boolean).join(" ");
|
|
81
|
+
const fieldCls = `bu-input__field bu-input__field--${type}`;
|
|
82
|
+
return /* @__PURE__ */ jsxs("div", { className: ["bu-input", className].filter(Boolean).join(" "), style, children: [
|
|
83
|
+
label && /* @__PURE__ */ jsxs("label", { className: "bu-input__label", htmlFor: id, children: [
|
|
84
|
+
required && /* @__PURE__ */ jsx("span", { className: "bu-input__required", children: "*" }),
|
|
85
|
+
label
|
|
86
|
+
] }),
|
|
87
|
+
/* @__PURE__ */ jsxs("div", { className: "bu-input__row", children: [
|
|
88
|
+
leftIcon && /* @__PURE__ */ jsx("span", { className: "bu-input__icon bu-input__icon--left", children: leftIcon }),
|
|
89
|
+
/* @__PURE__ */ jsxs("div", { className: boxCls, children: [
|
|
90
|
+
type === "textarea" ? /* @__PURE__ */ jsx(
|
|
91
|
+
"textarea",
|
|
92
|
+
{
|
|
93
|
+
ref,
|
|
94
|
+
id,
|
|
95
|
+
className: fieldCls,
|
|
96
|
+
value,
|
|
97
|
+
onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
|
|
98
|
+
onBlur,
|
|
99
|
+
placeholder,
|
|
100
|
+
maxLength,
|
|
101
|
+
disabled
|
|
102
|
+
}
|
|
103
|
+
) : type === "number" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
104
|
+
/* @__PURE__ */ jsx(
|
|
105
|
+
"input",
|
|
106
|
+
{
|
|
107
|
+
ref,
|
|
108
|
+
id,
|
|
109
|
+
className: fieldCls,
|
|
110
|
+
value,
|
|
111
|
+
onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
|
|
112
|
+
onBlur,
|
|
113
|
+
placeholder,
|
|
114
|
+
disabled,
|
|
115
|
+
inputMode: "numeric"
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
/* @__PURE__ */ jsxs("div", { className: "bu-input__stepper", children: [
|
|
119
|
+
/* @__PURE__ */ jsx(
|
|
120
|
+
"button",
|
|
121
|
+
{
|
|
122
|
+
type: "button",
|
|
123
|
+
className: "bu-input__stepper-btn bu-input__stepper-btn--up",
|
|
124
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
125
|
+
onClick: () => handleStep(step),
|
|
126
|
+
disabled: disabled || max !== void 0 && parseFloat(value || "0") >= max,
|
|
127
|
+
tabIndex: -1,
|
|
128
|
+
children: /* @__PURE__ */ jsx(ArrowUp, {})
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
/* @__PURE__ */ jsx(
|
|
132
|
+
"button",
|
|
133
|
+
{
|
|
134
|
+
type: "button",
|
|
135
|
+
className: "bu-input__stepper-btn bu-input__stepper-btn--down",
|
|
136
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
137
|
+
onClick: () => handleStep(-step),
|
|
138
|
+
disabled: disabled || min !== void 0 && parseFloat(value || "0") <= min,
|
|
139
|
+
tabIndex: -1,
|
|
140
|
+
children: /* @__PURE__ */ jsx(ArrowDown, {})
|
|
141
|
+
}
|
|
142
|
+
)
|
|
143
|
+
] })
|
|
144
|
+
] }) : /* @__PURE__ */ jsx(
|
|
145
|
+
"input",
|
|
146
|
+
{
|
|
147
|
+
ref,
|
|
148
|
+
id,
|
|
149
|
+
className: fieldCls,
|
|
150
|
+
value,
|
|
151
|
+
onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
|
|
152
|
+
onBlur,
|
|
153
|
+
placeholder,
|
|
154
|
+
maxLength,
|
|
155
|
+
disabled
|
|
156
|
+
}
|
|
157
|
+
),
|
|
158
|
+
showFooter && /* @__PURE__ */ jsxs("div", { className: `bu-input__footer${type === "textarea" ? " bu-input__footer--bottom" : ""}`, children: [
|
|
159
|
+
showCharCount && /* @__PURE__ */ jsx("span", { className: "bu-input__count", children: countText }),
|
|
160
|
+
translating && /* @__PURE__ */ jsxs("span", { className: "bu-input__translating", children: [
|
|
161
|
+
/* @__PURE__ */ jsx("svg", { className: "bu-input__translating-icon", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "9", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeDasharray: "14 42" }) }),
|
|
162
|
+
"翻译中…"
|
|
163
|
+
] }),
|
|
164
|
+
translated && !translating && /* @__PURE__ */ jsxs("span", { className: "bu-input__translated", children: [
|
|
165
|
+
/* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("path", { d: "M3 8l3.5 3.5L13 4.5", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) }),
|
|
166
|
+
"翻译完成"
|
|
167
|
+
] }),
|
|
168
|
+
mode === "bilingual" && !translating && !translated && (langToggle ?? /* @__PURE__ */ jsx("div", { className: "bu-input__lang-toggle" }))
|
|
169
|
+
] })
|
|
170
|
+
] }),
|
|
171
|
+
rightIcon && /* @__PURE__ */ jsx("span", { className: "bu-input__icon bu-input__icon--right", children: rightIcon })
|
|
172
|
+
] }),
|
|
173
|
+
showErrorMsg && /* @__PURE__ */ jsxs("div", { className: "bu-input__error-msg", children: [
|
|
174
|
+
/* @__PURE__ */ jsx(ErrorIcon, {}),
|
|
175
|
+
errorMessage
|
|
176
|
+
] })
|
|
177
|
+
] });
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
export {
|
|
181
|
+
BuInput as default
|
|
182
|
+
};
|