UNPKG

3.45 kBTypeScriptView Raw
1import { ITranslator } from '@jupyterlab/translation';
2import { ReadonlyJSONObject } from '@lumino/coreutils';
3import { FormProps, IChangeEvent } from '@rjsf/core';
4import { ArrayFieldTemplateProps } from '@rjsf/utils';
5import React from 'react';
6/**
7 * Default `ui:options` for the UiSchema.
8 */
9export declare const DEFAULT_UI_OPTIONS: {
10 /**
11 * This prevents the submit button from being rendered, by default, as it is
12 * almost never what is wanted.
13 *
14 * Provide any `uiSchema#/ui:options/submitButtonOptions` to override this.
15 */
16 submitButtonOptions: {
17 norender: boolean;
18 };
19};
20/**
21 * Form component namespace.
22 */
23export declare namespace FormComponent {
24 interface IButtonProps {
25 /**
26 * Button style.
27 */
28 buttonStyle?: 'icons' | 'text';
29 /**
30 * Translator for button text.
31 */
32 translator?: ITranslator;
33 }
34 /**
35 * Properties for React JSON schema form's container template (array and object).
36 */
37 interface ILabCustomizerProps extends IButtonProps {
38 /**
39 * Whether the container is in compact mode or not.
40 * In compact mode the title and description are displayed more compactness.
41 */
42 compact?: boolean;
43 /**
44 * Whether to display if the current value is not the default one.
45 */
46 showModifiedFromDefault?: boolean;
47 }
48 /**
49 * Properties of the button to move an item.
50 */
51 interface IMoveButtonProps extends IButtonProps {
52 /**
53 * Item index to move with this button.
54 */
55 item: ArrayFieldTemplateProps['items'][number];
56 /**
57 * Direction in which to move the item.
58 */
59 direction: 'up' | 'down';
60 }
61 /**
62 * Properties of the button to drop an item.
63 */
64 interface IDropButtonProps extends IButtonProps {
65 /**
66 * Item index to drop with this button.
67 */
68 item: ArrayFieldTemplateProps['items'][number];
69 }
70 /**
71 * Properties of the button to add an item.
72 */
73 interface IAddButtonProps extends IButtonProps {
74 /**
75 * Function to call to add an item.
76 */
77 onAddClick: ArrayFieldTemplateProps['onAddClick'];
78 }
79}
80/**
81 * Button to move an item.
82 *
83 * @returns - the button as a react element.
84 */
85export declare const MoveButton: (props: FormComponent.IMoveButtonProps) => JSX.Element;
86/**
87 * Button to drop an item.
88 *
89 * @returns - the button as a react element.
90 */
91export declare const DropButton: (props: FormComponent.IDropButtonProps) => JSX.Element;
92/**
93 * Button to add an item.
94 *
95 * @returns - the button as a react element.
96 */
97export declare const AddButton: (props: FormComponent.IAddButtonProps) => JSX.Element;
98export interface ILabCustomizerOptions<P> extends FormComponent.ILabCustomizerProps {
99 name?: string;
100 component: React.FunctionComponent<P & Required<FormComponent.ILabCustomizerProps>>;
101}
102/**
103 * FormComponent properties
104 */
105export interface IFormComponentProps<T = ReadonlyJSONObject> extends FormProps<T>, FormComponent.ILabCustomizerProps {
106 /**
107 *
108 */
109 formData: T;
110 /**
111 *
112 */
113 onChange: (e: IChangeEvent<T>) => any;
114 /**
115 *
116 */
117 formContext?: unknown;
118}
119/**
120 * Generic rjsf form component for JupyterLab UI.
121 */
122export declare function FormComponent(props: IFormComponentProps): JSX.Element;