couds / react-bulma-components

React components for Bulma framework
MIT License
1.2k stars 129 forks source link

Form.Input typing explicitly does not contain renderAs #424

Open Adelrisk opened 1 year ago

Adelrisk commented 1 year ago

Describe the bug

Form.Input in the typings file explicitly excludes renderAs

// https://github.com/couds/react-bulma-components/blob/v4.1.0/src/components/form/index.d.ts#L91
declare const Form: {
  Input: <TValue>(
    props: OmitKeys<
      InputProps<TValue> & ElementProps<InputProps<TValue>, 'input'>,
      'renderAs' | 'readonly'
    >,
  ) => React.ReactElement;
}

However, the documentation explicitly describes the availability of renderAs on every component. https://couds.github.io/react-bulma-components/iframe.html?id=core-component-the-renderas-prop--page&viewMode=docs

Under the hood, each Bulma component has a specified default `renderAs` component
that they will use to render, along with all the generated Bulma classes.

In the Javascript file, the functionality appears to be available:

//https://github.com/couds/react-bulma-components/blob/v4.1.0/src/components/form/components/input.js#L78
Input.propTypes = {
// ...
  renderAs: PropTypes.oneOfType([
    PropTypes.func,
    PropTypes.string,
    PropTypes.object,
  ]),
};

Input.defaultProps = {
  renderAs: 'input',
};

To Reproduce Not applicable. This is a compile-time error.

Expected behavior The component Form.Input (and other components?) should support renderAs.

Screenshots If applicable, add screenshots to help explain your problem.

Versions

Additional context

Purpose: I'd like to combine the form validation of a Formik Field with these react bulma components.

The current state of the code appears to be the result of a re-write in version 4.0.0 (see #265). Funnily enough, the following commit seems to enable/address this functionality with the comment Allow override of renderAs of Form.Input; remove default HTML attrs propTypes

https://github.com/couds/react-bulma-components/pull/265/commits/f0635ef8bef334d4c380507c9dbcb7e8de888b90