@coreui/react-pro
Version:
UI Components Library for React.js
25 lines (22 loc) • 1.3 kB
JavaScript
import { __rest } from '../../node_modules/tslib/tslib.es6.js';
import React, { forwardRef } from 'react';
import PropTypes from 'prop-types';
const createNativeOptions = (options) => options &&
options.map((option, index) => option.options ? (React.createElement("optgroup", { label: option.label, key: index }, createNativeOptions(option.options))) : (React.createElement("option", { value: option.value, key: index, disabled: option.disabled }, option.label)));
const CMultiSelectNativeSelect = forwardRef((_a, ref) => {
var { id, name, options } = _a, rest = __rest(_a, ["id", "name", "options"]);
return (React.createElement("select", Object.assign({ id: id }, (id && !name && { name: `${id}-multi-select` }), (name && { name: name }), { tabIndex: -1, style: { display: 'none' } }, rest, { ref: ref }), options && createNativeOptions(options)));
});
CMultiSelectNativeSelect.propTypes = {
id: PropTypes.string,
name: PropTypes.string,
options: PropTypes.array,
value: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
PropTypes.arrayOf(PropTypes.string.isRequired),
]),
};
CMultiSelectNativeSelect.displayName = 'CMultiSelectNativeSelect';
export { CMultiSelectNativeSelect };
//# sourceMappingURL=CMultiSelectNativeSelect.js.map