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,208 +1 @@
1
- "use strict";
2
- const jsxRuntime = require("react/jsx-runtime");
3
- const react = require("react");
4
- const utils = require("./utils.js");
5
- ;/* empty css */
6
- function classNames(...values) {
7
- return values.filter(Boolean).join(" ");
8
- }
9
- function BaseInput({
10
- addonAfter,
11
- addonBefore,
12
- allowClear,
13
- children,
14
- className,
15
- disabled,
16
- focused,
17
- handleReset,
18
- onClear,
19
- prefix,
20
- readOnly,
21
- size,
22
- status,
23
- suffix,
24
- triggerInputFocus,
25
- value
26
- }) {
27
- const containerRef = react.useRef(null);
28
- const hasAffix = utils.hasPrefixSuffix({ prefix, suffix, allowClear });
29
- const inputElement = react.cloneElement(children, { value });
30
- let element = inputElement;
31
- if (hasAffix) {
32
- const needClear = Boolean(allowClear && !disabled && !readOnly && value);
33
- const clearIcon = typeof allowClear === "object" && allowClear.clearIcon ? allowClear.clearIcon : "×";
34
- element = /* @__PURE__ */ jsxRuntime.jsxs(
35
- "span",
36
- {
37
- className: classNames(
38
- "bj-input__affix-wrapper",
39
- disabled && "bj-input__affix-wrapper--disabled",
40
- focused && "bj-input__affix-wrapper--focused",
41
- readOnly && "bj-input__affix-wrapper--readonly",
42
- size && `bj-input__affix-wrapper--${size}`,
43
- status && `bj-input__affix-wrapper--${status}`
44
- ),
45
- onClick: triggerInputFocus,
46
- ref: containerRef,
47
- children: [
48
- prefix && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bj-input__prefix", children: prefix }),
49
- inputElement,
50
- (suffix || allowClear) && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "bj-input__suffix", children: [
51
- allowClear && /* @__PURE__ */ jsxRuntime.jsx(
52
- "button",
53
- {
54
- "aria-label": "清除输入内容",
55
- className: classNames("bj-input__clear-icon", !needClear && "bj-input__clear-icon--hidden"),
56
- onClick: (event) => {
57
- handleReset(event);
58
- onClear == null ? void 0 : onClear();
59
- },
60
- onMouseDown: (event) => event.preventDefault(),
61
- tabIndex: -1,
62
- type: "button",
63
- children: clearIcon
64
- }
65
- ),
66
- suffix
67
- ] })
68
- ]
69
- }
70
- );
71
- }
72
- if (utils.hasAddon({ addonBefore, addonAfter })) {
73
- element = /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bj-input__group-wrapper", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "bj-input__group", children: [
74
- addonBefore && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bj-input__group-addon", children: addonBefore }),
75
- element,
76
- addonAfter && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bj-input__group-addon", children: addonAfter })
77
- ] }) });
78
- }
79
- return react.cloneElement(element, { className: classNames(element.props.className, className) });
80
- }
81
- const BInput = react.forwardRef((props, ref) => {
82
- const {
83
- addonAfter,
84
- addonBefore,
85
- allowClear,
86
- bordered = true,
87
- className,
88
- defaultValue,
89
- disabled,
90
- htmlSize,
91
- onBlur,
92
- onChange,
93
- onClear,
94
- onCompositionEnd,
95
- onCompositionStart,
96
- onFocus,
97
- onKeyDown,
98
- onKeyUp,
99
- onPressEnter,
100
- prefix,
101
- readOnly,
102
- size = "middle",
103
- status,
104
- suffix,
105
- type = "text",
106
- value: controlledValue,
107
- ...restProps
108
- } = props;
109
- const [focused, setFocused] = react.useState(false);
110
- const [innerValue, setInnerValue] = react.useState(defaultValue);
111
- const inputRef = react.useRef(null);
112
- const compositionRef = react.useRef(false);
113
- const keyLockRef = react.useRef(false);
114
- const hasAffix = utils.hasPrefixSuffix({ prefix, suffix, allowClear });
115
- const value = controlledValue === void 0 ? innerValue : controlledValue;
116
- const formattedValue = value === void 0 || value === null ? "" : String(value);
117
- react.useImperativeHandle(ref, () => ({
118
- focus: (option) => utils.triggerFocus(inputRef.current, option),
119
- blur: () => {
120
- var _a;
121
- return (_a = inputRef.current) == null ? void 0 : _a.blur();
122
- },
123
- setSelectionRange: (...argumentsList) => {
124
- var _a;
125
- return (_a = inputRef.current) == null ? void 0 : _a.setSelectionRange(...argumentsList);
126
- },
127
- select: () => {
128
- var _a;
129
- return (_a = inputRef.current) == null ? void 0 : _a.select();
130
- },
131
- input: inputRef.current,
132
- nativeElement: inputRef.current
133
- }));
134
- react.useEffect(() => setFocused((previous) => previous && !disabled), [disabled]);
135
- const triggerChange = (event, nextValue, source) => {
136
- if (source === "compositionEnd") return;
137
- if (controlledValue === void 0) setInnerValue(nextValue);
138
- if (inputRef.current) utils.resolveOnChange(inputRef.current, event, onChange, nextValue);
139
- };
140
- const input = /* @__PURE__ */ jsxRuntime.jsx(
141
- "input",
142
- {
143
- ...restProps,
144
- className: classNames("bj-input", `bj-input--${size}`, focused && !hasAffix && "bj-input--focused", status && `bj-input--${status}`, !bordered && "bj-input--borderless", disabled && "bj-input--disabled"),
145
- disabled,
146
- onBlur: (event) => {
147
- keyLockRef.current = false;
148
- setFocused(false);
149
- onBlur == null ? void 0 : onBlur(event);
150
- },
151
- onChange: (event) => triggerChange(event, event.target.value, "change"),
152
- onCompositionEnd: (event) => {
153
- compositionRef.current = false;
154
- triggerChange(event, event.currentTarget.value, "compositionEnd");
155
- onCompositionEnd == null ? void 0 : onCompositionEnd(event);
156
- },
157
- onCompositionStart: (event) => {
158
- compositionRef.current = true;
159
- onCompositionStart == null ? void 0 : onCompositionStart(event);
160
- },
161
- onFocus: (event) => {
162
- setFocused(true);
163
- onFocus == null ? void 0 : onFocus(event);
164
- },
165
- onKeyDown: (event) => {
166
- if (onPressEnter && event.key === "Enter" && !keyLockRef.current) {
167
- keyLockRef.current = true;
168
- onPressEnter(event);
169
- }
170
- onKeyDown == null ? void 0 : onKeyDown(event);
171
- },
172
- onKeyUp: (event) => {
173
- if (event.key === "Enter") keyLockRef.current = false;
174
- onKeyUp == null ? void 0 : onKeyUp(event);
175
- },
176
- ref: inputRef,
177
- size: htmlSize,
178
- type
179
- }
180
- );
181
- return /* @__PURE__ */ jsxRuntime.jsx(
182
- BaseInput,
183
- {
184
- addonAfter,
185
- addonBefore,
186
- allowClear,
187
- className,
188
- disabled,
189
- focused,
190
- handleReset: (event) => {
191
- if (controlledValue === void 0) setInnerValue("");
192
- utils.triggerFocus(inputRef.current);
193
- if (inputRef.current) utils.resolveOnChange(inputRef.current, event, onChange);
194
- },
195
- onClear,
196
- prefix,
197
- readOnly,
198
- size,
199
- status,
200
- suffix,
201
- triggerInputFocus: () => utils.triggerFocus(inputRef.current),
202
- value: formattedValue,
203
- children: input
204
- }
205
- );
206
- });
207
- BInput.displayName = "BInput";
208
- module.exports = BInput;
1
+ "use strict";const r=require("react/jsx-runtime"),t=require("react"),i=require("./utils.js");;/* empty css */function v(...a){return a.filter(Boolean).join(" ")}function K({addonAfter:a,addonBefore:d,allowClear:s,children:k,className:N,disabled:R,focused:F,handleReset:q,onClear:u,prefix:j,readOnly:p,size:b,status:E,suffix:o,triggerInputFocus:_,value:f}){const m=t.useRef(null),g=i.hasPrefixSuffix({prefix:j,suffix:o,allowClear:s}),x=t.cloneElement(k,{value:f});let c=x;if(g){const w=!!(s&&!R&&!p&&f),I=typeof s=="object"&&s.clearIcon?s.clearIcon:"×";c=r.jsxs("span",{className:v("bj-input__affix-wrapper",R&&"bj-input__affix-wrapper--disabled",F&&"bj-input__affix-wrapper--focused",p&&"bj-input__affix-wrapper--readonly",b&&`bj-input__affix-wrapper--${b}`,E&&`bj-input__affix-wrapper--${E}`),onClick:_,ref:m,children:[j&&r.jsx("span",{className:"bj-input__prefix",children:j}),x,(o||s)&&r.jsxs("span",{className:"bj-input__suffix",children:[s&&r.jsx("button",{"aria-label":"清除输入内容",className:v("bj-input__clear-icon",!w&&"bj-input__clear-icon--hidden"),onClick:l=>{q(l),u==null||u()},onMouseDown:l=>l.preventDefault(),tabIndex:-1,type:"button",children:I}),o]})]})}return i.hasAddon({addonBefore:d,addonAfter:a})&&(c=r.jsx("span",{className:"bj-input__group-wrapper",children:r.jsxs("span",{className:"bj-input__group",children:[d&&r.jsx("span",{className:"bj-input__group-addon",children:d}),c,a&&r.jsx("span",{className:"bj-input__group-addon",children:a})]})})),t.cloneElement(c,{className:v(c.props.className,N)})}const O=t.forwardRef((a,d)=>{const{addonAfter:s,addonBefore:k,allowClear:N,bordered:R=!0,className:F,defaultValue:q,disabled:u,htmlSize:j,onBlur:p,onChange:b,onClear:E,onCompositionEnd:o,onCompositionStart:_,onFocus:f,onKeyDown:m,onKeyUp:g,onPressEnter:x,prefix:c,readOnly:w,size:I="middle",status:l,suffix:V,type:H="text",value:y,...L}=a,[$,B]=t.useState(!1),[M,z]=t.useState(q),n=t.useRef(null),A=t.useRef(!1),S=t.useRef(!1),T=i.hasPrefixSuffix({prefix:c,suffix:V,allowClear:N}),P=y===void 0?M:y,C=P==null?"":String(P);t.useImperativeHandle(d,()=>({focus:e=>i.triggerFocus(n.current,e),blur:()=>{var e;return(e=n.current)==null?void 0:e.blur()},setSelectionRange:(...e)=>{var h;return(h=n.current)==null?void 0:h.setSelectionRange(...e)},select:()=>{var e;return(e=n.current)==null?void 0:e.select()},input:n.current,nativeElement:n.current})),t.useEffect(()=>B(e=>e&&!u),[u]);const D=(e,h,J)=>{J!=="compositionEnd"&&(y===void 0&&z(h),n.current&&i.resolveOnChange(n.current,e,b,h))},G=r.jsx("input",{...L,className:v("bj-input",`bj-input--${I}`,$&&!T&&"bj-input--focused",l&&`bj-input--${l}`,!R&&"bj-input--borderless",u&&"bj-input--disabled"),disabled:u,onBlur:e=>{S.current=!1,B(!1),p==null||p(e)},onChange:e=>D(e,e.target.value,"change"),onCompositionEnd:e=>{A.current=!1,D(e,e.currentTarget.value,"compositionEnd"),o==null||o(e)},onCompositionStart:e=>{A.current=!0,_==null||_(e)},onFocus:e=>{B(!0),f==null||f(e)},onKeyDown:e=>{x&&e.key==="Enter"&&!S.current&&(S.current=!0,x(e)),m==null||m(e)},onKeyUp:e=>{e.key==="Enter"&&(S.current=!1),g==null||g(e)},ref:n,size:j,type:H});return r.jsx(K,{addonAfter:s,addonBefore:k,allowClear:N,className:F,disabled:u,focused:$,handleReset:e=>{y===void 0&&z(""),i.triggerFocus(n.current),n.current&&i.resolveOnChange(n.current,e,b)},onClear:E,prefix:c,readOnly:w,size:I,status:l,suffix:V,triggerInputFocus:()=>i.triggerFocus(n.current),value:C,children:G})});O.displayName="BInput";module.exports=O;
@@ -1,209 +1,177 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { forwardRef, useState, useRef, useImperativeHandle, useEffect, cloneElement } from "react";
3
- import { triggerFocus, resolveOnChange, hasPrefixSuffix, hasAddon } from "./utils.mjs";
1
+ import { jsx as a, jsxs as F } from "react/jsx-runtime";
2
+ import { forwardRef as Y, useState as M, useRef as y, useImperativeHandle as Z, useEffect as C, cloneElement as O } from "react";
3
+ import { triggerFocus as P, resolveOnChange as T, hasPrefixSuffix as q, hasAddon as ee } from "./utils.mjs";
4
4
  /* empty css */
5
- function classNames(...values) {
6
- return values.filter(Boolean).join(" ");
5
+ function k(...c) {
6
+ return c.filter(Boolean).join(" ");
7
7
  }
8
- function BaseInput({
9
- addonAfter,
10
- addonBefore,
11
- allowClear,
12
- children,
13
- className,
14
- disabled,
15
- focused,
16
- handleReset,
17
- onClear,
18
- prefix,
19
- readOnly,
20
- size,
21
- status,
22
- suffix,
23
- triggerInputFocus,
24
- value
8
+ function ne({
9
+ addonAfter: c,
10
+ addonBefore: l,
11
+ allowClear: t,
12
+ children: v,
13
+ className: g,
14
+ disabled: x,
15
+ focused: S,
16
+ handleReset: w,
17
+ onClear: r,
18
+ prefix: f,
19
+ readOnly: o,
20
+ size: d,
21
+ status: N,
22
+ suffix: i,
23
+ triggerInputFocus: m,
24
+ value: p
25
25
  }) {
26
- const containerRef = useRef(null);
27
- const hasAffix = hasPrefixSuffix({ prefix, suffix, allowClear });
28
- const inputElement = cloneElement(children, { value });
29
- let element = inputElement;
30
- if (hasAffix) {
31
- const needClear = Boolean(allowClear && !disabled && !readOnly && value);
32
- const clearIcon = typeof allowClear === "object" && allowClear.clearIcon ? allowClear.clearIcon : "×";
33
- element = /* @__PURE__ */ jsxs(
26
+ const b = y(null), _ = q({ prefix: f, suffix: i, allowClear: t }), j = O(v, { value: p });
27
+ let s = j;
28
+ if (_) {
29
+ const B = !!(t && !x && !o && p), I = typeof t == "object" && t.clearIcon ? t.clearIcon : "×";
30
+ s = /* @__PURE__ */ F(
34
31
  "span",
35
32
  {
36
- className: classNames(
33
+ className: k(
37
34
  "bj-input__affix-wrapper",
38
- disabled && "bj-input__affix-wrapper--disabled",
39
- focused && "bj-input__affix-wrapper--focused",
40
- readOnly && "bj-input__affix-wrapper--readonly",
41
- size && `bj-input__affix-wrapper--${size}`,
42
- status && `bj-input__affix-wrapper--${status}`
35
+ x && "bj-input__affix-wrapper--disabled",
36
+ S && "bj-input__affix-wrapper--focused",
37
+ o && "bj-input__affix-wrapper--readonly",
38
+ d && `bj-input__affix-wrapper--${d}`,
39
+ N && `bj-input__affix-wrapper--${N}`
43
40
  ),
44
- onClick: triggerInputFocus,
45
- ref: containerRef,
41
+ onClick: m,
42
+ ref: b,
46
43
  children: [
47
- prefix && /* @__PURE__ */ jsx("span", { className: "bj-input__prefix", children: prefix }),
48
- inputElement,
49
- (suffix || allowClear) && /* @__PURE__ */ jsxs("span", { className: "bj-input__suffix", children: [
50
- allowClear && /* @__PURE__ */ jsx(
44
+ f && /* @__PURE__ */ a("span", { className: "bj-input__prefix", children: f }),
45
+ j,
46
+ (i || t) && /* @__PURE__ */ F("span", { className: "bj-input__suffix", children: [
47
+ t && /* @__PURE__ */ a(
51
48
  "button",
52
49
  {
53
50
  "aria-label": "清除输入内容",
54
- className: classNames("bj-input__clear-icon", !needClear && "bj-input__clear-icon--hidden"),
55
- onClick: (event) => {
56
- handleReset(event);
57
- onClear == null ? void 0 : onClear();
51
+ className: k("bj-input__clear-icon", !B && "bj-input__clear-icon--hidden"),
52
+ onClick: (u) => {
53
+ w(u), r == null || r();
58
54
  },
59
- onMouseDown: (event) => event.preventDefault(),
55
+ onMouseDown: (u) => u.preventDefault(),
60
56
  tabIndex: -1,
61
57
  type: "button",
62
- children: clearIcon
58
+ children: I
63
59
  }
64
60
  ),
65
- suffix
61
+ i
66
62
  ] })
67
63
  ]
68
64
  }
69
65
  );
70
66
  }
71
- if (hasAddon({ addonBefore, addonAfter })) {
72
- element = /* @__PURE__ */ jsx("span", { className: "bj-input__group-wrapper", children: /* @__PURE__ */ jsxs("span", { className: "bj-input__group", children: [
73
- addonBefore && /* @__PURE__ */ jsx("span", { className: "bj-input__group-addon", children: addonBefore }),
74
- element,
75
- addonAfter && /* @__PURE__ */ jsx("span", { className: "bj-input__group-addon", children: addonAfter })
76
- ] }) });
77
- }
78
- return cloneElement(element, { className: classNames(element.props.className, className) });
67
+ return ee({ addonBefore: l, addonAfter: c }) && (s = /* @__PURE__ */ a("span", { className: "bj-input__group-wrapper", children: /* @__PURE__ */ F("span", { className: "bj-input__group", children: [
68
+ l && /* @__PURE__ */ a("span", { className: "bj-input__group-addon", children: l }),
69
+ s,
70
+ c && /* @__PURE__ */ a("span", { className: "bj-input__group-addon", children: c })
71
+ ] }) })), O(s, { className: k(s.props.className, g) });
79
72
  }
80
- const BInput = forwardRef((props, ref) => {
73
+ const te = Y((c, l) => {
81
74
  const {
82
- addonAfter,
83
- addonBefore,
84
- allowClear,
85
- bordered = true,
86
- className,
87
- defaultValue,
88
- disabled,
89
- htmlSize,
90
- onBlur,
91
- onChange,
92
- onClear,
93
- onCompositionEnd,
94
- onCompositionStart,
95
- onFocus,
96
- onKeyDown,
97
- onKeyUp,
98
- onPressEnter,
99
- prefix,
100
- readOnly,
101
- size = "middle",
102
- status,
103
- suffix,
104
- type = "text",
105
- value: controlledValue,
106
- ...restProps
107
- } = props;
108
- const [focused, setFocused] = useState(false);
109
- const [innerValue, setInnerValue] = useState(defaultValue);
110
- const inputRef = useRef(null);
111
- const compositionRef = useRef(false);
112
- const keyLockRef = useRef(false);
113
- const hasAffix = hasPrefixSuffix({ prefix, suffix, allowClear });
114
- const value = controlledValue === void 0 ? innerValue : controlledValue;
115
- const formattedValue = value === void 0 || value === null ? "" : String(value);
116
- useImperativeHandle(ref, () => ({
117
- focus: (option) => triggerFocus(inputRef.current, option),
75
+ addonAfter: t,
76
+ addonBefore: v,
77
+ allowClear: g,
78
+ bordered: x = !0,
79
+ className: S,
80
+ defaultValue: w,
81
+ disabled: r,
82
+ htmlSize: f,
83
+ onBlur: o,
84
+ onChange: d,
85
+ onClear: N,
86
+ onCompositionEnd: i,
87
+ onCompositionStart: m,
88
+ onFocus: p,
89
+ onKeyDown: b,
90
+ onKeyUp: _,
91
+ onPressEnter: j,
92
+ prefix: s,
93
+ readOnly: B,
94
+ size: I = "middle",
95
+ status: u,
96
+ suffix: z,
97
+ type: G = "text",
98
+ value: E,
99
+ ...J
100
+ } = c, [A, V] = M(!1), [K, D] = M(w), n = y(null), H = y(!1), R = y(!1), Q = q({ prefix: s, suffix: z, allowClear: g }), $ = E === void 0 ? K : E, U = $ == null ? "" : String($);
101
+ Z(l, () => ({
102
+ focus: (e) => P(n.current, e),
118
103
  blur: () => {
119
- var _a;
120
- return (_a = inputRef.current) == null ? void 0 : _a.blur();
104
+ var e;
105
+ return (e = n.current) == null ? void 0 : e.blur();
121
106
  },
122
- setSelectionRange: (...argumentsList) => {
123
- var _a;
124
- return (_a = inputRef.current) == null ? void 0 : _a.setSelectionRange(...argumentsList);
107
+ setSelectionRange: (...e) => {
108
+ var h;
109
+ return (h = n.current) == null ? void 0 : h.setSelectionRange(...e);
125
110
  },
126
111
  select: () => {
127
- var _a;
128
- return (_a = inputRef.current) == null ? void 0 : _a.select();
112
+ var e;
113
+ return (e = n.current) == null ? void 0 : e.select();
129
114
  },
130
- input: inputRef.current,
131
- nativeElement: inputRef.current
132
- }));
133
- useEffect(() => setFocused((previous) => previous && !disabled), [disabled]);
134
- const triggerChange = (event, nextValue, source) => {
135
- if (source === "compositionEnd") return;
136
- if (controlledValue === void 0) setInnerValue(nextValue);
137
- if (inputRef.current) resolveOnChange(inputRef.current, event, onChange, nextValue);
138
- };
139
- const input = /* @__PURE__ */ jsx(
115
+ input: n.current,
116
+ nativeElement: n.current
117
+ })), C(() => V((e) => e && !r), [r]);
118
+ const L = (e, h, X) => {
119
+ X !== "compositionEnd" && (E === void 0 && D(h), n.current && T(n.current, e, d, h));
120
+ }, W = /* @__PURE__ */ a(
140
121
  "input",
141
122
  {
142
- ...restProps,
143
- className: classNames("bj-input", `bj-input--${size}`, focused && !hasAffix && "bj-input--focused", status && `bj-input--${status}`, !bordered && "bj-input--borderless", disabled && "bj-input--disabled"),
144
- disabled,
145
- onBlur: (event) => {
146
- keyLockRef.current = false;
147
- setFocused(false);
148
- onBlur == null ? void 0 : onBlur(event);
123
+ ...J,
124
+ className: k("bj-input", `bj-input--${I}`, A && !Q && "bj-input--focused", u && `bj-input--${u}`, !x && "bj-input--borderless", r && "bj-input--disabled"),
125
+ disabled: r,
126
+ onBlur: (e) => {
127
+ R.current = !1, V(!1), o == null || o(e);
149
128
  },
150
- onChange: (event) => triggerChange(event, event.target.value, "change"),
151
- onCompositionEnd: (event) => {
152
- compositionRef.current = false;
153
- triggerChange(event, event.currentTarget.value, "compositionEnd");
154
- onCompositionEnd == null ? void 0 : onCompositionEnd(event);
129
+ onChange: (e) => L(e, e.target.value, "change"),
130
+ onCompositionEnd: (e) => {
131
+ H.current = !1, L(e, e.currentTarget.value, "compositionEnd"), i == null || i(e);
155
132
  },
156
- onCompositionStart: (event) => {
157
- compositionRef.current = true;
158
- onCompositionStart == null ? void 0 : onCompositionStart(event);
133
+ onCompositionStart: (e) => {
134
+ H.current = !0, m == null || m(e);
159
135
  },
160
- onFocus: (event) => {
161
- setFocused(true);
162
- onFocus == null ? void 0 : onFocus(event);
136
+ onFocus: (e) => {
137
+ V(!0), p == null || p(e);
163
138
  },
164
- onKeyDown: (event) => {
165
- if (onPressEnter && event.key === "Enter" && !keyLockRef.current) {
166
- keyLockRef.current = true;
167
- onPressEnter(event);
168
- }
169
- onKeyDown == null ? void 0 : onKeyDown(event);
139
+ onKeyDown: (e) => {
140
+ j && e.key === "Enter" && !R.current && (R.current = !0, j(e)), b == null || b(e);
170
141
  },
171
- onKeyUp: (event) => {
172
- if (event.key === "Enter") keyLockRef.current = false;
173
- onKeyUp == null ? void 0 : onKeyUp(event);
142
+ onKeyUp: (e) => {
143
+ e.key === "Enter" && (R.current = !1), _ == null || _(e);
174
144
  },
175
- ref: inputRef,
176
- size: htmlSize,
177
- type
145
+ ref: n,
146
+ size: f,
147
+ type: G
178
148
  }
179
149
  );
180
- return /* @__PURE__ */ jsx(
181
- BaseInput,
150
+ return /* @__PURE__ */ a(
151
+ ne,
182
152
  {
183
- addonAfter,
184
- addonBefore,
185
- allowClear,
186
- className,
187
- disabled,
188
- focused,
189
- handleReset: (event) => {
190
- if (controlledValue === void 0) setInnerValue("");
191
- triggerFocus(inputRef.current);
192
- if (inputRef.current) resolveOnChange(inputRef.current, event, onChange);
153
+ addonAfter: t,
154
+ addonBefore: v,
155
+ allowClear: g,
156
+ className: S,
157
+ disabled: r,
158
+ focused: A,
159
+ handleReset: (e) => {
160
+ E === void 0 && D(""), P(n.current), n.current && T(n.current, e, d);
193
161
  },
194
- onClear,
195
- prefix,
196
- readOnly,
197
- size,
198
- status,
199
- suffix,
200
- triggerInputFocus: () => triggerFocus(inputRef.current),
201
- value: formattedValue,
202
- children: input
162
+ onClear: N,
163
+ prefix: s,
164
+ readOnly: B,
165
+ size: I,
166
+ status: u,
167
+ suffix: z,
168
+ triggerInputFocus: () => P(n.current),
169
+ value: U,
170
+ children: W
203
171
  }
204
172
  );
205
173
  });
206
- BInput.displayName = "BInput";
174
+ te.displayName = "BInput";
207
175
  export {
208
- BInput as default
176
+ te as default
209
177
  };
@@ -1,47 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- function hasAddon(props) {
4
- return Boolean(props.addonBefore || props.addonAfter);
5
- }
6
- function hasPrefixSuffix(props) {
7
- return Boolean(props.prefix || props.suffix || props.allowClear);
8
- }
9
- function cloneEvent(event, target, value) {
10
- const currentTarget = target.cloneNode(true);
11
- const nextEvent = Object.create(event, {
12
- target: { value: currentTarget },
13
- currentTarget: { value: currentTarget }
14
- });
15
- currentTarget.value = value;
16
- if (typeof target.selectionStart === "number" && typeof target.selectionEnd === "number") {
17
- currentTarget.selectionStart = target.selectionStart;
18
- currentTarget.selectionEnd = target.selectionEnd;
19
- }
20
- currentTarget.setSelectionRange = (...argumentsList) => target.setSelectionRange(...argumentsList);
21
- return nextEvent;
22
- }
23
- function resolveOnChange(target, event, onChange, targetValue) {
24
- if (!onChange) return;
25
- if (event.type === "click") {
26
- onChange(cloneEvent(event, target, ""));
27
- return;
28
- }
29
- if (target.type !== "file" && targetValue !== void 0) {
30
- onChange(cloneEvent(event, target, targetValue));
31
- return;
32
- }
33
- onChange(event);
34
- }
35
- function triggerFocus(element, option) {
36
- if (!element) return;
37
- element.focus(option);
38
- if (!(option == null ? void 0 : option.cursor)) return;
39
- const length = element.value.length;
40
- if (option.cursor === "start") element.setSelectionRange(0, 0);
41
- else if (option.cursor === "end") element.setSelectionRange(length, length);
42
- else element.setSelectionRange(0, length);
43
- }
44
- exports.hasAddon = hasAddon;
45
- exports.hasPrefixSuffix = hasPrefixSuffix;
46
- exports.resolveOnChange = resolveOnChange;
47
- exports.triggerFocus = triggerFocus;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function f(e){return!!(e.addonBefore||e.addonAfter)}function s(e){return!!(e.prefix||e.suffix||e.allowClear)}function c(e,n,r){const t=n.cloneNode(!0),u=Object.create(e,{target:{value:t},currentTarget:{value:t}});return t.value=r,typeof n.selectionStart=="number"&&typeof n.selectionEnd=="number"&&(t.selectionStart=n.selectionStart,t.selectionEnd=n.selectionEnd),t.setSelectionRange=(...i)=>n.setSelectionRange(...i),u}function l(e,n,r,t){if(r){if(n.type==="click"){r(c(n,e,""));return}if(e.type!=="file"&&t!==void 0){r(c(n,e,t));return}r(n)}}function o(e,n){if(!e||(e.focus(n),!(n!=null&&n.cursor)))return;const r=e.value.length;n.cursor==="start"?e.setSelectionRange(0,0):n.cursor==="end"?e.setSelectionRange(r,r):e.setSelectionRange(0,r)}exports.hasAddon=f;exports.hasPrefixSuffix=s;exports.resolveOnChange=l;exports.triggerFocus=o;