Skip to content

Commit

Permalink
Allow generate-readmes script to work with components using forwardref (
Browse files Browse the repository at this point in the history
#2219)

* fix(generate readmes): patch package to allow forwardref components

* fix(readme generator): update path check method

* fix(readme generatot): update component prop type to allow docs generator properly transform document
  • Loading branch information
ddouglasz authored Jul 4, 2022
1 parent 580ecd5 commit e43688c
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 36 deletions.
3 changes: 1 addition & 2 deletions packages/components/buttons/accessible-button/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

## Description

A React component that you can use to wrap your buttons in an accessibile \<button/> element.
A React component that you can use to wrap your buttons in an accessible \<button/> element.

## Installation

Expand Down Expand Up @@ -58,7 +58,6 @@ export default Example;
| `className` | `string` | | | Allow to override the styles by passing a `className` prop.&#xA;<br/>&#xA;Custom styles can also be passed using the [`css` prop from emotion](https://emotion.sh/docs/css-prop#style-precedence). |
| `onClick` | `Function`<br/>[See signature.](#signature-onClick) | | | Event handler when the button is clicked, or the user presses `ENTER` or `SPACE`. |
| `buttonAttributes` | `Record` | | `{}` | Any HTML attributes to be forwarded to the HTML element. |
| `ref` | `ForwardedRef` | | | |

## Signatures

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const defaultProps: Pick<
};

const AccessibleButton = forwardRef<HTMLButtonElement, TAccessibleButtonProps>(
(props, ref) => {
(props: TAccessibleButtonProps, ref) => {
warning(
props.as ? isValidElementType(props.as) : true,
`ui-kit/AccessibleButton: "as" must be a valid element type.`
Expand Down
16 changes: 2 additions & 14 deletions packages/components/inputs/localized-rich-text-input/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export default Example;
| `value` | `Record` || | Values to use. Keyed by language, the values are the actual values, e.g. \`{ en: '<p>Horse</p>', de: '<p>Pferd</p>' } |
| `onChange` | `Function`<br/>[See signature.](#signature-onChange) | | | Gets called when any input is changed. Is called with the change event of the changed input. |
| `selectedLanguage` | `string` || | Specifies which language will be shown in case the `LocalizedRichTextInput` is collapsed. |
| `onBlur` | `Function`<br/>[See signature.](#signature-onBlur) | | | Called when any field is blurred. Is called with the `event` of that field. |
| `onFocus` | `Function`<br/>[See signature.](#signature-onFocus) | | | Called when any field is focussed. Is called with the `event` of that field. |
| `onBlur` | `FocusEventHandler` | | | Called when any field is blurred. Is called with the `event` of that field. |
| `onFocus` | `FocusEventHandler` | | | Called when any field is focussed. Is called with the `event` of that field. |
| `defaultExpandMultilineText` | `boolean` | | | Expands input components holding multiline values instead of collapsing them by default. |
| `hideLanguageExpansionControls` | `boolean` | | | Will hide the language expansion controls when set to `true`. All languages will be shown when set to `true` |
| `defaultExpandLanguages` | `boolean` | | | Controls whether one or all languages are visible by default. Pass `true` to show all languages by default. |
Expand All @@ -80,18 +80,6 @@ export default Example;
(event: TCustomEvent) => void
```

### Signature `onBlur`

```ts
(event: TCustomEvent) => void
```

### Signature `onFocus`

```ts
(event: TCustomEvent) => void
```

### Signature `onClickExpand`

```ts
Expand Down
37 changes: 18 additions & 19 deletions packages/components/inputs/rich-text-input/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,24 @@ export default Example;
## Properties
| Props | Type | Required | Default | Description |
| ---------------------------- | ----------------------------------------------------------------------------------------- | :------: | --------- | ------------------------------------------------------------------------------------------------------------------------- |
| `isAutofocussed` | `boolean` | | | Focus the control when it is mounted |
| `defaultExpandMultilineText` | `boolean` | | `false` | Expands multiline text input initially |
| `hasError` | `boolean` | | | Indicates the input field has an error |
| `hasWarning` | `boolean` | | | Indicates the input field has warning |
| `id` | `string` | | | Used as the HTML `id` attribute. |
| `name` | `string` | | | Used as the HTML `name` attribute. |
| `placeholder` | `string` | | `''` | Placeholder value to show in the input field |
| `isDisabled` | `boolean` | | | Disables the rich text input |
| `isReadOnly` | `boolean` | | | Indicates that the rich text input is displaying read-only content |
| `horizontalConstraint` | `union`<br/>Possible values:<br/>`, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'` | | `'scale'` | Horizontal size limit of the input fields |
| `onChange` | `Function`<br/>[See signature.](#signature-onChange) | | | Called with an event containing the new value. Required when input is not read only. Parent should pass it back as value. |
| `onFocus` | `FocusEventHandler` | | | Called when input is focused |
| `onBlur` | `FocusEventHandler` | | | Called when input is blurred |
| `value` | `string` | | | Value of the input component. |
| `showExpandIcon` | `boolean` | | `false` | Indicates whether the expand icon should be visible |
| `onClickExpand` | `Function`<br/>[See signature.](#signature-onClickExpand) | | | Called when the `expand` button is clicked |
| `parentRef` | `ForwardedRef` | | | |
| Props | Type | Required | Default | Description |
| ---------------------------- | ----------------------------------------------------------------------------------------- | :------: | ------- | ------------------------------------------------------------------------------------------------------------------------- |
| `isAutofocussed` | `boolean` | | | Focus the control when it is mounted |
| `defaultExpandMultilineText` | `boolean` | | | Expands multiline text input initially |
| `hasError` | `boolean` | | | Indicates the input field has an error |
| `hasWarning` | `boolean` | | | Indicates the input field has warning |
| `id` | `string` | | | Used as the HTML `id` attribute. |
| `name` | `string` | | | Used as the HTML `name` attribute. |
| `placeholder` | `string` | ✅ | | Placeholder value to show in the input field |
| `isDisabled` | `boolean` | | | Disables the rich text input |
| `isReadOnly` | `boolean` | | | Indicates that the rich text input is displaying read-only content |
| `horizontalConstraint` | `union`<br/>Possible values:<br/>`, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'` | | | Horizontal size limit of the input fields |
| `onChange` | `Function`<br/>[See signature.](#signature-onChange) | | | Called with an event containing the new value. Required when input is not read only. Parent should pass it back as value. |
| `onFocus` | `FocusEventHandler` | | | Called when input is focused |
| `onBlur` | `FocusEventHandler` | | | Called when input is blurred |
| `value` | `string` | | | Value of the input component. |
| `showExpandIcon` | `boolean` | ✅ | | Indicates whether the expand icon should be visible |
| `onClickExpand` | `Function`<br/>[See signature.](#signature-onClickExpand) | | | Called when the `expand` button is clicked |
## Signatures
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/node_modules/typescript-react-function-component-props-handler/index.js b/node_modules/typescript-react-function-component-props-handler/index.js
index 5c636b9..2f3cb68 100644
--- a/node_modules/typescript-react-function-component-props-handler/index.js
+++ b/node_modules/typescript-react-function-component-props-handler/index.js
@@ -47,9 +47,9 @@ function checkForProptypes(path, paramTypeName) {
}

function setParamsTypeDefinitionFromFunctionType(documentation, path) {
- if (path.parentPath.node.init && path.parentPath.node.init.params.length === 0) {
+ if (path.parentPath.node.init && Array.isArray(path.parentPath.node.init.params) && path.parentPath.node.init.params.length === 0) {
return;
- }
+ }

if (
path.node.type === 'ArrowFunctionExpression' &&

1 comment on commit e43688c

@vercel
Copy link

@vercel vercel bot commented on e43688c Jul 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.