UNPKG

@finos/legend-extension-dsl-data-quality

Version:
57 lines 3.71 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; /** * Copyright (c) 2026-present, Goldman Sachs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { FunctionSelectionHandler, RenderColumn, } from './DataQualityRelationLambdaGUIDataTypeHandlers.js'; import { EditableBasicValueSpecificationEditor } from '@finos/legend-query-builder'; import { PRIMITIVE_TYPE, } from '@finos/legend-graph'; import { useState } from 'react'; export function DataQualityValidationFunctionRenderer({ id, columnOptions, functionOptions, handleColChange, readOnly, selectedColumn, functionParameters, handleFunctionChange, handleFunctionParametersChange, functionName, graph, observerContext, onInputBlur, }) { const [initializeAsEditable, setInitializeAsEditable] = useState(false); return (_jsxs("div", { className: "data-quality-validation-gui-editor__function", children: [_jsx("div", { className: "data-quality-validation-gui-editor__function__parameter", children: _jsx(RenderColumn, { column: selectedColumn, onChange: ({ value, type, isOptional }) => { handleColChange(value, type, isOptional); }, options: columnOptions, disabled: readOnly }) }), _jsx("div", { className: "data-quality-validation-gui-editor__function__selector", children: _jsx(FunctionSelectionHandler, { value: functionName, options: functionOptions ?? [], onChange: (name) => { handleFunctionChange(name, id); }, disabled: readOnly }) }), functionParameters.map((param, idx) => { const genericType = param.genericType; if (!genericType) { return null; } const type = genericType.value.rawType.name; return (_jsx("div", { className: "data-quality-validation-gui-editor__function__parameter data-quality-validation-gui-editor__function__parameter--value", onFocus: () => setInitializeAsEditable(true), onBlur: () => { setInitializeAsEditable(false); onInputBlur?.(); }, role: "group", tabIndex: -1, children: _jsx(EditableBasicValueSpecificationEditor, { valueSpecification: param, enableExpressionCalculation: false, displayAsString: !isPrimitiveNumber(type), setValueSpecification: (newValue) => { handleFunctionParametersChange?.(newValue, idx); }, graph: graph, observerContext: observerContext, typeCheckOption: { expectedType: genericType.value.rawType, }, resetValue: () => null, isConstant: false, initializeAsEditable: initializeAsEditable, readOnly: readOnly }) }, getParameterKey(param.hashCode, idx))); })] })); } function getParameterKey(hasCode, index) { return `${hasCode}${index}`; } function isPrimitiveNumber(type) { switch (type) { case PRIMITIVE_TYPE.NUMBER: case PRIMITIVE_TYPE.INTEGER: case PRIMITIVE_TYPE.FLOAT: case PRIMITIVE_TYPE.DECIMAL: return true; default: return false; } } //# sourceMappingURL=DataQualityValidationFunctionRenderer.js.map