···
29
-
Select as DiscordSelect
29
+
Select as DiscordSelect,
} from "@moonlight-mod/wp/discord/components/common/index";
import { useStateFromStores } from "@moonlight-mod/wp/discord/packages/flux";
import Flex from "@moonlight-mod/wp/discord/uikit/Flex";
···
const { value, displayName, description } = useConfigEntry<number>(ext.uniqueId, name);
const castedSetting = setting as NumberSettingType;
104
-
const min = castedSetting.min ?? 0;
105
-
const max = castedSetting.max ?? 100;
105
+
const min = castedSetting.min;
106
+
const max = castedSetting.max;
108
+
const onChange = (value: number) => {
109
+
const rounded = min == null || max == null ? Math.round(value) : Math.max(min, Math.min(max, Math.round(value)));
110
+
MoonbaseSettingsStore.setExtensionConfig(ext.id, name, rounded);
<FormItem className={Margins.marginTop20} title={displayName}>
109
-
{description && <FormText>{markdownify(description)}</FormText>}
111
-
initialValue={value ?? 0}
112
-
disabled={disabled}
113
-
minValue={castedSetting.min ?? 0}
114
-
maxValue={castedSetting.max ?? 100}
115
-
onValueChange={(value: number) => {
116
-
const rounded = Math.max(min, Math.min(max, Math.round(value)));
117
-
MoonbaseSettingsStore.setExtensionConfig(ext.id, name, rounded);
115
+
{min == null || max == null ? (
116
+
<Flex justify={Flex.Justify.BETWEEN} direction={Flex.Direction.HORIZONTAL}>
117
+
{description && <FormText>{markdownify(description)}</FormText>}
118
+
<NumberInputStepper value={value ?? 0} onChange={onChange} />
122
+
{description && <FormText>{markdownify(description)}</FormText>}
124
+
initialValue={value ?? 0}
125
+
disabled={disabled}
128
+
onValueChange={onChange}
129
+
onValueRender={(value: number) => `${Math.round(value)}`}