All files / modal modal.helpers.ts

90.9% Statements 10/11
50% Branches 2/4
100% Functions 2/2
90% Lines 9/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27            1x   1x 15x 46x       15x             15x 15x 15x 15x    
/**
 * Copyright (c) Siemens 2016 - 2025
 * SPDX-License-Identifier: MIT
 */
import { ModalOptions } from './si-modal.service';
 
let idCounter = 1;
 
export const createModalConfig = (inputs?: { [key: string]: any }): ModalOptions => {
  if (inputs) {
    Object.keys(inputs).forEach(k => inputs![k] === undefined && delete inputs![k]);
  } else E{
    inputs = {};
  }
  const config: ModalOptions<any> = {
    inputValues: inputs as { [key: string]: any },
    ignoreBackdropClick: true,
    keyboard: false,
    animated: true,
    class: 'modal-dialog-centered'
  };
  const id = `__si-modal-id-${idCounter++}`;
  config.inputValues!.titleId = id;
  config.ariaLabelledBy = id;
  return config;
};