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
package/dist/web/Input/Input.js
CHANGED
|
@@ -1 +1,181 @@
|
|
|
1
|
-
"use strict";
|
|
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;
|
package/dist/web/Input/Input.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsxs
|
|
2
|
-
import { forwardRef
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
3
|
/* empty css */
|
|
4
|
-
function
|
|
5
|
-
return /* @__PURE__ */
|
|
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
6
|
"path",
|
|
7
7
|
{
|
|
8
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",
|
|
@@ -10,8 +10,8 @@ function R() {
|
|
|
10
10
|
}
|
|
11
11
|
) });
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
return /* @__PURE__ */
|
|
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
15
|
"path",
|
|
16
16
|
{
|
|
17
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",
|
|
@@ -19,155 +19,164 @@ function T() {
|
|
|
19
19
|
}
|
|
20
20
|
) });
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
return /* @__PURE__ */
|
|
24
|
-
/* @__PURE__ */
|
|
25
|
-
/* @__PURE__ */
|
|
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
26
|
] });
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
function({
|
|
30
|
-
type
|
|
31
|
-
mode
|
|
32
|
-
activeLang
|
|
33
|
-
onLangChange
|
|
34
|
-
value
|
|
35
|
-
onChange
|
|
36
|
-
label
|
|
37
|
-
required
|
|
38
|
-
placeholder
|
|
39
|
-
maxLength
|
|
40
|
-
showCount
|
|
41
|
-
error
|
|
42
|
-
errorMessage
|
|
43
|
-
disabled
|
|
44
|
-
leftIcon
|
|
45
|
-
rightIcon
|
|
46
|
-
langToggle
|
|
47
|
-
translating
|
|
48
|
-
translated
|
|
49
|
-
onBlur
|
|
50
|
-
min
|
|
51
|
-
max
|
|
52
|
-
step
|
|
53
|
-
labels
|
|
54
|
-
id
|
|
55
|
-
className
|
|
56
|
-
style
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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));
|
|
62
66
|
}
|
|
63
|
-
const
|
|
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 = [
|
|
64
72
|
"bu-input__box",
|
|
65
|
-
(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
!!
|
|
71
|
-
!!
|
|
72
|
-
].filter(Boolean).join(" ")
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
|
77
86
|
] }),
|
|
78
|
-
/* @__PURE__ */
|
|
79
|
-
|
|
80
|
-
/* @__PURE__ */
|
|
81
|
-
|
|
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(
|
|
82
91
|
"textarea",
|
|
83
92
|
{
|
|
84
|
-
ref
|
|
85
|
-
id
|
|
86
|
-
className:
|
|
87
|
-
value
|
|
88
|
-
onChange: (
|
|
89
|
-
onBlur
|
|
90
|
-
placeholder
|
|
91
|
-
maxLength
|
|
92
|
-
disabled
|
|
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
|
|
93
102
|
}
|
|
94
|
-
) :
|
|
95
|
-
/* @__PURE__ */
|
|
103
|
+
) : type === "number" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
104
|
+
/* @__PURE__ */ jsx(
|
|
96
105
|
"input",
|
|
97
106
|
{
|
|
98
|
-
ref
|
|
99
|
-
id
|
|
100
|
-
className:
|
|
101
|
-
value
|
|
102
|
-
onChange: (
|
|
103
|
-
onBlur
|
|
104
|
-
placeholder
|
|
105
|
-
disabled
|
|
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,
|
|
106
115
|
inputMode: "numeric"
|
|
107
116
|
}
|
|
108
117
|
),
|
|
109
|
-
/* @__PURE__ */
|
|
110
|
-
/* @__PURE__ */
|
|
118
|
+
/* @__PURE__ */ jsxs("div", { className: "bu-input__stepper", children: [
|
|
119
|
+
/* @__PURE__ */ jsx(
|
|
111
120
|
"button",
|
|
112
121
|
{
|
|
113
122
|
type: "button",
|
|
114
123
|
className: "bu-input__stepper-btn bu-input__stepper-btn--up",
|
|
115
|
-
onMouseDown: (
|
|
116
|
-
onClick: () =>
|
|
117
|
-
disabled:
|
|
124
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
125
|
+
onClick: () => handleStep(step),
|
|
126
|
+
disabled: disabled || max !== void 0 && parseFloat(value || "0") >= max,
|
|
118
127
|
tabIndex: -1,
|
|
119
|
-
children: /* @__PURE__ */
|
|
128
|
+
children: /* @__PURE__ */ jsx(ArrowUp, {})
|
|
120
129
|
}
|
|
121
130
|
),
|
|
122
|
-
/* @__PURE__ */
|
|
131
|
+
/* @__PURE__ */ jsx(
|
|
123
132
|
"button",
|
|
124
133
|
{
|
|
125
134
|
type: "button",
|
|
126
135
|
className: "bu-input__stepper-btn bu-input__stepper-btn--down",
|
|
127
|
-
onMouseDown: (
|
|
128
|
-
onClick: () =>
|
|
129
|
-
disabled:
|
|
136
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
137
|
+
onClick: () => handleStep(-step),
|
|
138
|
+
disabled: disabled || min !== void 0 && parseFloat(value || "0") <= min,
|
|
130
139
|
tabIndex: -1,
|
|
131
|
-
children: /* @__PURE__ */
|
|
140
|
+
children: /* @__PURE__ */ jsx(ArrowDown, {})
|
|
132
141
|
}
|
|
133
142
|
)
|
|
134
143
|
] })
|
|
135
|
-
] }) : /* @__PURE__ */
|
|
144
|
+
] }) : /* @__PURE__ */ jsx(
|
|
136
145
|
"input",
|
|
137
146
|
{
|
|
138
|
-
ref
|
|
139
|
-
id
|
|
140
|
-
className:
|
|
141
|
-
value
|
|
142
|
-
onChange: (
|
|
143
|
-
onBlur
|
|
144
|
-
placeholder
|
|
145
|
-
maxLength
|
|
146
|
-
disabled
|
|
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
|
|
147
156
|
}
|
|
148
157
|
),
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
/* @__PURE__ */
|
|
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" }) }),
|
|
153
162
|
"翻译中…"
|
|
154
163
|
] }),
|
|
155
|
-
|
|
156
|
-
/* @__PURE__ */
|
|
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" }) }),
|
|
157
166
|
"翻译完成"
|
|
158
167
|
] }),
|
|
159
|
-
|
|
168
|
+
mode === "bilingual" && !translating && !translated && (langToggle ?? /* @__PURE__ */ jsx("div", { className: "bu-input__lang-toggle" }))
|
|
160
169
|
] })
|
|
161
170
|
] }),
|
|
162
|
-
|
|
171
|
+
rightIcon && /* @__PURE__ */ jsx("span", { className: "bu-input__icon bu-input__icon--right", children: rightIcon })
|
|
163
172
|
] }),
|
|
164
|
-
|
|
165
|
-
/* @__PURE__ */
|
|
166
|
-
|
|
173
|
+
showErrorMsg && /* @__PURE__ */ jsxs("div", { className: "bu-input__error-msg", children: [
|
|
174
|
+
/* @__PURE__ */ jsx(ErrorIcon, {}),
|
|
175
|
+
errorMessage
|
|
167
176
|
] })
|
|
168
177
|
] });
|
|
169
178
|
}
|
|
170
179
|
);
|
|
171
180
|
export {
|
|
172
|
-
|
|
181
|
+
BuInput as default
|
|
173
182
|
};
|