Skip to content

Commit b2cdb68

Browse files
Update types.ts
1 parent 36a2ef5 commit b2cdb68

File tree

1 file changed

+32
-48
lines changed

1 file changed

+32
-48
lines changed

packages/utils/src/types.ts

Lines changed: 32 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ export type RJSFBaseProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
255255
export type ErrorListProps<
256256
T = any,
257257
S extends StrictRJSFSchema = RJSFSchema,
258-
F extends FormContextType = any
258+
F extends FormContextType = any,
259259
> = RJSFBaseProps<T, S, F> & {
260260
/** The errorSchema constructed by `Form` */
261261
errorSchema: ErrorSchema<T>;
@@ -269,7 +269,7 @@ export type ErrorListProps<
269269
export type FieldErrorProps<
270270
T = any,
271271
S extends StrictRJSFSchema = RJSFSchema,
272-
F extends FormContextType = any
272+
F extends FormContextType = any,
273273
> = RJSFBaseProps<T, S, F> & {
274274
/** The errorSchema constructed by `Form` */
275275
errorSchema?: ErrorSchema<T>;
@@ -283,7 +283,7 @@ export type FieldErrorProps<
283283
export type FieldHelpProps<
284284
T = any,
285285
S extends StrictRJSFSchema = RJSFSchema,
286-
F extends FormContextType = any
286+
F extends FormContextType = any,
287287
> = RJSFBaseProps<T, S, F> & {
288288
/** The help information to be rendered */
289289
help?: string | ReactElement;
@@ -476,7 +476,7 @@ export type Field<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
476476
export type FieldTemplateProps<
477477
T = any,
478478
S extends StrictRJSFSchema = RJSFSchema,
479-
F extends FormContextType = any
479+
F extends FormContextType = any,
480480
> = RJSFBaseProps<T, S, F> & {
481481
/** The id of the field in the hierarchy. You can use it to render a label targeting the wrapped widget */
482482
id: string;
@@ -534,7 +534,7 @@ export type FieldTemplateProps<
534534
export type UnsupportedFieldProps<
535535
T = any,
536536
S extends StrictRJSFSchema = RJSFSchema,
537-
F extends FormContextType = any
537+
F extends FormContextType = any,
538538
> = RJSFBaseProps<T, S, F> & {
539539
/** The tree of unique ids for every child field */
540540
idSchema?: IdSchema<T>;
@@ -546,7 +546,7 @@ export type UnsupportedFieldProps<
546546
export type TitleFieldProps<
547547
T = any,
548548
S extends StrictRJSFSchema = RJSFSchema,
549-
F extends FormContextType = any
549+
F extends FormContextType = any,
550550
> = RJSFBaseProps<T, S, F> & {
551551
/** The id of the field title in the hierarchy */
552552
id: string;
@@ -560,7 +560,7 @@ export type TitleFieldProps<
560560
export type DescriptionFieldProps<
561561
T = any,
562562
S extends StrictRJSFSchema = RJSFSchema,
563-
F extends FormContextType = any
563+
F extends FormContextType = any,
564564
> = RJSFBaseProps<T, S, F> & {
565565
/** The id of the field description in the hierarchy */
566566
id: string;
@@ -596,12 +596,8 @@ export type ArrayFieldDescriptionProps<
596596
export type ArrayFieldItemButtonsTemplateType<
597597
T = any,
598598
S extends StrictRJSFSchema = RJSFSchema,
599-
F extends FormContextType = any
600-
> = RJSFBaseProps<T, S, F> & {
601-
/** The html for the item's content */
602-
children: ReactElement;
603599
F extends FormContextType = any,
604-
> = {
600+
> = RJSFBaseProps<T, S, F> & {
605601
/** The idSchema of the item for which buttons are being rendered */
606602
idSchema: IdSchema<T>;
607603
/** The className string */
@@ -634,20 +630,14 @@ export type ArrayFieldItemButtonsTemplateType<
634630
onReorderClick: (index: number, newIndex: number) => (event?: any) => void;
635631
/** A boolean value stating if the array item is read-only */
636632
readonly?: boolean;
637-
/** The schema object for this array item */
638-
schema: S;
639-
/** The uiSchema object for this array item */
640-
uiSchema?: UiSchema<T, S, F>;
641-
/** The `registry` object */
642-
registry: Registry<T, S, F>;
643633
};
644634

645635
/** The properties of each element in the ArrayFieldTemplateProps.items array */
646636
export type ArrayFieldItemTemplateType<
647637
T = any,
648638
S extends StrictRJSFSchema = RJSFSchema,
649639
F extends FormContextType = any,
650-
> = {
640+
> = RJSFBaseProps<T, S, F> & {
651641
/** The html for the item's content */
652642
children: ReactNode;
653643
/** The props to pass to the `ArrayFieldItemButtonTemplate` */
@@ -681,7 +671,7 @@ export type ArrayFieldTemplateItemType<
681671
export type ArrayFieldTemplateProps<
682672
T = any,
683673
S extends StrictRJSFSchema = RJSFSchema,
684-
F extends FormContextType = any
674+
F extends FormContextType = any,
685675
> = RJSFBaseProps<T, S, F> & {
686676
/** A boolean value stating whether new elements can be added to the array */
687677
canAdd?: boolean;
@@ -731,7 +721,7 @@ export type ObjectFieldTemplatePropertyType = {
731721
export type ObjectFieldTemplateProps<
732722
T = any,
733723
S extends StrictRJSFSchema = RJSFSchema,
734-
F extends FormContextType = any
724+
F extends FormContextType = any,
735725
> = RJSFBaseProps<T, S, F> & {
736726
/** A string value containing the title for the object */
737727
title: string;
@@ -763,31 +753,32 @@ export type ObjectFieldTemplateProps<
763753
export type WrapIfAdditionalTemplateProps<
764754
T = any,
765755
S extends StrictRJSFSchema = RJSFSchema,
766-
F extends FormContextType = any
756+
F extends FormContextType = any,
767757
> = RJSFBaseProps<T, S, F> & {
768758
/** The field or widget component instance for this field row */
769759
children: ReactNode;
770760
} & Pick<
771-
FieldTemplateProps<T, S, F>,
772-
| 'id'
773-
| 'classNames'
774-
| 'hideError'
775-
| 'rawErrors'
776-
| 'style'
777-
| 'label'
778-
| 'required'
779-
| 'readonly'
780-
| 'disabled'
781-
| 'schema'
782-
| 'uiSchema'
783-
| 'onKeyChange'
784-
| 'onDropPropertyClick'
785-
| 'registry'
786-
>;
761+
FieldTemplateProps<T, S, F>,
762+
| 'id'
763+
| 'classNames'
764+
| 'hideError'
765+
| 'rawErrors'
766+
| 'style'
767+
| 'label'
768+
| 'required'
769+
| 'readonly'
770+
| 'disabled'
771+
| 'schema'
772+
| 'uiSchema'
773+
| 'onKeyChange'
774+
| 'onDropPropertyClick'
775+
| 'registry'
776+
>;
787777

788778
/** The properties that are passed to a Widget implementation */
789779
export interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>
790780
extends GenericObjectType,
781+
RJSFBaseProps<T, S, F>,
791782
Pick<HTMLAttributes<HTMLElement>, Exclude<keyof HTMLAttributes<HTMLElement>, 'onBlur' | 'onFocus'>> {
792783
/** The generated id for this widget, used to provide unique `name`s and `id`s for the HTML field elements rendered by
793784
* widgets
@@ -797,10 +788,6 @@ export interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
797788
* of custom widgets.
798789
*/
799790
name: string;
800-
/** The JSONSchema subschema object for this widget */
801-
schema: S;
802-
/** The uiSchema for this widget */
803-
uiSchema?: UiSchema<T, S, F>;
804791
/** The current value for this widget */
805792
value: any;
806793
/** The required status of this widget */
@@ -840,8 +827,6 @@ export interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
840827
multiple?: boolean;
841828
/** An array of strings listing all generated error messages from encountered errors for this widget */
842829
rawErrors?: string[];
843-
/** The `registry` object */
844-
registry: Registry<T, S, F>;
845830
}
846831

847832
/** The definition of a React-based Widget component */
@@ -853,9 +838,8 @@ export type Widget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends F
853838
export interface BaseInputTemplateProps<
854839
T = any,
855840
S extends StrictRJSFSchema = RJSFSchema,
856-
F extends FormContextType = any
857-
> extends WidgetProps<T, S, F>,
858-
RJSFBaseProps<T, S, F> {
841+
F extends FormContextType = any,
842+
> extends WidgetProps<T, S, F> {
859843
/** A `BaseInputTemplate` implements a default `onChange` handler that it passes to the HTML input component to handle
860844
* the `ChangeEvent`. Sometimes a widget may need to handle the `ChangeEvent` using custom logic. If that is the case,
861845
* that widget should provide its own handler via this prop.
@@ -875,7 +859,7 @@ export type SubmitButtonProps<T = any, S extends StrictRJSFSchema = RJSFSchema,
875859
export type IconButtonProps<
876860
T = any,
877861
S extends StrictRJSFSchema = RJSFSchema,
878-
F extends FormContextType = any
862+
F extends FormContextType = any,
879863
> = ButtonHTMLAttributes<HTMLButtonElement> &
880864
Omit<RJSFBaseProps<T, S, F>, 'schema'> & {
881865
/** An alternative specification for the type of the icon button */

0 commit comments

Comments
 (0)