1 |
|
2 |
|
3 | import * as React from 'react';
|
4 | import { caretDownEmptyIcon } from '../icon';
|
5 | import { classes } from '../utils';
|
6 | import { DEFAULT_STYLE_CLASS } from './interface';
|
7 | export const HTML_SELECT_CLASS = 'jp-HTMLSelect';
|
8 | export class HTMLSelect extends React.Component {
|
9 | render() {
|
10 | const { className, defaultStyle = true, disabled, elementRef, iconProps, icon = caretDownEmptyIcon, options = [], ...htmlProps } = this.props;
|
11 | const cls = classes(HTML_SELECT_CLASS, {
|
12 | [DEFAULT_STYLE_CLASS]: defaultStyle
|
13 | }, className);
|
14 |
|
15 |
|
16 | const handleFocus = (event) => {
|
17 | event.stopPropagation();
|
18 | };
|
19 | const optionChildren = options.map(option => {
|
20 | const props = typeof option === 'object' ? option : { value: option };
|
21 | return (React.createElement("option", { ...props, key: props.value }, props.label || props.value));
|
22 | });
|
23 | return (React.createElement("div", { className: cls },
|
24 | React.createElement("select", { onFocus: handleFocus, disabled: disabled, ref: elementRef, ...htmlProps, multiple: false },
|
25 | optionChildren,
|
26 | htmlProps.children),
|
27 | React.createElement(icon.react, { tag: 'span',
|
28 | stylesheet: 'select',
|
29 | right: '7px',
|
30 | top: '5px',
|
31 | ...iconProps })));
|
32 | }
|
33 | }
|
34 |
|
\ | No newline at end of file |