bj-web-components 0.2.28 → 0.2.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/index.js +1 -51
  2. package/dist/index.mjs +49 -49
  3. package/dist/style.css +1 -3744
  4. package/dist/web/BasicInput/BInput.js +1 -208
  5. package/dist/web/BasicInput/BInput.mjs +132 -164
  6. package/dist/web/BasicInput/utils.js +1 -47
  7. package/dist/web/BasicInput/utils.mjs +28 -38
  8. package/dist/web/CategoryDropdown/CategoryDropdown.js +1 -307
  9. package/dist/web/CategoryDropdown/CategoryDropdown.mjs +170 -218
  10. package/dist/web/CheckBox/BCheckBox.js +1 -116
  11. package/dist/web/CheckBox/BCheckBox.mjs +70 -86
  12. package/dist/web/CheckBox/Group.js +1 -73
  13. package/dist/web/CheckBox/Group.mjs +56 -63
  14. package/dist/web/CheckBox/context.js +1 -5
  15. package/dist/web/CheckBox/context.mjs +3 -3
  16. package/dist/web/CheckBox/index.js +1 -8
  17. package/dist/web/CheckBox/index.mjs +6 -6
  18. package/dist/web/Dropdown/BDropdown.js +1 -186
  19. package/dist/web/Dropdown/BDropdown.mjs +106 -132
  20. package/dist/web/EmptyInputBox/EmptyInputBox.js +1 -77
  21. package/dist/web/EmptyInputBox/EmptyInputBox.mjs +48 -52
  22. package/dist/web/FileCard/FileCard.js +1 -157
  23. package/dist/web/FileCard/FileCard.mjs +82 -112
  24. package/dist/web/Icon/Icon.js +1 -9
  25. package/dist/web/Icon/Icon.mjs +6 -6
  26. package/dist/web/Input/Input.js +1 -181
  27. package/dist/web/Input/Input.mjs +113 -122
  28. package/dist/web/InputNumber/BInputNumber.js +1 -311
  29. package/dist/web/InputNumber/BInputNumber.mjs +167 -275
  30. package/dist/web/InputNumber/StepHandler.js +1 -69
  31. package/dist/web/InputNumber/StepHandler.mjs +32 -38
  32. package/dist/web/InputNumber/hooks/useCursor.js +1 -40
  33. package/dist/web/InputNumber/hooks/useCursor.mjs +33 -35
  34. package/dist/web/InputNumber/hooks/useFrame.js +1 -12
  35. package/dist/web/InputNumber/hooks/useFrame.mjs +6 -9
  36. package/dist/web/InputNumber/utils/decimal.js +1 -147
  37. package/dist/web/InputNumber/utils/decimal.mjs +81 -109
  38. package/dist/web/Modal/Modal.js +1 -84
  39. package/dist/web/Modal/Modal.mjs +49 -52
  40. package/dist/web/OverlayScrollbar/BOverlayScrollbar.js +1 -232
  41. package/dist/web/OverlayScrollbar/BOverlayScrollbar.mjs +125 -206
  42. package/dist/web/Pagination/Pagination.js +1 -328
  43. package/dist/web/Pagination/Pagination.mjs +178 -254
  44. package/dist/web/ProductField/ProductField.js +1 -272
  45. package/dist/web/ProductField/ProductField.mjs +143 -190
  46. package/dist/web/ProductField/arrow-up.svg.js +1 -3
  47. package/dist/web/ProductField/arrow-up.svg.mjs +2 -2
  48. package/dist/web/ProductField/checkbox-no.svg.js +1 -3
  49. package/dist/web/ProductField/checkbox-no.svg.mjs +2 -2
  50. package/dist/web/ProductField/checkbox-ok.svg.js +1 -3
  51. package/dist/web/ProductField/checkbox-ok.svg.mjs +2 -2
  52. package/dist/web/ProductField/no_data_light.svg.js +1 -3
  53. package/dist/web/ProductField/no_data_light.svg.mjs +2 -2
  54. package/dist/web/ProductField/search.svg.js +1 -3
  55. package/dist/web/ProductField/search.svg.mjs +2 -2
  56. package/dist/web/ProductField/sort.svg.js +1 -3
  57. package/dist/web/ProductField/sort.svg.mjs +2 -2
  58. package/dist/web/SkuInputCard/SkuInputCard.js +1 -276
  59. package/dist/web/SkuInputCard/SkuInputCard.mjs +149 -188
  60. package/dist/web/SkuInputCard/spin_loading_red.gif.js +1 -3
  61. package/dist/web/SkuInputCard/spin_loading_red.gif.mjs +2 -2
  62. package/dist/web/Switch/Switch.js +1 -70
  63. package/dist/web/Switch/Switch.mjs +37 -47
  64. package/dist/web/Table/BTable.js +1 -950
  65. package/dist/web/Table/BTable.mjs +521 -767
  66. package/dist/web/Table/Column.js +1 -5
  67. package/dist/web/Table/Column.mjs +2 -2
  68. package/dist/web/Table/ColumnGroup.js +1 -5
  69. package/dist/web/Table/ColumnGroup.mjs +2 -2
  70. package/dist/web/Table/utils/columns.js +1 -48
  71. package/dist/web/Table/utils/columns.mjs +30 -35
  72. package/dist/web/Table/utils/sortFilter.js +1 -84
  73. package/dist/web/Table/utils/sortFilter.mjs +52 -73
  74. package/dist/web/Tabs/BTabs.js +1 -150
  75. package/dist/web/Tabs/BTabs.mjs +98 -118
  76. package/dist/web/Tabs/TabPane.js +1 -8
  77. package/dist/web/Tabs/TabPane.mjs +4 -4
  78. package/dist/web/Tooltip/ConfirmTooltip.js +1 -26
  79. package/dist/web/Tooltip/ConfirmTooltip.mjs +19 -20
  80. package/dist/web/Tooltip/ContentTooltip.js +1 -94
  81. package/dist/web/Tooltip/ContentTooltip.mjs +62 -72
  82. package/dist/web/Tooltip/ProgressTooltip.js +1 -36
  83. package/dist/web/Tooltip/ProgressTooltip.mjs +20 -22
  84. package/dist/web/Tooltip/TooltipWrapper.js +1 -12
  85. package/dist/web/Tooltip/TooltipWrapper.mjs +8 -8
  86. package/dist/web/Tooltip/useAutoPlacement.js +1 -41
  87. package/dist/web/Tooltip/useAutoPlacement.mjs +25 -34
  88. package/dist/web.js +1 -51
  89. package/dist/web.mjs +49 -49
  90. package/package.json +1 -1
@@ -1,181 +1 @@
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
+ "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,8 +1,8 @@
1
- import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
- import { forwardRef } from "react";
1
+ import { jsxs as i, jsx as t, Fragment as H } from "react/jsx-runtime";
2
+ import { forwardRef as I } from "react";
3
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(
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(
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 ArrowUp() {
10
10
  }
11
11
  ) });
12
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(
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(
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,164 +19,155 @@ function ArrowDown() {
19
19
  }
20
20
  ) });
21
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" })
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" })
26
26
  ] });
27
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));
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));
66
62
  }
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 = [
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 = [
72
64
  "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
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
86
77
  ] }),
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(
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(
91
82
  "textarea",
92
83
  {
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
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
102
93
  }
103
- ) : type === "number" ? /* @__PURE__ */ jsxs(Fragment, { children: [
104
- /* @__PURE__ */ jsx(
94
+ ) : e === "number" ? /* @__PURE__ */ i(H, { children: [
95
+ /* @__PURE__ */ t(
105
96
  "input",
106
97
  {
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,
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,
115
106
  inputMode: "numeric"
116
107
  }
117
108
  ),
118
- /* @__PURE__ */ jsxs("div", { className: "bu-input__stepper", children: [
119
- /* @__PURE__ */ jsx(
109
+ /* @__PURE__ */ i("div", { className: "bu-input__stepper", children: [
110
+ /* @__PURE__ */ t(
120
111
  "button",
121
112
  {
122
113
  type: "button",
123
114
  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,
115
+ onMouseDown: (n) => n.preventDefault(),
116
+ onClick: () => D(B),
117
+ disabled: o || _ !== void 0 && parseFloat(u || "0") >= _,
127
118
  tabIndex: -1,
128
- children: /* @__PURE__ */ jsx(ArrowUp, {})
119
+ children: /* @__PURE__ */ t(R, {})
129
120
  }
130
121
  ),
131
- /* @__PURE__ */ jsx(
122
+ /* @__PURE__ */ t(
132
123
  "button",
133
124
  {
134
125
  type: "button",
135
126
  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,
127
+ onMouseDown: (n) => n.preventDefault(),
128
+ onClick: () => D(-B),
129
+ disabled: o || a !== void 0 && parseFloat(u || "0") <= a,
139
130
  tabIndex: -1,
140
- children: /* @__PURE__ */ jsx(ArrowDown, {})
131
+ children: /* @__PURE__ */ t(T, {})
141
132
  }
142
133
  )
143
134
  ] })
144
- ] }) : /* @__PURE__ */ jsx(
135
+ ] }) : /* @__PURE__ */ t(
145
136
  "input",
146
137
  {
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
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
156
147
  }
157
148
  ),
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" }) }),
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" }) }),
162
153
  "翻译中…"
163
154
  ] }),
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" }) }),
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" }) }),
166
157
  "翻译完成"
167
158
  ] }),
168
- mode === "bilingual" && !translating && !translated && (langToggle ?? /* @__PURE__ */ jsx("div", { className: "bu-input__lang-toggle" }))
159
+ N === "bilingual" && !p && !m && (z ?? /* @__PURE__ */ t("div", { className: "bu-input__lang-toggle" }))
169
160
  ] })
170
161
  ] }),
171
- rightIcon && /* @__PURE__ */ jsx("span", { className: "bu-input__icon bu-input__icon--right", children: rightIcon })
162
+ w && /* @__PURE__ */ t("span", { className: "bu-input__icon bu-input__icon--right", children: w })
172
163
  ] }),
173
- showErrorMsg && /* @__PURE__ */ jsxs("div", { className: "bu-input__error-msg", children: [
174
- /* @__PURE__ */ jsx(ErrorIcon, {}),
175
- errorMessage
164
+ S && /* @__PURE__ */ i("div", { className: "bu-input__error-msg", children: [
165
+ /* @__PURE__ */ t(U, {}),
166
+ M
176
167
  ] })
177
168
  ] });
178
169
  }
179
170
  );
180
171
  export {
181
- BuInput as default
172
+ X as default
182
173
  };