Skip to content

Commit e4c83fd

Browse files
committed
Improve RowProps and CellProps generics docs
1 parent 03fd826 commit e4c83fd

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

lib/components/grid/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type {
77
} from "react";
88
import type { TagNames } from "../../types";
99

10-
type ForbiddenKeys = "columnIndex" | "rowIndex" | "style";
10+
type ForbiddenKeys = "ariaAttributes" | "columnIndex" | "rowIndex" | "style";
1111
type ExcludeForbiddenKeys<Type> = {
1212
[Key in keyof Type]: Key extends ForbiddenKeys ? never : Type[Key];
1313
};
@@ -40,7 +40,7 @@ export type GridProps<
4040
* Additional props to be passed to the cell-rendering component.
4141
* Grid will automatically re-render cells when values in this object change.
4242
*
43-
* ⚠️ This object must not contain either an `index` or `style` prop.
43+
* ⚠️ This object must not contain `ariaAttributes`, `columnIndex`, `rowIndex`, or `style` props.
4444
*/
4545
cellProps: ExcludeForbiddenKeys<CellProps>;
4646

lib/components/list/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export type ListProps<
125125
* Additional props to be passed to the row-rendering component.
126126
* List will automatically re-render rows when values in this object change.
127127
*
128-
* ⚠️ This object must not contain either an `index` or `style` prop.
128+
* ⚠️ This object must not contain `ariaAttributes`, `index`, or `style` props.
129129
*/
130130
rowProps: ExcludeForbiddenKeys<RowProps>;
131131

public/generated/js-docs/Grid.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
},
3636
"cellProps": {
3737
"description": "Additional props to be passed to the cell-rendering component.\nGrid will automatically re-render cells when values in this object change.",
38-
"html": "<div style=\"min-height: 1rem; padding-left: 2ch; text-indent: -2ch;\"><span class=\"tok-labelName\"><span class=\"tok-propertyName\">cellProps</span></span><span class=\"tok-punctuation\">:</span><span class=\"\"> </span><span class=\"tok-variableName\">ExcludeForbiddenKeys</span><span class=\"\">&#60;</span><span class=\"tok-typeName\">CellProps</span></div>",
38+
"html": "<div style=\"min-height: 1rem; padding-left: 2ch; text-indent: -2ch;\"><span class=\"tok-labelName\"><span class=\"tok-propertyName\">cellProps</span></span><span class=\"tok-punctuation\">:</span><span class=\"\"> </span><span class=\"tok-variableName\">CellProps</span></div>",
3939
"name": "cellProps",
4040
"required": true,
41-
"warning": "This object must not contain either an <code>index</code> or <code>style</code> prop."
41+
"warning": "This object must not contain <code>ariaAttributes</code>, <code>columnIndex</code>, <code>rowIndex</code>, or <code>style</code> props."
4242
},
4343
"columnCount": {
4444
"description": "Number of columns to be rendered in the grid.",

public/generated/js-docs/List.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@
7373
},
7474
"rowProps": {
7575
"description": "Additional props to be passed to the row-rendering component.\nList will automatically re-render rows when values in this object change.",
76-
"html": "<div style=\"min-height: 1rem; padding-left: 2ch; text-indent: -2ch;\"><span class=\"tok-labelName\"><span class=\"tok-propertyName\">rowProps</span></span><span class=\"tok-punctuation\">:</span><span class=\"\"> </span><span class=\"tok-variableName\">ExcludeForbiddenKeys</span><span class=\"\">&#60;</span><span class=\"tok-typeName\">RowProps</span></div>",
76+
"html": "<div style=\"min-height: 1rem; padding-left: 2ch; text-indent: -2ch;\"><span class=\"tok-labelName\"><span class=\"tok-propertyName\">rowProps</span></span><span class=\"tok-punctuation\">:</span><span class=\"\"> </span><span class=\"tok-variableName\">RowProps</span></div>",
7777
"name": "rowProps",
7878
"required": true,
79-
"warning": "This object must not contain either an <code>index</code> or <code>style</code> prop."
79+
"warning": "This object must not contain <code>ariaAttributes</code>, <code>index</code>, or <code>style</code> props."
8080
},
8181
"tagName": {
8282
"description": "Can be used to override the root HTML element rendered by the List component.\nThe default value is \"div\", meaning that List renders an HTMLDivElement as its root.",

scripts/compile-docs.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ async function run() {
5555
for (const name in component.props) {
5656
const prop = component.props[name];
5757

58-
// TODO ExcludeForbiddenKeys
59-
6058
let textToFormat = prop.type.raw;
6159
if (!textToFormat && prop.type.name.includes(":")) {
6260
// Edge case where some prop types aren't registered as containing raw TS
@@ -65,6 +63,11 @@ async function run() {
6563

6664
if (!textToFormat) {
6765
textToFormat = `${prop.type.name}`;
66+
67+
const match = textToFormat.match(/ExcludeForbiddenKeys<([^>]+)>/);
68+
if (match) {
69+
textToFormat = match[1];
70+
}
6871
}
6972

7073
if (prop.defaultValue?.value) {

0 commit comments

Comments
 (0)