| 1 |
/** |
| 2 |
* WordPress dependencies |
| 3 |
*/ |
| 4 |
import React from "react"; |
| 5 |
import { SelectControl as WPSelectControl } from "@wordpress/components"; |
| 6 |
|
| 7 |
/** |
| 8 |
* Internal dependencies |
| 9 |
*/ |
| 10 |
import { SelectControlProps } from "./types"; |
| 11 |
|
| 12 |
/** |
| 13 |
* Select control component |
| 14 |
* Wrapper around WordPress SelectControl with default value handling |
| 15 |
*/ |
| 16 |
const UBSelectControl: React.FC<SelectControlProps> = ({ |
| 17 |
label, |
| 18 |
value, |
| 19 |
onChange = () => {}, |
| 20 |
options, |
| 21 |
disabled = false, |
| 22 |
}) => { |
| 23 |
const displayValue = value ?? "auto"; |
| 24 |
|
| 25 |
return ( |
| 26 |
<WPSelectControl |
| 27 |
disabled={disabled} |
| 28 |
label={label} |
| 29 |
value={displayValue} |
| 30 |
options={options} |
| 31 |
onChange={onChange} |
| 32 |
__next40pxDefaultSize |
| 33 |
__nextHasNoMarginBottom |
| 34 |
/> |
| 35 |
); |
| 36 |
}; |
| 37 |
|
| 38 |
export default UBSelectControl; |
| 39 |
|