UNPKG

@eccenca/gui-elements

Version:

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

44 lines 4.25 kB
"use strict"; 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; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Select = Select; const react_1 = __importDefault(require("react")); const core_1 = require("@blueprintjs/core"); const select_1 = require("@blueprintjs/select"); const constants_1 = require("../../configuration/constants"); const index_1 = require("./../../index"); /** * 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.** */ function Select(_a) { var _b, _c, _d; var { contextOverlayProps, className, children, text, placeholder = "Select item ...", icon, rightIcon, onClearanceHandler, inputProps, onClearanceText = "Reset selection", "data-test-id": dataTestId, "data-testid": dataTestid, wrapperProps } = _a, otherSelectProps = __rest(_a, ["contextOverlayProps", "className", "children", "text", "placeholder", "icon", "rightIcon", "onClearanceHandler", "inputProps", "onClearanceText", "data-test-id", "data-testid", "wrapperProps"]); const selectContent = (react_1.default.createElement(select_1.Select, Object.assign({ popoverProps: Object.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: Object.assign({ round: true, fill: otherSelectProps.fill, "data-test-id": dataTestId ? dataTestId + "_searchinput" : undefined, "data-testid": dataTestid ? dataTestid + "_searchinput" : undefined }, inputProps), className: `${constants_1.CLASSPREFIX}-select` + (className ? ` ${className}` : "") }, otherSelectProps), children !== null && children !== void 0 ? children : (react_1.default.createElement(index_1.Button, { text: text ? react_1.default.createElement(index_1.OverflowText, null, text) : react_1.default.createElement(index_1.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_1.default.createElement(react_1.default.Fragment, null, onClearanceHandler && text && (react_1.default.createElement(index_1.Icon, { name: "operation-clear", tooltipText: onClearanceText ? onClearanceText : undefined, onClick: (e) => { e.stopPropagation(); onClearanceHandler(); } })), typeof rightIcon === "string" ? (react_1.default.createElement(index_1.Icon, { name: rightIcon })) : (rightIcon !== null && rightIcon !== void 0 ? rightIcon : react_1.default.createElement(index_1.Icon, { name: "toggler-caretdown" }))), textClassName: text ? "" : core_1.Classes.TEXT_MUTED, "data-test-id": dataTestId ? dataTestId + "_toggler" : undefined, "data-testid": dataTestid ? dataTestid + "_toggler" : undefined })))); return wrapperProps || dataTestId || dataTestid ? (react_1.default.createElement("div", Object.assign({ className: `${constants_1.CLASSPREFIX}-select__wrapper` }, (wrapperProps !== null && wrapperProps !== void 0 ? wrapperProps : {}), { "data-test-id": dataTestId, "data-testid": dataTestid }), selectContent)) : (react_1.default.createElement(react_1.default.Fragment, null, selectContent)); } exports.default = Select; //# sourceMappingURL=Select.js.map