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.
Files changed (90) hide show
  1. package/dist/index.js +51 -1
  2. package/dist/index.mjs +49 -49
  3. package/dist/style.css +3744 -1
  4. package/dist/web/BasicInput/BInput.js +208 -1
  5. package/dist/web/BasicInput/BInput.mjs +164 -132
  6. package/dist/web/BasicInput/utils.js +47 -1
  7. package/dist/web/BasicInput/utils.mjs +38 -28
  8. package/dist/web/CategoryDropdown/CategoryDropdown.js +307 -1
  9. package/dist/web/CategoryDropdown/CategoryDropdown.mjs +218 -170
  10. package/dist/web/CheckBox/BCheckBox.js +116 -1
  11. package/dist/web/CheckBox/BCheckBox.mjs +86 -70
  12. package/dist/web/CheckBox/Group.js +73 -1
  13. package/dist/web/CheckBox/Group.mjs +63 -56
  14. package/dist/web/CheckBox/context.js +5 -1
  15. package/dist/web/CheckBox/context.mjs +3 -3
  16. package/dist/web/CheckBox/index.js +8 -1
  17. package/dist/web/CheckBox/index.mjs +6 -6
  18. package/dist/web/Dropdown/BDropdown.js +186 -1
  19. package/dist/web/Dropdown/BDropdown.mjs +132 -106
  20. package/dist/web/EmptyInputBox/EmptyInputBox.js +77 -1
  21. package/dist/web/EmptyInputBox/EmptyInputBox.mjs +52 -48
  22. package/dist/web/FileCard/FileCard.js +157 -1
  23. package/dist/web/FileCard/FileCard.mjs +112 -82
  24. package/dist/web/Icon/Icon.js +9 -1
  25. package/dist/web/Icon/Icon.mjs +6 -6
  26. package/dist/web/Input/Input.js +181 -1
  27. package/dist/web/Input/Input.mjs +122 -113
  28. package/dist/web/InputNumber/BInputNumber.js +311 -1
  29. package/dist/web/InputNumber/BInputNumber.mjs +275 -167
  30. package/dist/web/InputNumber/StepHandler.js +69 -1
  31. package/dist/web/InputNumber/StepHandler.mjs +38 -32
  32. package/dist/web/InputNumber/hooks/useCursor.js +40 -1
  33. package/dist/web/InputNumber/hooks/useCursor.mjs +35 -33
  34. package/dist/web/InputNumber/hooks/useFrame.js +12 -1
  35. package/dist/web/InputNumber/hooks/useFrame.mjs +9 -6
  36. package/dist/web/InputNumber/utils/decimal.js +147 -1
  37. package/dist/web/InputNumber/utils/decimal.mjs +109 -81
  38. package/dist/web/Modal/Modal.js +84 -1
  39. package/dist/web/Modal/Modal.mjs +52 -49
  40. package/dist/web/OverlayScrollbar/BOverlayScrollbar.js +232 -1
  41. package/dist/web/OverlayScrollbar/BOverlayScrollbar.mjs +206 -125
  42. package/dist/web/Pagination/Pagination.js +328 -1
  43. package/dist/web/Pagination/Pagination.mjs +254 -178
  44. package/dist/web/ProductField/ProductField.js +272 -1
  45. package/dist/web/ProductField/ProductField.mjs +190 -143
  46. package/dist/web/ProductField/arrow-up.svg.js +3 -1
  47. package/dist/web/ProductField/arrow-up.svg.mjs +2 -2
  48. package/dist/web/ProductField/checkbox-no.svg.js +3 -1
  49. package/dist/web/ProductField/checkbox-no.svg.mjs +2 -2
  50. package/dist/web/ProductField/checkbox-ok.svg.js +3 -1
  51. package/dist/web/ProductField/checkbox-ok.svg.mjs +2 -2
  52. package/dist/web/ProductField/no_data_light.svg.js +3 -1
  53. package/dist/web/ProductField/no_data_light.svg.mjs +2 -2
  54. package/dist/web/ProductField/search.svg.js +3 -1
  55. package/dist/web/ProductField/search.svg.mjs +2 -2
  56. package/dist/web/ProductField/sort.svg.js +3 -1
  57. package/dist/web/ProductField/sort.svg.mjs +2 -2
  58. package/dist/web/SkuInputCard/SkuInputCard.js +276 -1
  59. package/dist/web/SkuInputCard/SkuInputCard.mjs +188 -149
  60. package/dist/web/SkuInputCard/spin_loading_red.gif.js +3 -1
  61. package/dist/web/SkuInputCard/spin_loading_red.gif.mjs +2 -2
  62. package/dist/web/Switch/Switch.js +70 -1
  63. package/dist/web/Switch/Switch.mjs +47 -37
  64. package/dist/web/Table/BTable.js +950 -1
  65. package/dist/web/Table/BTable.mjs +771 -519
  66. package/dist/web/Table/Column.js +5 -1
  67. package/dist/web/Table/Column.mjs +2 -2
  68. package/dist/web/Table/ColumnGroup.js +5 -1
  69. package/dist/web/Table/ColumnGroup.mjs +2 -2
  70. package/dist/web/Table/utils/columns.js +48 -1
  71. package/dist/web/Table/utils/columns.mjs +35 -30
  72. package/dist/web/Table/utils/sortFilter.js +84 -1
  73. package/dist/web/Table/utils/sortFilter.mjs +73 -52
  74. package/dist/web/Tabs/BTabs.js +150 -1
  75. package/dist/web/Tabs/BTabs.mjs +118 -98
  76. package/dist/web/Tabs/TabPane.js +8 -1
  77. package/dist/web/Tabs/TabPane.mjs +4 -4
  78. package/dist/web/Tooltip/ConfirmTooltip.js +26 -1
  79. package/dist/web/Tooltip/ConfirmTooltip.mjs +20 -19
  80. package/dist/web/Tooltip/ContentTooltip.js +94 -1
  81. package/dist/web/Tooltip/ContentTooltip.mjs +72 -62
  82. package/dist/web/Tooltip/ProgressTooltip.js +36 -1
  83. package/dist/web/Tooltip/ProgressTooltip.mjs +22 -20
  84. package/dist/web/Tooltip/TooltipWrapper.js +12 -1
  85. package/dist/web/Tooltip/TooltipWrapper.mjs +8 -8
  86. package/dist/web/Tooltip/useAutoPlacement.js +41 -1
  87. package/dist/web/Tooltip/useAutoPlacement.mjs +34 -25
  88. package/dist/web.js +51 -1
  89. package/dist/web.mjs +49 -49
  90. package/package.json +1 -1
@@ -1 +1,181 @@
1
- "use strict";const t=require("react/jsx-runtime"),R=require("react");;/* empty css */function S(){return t.jsx("svg",{width:"8",height:"4.5",viewBox:"315 270 365 185",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("path",{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",fill:"currentColor"})})}function H(){return t.jsx("svg",{width:"8",height:"4.5",viewBox:"315 565 365 215",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("path",{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",fill:"currentColor"})})}function I(){return t.jsxs("svg",{className:"bu-input__error-icon",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),t.jsx("path",{d:"M5 8h6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}const T=R.forwardRef(function({type:n="input",mode:f="single",activeLang:G="zh",onLangChange:J,value:i="",onChange:s,label:v,required:D,placeholder:_,maxLength:c,showCount:F,error:N=!1,errorMessage:g,disabled:e,leftIcon:b,rightIcon:d,langToggle:$,translating:l=!1,translated:h=!1,onBlur:j,min:p,max:a,step:k=1,labels:u,id:x,className:q,style:z},w){u==null||u.zh,u==null||u.en;function M(r){let o=(parseFloat(i)||0)+r;p!==void 0&&(o=Math.max(p,o)),a!==void 0&&(o=Math.min(a,o)),s==null||s(String(o))}const B=n==="textarea"&&!!F,L=B||f==="bilingual"||l||h,W=c?`${i.length}/${c}`:`${i.length}`,E=N&&!!g&&i.length>0,A=["bu-input__box",(n==="input"||n==="number")&&"bu-input__box--single",n==="number"&&"bu-input__box--number",n==="textarea"&&"bu-input__box--textarea",N&&"bu-input__box--error",e&&"bu-input__box--disabled",!!b&&"bu-input__box--has-left",!!d&&"bu-input__box--has-right"].filter(Boolean).join(" "),m=`bu-input__field bu-input__field--${n}`;return t.jsxs("div",{className:["bu-input",q].filter(Boolean).join(" "),style:z,children:[v&&t.jsxs("label",{className:"bu-input__label",htmlFor:x,children:[D&&t.jsx("span",{className:"bu-input__required",children:"*"}),v]}),t.jsxs("div",{className:"bu-input__row",children:[b&&t.jsx("span",{className:"bu-input__icon bu-input__icon--left",children:b}),t.jsxs("div",{className:A,children:[n==="textarea"?t.jsx("textarea",{ref:w,id:x,className:m,value:i,onChange:r=>s==null?void 0:s(r.target.value),onBlur:j,placeholder:_,maxLength:c,disabled:e}):n==="number"?t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:w,id:x,className:m,value:i,onChange:r=>s==null?void 0:s(r.target.value),onBlur:j,placeholder:_,disabled:e,inputMode:"numeric"}),t.jsxs("div",{className:"bu-input__stepper",children:[t.jsx("button",{type:"button",className:"bu-input__stepper-btn bu-input__stepper-btn--up",onMouseDown:r=>r.preventDefault(),onClick:()=>M(k),disabled:e||a!==void 0&&parseFloat(i||"0")>=a,tabIndex:-1,children:t.jsx(S,{})}),t.jsx("button",{type:"button",className:"bu-input__stepper-btn bu-input__stepper-btn--down",onMouseDown:r=>r.preventDefault(),onClick:()=>M(-k),disabled:e||p!==void 0&&parseFloat(i||"0")<=p,tabIndex:-1,children:t.jsx(H,{})})]})]}):t.jsx("input",{ref:w,id:x,className:m,value:i,onChange:r=>s==null?void 0:s(r.target.value),onBlur:j,placeholder:_,maxLength:c,disabled:e}),L&&t.jsxs("div",{className:`bu-input__footer${n==="textarea"?" bu-input__footer--bottom":""}`,children:[B&&t.jsx("span",{className:"bu-input__count",children:W}),l&&t.jsxs("span",{className:"bu-input__translating",children:[t.jsx("svg",{className:"bu-input__translating-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeDasharray:"14 42"})}),"翻译中…"]}),h&&!l&&t.jsxs("span",{className:"bu-input__translated",children:[t.jsx("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("path",{d:"M3 8l3.5 3.5L13 4.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})}),"翻译完成"]}),f==="bilingual"&&!l&&!h&&($??t.jsx("div",{className:"bu-input__lang-toggle"}))]})]}),d&&t.jsx("span",{className:"bu-input__icon bu-input__icon--right",children:d})]}),E&&t.jsxs("div",{className:"bu-input__error-msg",children:[t.jsx(I,{}),g]})]})});module.exports=T;
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;
@@ -1,8 +1,8 @@
1
- import { jsxs as i, jsx as t, Fragment as H } from "react/jsx-runtime";
2
- import { forwardRef as I } from "react";
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
3
  /* empty css */
4
- function R() {
5
- return /* @__PURE__ */ t("svg", { width: "8", height: "4.5", viewBox: "315 270 365 185", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ t(
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 T() {
14
- return /* @__PURE__ */ t("svg", { width: "8", height: "4.5", viewBox: "315 565 365 215", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ t(
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 U() {
23
- return /* @__PURE__ */ i("svg", { className: "bu-input__error-icon", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
24
- /* @__PURE__ */ t("circle", { cx: "8", cy: "8", r: "7", stroke: "currentColor", strokeWidth: "1.5" }),
25
- /* @__PURE__ */ t("path", { d: "M5 8h6", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
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 X = I(
29
- function({
30
- type: e = "input",
31
- mode: N = "single",
32
- activeLang: J = "zh",
33
- onLangChange: K,
34
- value: u = "",
35
- onChange: r,
36
- label: g,
37
- required: j,
38
- placeholder: d,
39
- maxLength: l,
40
- showCount: $,
41
- error: k = !1,
42
- errorMessage: M,
43
- disabled: o,
44
- leftIcon: h,
45
- rightIcon: w,
46
- langToggle: z,
47
- translating: p = !1,
48
- translated: m = !1,
49
- onBlur: x,
50
- min: a,
51
- max: _,
52
- step: B = 1,
53
- labels: s,
54
- id: b,
55
- className: L,
56
- style: W
57
- }, f) {
58
- s == null || s.zh, s == null || s.en;
59
- function D(n) {
60
- let c = (parseFloat(u) || 0) + n;
61
- a !== void 0 && (c = Math.max(a, c)), _ !== void 0 && (c = Math.min(_, c)), r == null || r(String(c));
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 F = e === "textarea" && !!$, E = F || N === "bilingual" || p || m, A = l ? `${u.length}/${l}` : `${u.length}`, S = k && !!M && u.length > 0, q = [
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
- (e === "input" || e === "number") && "bu-input__box--single",
66
- e === "number" && "bu-input__box--number",
67
- e === "textarea" && "bu-input__box--textarea",
68
- k && "bu-input__box--error",
69
- o && "bu-input__box--disabled",
70
- !!h && "bu-input__box--has-left",
71
- !!w && "bu-input__box--has-right"
72
- ].filter(Boolean).join(" "), v = `bu-input__field bu-input__field--${e}`;
73
- return /* @__PURE__ */ i("div", { className: ["bu-input", L].filter(Boolean).join(" "), style: W, children: [
74
- g && /* @__PURE__ */ i("label", { className: "bu-input__label", htmlFor: b, children: [
75
- j && /* @__PURE__ */ t("span", { className: "bu-input__required", children: "*" }),
76
- g
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__ */ i("div", { className: "bu-input__row", children: [
79
- h && /* @__PURE__ */ t("span", { className: "bu-input__icon bu-input__icon--left", children: h }),
80
- /* @__PURE__ */ i("div", { className: q, children: [
81
- e === "textarea" ? /* @__PURE__ */ t(
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: f,
85
- id: b,
86
- className: v,
87
- value: u,
88
- onChange: (n) => r == null ? void 0 : r(n.target.value),
89
- onBlur: x,
90
- placeholder: d,
91
- maxLength: l,
92
- disabled: o
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
- ) : e === "number" ? /* @__PURE__ */ i(H, { children: [
95
- /* @__PURE__ */ t(
103
+ ) : type === "number" ? /* @__PURE__ */ jsxs(Fragment, { children: [
104
+ /* @__PURE__ */ jsx(
96
105
  "input",
97
106
  {
98
- ref: f,
99
- id: b,
100
- className: v,
101
- value: u,
102
- onChange: (n) => r == null ? void 0 : r(n.target.value),
103
- onBlur: x,
104
- placeholder: d,
105
- disabled: o,
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__ */ i("div", { className: "bu-input__stepper", children: [
110
- /* @__PURE__ */ t(
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: (n) => n.preventDefault(),
116
- onClick: () => D(B),
117
- disabled: o || _ !== void 0 && parseFloat(u || "0") >= _,
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__ */ t(R, {})
128
+ children: /* @__PURE__ */ jsx(ArrowUp, {})
120
129
  }
121
130
  ),
122
- /* @__PURE__ */ t(
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: (n) => n.preventDefault(),
128
- onClick: () => D(-B),
129
- disabled: o || a !== void 0 && parseFloat(u || "0") <= a,
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__ */ t(T, {})
140
+ children: /* @__PURE__ */ jsx(ArrowDown, {})
132
141
  }
133
142
  )
134
143
  ] })
135
- ] }) : /* @__PURE__ */ t(
144
+ ] }) : /* @__PURE__ */ jsx(
136
145
  "input",
137
146
  {
138
- ref: f,
139
- id: b,
140
- className: v,
141
- value: u,
142
- onChange: (n) => r == null ? void 0 : r(n.target.value),
143
- onBlur: x,
144
- placeholder: d,
145
- maxLength: l,
146
- disabled: o
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
- E && /* @__PURE__ */ i("div", { className: `bu-input__footer${e === "textarea" ? " bu-input__footer--bottom" : ""}`, children: [
150
- F && /* @__PURE__ */ t("span", { className: "bu-input__count", children: A }),
151
- p && /* @__PURE__ */ i("span", { className: "bu-input__translating", children: [
152
- /* @__PURE__ */ t("svg", { className: "bu-input__translating-icon", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ t("circle", { cx: "12", cy: "12", r: "9", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeDasharray: "14 42" }) }),
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
- m && !p && /* @__PURE__ */ i("span", { className: "bu-input__translated", children: [
156
- /* @__PURE__ */ t("svg", { viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ t("path", { d: "M3 8l3.5 3.5L13 4.5", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) }),
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
- N === "bilingual" && !p && !m && (z ?? /* @__PURE__ */ t("div", { className: "bu-input__lang-toggle" }))
168
+ mode === "bilingual" && !translating && !translated && (langToggle ?? /* @__PURE__ */ jsx("div", { className: "bu-input__lang-toggle" }))
160
169
  ] })
161
170
  ] }),
162
- w && /* @__PURE__ */ t("span", { className: "bu-input__icon bu-input__icon--right", children: w })
171
+ rightIcon && /* @__PURE__ */ jsx("span", { className: "bu-input__icon bu-input__icon--right", children: rightIcon })
163
172
  ] }),
164
- S && /* @__PURE__ */ i("div", { className: "bu-input__error-msg", children: [
165
- /* @__PURE__ */ t(U, {}),
166
- M
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
- X as default
181
+ BuInput as default
173
182
  };