(nodeData, inputType, overrideParams, arrayIndex)
| 1302 | } |
| 1303 | |
| 1304 | export const showHideInputs = (nodeData, inputType, overrideParams, arrayIndex) => { |
| 1305 | const params = overrideParams ?? nodeData[inputType] ?? [] |
| 1306 | const effectiveNodeData = { ...nodeData, inputs: _inputsWithDeclaredDefaults(params, nodeData.inputs) } |
| 1307 | |
| 1308 | for (let i = 0; i < params.length; i += 1) { |
| 1309 | const inputParam = params[i] |
| 1310 | |
| 1311 | // Reset display flag to false for each inputParam |
| 1312 | inputParam.display = true |
| 1313 | |
| 1314 | if (inputParam.show) { |
| 1315 | _showHideOperation(effectiveNodeData, inputParam, 'show', arrayIndex) |
| 1316 | } |
| 1317 | if (inputParam.hide) { |
| 1318 | _showHideOperation(effectiveNodeData, inputParam, 'hide', arrayIndex) |
| 1319 | } |
| 1320 | |
| 1321 | // Filter individual options within dropdowns based on their own show/hide conditions |
| 1322 | if (inputParam.type === 'options' && inputParam.options) { |
| 1323 | inputParam.options = inputParam.options.filter((opt) => { |
| 1324 | if (typeof opt === 'string' || (!opt.show && !opt.hide)) return true |
| 1325 | const synthetic = { show: opt.show, hide: opt.hide, display: true } |
| 1326 | if (opt.show) _showHideOperation(nodeData, synthetic, 'show', arrayIndex) |
| 1327 | if (opt.hide) _showHideOperation(nodeData, synthetic, 'hide', arrayIndex) |
| 1328 | return synthetic.display !== false |
| 1329 | }) |
| 1330 | } |
| 1331 | } |
| 1332 | |
| 1333 | return params |
| 1334 | } |
| 1335 | |
| 1336 | export const showHideInputParams = (nodeData) => { |
| 1337 | return showHideInputs(nodeData, 'inputParams') |
no test coverage detected