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,49 +1,56 @@
1
- import { jsxs as r, jsx as l } from "react/jsx-runtime";
2
- import { useRef as M, useState as j } from "react";
3
- import { createPortal as Y } from "react-dom";
4
- import Z from "../BasicInput/BInput.mjs";
5
- import { BCheckBox as $ } from "../CheckBox/index.mjs";
6
- import V from "../Icon/Icon.mjs";
7
- import ee from "../OverlayScrollbar/BOverlayScrollbar.mjs";
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useRef, useState } from "react";
3
+ import { createPortal } from "react-dom";
4
+ import BInput from "../BasicInput/BInput.mjs";
5
+ import { BCheckBox as CompoundBCheckBox } from "../CheckBox/index.mjs";
6
+ import BuIcon from "../Icon/Icon.mjs";
7
+ import BOverlayScrollbar from "../OverlayScrollbar/BOverlayScrollbar.mjs";
8
8
  /* empty css */
9
- import le from "../Tooltip/ContentTooltip.mjs";
9
+ import BTooltip from "../Tooltip/ContentTooltip.mjs";
10
10
  import "../Tooltip/TooltipWrapper.mjs";
11
- import ne from "../ProductField/no_data_light.svg.mjs";
11
+ import defaultEmptyImage from "../ProductField/no_data_light.svg.mjs";
12
12
  /* empty css */
13
- function u(...n) {
14
- return n.filter(Boolean).join(" ");
13
+ function classNames(...values) {
14
+ return values.filter(Boolean).join(" ");
15
15
  }
16
- function te(n) {
17
- return typeof n.label == "string" || typeof n.label == "number" ? String(n.label) : String(n.value);
16
+ function getOptionText(option) {
17
+ return typeof option.label === "string" || typeof option.label === "number" ? String(option.label) : String(option.value);
18
18
  }
19
- function R({ option: n }) {
20
- const d = M(null), [p, i] = j(!1), [o, g] = j(null), b = typeof n.label == "string" || typeof n.label == "number", m = b ? String(n.label) : n.label;
21
- function f() {
22
- const a = d.current;
23
- b && a && a.scrollWidth > a.clientWidth && (g(a.getBoundingClientRect()), i(!0));
19
+ function TruncatedOptionLabel({ option }) {
20
+ const labelRef = useRef(null);
21
+ const [visible, setVisible] = useState(false);
22
+ const [anchorRect, setAnchorRect] = useState(null);
23
+ const isTextLabel = typeof option.label === "string" || typeof option.label === "number";
24
+ const label = isTextLabel ? String(option.label) : option.label;
25
+ function handleMouseEnter() {
26
+ const element = labelRef.current;
27
+ if (isTextLabel && element && element.scrollWidth > element.clientWidth) {
28
+ setAnchorRect(element.getBoundingClientRect());
29
+ setVisible(true);
30
+ }
24
31
  }
25
- return /* @__PURE__ */ r(
32
+ return /* @__PURE__ */ jsxs(
26
33
  "span",
27
34
  {
28
- ref: d,
35
+ ref: labelRef,
29
36
  className: "bj-dropdown__option-label",
30
- onMouseEnter: f,
31
- onMouseLeave: () => i(!1),
37
+ onMouseEnter: handleMouseEnter,
38
+ onMouseLeave: () => setVisible(false),
32
39
  children: [
33
- m,
34
- p && o && typeof document < "u" && Y(
35
- /* @__PURE__ */ l(
40
+ label,
41
+ visible && anchorRect && typeof document !== "undefined" && createPortal(
42
+ /* @__PURE__ */ jsx(
36
43
  "span",
37
44
  {
38
45
  className: "bj-dropdown__option-tooltip-anchor",
39
46
  style: {
40
47
  position: "fixed",
41
- top: o.top,
42
- left: o.left,
43
- width: o.width,
44
- height: o.height
48
+ top: anchorRect.top,
49
+ left: anchorRect.left,
50
+ width: anchorRect.width,
51
+ height: anchorRect.height
45
52
  },
46
- children: /* @__PURE__ */ l(le, { className: "bj-dropdown__option-tooltip", content: m, placement: "top" })
53
+ children: /* @__PURE__ */ jsx(BTooltip, { className: "bj-dropdown__option-tooltip", content: label, placement: "top" })
47
54
  }
48
55
  ),
49
56
  document.body
@@ -52,109 +59,128 @@ function R({ option: n }) {
52
59
  }
53
60
  );
54
61
  }
55
- function W({ option: n, doubleLine: d }) {
56
- return d ? /* @__PURE__ */ r("span", { className: "bj-dropdown__option-content", children: [
57
- /* @__PURE__ */ l(R, { option: n }),
58
- n.description !== void 0 && /* @__PURE__ */ l("span", { className: "bj-dropdown__option-description", children: n.description })
59
- ] }) : /* @__PURE__ */ l(R, { option: n });
62
+ function DefaultOptionContent({ option, doubleLine }) {
63
+ if (!doubleLine) return /* @__PURE__ */ jsx(TruncatedOptionLabel, { option });
64
+ return /* @__PURE__ */ jsxs("span", { className: "bj-dropdown__option-content", children: [
65
+ /* @__PURE__ */ jsx(TruncatedOptionLabel, { option }),
66
+ option.description !== void 0 && /* @__PURE__ */ jsx("span", { className: "bj-dropdown__option-description", children: option.description })
67
+ ] });
60
68
  }
61
- function _e({
62
- className: n,
63
- style: d,
64
- options: p,
65
- value: i,
66
- defaultValue: o = [],
67
- multiple: g = !1,
68
- optionMode: b = "single-line",
69
- searchable: m = !1,
70
- searchValue: f,
71
- searchPlaceholder: a = "搜索",
72
- onSearch: _,
73
- filterOption: y = !0,
74
- emptyText: z,
75
- labels: N,
76
- t: x = (w) => w,
77
- optionRender: h,
78
- onChange: B,
79
- footer: L = !0,
80
- showReset: A = !0,
81
- showConfirm: G = !0,
82
- resetText: P = x("重置"),
83
- confirmText: q = x("确定"),
84
- onReset: k,
85
- onConfirm: C
69
+ function BDropdown({
70
+ className,
71
+ style,
72
+ options,
73
+ value,
74
+ defaultValue = [],
75
+ multiple = false,
76
+ optionMode = "single-line",
77
+ searchable = false,
78
+ searchValue,
79
+ searchPlaceholder = "搜索",
80
+ onSearch,
81
+ filterOption = true,
82
+ emptyText,
83
+ labels,
84
+ t = (text) => text,
85
+ optionRender,
86
+ onChange,
87
+ footer = true,
88
+ showReset = true,
89
+ showConfirm = true,
90
+ resetText = t("重置"),
91
+ confirmText = t("确定"),
92
+ onReset,
93
+ onConfirm
86
94
  }) {
87
- const w = M(null), S = M(null), [F, E] = j(o), [H, J] = j(""), t = i ?? F, s = g === !0, c = b === "double-line", v = f ?? H, K = z ?? (N == null ? void 0 : N.emptyText) ?? x("暂无结果"), I = !_ && y !== !1 && v ? p.filter((e) => typeof y == "function" ? y(v, e) : te(e).toLocaleLowerCase().includes(v.toLocaleLowerCase())) : p;
88
- function Q(e, T) {
89
- i === void 0 && E(e), B == null || B(e, T);
95
+ const dropdownRef = useRef(null);
96
+ const optionsRef = useRef(null);
97
+ const [internalValue, setInternalValue] = useState(defaultValue);
98
+ const [internalSearchValue, setInternalSearchValue] = useState("");
99
+ const selectedValue = value ?? internalValue;
100
+ const isMultiple = multiple === true;
101
+ const isDoubleLine = optionMode === "double-line";
102
+ const currentSearchValue = searchValue ?? internalSearchValue;
103
+ const resolvedEmptyText = emptyText ?? (labels == null ? void 0 : labels.emptyText) ?? t("暂无结果");
104
+ const visibleOptions = !onSearch && filterOption !== false && currentSearchValue ? options.filter((option) => typeof filterOption === "function" ? filterOption(currentSearchValue, option) : getOptionText(option).toLocaleLowerCase().includes(currentSearchValue.toLocaleLowerCase())) : options;
105
+ function updateValue(nextValue, option) {
106
+ if (value === void 0) {
107
+ setInternalValue(nextValue);
108
+ }
109
+ onChange == null ? void 0 : onChange(nextValue, option);
90
110
  }
91
- function O(e) {
92
- f === void 0 && J(e), _ == null || _(e);
111
+ function handleSearch(nextSearchValue) {
112
+ if (searchValue === void 0) {
113
+ setInternalSearchValue(nextSearchValue);
114
+ }
115
+ onSearch == null ? void 0 : onSearch(nextSearchValue);
93
116
  }
94
- function D(e) {
95
- if (e.disabled) return;
96
- const T = s ? t.includes(e.value) ? t.filter((X) => X !== e.value) : [...t, e.value] : [e.value];
97
- Q(T, e);
117
+ function handleOptionChange(option) {
118
+ if (option.disabled) return;
119
+ const nextValue = isMultiple ? selectedValue.includes(option.value) ? selectedValue.filter((item) => item !== option.value) : [...selectedValue, option.value] : [option.value];
120
+ updateValue(nextValue, option);
98
121
  }
99
- function U() {
100
- i === void 0 && E([]), k == null || k();
122
+ function handleReset() {
123
+ if (value === void 0) {
124
+ setInternalValue([]);
125
+ }
126
+ onReset == null ? void 0 : onReset();
101
127
  }
102
- return /* @__PURE__ */ r("div", { ref: w, className: u("bj-dropdown", c && "bj-dropdown--double-line", !s && "bj-dropdown--single", n), role: "dialog", style: d, children: [
103
- m && /* @__PURE__ */ l("div", { className: "bj-dropdown__search", children: /* @__PURE__ */ l(
104
- Z,
128
+ return /* @__PURE__ */ jsxs("div", { ref: dropdownRef, className: classNames("bj-dropdown", isDoubleLine && "bj-dropdown--double-line", !isMultiple && "bj-dropdown--single", className), role: "dialog", style, children: [
129
+ searchable && /* @__PURE__ */ jsx("div", { className: "bj-dropdown__search", children: /* @__PURE__ */ jsx(
130
+ BInput,
105
131
  {
106
132
  "aria-label": "搜索选项",
107
- allowClear: { clearIcon: /* @__PURE__ */ l(V, { className: "bj-dropdown__search-clear-icon", type: "icon-a-guanbixi" }) },
108
- onChange: (e) => O(e.target.value),
109
- onClear: () => O(""),
110
- placeholder: a,
111
- prefix: /* @__PURE__ */ l(V, { type: "icon-a-sousuoxi" }),
133
+ allowClear: { clearIcon: /* @__PURE__ */ jsx(BuIcon, { className: "bj-dropdown__search-clear-icon", type: "icon-a-guanbixi" }) },
134
+ onChange: (event) => handleSearch(event.target.value),
135
+ onClear: () => handleSearch(""),
136
+ placeholder: searchPlaceholder,
137
+ prefix: /* @__PURE__ */ jsx(BuIcon, { type: "icon-a-sousuoxi" }),
112
138
  inputMode: "search",
113
139
  role: "searchbox",
114
140
  type: "text",
115
- value: v
141
+ value: currentSearchValue
116
142
  }
117
143
  ) }),
118
- /* @__PURE__ */ r("div", { ref: S, className: u("bj-dropdown__options", "bj-overlay-scrollbar-hidden", I.length === 0 && "bj-dropdown__options--empty", !s && "bj-dropdown__options--single"), children: [
119
- I.map((e) => s ? /* @__PURE__ */ l(
120
- $,
144
+ /* @__PURE__ */ jsxs("div", { ref: optionsRef, className: classNames("bj-dropdown__options", "bj-overlay-scrollbar-hidden", visibleOptions.length === 0 && "bj-dropdown__options--empty", !isMultiple && "bj-dropdown__options--single"), children: [
145
+ visibleOptions.map((option) => isMultiple ? /* @__PURE__ */ jsx(
146
+ CompoundBCheckBox,
121
147
  {
122
- checked: t.includes(e.value),
123
- className: u("bj-dropdown__option", c && e.description !== void 0 && "bj-dropdown__option--double-line"),
124
- disabled: e.disabled,
125
- onChange: () => D(e),
126
- skipGroup: !0,
148
+ checked: selectedValue.includes(option.value),
149
+ className: classNames("bj-dropdown__option", isDoubleLine && option.description !== void 0 && "bj-dropdown__option--double-line"),
150
+ disabled: option.disabled,
151
+ onChange: () => handleOptionChange(option),
152
+ skipGroup: true,
127
153
  variant: "white",
128
- children: h ? h(e) : /* @__PURE__ */ l(W, { doubleLine: c && e.description !== void 0, option: e })
154
+ children: optionRender ? optionRender(option) : /* @__PURE__ */ jsx(DefaultOptionContent, { doubleLine: isDoubleLine && option.description !== void 0, option })
129
155
  },
130
- String(e.value)
131
- ) : /* @__PURE__ */ r(
156
+ String(option.value)
157
+ ) : /* @__PURE__ */ jsxs(
132
158
  "button",
133
159
  {
134
- "aria-pressed": t.includes(e.value),
135
- className: u("bj-dropdown__option", "bj-dropdown__option--single", c && e.description !== void 0 && "bj-dropdown__option--double-line", t.includes(e.value) && "bj-dropdown__option--selected"),
136
- disabled: e.disabled,
137
- onClick: () => D(e),
160
+ "aria-pressed": selectedValue.includes(option.value),
161
+ className: classNames("bj-dropdown__option", "bj-dropdown__option--single", isDoubleLine && option.description !== void 0 && "bj-dropdown__option--double-line", selectedValue.includes(option.value) && "bj-dropdown__option--selected"),
162
+ disabled: option.disabled,
163
+ onClick: () => handleOptionChange(option),
138
164
  type: "button",
139
165
  children: [
140
- h ? /* @__PURE__ */ l("span", { className: "bj-dropdown__option-label", children: h(e) }) : /* @__PURE__ */ l(W, { doubleLine: c && e.description !== void 0, option: e }),
141
- t.includes(e.value) && /* @__PURE__ */ l(V, { className: "bj-dropdown__option-icon", type: "icon-a-dagouxi" })
166
+ optionRender ? /* @__PURE__ */ jsx("span", { className: "bj-dropdown__option-label", children: optionRender(option) }) : /* @__PURE__ */ jsx(DefaultOptionContent, { doubleLine: isDoubleLine && option.description !== void 0, option }),
167
+ selectedValue.includes(option.value) && /* @__PURE__ */ jsx(BuIcon, { className: "bj-dropdown__option-icon", type: "icon-a-dagouxi" })
142
168
  ]
143
169
  },
144
- String(e.value)
170
+ String(option.value)
145
171
  )),
146
- I.length === 0 && /* @__PURE__ */ r("div", { className: "bj-dropdown__empty", children: [
147
- /* @__PURE__ */ l("img", { alt: "", className: "bj-dropdown__empty-image", src: ne }),
148
- /* @__PURE__ */ l("span", { className: "bj-dropdown__empty-text", children: K })
172
+ visibleOptions.length === 0 && /* @__PURE__ */ jsxs("div", { className: "bj-dropdown__empty", children: [
173
+ /* @__PURE__ */ jsx("img", { alt: "", className: "bj-dropdown__empty-image", src: defaultEmptyImage }),
174
+ /* @__PURE__ */ jsx("span", { className: "bj-dropdown__empty-text", children: resolvedEmptyText })
149
175
  ] })
150
176
  ] }),
151
- /* @__PURE__ */ l(ee, { containerRef: w, gap: 2, size: 2, targetRef: S }),
152
- L !== !1 && (L !== !0 ? L : /* @__PURE__ */ r("div", { className: u("bj-dropdown__actions", !s && "bj-dropdown__actions--single"), children: [
153
- A && /* @__PURE__ */ l("button", { onClick: U, type: "button", children: P }),
154
- s && G && /* @__PURE__ */ l("button", { onClick: () => C == null ? void 0 : C(t), type: "button", children: q })
177
+ /* @__PURE__ */ jsx(BOverlayScrollbar, { containerRef: dropdownRef, gap: 2, size: 2, targetRef: optionsRef }),
178
+ footer !== false && (footer !== true ? footer : /* @__PURE__ */ jsxs("div", { className: classNames("bj-dropdown__actions", !isMultiple && "bj-dropdown__actions--single"), children: [
179
+ showReset && /* @__PURE__ */ jsx("button", { onClick: handleReset, type: "button", children: resetText }),
180
+ isMultiple && showConfirm && /* @__PURE__ */ jsx("button", { onClick: () => onConfirm == null ? void 0 : onConfirm(selectedValue), type: "button", children: confirmText })
155
181
  ] }))
156
182
  ] });
157
183
  }
158
184
  export {
159
- _e as BDropdown
185
+ BDropdown
160
186
  };
@@ -1 +1,77 @@
1
- "use strict";const t=require("react/jsx-runtime"),h=require("react");;/* empty css */function v(){return t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("path",{d:"M14.1667 5.3335C15.1792 5.3335 16 6.15431 16 7.16683V8.00016H19C19.2761 8.00016 19.5 8.22402 19.5 8.50016C19.5 8.7763 19.2761 9.00016 19 9.00016H17.3333V16.8335C17.3333 17.846 16.5125 18.6668 15.5 18.6668H8.5C7.48748 18.6668 6.66667 17.846 6.66667 16.8335V9.00016H5C4.72386 9.00016 4.5 8.7763 4.5 8.50016C4.5 8.22402 4.72386 8.00016 5 8.00016H8V7.16683C8 6.15431 8.82081 5.3335 9.83333 5.3335H14.1667ZM7.66667 16.8335C7.66667 17.2937 8.03976 17.6668 8.5 17.6668H15.5C15.9602 17.6668 16.3333 17.2937 16.3333 16.8335V9.00016H7.66667V16.8335ZM10.5 11.3335C10.7761 11.3335 11 11.5574 11 11.8335V15.0002C11 15.2763 10.7761 15.5002 10.5 15.5002C10.2239 15.5002 10 15.2763 10 15.0002V11.8335C10 11.5574 10.2239 11.3335 10.5 11.3335ZM13.5 11.3335C13.7761 11.3335 14 11.5574 14 11.8335V15.0002C14 15.2763 13.7761 15.5002 13.5 15.5002C13.2239 15.5002 13 15.2763 13 15.0002V11.8335C13 11.5574 13.2239 11.3335 13.5 11.3335ZM9.83333 6.3335C9.3731 6.3335 9 6.70659 9 7.16683V8.00016H15V7.16683C15 6.70659 14.6269 6.3335 14.1667 6.3335H9.83333Z",fill:"currentColor"})})}const N=h.forwardRef(function({mode:l="single",activeLang:c="zh",onLangChange:e,value:n="",onChange:u,placeholder:_,maxLength:x,error:d=!1,disabled:o,onDelete:r,labels:i,id:j,className:C,style:m},V){const p=(i==null?void 0:i.zh)??"中文",f=(i==null?void 0:i.en)??"EN",s=l==="bilingual",b=!!r,H=["bu-eib__box",s&&b&&"bu-eib__box--actions-both",s&&!b&&"bu-eib__box--actions-toggle",!s&&b&&"bu-eib__box--actions-delete",d&&"bu-eib__box--error",o&&"bu-eib__box--disabled"].filter(Boolean).join(" ");return t.jsx("div",{className:["bu-eib",C].filter(Boolean).join(" "),style:m,children:t.jsxs("div",{className:H,children:[t.jsx("input",{ref:V,id:j,className:"bu-eib__field",value:n,onChange:a=>u==null?void 0:u(a.target.value),placeholder:_,maxLength:x,disabled:o}),(s||b)&&t.jsxs("div",{className:"bu-eib__actions",children:[s&&t.jsxs("div",{className:"bu-eib__lang-toggle",children:[t.jsx("button",{type:"button",className:`bu-eib__lang-btn${c==="zh"?" bu-eib__lang-btn--active":""}`,onClick:()=>e==null?void 0:e("zh"),children:p}),t.jsx("button",{type:"button",className:`bu-eib__lang-btn${c==="en"?" bu-eib__lang-btn--active":""}`,onClick:()=>e==null?void 0:e("en"),children:f})]}),b&&t.jsx("button",{type:"button",className:"bu-eib__delete",onClick:r,children:t.jsx(v,{})})]})]})})});module.exports=N;
1
+ "use strict";
2
+ const jsxRuntime = require("react/jsx-runtime");
3
+ const react = require("react");
4
+ ;/* empty css */
5
+ function DeleteIcon() {
6
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M14.1667 5.3335C15.1792 5.3335 16 6.15431 16 7.16683V8.00016H19C19.2761 8.00016 19.5 8.22402 19.5 8.50016C19.5 8.7763 19.2761 9.00016 19 9.00016H17.3333V16.8335C17.3333 17.846 16.5125 18.6668 15.5 18.6668H8.5C7.48748 18.6668 6.66667 17.846 6.66667 16.8335V9.00016H5C4.72386 9.00016 4.5 8.7763 4.5 8.50016C4.5 8.22402 4.72386 8.00016 5 8.00016H8V7.16683C8 6.15431 8.82081 5.3335 9.83333 5.3335H14.1667ZM7.66667 16.8335C7.66667 17.2937 8.03976 17.6668 8.5 17.6668H15.5C15.9602 17.6668 16.3333 17.2937 16.3333 16.8335V9.00016H7.66667V16.8335ZM10.5 11.3335C10.7761 11.3335 11 11.5574 11 11.8335V15.0002C11 15.2763 10.7761 15.5002 10.5 15.5002C10.2239 15.5002 10 15.2763 10 15.0002V11.8335C10 11.5574 10.2239 11.3335 10.5 11.3335ZM13.5 11.3335C13.7761 11.3335 14 11.5574 14 11.8335V15.0002C14 15.2763 13.7761 15.5002 13.5 15.5002C13.2239 15.5002 13 15.2763 13 15.0002V11.8335C13 11.5574 13.2239 11.3335 13.5 11.3335ZM9.83333 6.3335C9.3731 6.3335 9 6.70659 9 7.16683V8.00016H15V7.16683C15 6.70659 14.6269 6.3335 14.1667 6.3335H9.83333Z", fill: "currentColor" }) });
7
+ }
8
+ const BuEmptyInputBox = react.forwardRef(
9
+ function BuEmptyInputBox2({
10
+ mode = "single",
11
+ activeLang = "zh",
12
+ onLangChange,
13
+ value = "",
14
+ onChange,
15
+ placeholder,
16
+ maxLength,
17
+ error = false,
18
+ disabled,
19
+ onDelete,
20
+ labels,
21
+ id,
22
+ className,
23
+ style
24
+ }, ref) {
25
+ const zhLabel = (labels == null ? void 0 : labels.zh) ?? "中文";
26
+ const enLabel = (labels == null ? void 0 : labels.en) ?? "EN";
27
+ const hasBilingual = mode === "bilingual";
28
+ const hasDelete = !!onDelete;
29
+ const boxCls = [
30
+ "bu-eib__box",
31
+ hasBilingual && hasDelete && "bu-eib__box--actions-both",
32
+ hasBilingual && !hasDelete && "bu-eib__box--actions-toggle",
33
+ !hasBilingual && hasDelete && "bu-eib__box--actions-delete",
34
+ error && "bu-eib__box--error",
35
+ disabled && "bu-eib__box--disabled"
36
+ ].filter(Boolean).join(" ");
37
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: ["bu-eib", className].filter(Boolean).join(" "), style, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: boxCls, children: [
38
+ /* @__PURE__ */ jsxRuntime.jsx(
39
+ "input",
40
+ {
41
+ ref,
42
+ id,
43
+ className: "bu-eib__field",
44
+ value,
45
+ onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
46
+ placeholder,
47
+ maxLength,
48
+ disabled
49
+ }
50
+ ),
51
+ (hasBilingual || hasDelete) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bu-eib__actions", children: [
52
+ hasBilingual && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bu-eib__lang-toggle", children: [
53
+ /* @__PURE__ */ jsxRuntime.jsx(
54
+ "button",
55
+ {
56
+ type: "button",
57
+ className: `bu-eib__lang-btn${activeLang === "zh" ? " bu-eib__lang-btn--active" : ""}`,
58
+ onClick: () => onLangChange == null ? void 0 : onLangChange("zh"),
59
+ children: zhLabel
60
+ }
61
+ ),
62
+ /* @__PURE__ */ jsxRuntime.jsx(
63
+ "button",
64
+ {
65
+ type: "button",
66
+ className: `bu-eib__lang-btn${activeLang === "en" ? " bu-eib__lang-btn--active" : ""}`,
67
+ onClick: () => onLangChange == null ? void 0 : onLangChange("en"),
68
+ children: enLabel
69
+ }
70
+ )
71
+ ] }),
72
+ hasDelete && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "bu-eib__delete", onClick: onDelete, children: /* @__PURE__ */ jsxRuntime.jsx(DeleteIcon, {}) })
73
+ ] })
74
+ ] }) });
75
+ }
76
+ );
77
+ module.exports = BuEmptyInputBox;
@@ -1,74 +1,78 @@
1
- import { jsx as t, jsxs as c } from "react/jsx-runtime";
2
- import { forwardRef as N } from "react";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
3
  /* empty css */
4
- function B() {
5
- return /* @__PURE__ */ t("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ t("path", { d: "M14.1667 5.3335C15.1792 5.3335 16 6.15431 16 7.16683V8.00016H19C19.2761 8.00016 19.5 8.22402 19.5 8.50016C19.5 8.7763 19.2761 9.00016 19 9.00016H17.3333V16.8335C17.3333 17.846 16.5125 18.6668 15.5 18.6668H8.5C7.48748 18.6668 6.66667 17.846 6.66667 16.8335V9.00016H5C4.72386 9.00016 4.5 8.7763 4.5 8.50016C4.5 8.22402 4.72386 8.00016 5 8.00016H8V7.16683C8 6.15431 8.82081 5.3335 9.83333 5.3335H14.1667ZM7.66667 16.8335C7.66667 17.2937 8.03976 17.6668 8.5 17.6668H15.5C15.9602 17.6668 16.3333 17.2937 16.3333 16.8335V9.00016H7.66667V16.8335ZM10.5 11.3335C10.7761 11.3335 11 11.5574 11 11.8335V15.0002C11 15.2763 10.7761 15.5002 10.5 15.5002C10.2239 15.5002 10 15.2763 10 15.0002V11.8335C10 11.5574 10.2239 11.3335 10.5 11.3335ZM13.5 11.3335C13.7761 11.3335 14 11.5574 14 11.8335V15.0002C14 15.2763 13.7761 15.5002 13.5 15.5002C13.2239 15.5002 13 15.2763 13 15.0002V11.8335C13 11.5574 13.2239 11.3335 13.5 11.3335ZM9.83333 6.3335C9.3731 6.3335 9 6.70659 9 7.16683V8.00016H15V7.16683C15 6.70659 14.6269 6.3335 14.1667 6.3335H9.83333Z", fill: "currentColor" }) });
4
+ function DeleteIcon() {
5
+ return /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("path", { d: "M14.1667 5.3335C15.1792 5.3335 16 6.15431 16 7.16683V8.00016H19C19.2761 8.00016 19.5 8.22402 19.5 8.50016C19.5 8.7763 19.2761 9.00016 19 9.00016H17.3333V16.8335C17.3333 17.846 16.5125 18.6668 15.5 18.6668H8.5C7.48748 18.6668 6.66667 17.846 6.66667 16.8335V9.00016H5C4.72386 9.00016 4.5 8.7763 4.5 8.50016C4.5 8.22402 4.72386 8.00016 5 8.00016H8V7.16683C8 6.15431 8.82081 5.3335 9.83333 5.3335H14.1667ZM7.66667 16.8335C7.66667 17.2937 8.03976 17.6668 8.5 17.6668H15.5C15.9602 17.6668 16.3333 17.2937 16.3333 16.8335V9.00016H7.66667V16.8335ZM10.5 11.3335C10.7761 11.3335 11 11.5574 11 11.8335V15.0002C11 15.2763 10.7761 15.5002 10.5 15.5002C10.2239 15.5002 10 15.2763 10 15.0002V11.8335C10 11.5574 10.2239 11.3335 10.5 11.3335ZM13.5 11.3335C13.7761 11.3335 14 11.5574 14 11.8335V15.0002C14 15.2763 13.7761 15.5002 13.5 15.5002C13.2239 15.5002 13 15.2763 13 15.0002V11.8335C13 11.5574 13.2239 11.3335 13.5 11.3335ZM9.83333 6.3335C9.3731 6.3335 9 6.70659 9 7.16683V8.00016H15V7.16683C15 6.70659 14.6269 6.3335 14.1667 6.3335H9.83333Z", fill: "currentColor" }) });
6
6
  }
7
- const Z = N(
8
- function({
9
- mode: _ = "single",
10
- activeLang: l = "zh",
11
- onLangChange: i,
12
- value: n = "",
13
- onChange: u,
14
- placeholder: d,
15
- maxLength: m,
16
- error: p = !1,
17
- disabled: r,
18
- onDelete: s,
19
- labels: e,
20
- id: x,
21
- className: f,
22
- style: C
23
- }, V) {
24
- const a = (e == null ? void 0 : e.zh) ?? "中文", H = (e == null ? void 0 : e.en) ?? "EN", b = _ === "bilingual", o = !!s, h = [
7
+ const BuEmptyInputBox = forwardRef(
8
+ function BuEmptyInputBox2({
9
+ mode = "single",
10
+ activeLang = "zh",
11
+ onLangChange,
12
+ value = "",
13
+ onChange,
14
+ placeholder,
15
+ maxLength,
16
+ error = false,
17
+ disabled,
18
+ onDelete,
19
+ labels,
20
+ id,
21
+ className,
22
+ style
23
+ }, ref) {
24
+ const zhLabel = (labels == null ? void 0 : labels.zh) ?? "中文";
25
+ const enLabel = (labels == null ? void 0 : labels.en) ?? "EN";
26
+ const hasBilingual = mode === "bilingual";
27
+ const hasDelete = !!onDelete;
28
+ const boxCls = [
25
29
  "bu-eib__box",
26
- b && o && "bu-eib__box--actions-both",
27
- b && !o && "bu-eib__box--actions-toggle",
28
- !b && o && "bu-eib__box--actions-delete",
29
- p && "bu-eib__box--error",
30
- r && "bu-eib__box--disabled"
30
+ hasBilingual && hasDelete && "bu-eib__box--actions-both",
31
+ hasBilingual && !hasDelete && "bu-eib__box--actions-toggle",
32
+ !hasBilingual && hasDelete && "bu-eib__box--actions-delete",
33
+ error && "bu-eib__box--error",
34
+ disabled && "bu-eib__box--disabled"
31
35
  ].filter(Boolean).join(" ");
32
- return /* @__PURE__ */ t("div", { className: ["bu-eib", f].filter(Boolean).join(" "), style: C, children: /* @__PURE__ */ c("div", { className: h, children: [
33
- /* @__PURE__ */ t(
36
+ return /* @__PURE__ */ jsx("div", { className: ["bu-eib", className].filter(Boolean).join(" "), style, children: /* @__PURE__ */ jsxs("div", { className: boxCls, children: [
37
+ /* @__PURE__ */ jsx(
34
38
  "input",
35
39
  {
36
- ref: V,
37
- id: x,
40
+ ref,
41
+ id,
38
42
  className: "bu-eib__field",
39
- value: n,
40
- onChange: (v) => u == null ? void 0 : u(v.target.value),
41
- placeholder: d,
42
- maxLength: m,
43
- disabled: r
43
+ value,
44
+ onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
45
+ placeholder,
46
+ maxLength,
47
+ disabled
44
48
  }
45
49
  ),
46
- (b || o) && /* @__PURE__ */ c("div", { className: "bu-eib__actions", children: [
47
- b && /* @__PURE__ */ c("div", { className: "bu-eib__lang-toggle", children: [
48
- /* @__PURE__ */ t(
50
+ (hasBilingual || hasDelete) && /* @__PURE__ */ jsxs("div", { className: "bu-eib__actions", children: [
51
+ hasBilingual && /* @__PURE__ */ jsxs("div", { className: "bu-eib__lang-toggle", children: [
52
+ /* @__PURE__ */ jsx(
49
53
  "button",
50
54
  {
51
55
  type: "button",
52
- className: `bu-eib__lang-btn${l === "zh" ? " bu-eib__lang-btn--active" : ""}`,
53
- onClick: () => i == null ? void 0 : i("zh"),
54
- children: a
56
+ className: `bu-eib__lang-btn${activeLang === "zh" ? " bu-eib__lang-btn--active" : ""}`,
57
+ onClick: () => onLangChange == null ? void 0 : onLangChange("zh"),
58
+ children: zhLabel
55
59
  }
56
60
  ),
57
- /* @__PURE__ */ t(
61
+ /* @__PURE__ */ jsx(
58
62
  "button",
59
63
  {
60
64
  type: "button",
61
- className: `bu-eib__lang-btn${l === "en" ? " bu-eib__lang-btn--active" : ""}`,
62
- onClick: () => i == null ? void 0 : i("en"),
63
- children: H
65
+ className: `bu-eib__lang-btn${activeLang === "en" ? " bu-eib__lang-btn--active" : ""}`,
66
+ onClick: () => onLangChange == null ? void 0 : onLangChange("en"),
67
+ children: enLabel
64
68
  }
65
69
  )
66
70
  ] }),
67
- o && /* @__PURE__ */ t("button", { type: "button", className: "bu-eib__delete", onClick: s, children: /* @__PURE__ */ t(B, {}) })
71
+ hasDelete && /* @__PURE__ */ jsx("button", { type: "button", className: "bu-eib__delete", onClick: onDelete, children: /* @__PURE__ */ jsx(DeleteIcon, {}) })
68
72
  ] })
69
73
  ] }) });
70
74
  }
71
75
  );
72
76
  export {
73
- Z as default
77
+ BuEmptyInputBox as default
74
78
  };