Files
console-dev/app/lib/resource-option-value.js

12 lines
455 B
JavaScript

/** radio 的 value 是可选值;step/total 的 value 可能只是占位,默认值应从区间下限读取。 */
export function resourceOptionValue(option) {
if (!option) return;
const value =
option.type === "step" || option.type === "total"
? (option.min_value ?? option.value)
: option.value;
if (value == null || value === "") return;
const number = Number(value);
return Number.isFinite(number) ? number : undefined;
}