@sia.soul/sia-react-ui 0.1.94 → 0.1.96
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/dist/chart.cjs +4 -2
- package/dist/chart.js +1 -1
- package/dist/{chunk-ZHQ7PCCF.js → chunk-T3EGAN7O.js} +4 -2
- package/dist/index.cjs +31 -9
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +28 -8
- package/package.json +1 -1
package/dist/chart.cjs
CHANGED
|
@@ -2554,7 +2554,8 @@ function transferPieValue(series, source, target, connector = " & ") {
|
|
|
2554
2554
|
return { integer: BigInt(m.replace(".", "")), scale: (m.split(".")[1]?.length ?? 0) - Number(e) };
|
|
2555
2555
|
};
|
|
2556
2556
|
const a = parts(value), b = parts(origin.value), scale = Math.max(a.scale, b.scale);
|
|
2557
|
-
const
|
|
2557
|
+
const factor = (digits) => BigInt(`1${"0".repeat(digits)}`);
|
|
2558
|
+
const merged = Number(`${a.integer * factor(scale - a.scale) + b.integer * factor(scale - b.scale)}e${-scale}`);
|
|
2558
2559
|
if (!Number.isFinite(merged)) throw new RangeError("\u5408\u5E76\u503C\u8D85\u51FA\u6709\u9650\u6570\u503C\u8303\u56F4");
|
|
2559
2560
|
next[target.series].data[target.index] = { ...destination, value: merged, name: destination.name + connector + origin.name };
|
|
2560
2561
|
} else if (target) {
|
|
@@ -2577,7 +2578,8 @@ function addValues(a, b) {
|
|
|
2577
2578
|
return { integer: BigInt(mantissa.replace(".", "")), scale: fraction - Number(exponent) };
|
|
2578
2579
|
};
|
|
2579
2580
|
const left = parts(a), right = parts(b), scale = Math.max(left.scale, right.scale);
|
|
2580
|
-
const
|
|
2581
|
+
const factor = (digits) => BigInt(`1${"0".repeat(digits)}`);
|
|
2582
|
+
const integer = left.integer * factor(scale - left.scale) + right.integer * factor(scale - right.scale);
|
|
2581
2583
|
const value = Number(`${integer}e${-scale}`);
|
|
2582
2584
|
if (!Number.isFinite(value)) throw new RangeError("\u5408\u5E76\u503C\u8D85\u51FA\u6709\u9650\u6570\u503C\u8303\u56F4");
|
|
2583
2585
|
return value;
|
package/dist/chart.js
CHANGED
|
@@ -2230,7 +2230,8 @@ function transferPieValue(series, source, target, connector = " & ") {
|
|
|
2230
2230
|
return { integer: BigInt(m.replace(".", "")), scale: (m.split(".")[1]?.length ?? 0) - Number(e) };
|
|
2231
2231
|
};
|
|
2232
2232
|
const a = parts(value), b = parts(origin.value), scale = Math.max(a.scale, b.scale);
|
|
2233
|
-
const
|
|
2233
|
+
const factor = (digits) => BigInt(`1${"0".repeat(digits)}`);
|
|
2234
|
+
const merged = Number(`${a.integer * factor(scale - a.scale) + b.integer * factor(scale - b.scale)}e${-scale}`);
|
|
2234
2235
|
if (!Number.isFinite(merged)) throw new RangeError("\u5408\u5E76\u503C\u8D85\u51FA\u6709\u9650\u6570\u503C\u8303\u56F4");
|
|
2235
2236
|
next[target.series].data[target.index] = { ...destination, value: merged, name: destination.name + connector + origin.name };
|
|
2236
2237
|
} else if (target) {
|
|
@@ -2253,7 +2254,8 @@ function addValues(a, b) {
|
|
|
2253
2254
|
return { integer: BigInt(mantissa.replace(".", "")), scale: fraction - Number(exponent) };
|
|
2254
2255
|
};
|
|
2255
2256
|
const left = parts(a), right = parts(b), scale = Math.max(left.scale, right.scale);
|
|
2256
|
-
const
|
|
2257
|
+
const factor = (digits) => BigInt(`1${"0".repeat(digits)}`);
|
|
2258
|
+
const integer = left.integer * factor(scale - left.scale) + right.integer * factor(scale - right.scale);
|
|
2257
2259
|
const value = Number(`${integer}e${-scale}`);
|
|
2258
2260
|
if (!Number.isFinite(value)) throw new RangeError("\u5408\u5E76\u503C\u8D85\u51FA\u6709\u9650\u6570\u503C\u8303\u56F4");
|
|
2259
2261
|
return value;
|
package/dist/index.cjs
CHANGED
|
@@ -11691,6 +11691,8 @@ var InputNumber = (0, import_react44.forwardRef)(function InputNumber2({
|
|
|
11691
11691
|
max,
|
|
11692
11692
|
step = 1,
|
|
11693
11693
|
precision,
|
|
11694
|
+
formatter,
|
|
11695
|
+
parser,
|
|
11694
11696
|
size: sizeProp,
|
|
11695
11697
|
status = "default",
|
|
11696
11698
|
prefix,
|
|
@@ -11711,10 +11713,14 @@ var InputNumber = (0, import_react44.forwardRef)(function InputNumber2({
|
|
|
11711
11713
|
const inputId = id ?? fallbackId;
|
|
11712
11714
|
const localRef = (0, import_react44.useRef)(null);
|
|
11713
11715
|
const [currentValue, setCurrentValue] = useControllableState({ value, defaultValue, onChange });
|
|
11714
|
-
const
|
|
11716
|
+
const displayValue = (next) => {
|
|
11717
|
+
const plain = formatValue(next, precision);
|
|
11718
|
+
return plain && formatter ? formatter(plain) : plain;
|
|
11719
|
+
};
|
|
11720
|
+
const [text, setText] = (0, import_react44.useState)(() => displayValue(currentValue));
|
|
11715
11721
|
(0, import_react44.useEffect)(() => {
|
|
11716
|
-
setText(
|
|
11717
|
-
}, [currentValue, precision]);
|
|
11722
|
+
setText(displayValue(currentValue));
|
|
11723
|
+
}, [currentValue, precision, formatter]);
|
|
11718
11724
|
function setRef(node) {
|
|
11719
11725
|
localRef.current = node;
|
|
11720
11726
|
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
@@ -11733,19 +11739,33 @@ var InputNumber = (0, import_react44.forwardRef)(function InputNumber2({
|
|
|
11733
11739
|
setCurrentValue(null);
|
|
11734
11740
|
return;
|
|
11735
11741
|
}
|
|
11736
|
-
|
|
11742
|
+
let parsed;
|
|
11743
|
+
try {
|
|
11744
|
+
const value2 = parser ? parser(rawText) : rawText;
|
|
11745
|
+
if (typeof value2 === "string" && value2.trim() === "") {
|
|
11746
|
+
setText("");
|
|
11747
|
+
setCurrentValue(null);
|
|
11748
|
+
return;
|
|
11749
|
+
}
|
|
11750
|
+
parsed = Number(value2);
|
|
11751
|
+
} catch {
|
|
11752
|
+
setText(displayValue(currentValue));
|
|
11753
|
+
return;
|
|
11754
|
+
}
|
|
11737
11755
|
if (!Number.isFinite(parsed)) {
|
|
11738
|
-
setText(
|
|
11756
|
+
setText(displayValue(currentValue));
|
|
11739
11757
|
return;
|
|
11740
11758
|
}
|
|
11741
11759
|
const nextValue = normalize(parsed);
|
|
11742
|
-
setText(
|
|
11760
|
+
setText(displayValue(nextValue));
|
|
11743
11761
|
setCurrentValue(nextValue);
|
|
11744
11762
|
}
|
|
11745
11763
|
function changeBy(direction) {
|
|
11746
11764
|
if (disabled || readOnly) return;
|
|
11747
11765
|
const baseValue = currentValue ?? 0;
|
|
11748
|
-
|
|
11766
|
+
const nextValue = normalize(baseValue + step * direction);
|
|
11767
|
+
setText(displayValue(nextValue));
|
|
11768
|
+
setCurrentValue(nextValue);
|
|
11749
11769
|
localRef.current?.focus();
|
|
11750
11770
|
}
|
|
11751
11771
|
function handleBlur(event) {
|
|
@@ -19081,7 +19101,8 @@ function transferPieValue(series, source, target, connector = " & ") {
|
|
|
19081
19101
|
return { integer: BigInt(m.replace(".", "")), scale: (m.split(".")[1]?.length ?? 0) - Number(e) };
|
|
19082
19102
|
};
|
|
19083
19103
|
const a = parts(value), b = parts(origin.value), scale = Math.max(a.scale, b.scale);
|
|
19084
|
-
const
|
|
19104
|
+
const factor = (digits) => BigInt(`1${"0".repeat(digits)}`);
|
|
19105
|
+
const merged = Number(`${a.integer * factor(scale - a.scale) + b.integer * factor(scale - b.scale)}e${-scale}`);
|
|
19085
19106
|
if (!Number.isFinite(merged)) throw new RangeError("\u5408\u5E76\u503C\u8D85\u51FA\u6709\u9650\u6570\u503C\u8303\u56F4");
|
|
19086
19107
|
next[target.series].data[target.index] = { ...destination, value: merged, name: destination.name + connector + origin.name };
|
|
19087
19108
|
} else if (target) {
|
|
@@ -19104,7 +19125,8 @@ function addValues(a, b) {
|
|
|
19104
19125
|
return { integer: BigInt(mantissa.replace(".", "")), scale: fraction - Number(exponent) };
|
|
19105
19126
|
};
|
|
19106
19127
|
const left = parts(a), right = parts(b), scale = Math.max(left.scale, right.scale);
|
|
19107
|
-
const
|
|
19128
|
+
const factor = (digits) => BigInt(`1${"0".repeat(digits)}`);
|
|
19129
|
+
const integer = left.integer * factor(scale - left.scale) + right.integer * factor(scale - right.scale);
|
|
19108
19130
|
const value = Number(`${integer}e${-scale}`);
|
|
19109
19131
|
if (!Number.isFinite(value)) throw new RangeError("\u5408\u5E76\u503C\u8D85\u51FA\u6709\u9650\u6570\u503C\u8303\u56F4");
|
|
19110
19132
|
return value;
|
package/dist/index.d.cts
CHANGED
|
@@ -1652,6 +1652,16 @@ interface InputNumberProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "
|
|
|
1652
1652
|
step?: number;
|
|
1653
1653
|
/** 固定小数位数 */
|
|
1654
1654
|
precision?: number;
|
|
1655
|
+
/**
|
|
1656
|
+
* 将已提交的数值转换为显示文本,例如千分位或货币符号;输入过程中保留原始草稿,失焦、回车、步进及外部 value 更新后格式化。
|
|
1657
|
+
* 参数为应用 precision 后的十进制文本,空值为空字符串;应返回显示文本,并与 parser 配套。未指定时显示普通十进制文本。
|
|
1658
|
+
*/
|
|
1659
|
+
formatter?: (value: string) => string;
|
|
1660
|
+
/**
|
|
1661
|
+
* 失焦或回车时将输入文本解析为数字或数字字符串;无效值或抛出异常时恢复当前值,不触发 onChange。
|
|
1662
|
+
* 空输入或解析为空字符串提交 null;未指定时使用 Number 转换。步进使用数值计算,不经过 parser。
|
|
1663
|
+
*/
|
|
1664
|
+
parser?: (text: string) => number | string;
|
|
1655
1665
|
/** small / medium / large 高度为 22 / 30 / 38px;默认继承 Form,组件自身 size 优先 */
|
|
1656
1666
|
size?: ControlSize;
|
|
1657
1667
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1652,6 +1652,16 @@ interface InputNumberProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "
|
|
|
1652
1652
|
step?: number;
|
|
1653
1653
|
/** 固定小数位数 */
|
|
1654
1654
|
precision?: number;
|
|
1655
|
+
/**
|
|
1656
|
+
* 将已提交的数值转换为显示文本,例如千分位或货币符号;输入过程中保留原始草稿,失焦、回车、步进及外部 value 更新后格式化。
|
|
1657
|
+
* 参数为应用 precision 后的十进制文本,空值为空字符串;应返回显示文本,并与 parser 配套。未指定时显示普通十进制文本。
|
|
1658
|
+
*/
|
|
1659
|
+
formatter?: (value: string) => string;
|
|
1660
|
+
/**
|
|
1661
|
+
* 失焦或回车时将输入文本解析为数字或数字字符串;无效值或抛出异常时恢复当前值,不触发 onChange。
|
|
1662
|
+
* 空输入或解析为空字符串提交 null;未指定时使用 Number 转换。步进使用数值计算,不经过 parser。
|
|
1663
|
+
*/
|
|
1664
|
+
parser?: (text: string) => number | string;
|
|
1655
1665
|
/** small / medium / large 高度为 22 / 30 / 38px;默认继承 Form,组件自身 size 优先 */
|
|
1656
1666
|
size?: ControlSize;
|
|
1657
1667
|
/**
|
package/dist/index.js
CHANGED
|
@@ -56,7 +56,7 @@ import {
|
|
|
56
56
|
smoothSvgPath,
|
|
57
57
|
svgArcPath,
|
|
58
58
|
transferCompositeValue
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-T3EGAN7O.js";
|
|
60
60
|
import {
|
|
61
61
|
Badge,
|
|
62
62
|
Breadcrumb,
|
|
@@ -4199,6 +4199,8 @@ var InputNumber = forwardRef4(function InputNumber2({
|
|
|
4199
4199
|
max,
|
|
4200
4200
|
step = 1,
|
|
4201
4201
|
precision,
|
|
4202
|
+
formatter,
|
|
4203
|
+
parser,
|
|
4202
4204
|
size: sizeProp,
|
|
4203
4205
|
status = "default",
|
|
4204
4206
|
prefix,
|
|
@@ -4219,10 +4221,14 @@ var InputNumber = forwardRef4(function InputNumber2({
|
|
|
4219
4221
|
const inputId = id ?? fallbackId;
|
|
4220
4222
|
const localRef = useRef11(null);
|
|
4221
4223
|
const [currentValue, setCurrentValue] = useControllableState({ value, defaultValue, onChange });
|
|
4222
|
-
const
|
|
4224
|
+
const displayValue = (next) => {
|
|
4225
|
+
const plain = formatValue(next, precision);
|
|
4226
|
+
return plain && formatter ? formatter(plain) : plain;
|
|
4227
|
+
};
|
|
4228
|
+
const [text, setText] = useState13(() => displayValue(currentValue));
|
|
4223
4229
|
useEffect9(() => {
|
|
4224
|
-
setText(
|
|
4225
|
-
}, [currentValue, precision]);
|
|
4230
|
+
setText(displayValue(currentValue));
|
|
4231
|
+
}, [currentValue, precision, formatter]);
|
|
4226
4232
|
function setRef(node) {
|
|
4227
4233
|
localRef.current = node;
|
|
4228
4234
|
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
@@ -4241,19 +4247,33 @@ var InputNumber = forwardRef4(function InputNumber2({
|
|
|
4241
4247
|
setCurrentValue(null);
|
|
4242
4248
|
return;
|
|
4243
4249
|
}
|
|
4244
|
-
|
|
4250
|
+
let parsed;
|
|
4251
|
+
try {
|
|
4252
|
+
const value2 = parser ? parser(rawText) : rawText;
|
|
4253
|
+
if (typeof value2 === "string" && value2.trim() === "") {
|
|
4254
|
+
setText("");
|
|
4255
|
+
setCurrentValue(null);
|
|
4256
|
+
return;
|
|
4257
|
+
}
|
|
4258
|
+
parsed = Number(value2);
|
|
4259
|
+
} catch {
|
|
4260
|
+
setText(displayValue(currentValue));
|
|
4261
|
+
return;
|
|
4262
|
+
}
|
|
4245
4263
|
if (!Number.isFinite(parsed)) {
|
|
4246
|
-
setText(
|
|
4264
|
+
setText(displayValue(currentValue));
|
|
4247
4265
|
return;
|
|
4248
4266
|
}
|
|
4249
4267
|
const nextValue = normalize(parsed);
|
|
4250
|
-
setText(
|
|
4268
|
+
setText(displayValue(nextValue));
|
|
4251
4269
|
setCurrentValue(nextValue);
|
|
4252
4270
|
}
|
|
4253
4271
|
function changeBy(direction) {
|
|
4254
4272
|
if (disabled || readOnly) return;
|
|
4255
4273
|
const baseValue = currentValue ?? 0;
|
|
4256
|
-
|
|
4274
|
+
const nextValue = normalize(baseValue + step * direction);
|
|
4275
|
+
setText(displayValue(nextValue));
|
|
4276
|
+
setCurrentValue(nextValue);
|
|
4257
4277
|
localRef.current?.focus();
|
|
4258
4278
|
}
|
|
4259
4279
|
function handleBlur(event) {
|