Skip to content

Commit 555c5de

Browse files
committed
Support specific numeric values as a dropdown.
1 parent 3b04776 commit 555c5de

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

web-ui/src/components/settings/types/number.jsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import React from 'react';
2-
import { Input, Typography } from '@mui/material';
2+
import {
3+
Select,
4+
MenuItem,
5+
ListItemText,
6+
Input,
7+
Typography
8+
} from '@mui/material';
39
import { createLabelId } from '../../../helpers/strings.js';
410

511
/**
@@ -13,7 +19,7 @@ import { createLabelId } from '../../../helpers/strings.js';
1319
* @param {function} props.handleChange - The callback function to handle value changes.
1420
* @returns {JSX.Element} - The rendered component.
1521
*/
16-
const SettingsNumber = ({ name, description, value, handleChange }) => {
22+
const SettingsNumber = ({ name, description, values, value, handleChange }) => {
1723
const labelId = createLabelId(name);
1824

1925
return (
@@ -24,13 +30,25 @@ const SettingsNumber = ({ name, description, value, handleChange }) => {
2430
</Typography>
2531
</label>
2632
{description && <p>{description}</p>}
33+
{values && values.length > 0 ?
34+
<Select
35+
labelId={labelId}
36+
value={value}
37+
onChange={handleChange}
38+
>
39+
{values.map((option) => (
40+
<MenuItem key={option} value={option}>
41+
<ListItemText primary={option} />
42+
</MenuItem>
43+
))}
44+
</Select> :
2745
<Input
2846
id={labelId}
2947
className="settings-control"
3048
type="number"
3149
value={value}
3250
onChange={handleChange}
33-
/>
51+
/>}
3452
</div>
3553
);
3654
};

0 commit comments

Comments
 (0)