1 |
|
2 |
|
3 | var __rest = (this && this.__rest) || function (s, e) {
|
4 | var t = {};
|
5 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
6 | t[p] = s[p];
|
7 | if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
8 | for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
9 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
10 | t[p[i]] = s[p[i]];
|
11 | }
|
12 | return t;
|
13 | };
|
14 | import * as React from 'react';
|
15 | import { caretDownEmptyIcon } from '../icon';
|
16 | import { classes } from '../utils';
|
17 | import { DEFAULT_STYLE_CLASS } from './interface';
|
18 | export const HTML_SELECT_CLASS = 'jp-HTMLSelect';
|
19 | export class HTMLSelect extends React.Component {
|
20 | render() {
|
21 | const _a = this.props, { className, defaultStyle = true, disabled, elementRef, iconProps, icon = caretDownEmptyIcon, options = [] } = _a, htmlProps = __rest(_a, ["className", "defaultStyle", "disabled", "elementRef", "iconProps", "icon", "options"]);
|
22 | const cls = classes(HTML_SELECT_CLASS, {
|
23 | [DEFAULT_STYLE_CLASS]: defaultStyle
|
24 | }, className);
|
25 | const optionChildren = options.map(option => {
|
26 | const props = typeof option === 'object' ? option : { value: option };
|
27 | return (React.createElement("option", Object.assign({}, props, { key: props.value }), props.label || props.value));
|
28 | });
|
29 | return (React.createElement("div", { className: cls },
|
30 | React.createElement("select", Object.assign({ disabled: disabled, ref: elementRef }, htmlProps, { multiple: false }),
|
31 | optionChildren,
|
32 | htmlProps.children),
|
33 | React.createElement(icon.react, Object.assign({}, Object.assign({ tag: 'span', stylesheet: 'select', right: '7px', top: '5px' }, iconProps)))));
|
34 | }
|
35 | }
|
36 |
|
\ | No newline at end of file |