Skip to content

Commit 735dee7

Browse files
committed
Add JSDoc for primereact.
Set `id` property in `ArrayFieldTitleTemplate`
1 parent 64febb6 commit 735dee7

File tree

8 files changed

+56
-7
lines changed

8 files changed

+56
-7
lines changed

packages/primereact/src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import {
77
StrictRJSFSchema,
88
} from '@rjsf/utils';
99

10+
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
11+
*
12+
* @param props - The `ArrayFieldItemTemplateType` props for the component
13+
*/
1014
export default function ArrayFieldItemTemplate<
1115
T = any,
1216
S extends StrictRJSFSchema = RJSFSchema,

packages/primereact/src/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.tsx

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1-
import { ArrayFieldTitleProps, FormContextType, getUiOptions, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
1+
import {
2+
ArrayFieldTitleProps,
3+
FormContextType,
4+
getUiOptions,
5+
RJSFSchema,
6+
StrictRJSFSchema,
7+
titleId,
8+
} from '@rjsf/utils';
29

10+
/** The `ArrayFieldTitleTemplate` component renders a header for the array.
11+
*
12+
* @param props - The `ArrayFieldTitleProps` for the component
13+
*/
314
export default function ArrayFieldTitleTemplate<
415
T = any,
516
S extends StrictRJSFSchema = RJSFSchema,
617
F extends FormContextType = any,
7-
>({ title, uiSchema, required }: ArrayFieldTitleProps<T, S, F>) {
18+
>({ title, uiSchema, required, idSchema }: ArrayFieldTitleProps<T, S, F>) {
819
const uiOptions = getUiOptions<T, S, F>(uiSchema);
920
return (
10-
<h5 style={{ margin: 0, fontSize: '1.5rem', marginBottom: '0.2rem' }}>
21+
<h5 id={titleId(idSchema)} style={{ margin: 0, fontSize: '1.5rem', marginBottom: '0.2rem' }}>
1122
{uiOptions.title || title} {required ? '*' : ''}
1223
</h5>
1324
);

packages/primereact/src/AutoCompleteWidget/AutoCompleteWidget.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ import {
99
} from '@rjsf/utils';
1010
import { AutoComplete, AutoCompleteCompleteEvent } from 'primereact/autocomplete';
1111

12+
/** The `AutoCompleteWidget` is a widget for rendering a field with options.
13+
* This is used instead of the base input template if the schema has examples.
14+
*
15+
* @param props - The `WidgetProps` for this component
16+
*/
1217
export default function AutoCompleteWidget<
1318
T = any,
1419
S extends StrictRJSFSchema = RJSFSchema,

packages/primereact/src/ColorWidget/ColorWidget.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import {
99
} from '@rjsf/utils';
1010
import { ColorPicker } from 'primereact/colorpicker';
1111

12+
/** The `ColorWidget` component renders a color picker.
13+
*
14+
* @param props - The `WidgetProps` for this component
15+
*/
1216
export default function ColorWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
1317
props: WidgetProps<T, S, F>,
1418
) {

packages/primereact/src/GridTemplate/GridTemplate.tsx

+16-4
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,31 @@ function getInitialWidth(): number {
3636
return typeof window !== 'undefined' ? window.innerWidth : breakpoints.xs;
3737
}
3838

39+
/** Renders a `GridTemplate`, which is expecting the column size for each viewport breakpoint (xs, sm, md, lg, xl)
40+
* coming in via the extra props provided by the caller.
41+
* Uses a 12 column grid by default. This can be overridden by passing `layoutGrid` in `uiSchema`.
42+
*
43+
* @param props - The GridTemplateProps, including the extra props containing the grid sizing details
44+
*/
3945
export default function GridTemplate(props: GridTemplateProps) {
4046
return props.column ? GridTemplateColumn(props) : GridTemplateRow(props);
4147
}
4248

4349
function GridTemplateRow(props: GridTemplateProps) {
44-
const { children, column, uiSchema, ...rest } = props;
50+
const { children, column, uiSchema, style, ...rest } = props;
4551
const layoutGrid = uiSchema?.['ui:layoutGrid'] ?? {};
4652
const totalColumns = layoutGrid.columns ?? 12;
4753
const gap = layoutGrid.gap ?? '16px';
4854

4955
return (
5056
<div
51-
style={{ display: 'grid', gridTemplateColumns: `repeat(${totalColumns}, 1fr)`, alignItems: 'start', gap }}
57+
style={{
58+
display: 'grid',
59+
gridTemplateColumns: `repeat(${totalColumns}, 1fr)`,
60+
alignItems: 'start',
61+
gap,
62+
...(style ?? {}),
63+
}}
5264
{...rest}
5365
>
5466
{children}
@@ -57,7 +69,7 @@ function GridTemplateRow(props: GridTemplateProps) {
5769
}
5870

5971
function GridTemplateColumn(props: GridTemplateProps) {
60-
const { children, column, uiSchema, xs, sm, md, lg, xl, ...rest } = props;
72+
const { children, column, uiSchema, xs, sm, md, lg, xl, style, ...rest } = props;
6173

6274
const [breakpoint, setBreakpoint] = useState<Breakpoint>(() => getBreakpoint(getInitialWidth()));
6375

@@ -74,7 +86,7 @@ function GridTemplateColumn(props: GridTemplateProps) {
7486
const span = getResponsiveSpan(props as ResponsiveSpan, breakpoint);
7587

7688
return (
77-
<div style={{ gridColumn: `span ${span} / span ${span}` }} {...rest}>
89+
<div style={{ gridColumn: `span ${span} / span ${span}`, ...(style ?? {}) }} {...rest}>
7890
{children}
7991
</div>
8092
);

packages/primereact/src/TitleField/TitleField.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { Divider } from 'primereact/divider';
22
import { FormContextType, getUiOptions, RJSFSchema, StrictRJSFSchema, TitleFieldProps } from '@rjsf/utils';
33

4+
/** The `TitleField` is the template to use to render the title of a field
5+
*
6+
* @param props - The `TitleFieldProps` for this component
7+
*/
48
export default function TitleField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
59
id,
610
title,

packages/primereact/src/UpDownWidget/UpDownWidget.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import {
88
} from '@rjsf/utils';
99
import { InputNumber, InputNumberChangeEvent } from 'primereact/inputnumber';
1010

11+
/** The `UpDownWidget` renders an input component for a number.
12+
*
13+
* @param props - The `WidgetProps` for this component
14+
*/
1115
export default function UpDownWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
1216
props: WidgetProps<T, S, F>,
1317
) {

packages/primereact/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ import {
1010
} from '@rjsf/utils';
1111
import { InputText } from 'primereact/inputtext';
1212

13+
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
14+
* part of an `additionalProperties` part of a schema.
15+
*
16+
* @param props - The `WrapIfAdditionalProps` for this component
17+
*/
1318
export default function WrapIfAdditionalTemplate<
1419
T = any,
1520
S extends StrictRJSFSchema = RJSFSchema,

0 commit comments

Comments
 (0)