UNPKG

@eccenca/gui-elements

Version:

GUI elements based on other libraries, usable in React application, written in Typescript.

49 lines 4.48 kB
var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import React from "react"; import { Classes as BlueprintClasses } from "@blueprintjs/core"; import { Select as BlueprintSelect } from "@blueprintjs/select"; import { CLASSPREFIX as eccgui } from "../../configuration/constants.js"; import { Button, Icon, OverflowText } from "./../../index.js"; /** * Create a Select box without the HTML select element. * It is possible to filter options, as well as to add new options if necessary. * * **Use this input element when the value is primarily selected from a defined set of elements.** */ export function Select(_a) { var _b, _c, _d; var contextOverlayProps = _a.contextOverlayProps, className = _a.className, children = _a.children, text = _a.text, _e = _a.placeholder, placeholder = _e === void 0 ? "Select item ..." : _e, icon = _a.icon, rightIcon = _a.rightIcon, onClearanceHandler = _a.onClearanceHandler, inputProps = _a.inputProps, _f = _a.onClearanceText, onClearanceText = _f === void 0 ? "Reset selection" : _f, dataTestId = _a["data-test-id"], dataTestid = _a["data-testid"], wrapperProps = _a.wrapperProps, otherSelectProps = __rest(_a, ["contextOverlayProps", "className", "children", "text", "placeholder", "icon", "rightIcon", "onClearanceHandler", "inputProps", "onClearanceText", "data-test-id", "data-testid", "wrapperProps"]); var selectContent = (React.createElement(BlueprintSelect, __assign({ popoverProps: __assign({ minimal: true, matchTargetWidth: (_b = otherSelectProps.fill) !== null && _b !== void 0 ? _b : false }, contextOverlayProps), popoverContentProps: { "data-test-id": dataTestId ? dataTestId + "_drowpdown" : undefined, "data-testid": dataTestid ? dataTestid + "_dropdown" : undefined, }, inputProps: __assign({ round: true, fill: otherSelectProps.fill, "data-test-id": dataTestId ? dataTestId + "_searchinput" : undefined, "data-testid": dataTestid ? dataTestid + "_searchinput" : undefined }, inputProps), className: "".concat(eccgui, "-select") + (className ? " ".concat(className) : "") }, otherSelectProps), children !== null && children !== void 0 ? children : (React.createElement(Button, { text: text ? React.createElement(OverflowText, null, text) : React.createElement(OverflowText, null, placeholder), alignText: "left", outlined: true, fill: (_c = otherSelectProps.fill) !== null && _c !== void 0 ? _c : false, disabled: (_d = otherSelectProps.disabled) !== null && _d !== void 0 ? _d : false, icon: icon, rightIcon: React.createElement(React.Fragment, null, onClearanceHandler && text && (React.createElement(Icon, { name: "operation-clear", tooltipText: onClearanceText ? onClearanceText : undefined, onClick: function (e) { e.stopPropagation(); onClearanceHandler(); } })), typeof rightIcon === "string" ? (React.createElement(Icon, { name: rightIcon })) : (rightIcon !== null && rightIcon !== void 0 ? rightIcon : React.createElement(Icon, { name: "toggler-caretdown" }))), textClassName: text ? "" : BlueprintClasses.TEXT_MUTED, "data-test-id": dataTestId ? dataTestId + "_toggler" : undefined, "data-testid": dataTestid ? dataTestid + "_toggler" : undefined })))); return wrapperProps || dataTestId || dataTestid ? (React.createElement("div", __assign({ className: "".concat(eccgui, "-select__wrapper") }, (wrapperProps !== null && wrapperProps !== void 0 ? wrapperProps : {}), { "data-test-id": dataTestId, "data-testid": dataTestid }), selectContent)) : (React.createElement(React.Fragment, null, selectContent)); } export default Select; //# sourceMappingURL=Select.js.map