private _transformButtonOptionsToProps()

in libs/fabric/src/lib/components/search-box/search-box.component.ts [117:152]


  private _transformButtonOptionsToProps(options: IButtonOptions): IButtonProps {
    const sharedProperties = omit(
      options,
      'renderIcon',
      'renderText',
      'renderDescription',
      'renderAriaDescription',
      'renderChildren',
      'renderMenuIcon'
    );

    const iconRenderer = this.createInputJsxRenderer(options.renderIcon);
    const textRenderer = this.createInputJsxRenderer(options.renderText);
    const descriptionRenderer = this.createInputJsxRenderer(options.renderDescription);
    const ariaDescriptionRenderer = this.createInputJsxRenderer(options.renderAriaDescription);
    const childrenRenderer = this.createInputJsxRenderer(options.renderChildren);
    const menuIconRenderer = this.createInputJsxRenderer(options.renderMenuIcon);

    return Object.assign(
      {},
      sharedProperties,
      iconRenderer && ({ onRenderIcon: props => iconRenderer(props) } as Pick<IButtonProps, 'onRenderIcon'>),
      textRenderer && ({ onRenderText: props => textRenderer(props) } as Pick<IButtonProps, 'onRenderText'>),
      descriptionRenderer &&
        ({ onRenderDescription: props => descriptionRenderer(props) } as Pick<IButtonProps, 'onRenderDescription'>),
      ariaDescriptionRenderer &&
        ({ onRenderAriaDescription: props => ariaDescriptionRenderer(props) } as Pick<
          IButtonProps,
          'onRenderAriaDescription'
        >),
      childrenRenderer &&
        ({ onRenderChildren: props => childrenRenderer(props) } as Pick<IButtonProps, 'onRenderChildren'>),
      menuIconRenderer &&
        ({ onRenderMenuIcon: props => menuIconRenderer(props) } as Pick<IButtonProps, 'onRenderMenuIcon'>)
    );
  }