@jsonforms/vue
Version:
Vue 3 module of JSON Forms
607 lines (606 loc) • 21.2 kB
TypeScript
import { ControlElement, Dispatch, Layout, JsonSchema, UISchemaElement, CoreActions, JsonFormsState, OwnPropsOfMasterListItem, mapStateToArrayControlProps, mapDispatchToArrayControlProps, JsonFormsRendererRegistryEntry, JsonFormsCellRendererRegistryEntry, LabelElement, Scopable } from '@jsonforms/core';
import { PropType, ComputedRef } from 'vue';
/**
* Constructs a props declaration for Vue components which can be used
* for registered renderers and cells. These are typically used in combination
* with one of the provided bindings, e.g. 'useJsonFormsControl'.
*
* Use the generic type parameter when using a specialized binding, e.g.
* `rendererProps<Layout>()` in combination with `useJsonFormsLayout` or
* `rendererProps<ControlElement>()` in combination with `useJsonFormsControl`.
*/
export declare const rendererProps: <U = UISchemaElement>() => {
schema: {
required: true;
type: PropType<JsonSchema>;
};
uischema: {
required: true;
type: PropType<U>;
};
path: {
required: true;
type: StringConstructor;
};
enabled: {
required: false;
type: BooleanConstructor;
default: undefined;
};
renderers: {
required: boolean;
type: PropType<JsonFormsRendererRegistryEntry[]>;
default: undefined;
};
cells: {
required: boolean;
type: PropType<JsonFormsCellRendererRegistryEntry[]>;
default: undefined;
};
config: {
required: boolean;
type: ObjectConstructor;
default: undefined;
};
};
/**
* Constructs a props declaration for Vue components which shall be used as
* master list items.
*/
export declare const masterListItemProps: () => {
index: {
required: true;
type: NumberConstructor;
};
selected: {
required: true;
type: BooleanConstructor;
};
path: {
required: true;
type: StringConstructor;
};
schema: {
required: true;
type: PropType<JsonSchema>;
};
handleSelect: {
required: false;
type: PropType<(index: number) => void>;
default: undefined;
};
removeItem: {
required: false;
type: PropType<(path: string, value: number) => void>;
default: undefined;
};
};
export interface RendererProps<U = UISchemaElement> {
schema: JsonSchema;
uischema: U;
path: string;
enabled?: boolean;
renderers?: JsonFormsRendererRegistryEntry[];
cells?: JsonFormsCellRendererRegistryEntry[];
config?: any;
}
export interface ControlProps extends RendererProps {
uischema: ControlElement;
}
export type Required<T> = T extends object ? {
[P in keyof T]-?: NonNullable<T[P]>;
} : T;
export declare function useControl<R, D, P extends {
schema: JsonSchema;
uischema: UISchemaElement & Scopable;
}>(props: P, stateMap: (state: JsonFormsState, props: P) => R): {
control: ComputedRef<Required<P & R>>;
};
export declare function useControl<R, D, P extends {
schema: JsonSchema;
uischema: UISchemaElement & Scopable;
}>(props: P, stateMap: (state: JsonFormsState, props: P) => R, dispatchMap: (dispatch: Dispatch<CoreActions>) => D): {
control: ComputedRef<Required<P & R>>;
} & D;
/**
* Provides generic bindings for 'Control' elements.
* Should be used when no specialized bindings are appropriate.
*
* Access bindings via the provided reactive `control` object.
* Dispatch changes via the provided `handleChange` method.
*/
export declare const useJsonFormsControl: (props: ControlProps) => {
control: ComputedRef<{
uischema: ControlElement;
schema: NonNullable<JsonSchema>;
path: string;
enabled: boolean;
renderers: JsonFormsRendererRegistryEntry[];
cells: JsonFormsCellRendererRegistryEntry[] & {
tester: import("@jsonforms/core").RankedTester;
cell: any;
}[];
config: any;
label: string;
description: string;
required: NonNullable<boolean | undefined>;
i18nKeyPrefix: string;
errors: string;
data: any;
rootSchema: NonNullable<JsonSchema>;
id: string;
visible: boolean;
}>;
} & import("@jsonforms/core").DispatchPropsOfControl;
/**
* Provides bindings for 'Control' elements which can provide a 'detail',
* for example array and object renderers.
*
* Access bindings via the provided reactive `control` object.
* Dispatch changes via the provided `handleChange` method.
*/
export declare const useJsonFormsControlWithDetail: (props: ControlProps) => {
control: ComputedRef<{
uischema: ControlElement;
schema: NonNullable<JsonSchema>;
path: string;
enabled: boolean;
renderers: JsonFormsRendererRegistryEntry[];
cells: JsonFormsCellRendererRegistryEntry[];
config: any;
uischemas: import("@jsonforms/core").JsonFormsUISchemaRegistryEntry[];
label: string;
description: string;
required: NonNullable<boolean | undefined>;
i18nKeyPrefix: string;
errors: string;
data: any;
rootSchema: NonNullable<JsonSchema>;
id: string;
visible: boolean;
}>;
} & import("@jsonforms/core").DispatchPropsOfControl;
/**
* Provides bindings for 'Control' elements which resolve to 'enum' schema elements.
*
* Access bindings via the provided reactive `control` object.
* Dispatch changes via the provided `handleChange` method.
*/
export declare const useJsonFormsEnumControl: (props: ControlProps) => {
control: ComputedRef<{
uischema: ControlElement;
schema: NonNullable<JsonSchema>;
path: string;
enabled: boolean;
renderers: JsonFormsRendererRegistryEntry[];
cells: JsonFormsCellRendererRegistryEntry[] & {
tester: import("@jsonforms/core").RankedTester;
cell: any;
}[];
config: any;
label: string;
description: string;
required: NonNullable<boolean | undefined>;
i18nKeyPrefix: string;
errors: string;
data: any;
rootSchema: NonNullable<JsonSchema>;
id: string;
visible: boolean;
options: import("@jsonforms/core").EnumOption[];
}>;
} & import("@jsonforms/core").DispatchPropsOfControl;
/**
* Provides bindings for 'Control' elements which resolve to manually constructed
* 'oneOf' enums. These are used to enhance enums with label support.
*
* Access bindings via the provided reactive `control` object.
* Dispatch changes via the provided `handleChange` method.
*/
export declare const useJsonFormsOneOfEnumControl: (props: ControlProps) => {
control: ComputedRef<{
uischema: ControlElement;
schema: NonNullable<JsonSchema>;
path: string;
enabled: boolean;
renderers: JsonFormsRendererRegistryEntry[];
cells: JsonFormsCellRendererRegistryEntry[] & {
tester: import("@jsonforms/core").RankedTester;
cell: any;
}[];
config: any;
label: string;
description: string;
required: NonNullable<boolean | undefined>;
i18nKeyPrefix: string;
errors: string;
data: any;
rootSchema: NonNullable<JsonSchema>;
id: string;
visible: boolean;
options: import("@jsonforms/core").EnumOption[];
}>;
} & import("@jsonforms/core").DispatchPropsOfControl;
type UseJsonFormsArrayControlReturnType = {
control: ComputedRef<Required<ReturnType<typeof mapStateToArrayControlProps>>>;
} & ReturnType<typeof mapDispatchToArrayControlProps>;
/**
* Provides bindings for 'Control' elements which resolve to 'array' schema elements.
*
* Access bindings via the provided reactive `control` object.
* Dispatch changes via the provided `handleChange` method.
*/
export declare const useJsonFormsArrayControl: (props: ControlProps) => UseJsonFormsArrayControlReturnType;
/**
* Provides bindings for 'Control' elements which resolve to 'allOf' schema elements.
*
* Access bindings via the provided reactive `control` object.
* Dispatch changes via the provided `handleChange` method.
*/
export declare const useJsonFormsAllOfControl: (props: ControlProps) => {
control: ComputedRef<{
uischema: ControlElement;
schema: NonNullable<JsonSchema>;
path: string;
enabled: boolean;
renderers: JsonFormsRendererRegistryEntry[];
cells: JsonFormsCellRendererRegistryEntry[] & {
tester: import("@jsonforms/core").RankedTester;
cell: any;
}[];
config: any;
rootSchema: NonNullable<JsonSchema>;
id: string;
indexOfFittingSchema: number;
uischemas: import("@jsonforms/core").JsonFormsUISchemaRegistryEntry[];
data: any;
label: string;
description: string;
required: NonNullable<boolean | undefined>;
i18nKeyPrefix: string;
errors: string;
visible: boolean;
}>;
} & import("@jsonforms/core").DispatchPropsOfControl;
/**
* Provides bindings for 'Control' elements which resolve to 'anyOf' schema elements.
*
* Access bindings via the provided reactive `control` object.
* Dispatch changes via the provided `handleChange` method.
*/
export declare const useJsonFormsAnyOfControl: (props: ControlProps) => {
control: ComputedRef<{
uischema: ControlElement;
schema: NonNullable<JsonSchema>;
path: string;
enabled: boolean;
renderers: JsonFormsRendererRegistryEntry[];
cells: JsonFormsCellRendererRegistryEntry[] & {
tester: import("@jsonforms/core").RankedTester;
cell: any;
}[];
config: any;
rootSchema: NonNullable<JsonSchema>;
id: string;
indexOfFittingSchema: number;
uischemas: import("@jsonforms/core").JsonFormsUISchemaRegistryEntry[];
data: any;
label: string;
description: string;
required: NonNullable<boolean | undefined>;
i18nKeyPrefix: string;
errors: string;
visible: boolean;
}>;
} & import("@jsonforms/core").DispatchPropsOfControl;
/**
* Provides bindings for 'Control' elements which resolve to 'oneOf' schema elements.
*
* Access bindings via the provided reactive `control` object.
* Dispatch changes via the provided `handleChange` method.
*/
export declare const useJsonFormsOneOfControl: (props: ControlProps) => {
control: ComputedRef<{
uischema: ControlElement;
schema: NonNullable<JsonSchema>;
path: string;
enabled: boolean;
renderers: JsonFormsRendererRegistryEntry[];
cells: JsonFormsCellRendererRegistryEntry[] & {
tester: import("@jsonforms/core").RankedTester;
cell: any;
}[];
config: any;
rootSchema: NonNullable<JsonSchema>;
id: string;
indexOfFittingSchema: number;
uischemas: import("@jsonforms/core").JsonFormsUISchemaRegistryEntry[];
data: any;
label: string;
description: string;
required: NonNullable<boolean | undefined>;
i18nKeyPrefix: string;
errors: string;
visible: boolean;
}>;
} & import("@jsonforms/core").DispatchPropsOfControl;
/**
* Provides bindings for 'Control' elements which resolve to multiple choice enums.
*
* Access bindings via the provided reactive `control` object.
* Dispatch changes via the provided `handleChange` method.
*/
export declare const useJsonFormsMultiEnumControl: (props: ControlProps) => {
control: ComputedRef<{
uischema: ControlElement;
schema: NonNullable<JsonSchema>;
path: string;
enabled: boolean;
renderers: JsonFormsRendererRegistryEntry[];
cells: JsonFormsCellRendererRegistryEntry[] & {
tester: import("@jsonforms/core").RankedTester;
cell: any;
}[];
config: any;
label: string;
description: string;
required: NonNullable<boolean | undefined>;
i18nKeyPrefix: string;
errors: string;
data: any;
rootSchema: NonNullable<JsonSchema>;
id: string;
visible: boolean;
options: import("@jsonforms/core").EnumOption[];
}>;
} & import("@jsonforms/core").DispatchPropsOfMultiEnumControl;
export interface LayoutProps extends RendererProps {
uischema: Layout;
}
/**
* Provides bindings for 'Layout' elements, e.g. VerticalLayout, HorizontalLayout, Group.
*
* Access bindings via the provided reactive 'layout' object.
*/
export declare const useJsonFormsLayout: (props: LayoutProps) => {
layout: ComputedRef<{
uischema: NonNullable<Layout & UISchemaElement>;
schema: NonNullable<JsonSchema>;
path: string;
enabled: boolean;
renderers: JsonFormsRendererRegistryEntry[];
cells: JsonFormsCellRendererRegistryEntry[];
config: any;
direction: NonNullable<"row" | "column">;
label: string;
data: any;
visible: boolean;
}>;
};
/**
* Provides bindings for 'Control' elements which resolve to 'array' elements which
* shall be rendered as a layout instead of a control.
*
* Access bindings via the provided reactive 'layout' object.
*/
export declare const useJsonFormsArrayLayout: (props: ControlProps) => {
layout: ComputedRef<{
uischema: ControlElement;
schema: NonNullable<JsonSchema>;
path: string;
enabled: boolean;
renderers: JsonFormsRendererRegistryEntry[];
cells: JsonFormsCellRendererRegistryEntry[];
config: any;
data: number;
arraySchema: NonNullable<JsonSchema>;
minItems: number;
disableRemove: NonNullable<boolean | undefined>;
disableAdd: NonNullable<boolean | undefined>;
uischemas: import("@jsonforms/core").JsonFormsUISchemaRegistryEntry[];
label: string;
description: string;
required: NonNullable<boolean | undefined>;
i18nKeyPrefix: string;
errors: string;
rootSchema: NonNullable<JsonSchema>;
id: string;
visible: boolean;
}>;
};
/**
* Provides bindings for list elements of a master-list-detail control setup.
* The element using this binding is not supposed to be registered as an own renderer
* but used in a more specialized control.
*
* Access bindings via the provided reactive 'item' object.
*/
export declare const useJsonFormsMasterListItem: (props: OwnPropsOfMasterListItem) => {
item: ComputedRef<{
index: number;
selected: boolean;
path: string;
enabled: boolean;
schema: NonNullable<JsonSchema>;
uischema: NonNullable<UISchemaElement>;
childLabelProp: string;
handleSelect: (index: number) => () => void;
removeItem: (path: string, value: number) => () => void;
translations: import("@jsonforms/core").ArrayTranslations;
disableRemove: NonNullable<boolean | undefined>;
}>;
};
/**
* Provides specialized bindings which can be used for any renderer.
* Useful for meta elements like dispatchers.
*
* Access bindings via the provided reactive 'renderer' object.
*/
export declare const useJsonFormsRenderer: (props: RendererProps) => {
renderer: ComputedRef<{
config: any;
uischema: NonNullable<UISchemaElement | undefined>;
schema: NonNullable<JsonSchema | undefined>;
enabled: NonNullable<boolean | undefined>;
visible: NonNullable<boolean | undefined>;
path: string;
renderers: JsonFormsRendererRegistryEntry[];
cells: JsonFormsCellRendererRegistryEntry[];
uischemas: import("@jsonforms/core").JsonFormsUISchemaRegistryEntry[];
}>;
rootSchema: ComputedRef<NonNullable<JsonSchema>>;
};
/**
* Provides bindings for 'Label' elements.
*
* Access bindings via the provided reactive `label` object.
*/
export declare const useJsonFormsLabel: (props: RendererProps<LabelElement>) => {
label: ComputedRef<{
schema: NonNullable<JsonSchema>;
uischema: LabelElement;
path: string;
enabled: NonNullable<boolean | undefined>;
renderers: JsonFormsRendererRegistryEntry[];
cells: JsonFormsCellRendererRegistryEntry[];
config: any;
text: string;
visible: boolean;
}>;
};
/**
* Provides bindings for cell elements. Cells are meant to show simple inputs,
* for example without error validation, within a larger structure like tables.
*
* Access bindings via the provided reactive 'cell' object.
* Dispatch changes via the provided `handleChange` method.
*/
export declare const useJsonFormsCell: (props: ControlProps) => {
handleChange(path: string, value: any): void;
cell: ComputedRef<{
uischema: ControlElement;
schema: NonNullable<JsonSchema>;
path: string;
enabled: boolean;
renderers: JsonFormsRendererRegistryEntry[];
cells: JsonFormsCellRendererRegistryEntry[];
config: any;
isValid: boolean;
rootSchema: NonNullable<JsonSchema>;
errors: string;
data: any;
id: string;
visible: boolean;
}>;
};
/**
* Provides bindings for enum cell elements. Cells are meant to show simple inputs,
* for example without error validation, within a larger structure like tables.
*
* Access bindings via the provided reactive 'cell' object.
* Dispatch changes via the provided `handleChange` method.
*/
export declare const useJsonFormsEnumCell: (props: ControlProps) => {
handleChange(path: string, value: any): void;
cell: ComputedRef<{
uischema: ControlElement;
schema: NonNullable<JsonSchema>;
path: string;
enabled: boolean;
renderers: JsonFormsRendererRegistryEntry[];
cells: JsonFormsCellRendererRegistryEntry[];
config: any;
isValid: boolean;
rootSchema: NonNullable<JsonSchema>;
errors: string;
data: any;
id: string;
visible: boolean;
options: import("@jsonforms/core").EnumOption[];
}>;
};
/**
* Provides bindings for 'oneOf' enum cell elements. Cells are meant to show simple inputs,
* for example without error validation, within a larger structure like tables.
*
* Access bindings via the provided reactive 'cell' object.
* Dispatch changes via the provided `handleChange` method.
*/
export declare const useJsonFormsOneOfEnumCell: (props: ControlProps) => {
handleChange(path: string, value: any): void;
cell: ComputedRef<{
uischema: ControlElement;
schema: NonNullable<JsonSchema>;
path: string;
enabled: boolean;
renderers: JsonFormsRendererRegistryEntry[];
cells: JsonFormsCellRendererRegistryEntry[];
config: any;
isValid: boolean;
rootSchema: NonNullable<JsonSchema>;
errors: string;
data: any;
id: string;
visible: boolean;
options: import("@jsonforms/core").EnumOption[];
}>;
};
/**
* Provides bindings for a cell dispatcher. Cells are meant to show simple inputs,
* for example without error validation, within a larger structure like tables.
*
* Access bindings via the provided reactive 'cell' object.
* Dispatch changes via the provided `handleChange` method.
*/
export declare const useJsonFormsDispatchCell: (props: ControlProps) => {
handleChange(path: string, value: any): void;
cell: ComputedRef<{
uischema: ControlElement;
schema: NonNullable<JsonSchema>;
path: string;
enabled: boolean;
renderers: JsonFormsRendererRegistryEntry[];
cells: JsonFormsCellRendererRegistryEntry[];
config: any;
isValid: boolean;
rootSchema: NonNullable<JsonSchema>;
errors: string;
data: any;
id: string;
visible: boolean;
}>;
};
/**
* Provides bindings for 'Categorization' elements.
*
* Access bindings via the provided `categories` array with reactive category objects.
*/
export declare const useJsonFormsCategorization: (props: LayoutProps) => {
layout: ComputedRef<{
uischema: NonNullable<Layout & UISchemaElement>;
schema: NonNullable<JsonSchema>;
path: string;
enabled: boolean;
renderers: JsonFormsRendererRegistryEntry[];
cells: JsonFormsCellRendererRegistryEntry[];
config: any;
direction: NonNullable<"row" | "column">;
label: string;
data: any;
visible: boolean;
}>;
categories: ComputedRef<{
uischema: NonNullable<Layout & UISchemaElement>;
schema: NonNullable<JsonSchema>;
path: string;
enabled: boolean;
renderers: JsonFormsRendererRegistryEntry[];
cells: JsonFormsCellRendererRegistryEntry[];
config: any;
direction: NonNullable<"row" | "column">;
label: string;
data: any;
visible: boolean;
}>[];
};
export {};