UNPKG

@skbkontur/db-viewer-ui

Version:

Database Viewer with custom configuration

33 lines 1.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StyledSelect = exports.OperatorSelect = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const react_ui_1 = require("@skbkontur/react-ui"); const react_1 = require("react"); const operatorToString = (operation) => { const filterOperators = { GreaterThanOrEquals: ">=", LessThanOrEquals: "<=", DoesNotEqual: "!=", GreaterThan: ">", LessThan: "<", Equals: "=", }; const result = filterOperators[operation]; if (result != null) { return result; } return "="; }; const OperatorSelect = ({ availableValues, onChange, value }) => ((0, jsx_runtime_1.jsx)(exports.StyledSelect, { width: 70, "data-tid": "OperatorSelect", items: availableValues.map(x => [x, operatorToString(x)]), onValueChange: nextValue => { if (nextValue !== null && nextValue !== undefined) { onChange(nextValue); } }, value: value || undefined })); exports.OperatorSelect = OperatorSelect; const StyledSelect = (props) => { const theme = (0, react_1.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