You've already forked factorio-server-manager
mirror of
https://github.com/OpenFactorioServerManager/factorio-server-manager.git
synced 2025-12-26 00:42:03 +02:00
- add actual latest save to Load Latest - disable Controls and Load Mods from Save when no save is present
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
import React, {useEffect, useState} from "react";
|
|
|
|
const Select = ({register, options, className = "", defaultValue = "", disabled = undefined}) => {
|
|
|
|
const [value, setValue] = useState(defaultValue);
|
|
|
|
useEffect(() => {
|
|
if (value === "") {
|
|
setValue(defaultValue)
|
|
}
|
|
});
|
|
|
|
return (
|
|
<div className={`${className} relative`}>
|
|
<select
|
|
className="shadow appearance-none border w-full py-2 px-3 text-black"
|
|
{...register}
|
|
value={value}
|
|
disabled={disabled}
|
|
onChange={optionElement => setValue(optionElement.target.value)}
|
|
>
|
|
{options.map(option => <option value={option.value} key={option.value}>{option.name}</option>)}
|
|
</select>
|
|
<div
|
|
className="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-black">
|
|
<svg className="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg"
|
|
viewBox="0 0 20 20">
|
|
<path
|
|
d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"/>
|
|
</svg>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default Select;
|