UNPKG

@skbkontur/db-viewer-ui

Version:

Database Viewer with custom configuration

37 lines 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StyledSelect = exports.OperatorSelect = void 0; const tslib_1 = require("tslib"); const jsx_runtime_1 = require("react/jsx-runtime"); const react_ui_1 = require("@skbkontur/react-ui"); const react_1 = tslib_1.__importDefault(require("react")); function operatorToString(operation) { const filterOperators = { GreaterThanOrEquals: ">=", LessThanOrEquals: "<=", DoesNotEqual: "!=", GreaterThan: ">", LessThan: "<", Equals: "=", }; const result = filterOperators[operation]; if (result != null) { return result; } return "="; } function OperatorSelect(props) { const { availableValues, value, onChange } = props; return ((0, jsx_runtime_1.jsx)(StyledSelect, { width: 70, "data-tid": "OperatorSelect", items: availableValues.map(x => [x, operatorToString(x)]), onValueChange: (nextValue) => { if (nextValue != null) { onChange(nextValue); } }, value: value || undefined })); } exports.OperatorSelect = OperatorSelect; function StyledSelect(props) { const theme = react_1.default.useContext(react_ui_1.ThemeContext); return ((0, jsx_runtime_1.jsx)(react_ui_1.Select, Object.assign({}, props, { renderItem: (value, item) => (0, jsx_runtime_1.jsx)("span", { style: { color: theme.textColorDefault }, children: item }) }))); } exports.StyledSelect = StyledSelect; //# sourceMappingURL=OperatorSelect.js.map