UNPKG

@kadconsulting/dry

Version:
17 lines 1.53 kB
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; import { forwardRef } from 'react'; import classnames from 'classnames'; import { v4 as uuid } from 'uuid'; // Components import LoadingSpinner from '../LoadingSpinner/LoadingSpinner'; // import * as Utils from "./DropdownSelect.utils.js"; import './DropdownSelect.scss'; const DropdownSelect = forwardRef(({ id, className = '', name, value, options, onChange, label, isVisible = true, isLoading = false, width, disabled = false, 'data-testid': dataTestId, }, ref) => { return (_jsxs("div", { id: id, ref: ref, className: classnames({ 'dry-dropdown-select': true, 'dry-dropdown-select--hidden': !isVisible, [className]: true, }), "data-testid": dataTestId, children: [label && _jsx("label", { className: 'dry-dropdown-select__label', children: label }), _jsxs(_Fragment, { children: [_jsxs("select", { style: { width: width ? `${width}px` : '100%' }, name: name, className: 'dry-dropdown-select__dropdown', value: value, onChange: onChange, disabled: isLoading || disabled, children: [_jsxs("option", { value: '', disabled: true, children: ["Select ", name] }), isLoading ? (_jsx("option", { disabled: true, children: "Loading..." })) : (options.map((option) => (_jsx("option", { value: option.value, children: option.label }, `dropdown-${uuid()}-${option.value}`))))] }), isLoading && _jsx(LoadingSpinner, {})] })] })); }); export default DropdownSelect; //# sourceMappingURL=DropdownSelect.js.map