1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | import { __assign, __rest } from "tslib";
|
17 | import classNames from "classnames";
|
18 | import * as React from "react";
|
19 | import { CaretDown, DoubleCaretVertical } from "@blueprintjs/icons";
|
20 | import { DISABLED, FILL, HTML_SELECT, LARGE, MINIMAL } from "../../common/classes";
|
21 | import { DISPLAYNAME_PREFIX } from "../../common/props";
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | export var HTMLSelect = React.forwardRef(function (props, ref) {
|
30 | var _a;
|
31 | var className = props.className, children = props.children, disabled = props.disabled, fill = props.fill, _b = props.iconName, iconName = _b === void 0 ? "double-caret-vertical" : _b, iconProps = props.iconProps, large = props.large, minimal = props.minimal, _c = props.options, options = _c === void 0 ? [] : _c, value = props.value, htmlProps = __rest(props, ["className", "children", "disabled", "fill", "iconName", "iconProps", "large", "minimal", "options", "value"]);
|
32 | var classes = classNames(HTML_SELECT, (_a = {},
|
33 | _a[DISABLED] = disabled,
|
34 | _a[FILL] = fill,
|
35 | _a[LARGE] = large,
|
36 | _a[MINIMAL] = minimal,
|
37 | _a), className);
|
38 | var iconTitle = "Open dropdown";
|
39 | var rightIcon = iconName === "double-caret-vertical" ? (React.createElement(DoubleCaretVertical, __assign({ title: iconTitle }, iconProps))) : (React.createElement(CaretDown, __assign({ title: iconTitle }, iconProps)));
|
40 | var optionChildren = options.map(function (option) {
|
41 | var optionProps = typeof option === "object" ? option : { value: option };
|
42 | return React.createElement("option", __assign({}, optionProps, { key: optionProps.value, children: optionProps.label || optionProps.value }));
|
43 | });
|
44 | return (React.createElement("div", { className: classes },
|
45 | React.createElement("select", __assign({ disabled: disabled, ref: ref, value: value }, htmlProps, { multiple: false }),
|
46 | optionChildren,
|
47 | children),
|
48 | rightIcon));
|
49 | });
|
50 | HTMLSelect.displayName = "".concat(DISPLAYNAME_PREFIX, ".HTMLSelect");
|
51 |
|
\ | No newline at end of file |