mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 15:23:38 +01:00
feature(components): prop-type DropDown
This commit is contained in:
parent
303fffbc40
commit
b75ad8eec5
@ -1,4 +1,5 @@
|
|||||||
import React, { useState, useRef } from 'react';
|
import React, { useState, useRef } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import Menu from './Menu';
|
import Menu from './Menu';
|
||||||
import useDocumentClick from 'hooks/useDocumentClick';
|
import useDocumentClick from 'hooks/useDocumentClick';
|
||||||
@ -6,13 +7,7 @@ import Chevron from 'assets/chevron-down.svg';
|
|||||||
import styles from './Dropdown.module.css';
|
import styles from './Dropdown.module.css';
|
||||||
import Icon from './Icon';
|
import Icon from './Icon';
|
||||||
|
|
||||||
export default function DropDown({
|
function DropDown({ value, className, menuClassName, options = [], onChange = () => {} }) {
|
||||||
value,
|
|
||||||
className,
|
|
||||||
menuClassName,
|
|
||||||
options = [],
|
|
||||||
onChange = () => {},
|
|
||||||
}) {
|
|
||||||
const [showMenu, setShowMenu] = useState(false);
|
const [showMenu, setShowMenu] = useState(false);
|
||||||
const ref = useRef();
|
const ref = useRef();
|
||||||
const selectedOption = options.find(e => e.value === value);
|
const selectedOption = options.find(e => e.value === value);
|
||||||
@ -52,3 +47,18 @@ export default function DropDown({
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DropDown.propTypes = {
|
||||||
|
value: PropTypes.any,
|
||||||
|
className: PropTypes.string,
|
||||||
|
menuClassName: PropTypes.string,
|
||||||
|
options: PropTypes.arrayOf(
|
||||||
|
PropTypes.shape({
|
||||||
|
value: PropTypes.any.isRequired,
|
||||||
|
label: PropTypes.node,
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
onChange: PropTypes.func,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DropDown;
|
||||||
|
Loading…
Reference in New Issue
Block a user