best-unit 2.1.9 → 2.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "best-unit",
3
3
  "private": false,
4
- "version": "2.1.9",
4
+ "version": "2.1.11",
5
5
  "type": "module",
6
6
  "main": "dist/best-unit.cjs",
7
7
  "module": "dist/best-unit.js",
@@ -20,6 +20,25 @@ function getBizTypeLabel(bizType: string) {
20
20
  return bizType;
21
21
  }
22
22
 
23
+ function getBizTypePlaceholder(bizType: string) {
24
+ const prefix = t("请输入");
25
+ const label = getBizTypeLabel(bizType);
26
+ return /[A-Za-z]$/.test(prefix) ? `${prefix} ${label}` : `${prefix}${label}`;
27
+ }
28
+
29
+ function formatPercentageInput(value: string) {
30
+ let nextValue = value.replace(/[^\d.]/g, "");
31
+ nextValue = nextValue.replace(/\.(?=.*\.)/g, "");
32
+ nextValue = nextValue.replace(/^(\d+)(\.\d{0,2})?.*$/, "$1$2");
33
+ nextValue = nextValue.replace(/^0+(\d)/, "$1");
34
+
35
+ if (nextValue.startsWith(".")) {
36
+ nextValue = `0${nextValue}`;
37
+ }
38
+
39
+ return nextValue;
40
+ }
41
+
23
42
  export function useFundAllocation() {
24
43
  const [subBusinesses, setSubBusinesses] = useState<MerchantBalanceItem[]>([]);
25
44
  const [useFundAllocation, setUseFundAllocation] = useState(false);
@@ -200,16 +219,16 @@ export function FundAllocationSection({
200
219
  {" (%)"}
201
220
  </label>
202
221
  <input
203
- type="number"
204
- min="0"
205
- max="100"
206
- step="0.01"
207
- placeholder="0"
222
+ type="text"
223
+ inputMode="decimal"
224
+ placeholder={getBizTypePlaceholder(item.bizType)}
208
225
  value={subBizPercentages[item.bizType] || ""}
209
226
  onChange={(e) => {
210
227
  onPercentageChange(
211
228
  item.bizType,
212
- (e.target as HTMLInputElement).value,
229
+ formatPercentageInput(
230
+ (e.target as HTMLInputElement).value,
231
+ ),
213
232
  );
214
233
  }}
215
234
  style={{
package/src/local/en.ts CHANGED
@@ -131,6 +131,7 @@ export const en: Record<string, string> = {
131
131
  提交审核: "Submit for Review",
132
132
  请选择转账时间: "Please select transfer time",
133
133
  请输入转账金额: "Please enter transfer amount",
134
+ 请输入: "Please enter",
134
135
  是否使用资金分配: "Use fund allocation",
135
136
  是: "Yes",
136
137
  否: "No",
package/src/local/zh.ts CHANGED
@@ -94,6 +94,7 @@ export const zh: Record<string, string> = {
94
94
  提交审核: "提交审核",
95
95
  请选择转账时间: "请选择转账时间",
96
96
  请输入转账金额: "请输入转账金额",
97
+ 请输入: "请输入",
97
98
  是否使用资金分配: "是否使用资金分配",
98
99
  是: "是",
99
100
  否: "否",