Skip to content

Commit

Permalink
update: add RJSF form
Browse files Browse the repository at this point in the history
  • Loading branch information
k0stik committed Jul 29, 2024
1 parent dd3dfa2 commit f4633ac
Show file tree
Hide file tree
Showing 29 changed files with 7,274 additions and 3,375 deletions.
10 changes: 6 additions & 4 deletions dist/mui/components/custom/date-picker/DatePicker.styled.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export declare const DatePickerButtonsContainer: StyledComponent<ComponentProps, SpecificComponentProps, JSXProps>;
export declare const StyledPopover: StyledComponent<ComponentProps, SpecificComponentProps, JSXProps>;
export declare const StyledDatePicker: StyledComponent<ComponentProps, SpecificComponentProps, JSXProps>;
export declare const StyledDatePickerContainer: StyledComponent<ComponentProps, SpecificComponentProps, JSXProps>;
/// <reference types="react" />
import { Theme } from "@mui/material/styles";
export declare const DatePickerButtonsContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
export declare const StyledPopover: import("@emotion/styled").StyledComponent<import("@mui/material/Popover").PopoverProps & import("@mui/system").MUIStyledCommonProps<Theme>, {}, {}>;
export declare const StyledDatePicker: import("@emotion/styled").StyledComponent<import("@mui/x-date-pickers/DatePicker").DatePickerProps<unknown> & import("react").RefAttributes<HTMLDivElement> & import("@mui/system").MUIStyledCommonProps<Theme>, {}, {}>;
export declare const StyledDatePickerContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
2 changes: 1 addition & 1 deletion dist/mui/components/stepper/Stepper.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
export declare const StyledStepConnector: StyledComponent<ComponentProps, SpecificComponentProps, JSXProps>;
export declare const StyledStepConnector: import("@emotion/styled").StyledComponent<import("@mui/material/StepConnector").StepConnectorProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
export interface StyledStepperProps {
activeStep: number;
steps: string[];
Expand Down
7 changes: 4 additions & 3 deletions dist/other/fullscreen/FullscreenComponentMixin.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from "react";
import Fullscreen from "react-full-screen";
declare class FullscreenHandlerComponent extends Fullscreen {
render(): React.JSX.Element;
import { FullScreenProps } from "react-full-screen";
interface FullscreenHandlerComponent extends Omit<FullScreenProps, "handle"> {
enabled: boolean;
}
declare function FullscreenHandlerComponent({ enabled, ...props }: FullscreenHandlerComponent): React.JSX.Element;
declare const FullscreenComponentMixin: (superclass: React.ComponentClass) => {
new (props: never): {
toggleFullscreen(): void;
Expand Down
21 changes: 14 additions & 7 deletions dist/other/fullscreen/FullscreenComponentMixin.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
/* eslint-disable react/jsx-props-no-spreading */
import setClass from "classnames";
import React from "react";
import Fullscreen from "react-full-screen";
class FullscreenHandlerComponent extends Fullscreen {
render() {
// @ts-ignore
return React.createElement("div", { className: this.props.className }, super.render());
}
import React, { useEffect } from "react";
import { FullScreen, useFullScreenHandle } from "react-full-screen";
function FullscreenHandlerComponent({ enabled, ...props }) {
const handle = useFullScreenHandle();
useEffect(() => {
if (enabled) {
handle.enter();
}
else {
handle.exit();
}
}, [enabled]);
return React.createElement(FullScreen, { ...props, handle: handle });
}
const FullscreenComponentMixin = (superclass) => class extends superclass {
constructor(props) {
Expand Down
4 changes: 4 additions & 0 deletions dist/other/rjsf/RJSFForm.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { FormProps } from "@rjsf/core";
import { RJSFSchema } from "@rjsf/utils";
import React from "react";
export default function RJSFForm(props: FormProps<any, RJSFSchema, any>): React.JSX.Element;
17 changes: 17 additions & 0 deletions dist/other/rjsf/RJSFForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Form from "@rjsf/mui";
import React from "react";
import ArrayFieldItemTemplate from "./templates/ArrayFieldItemTemplate";
import ArrayFieldTemplate from "./templates/ArrayFieldTemplate";
import BaseInputTemplate from "./templates/BaseInputTemplate";
import ObjectFieldTemplate from "./templates/ObjectFieldTemplate";
import TitleFieldTemplate from "./templates/TitleFieldTemplate";
import SelectWidget from "./widgets/SelectWidget";
export default function RJSFForm(props) {
return (React.createElement(Form, { ...props, templates: {
ObjectFieldTemplate,
BaseInputTemplate,
ArrayFieldTemplate,
ArrayFieldItemTemplate,
TitleFieldTemplate,
}, widgets: { SelectWidget } }));
}
3 changes: 3 additions & 0 deletions dist/other/rjsf/templates/ArrayFieldItemTemplate.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { ArrayFieldTemplateItemType, FormContextType, RJSFSchema, StrictRJSFSchema } from "@rjsf/utils";
import React from "react";
export default function ArrayFieldItemTemplate<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: ArrayFieldTemplateItemType<T, S, F>): React.JSX.Element;
21 changes: 21 additions & 0 deletions dist/other/rjsf/templates/ArrayFieldItemTemplate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import Grid from "@mui/material/Grid";
import React from "react";
export default function ArrayFieldItemTemplate(props) {
const { children, disabled, hasToolbar, hasCopy, hasMoveDown, hasMoveUp, hasRemove, index, onCopyIndexClick, onDropIndexClick, onReorderClick, readonly, uiSchema, registry, } = props;
const { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } = registry.templates.ButtonTemplates;
const btnStyle = {
flex: 1,
paddingLeft: 6,
paddingRight: 6,
fontWeight: "bold",
minWidth: 0,
};
return (React.createElement(Grid, { container: true, alignItems: "center", className: "ArrayFieldItemTemplate" },
React.createElement(Grid, { item: true, xs: true, style: { overflow: "visible" } }, children),
hasToolbar && (React.createElement(Grid, { item: true },
(hasMoveUp || hasMoveDown) && (React.createElement(MoveUpButton, { style: btnStyle, disabled: disabled || readonly || !hasMoveUp, onClick: onReorderClick(index, index - 1), uiSchema: uiSchema, registry: registry })),
(hasMoveUp || hasMoveDown) && (React.createElement(MoveDownButton, { style: btnStyle, disabled: disabled || readonly || !hasMoveDown, onClick: onReorderClick(index, index + 1), uiSchema: uiSchema, registry: registry })),
hasCopy && (React.createElement(CopyButton, { style: btnStyle, disabled: disabled || readonly, onClick: onCopyIndexClick(index), uiSchema: uiSchema, registry: registry })),
hasRemove && (React.createElement(RemoveButton, { style: btnStyle, disabled: disabled || readonly, onClick: onDropIndexClick(index), uiSchema: uiSchema, registry: registry }))))));
}
3 changes: 3 additions & 0 deletions dist/other/rjsf/templates/ArrayFieldTemplate.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { ArrayFieldTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from "@rjsf/utils";
import React from "react";
export default function ArrayFieldTemplate<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: ArrayFieldTemplateProps<T, S, F>): React.JSX.Element;
25 changes: 25 additions & 0 deletions dist/other/rjsf/templates/ArrayFieldTemplate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable react/jsx-props-no-spreading */
import Box from "@mui/material/Box";
import Grid from "@mui/material/Grid";
import Stack from "@mui/material/Stack";
import { getTemplate, getUiOptions, } from "@rjsf/utils";
import React from "react";
export default function ArrayFieldTemplate(props) {
const { canAdd, disabled, idSchema, uiSchema, items, onAddClick, readonly, registry, required, schema, title, } = props;
const uiOptions = getUiOptions(uiSchema);
const ArrayFieldDescriptionTemplate = getTemplate("ArrayFieldDescriptionTemplate", registry, uiOptions);
const ArrayFieldItemTemplate = getTemplate("ArrayFieldItemTemplate", registry, uiOptions);
const ArrayFieldTitleTemplate = getTemplate("ArrayFieldTitleTemplate", registry, uiOptions);
// Button templates are not overridden in the uiSchema
const { ButtonTemplates: { AddButton }, } = registry.templates;
return (React.createElement(Stack, { spacing: 1, className: "ArrayFieldTemplate" },
React.createElement(ArrayFieldTitleTemplate, { idSchema: idSchema, title: uiOptions.title || title, schema: schema, uiSchema: uiSchema, required: required, registry: registry }),
React.createElement(ArrayFieldDescriptionTemplate, { idSchema: idSchema, description: uiOptions.description || schema.description, schema: schema, uiSchema: uiSchema, registry: registry }),
items &&
items.map(({ key, ...itemProps }) => (React.createElement(ArrayFieldItemTemplate, { key: key, ...itemProps }))),
canAdd && (React.createElement(Grid, { container: true, justifyContent: "flex-end" },
React.createElement(Grid, { item: true },
React.createElement(Box, { mt: 2 },
React.createElement(AddButton, { className: "array-item-add", onClick: onAddClick, disabled: disabled || readonly, uiSchema: uiSchema, registry: registry })))))));
}
3 changes: 3 additions & 0 deletions dist/other/rjsf/templates/BaseInputTemplate.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { BaseInputTemplateProps } from "@rjsf/utils";
import React from "react";
export default function BaseInputTemplate(props: BaseInputTemplateProps): React.JSX.Element | null;
9 changes: 9 additions & 0 deletions dist/other/rjsf/templates/BaseInputTemplate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable react/jsx-props-no-spreading */
import { Templates } from "@rjsf/mui";
import React from "react";
export default function BaseInputTemplate(props) {
if (Templates.BaseInputTemplate) {
return React.createElement(Templates.BaseInputTemplate, { ...props, size: "small" });
}
return null;
}
3 changes: 3 additions & 0 deletions dist/other/rjsf/templates/ObjectFieldTemplate.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { FormContextType, ObjectFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from "@rjsf/utils";
import React from "react";
export default function ObjectFieldTemplate<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: ObjectFieldTemplateProps<T, S, F>): React.JSX.Element;
27 changes: 27 additions & 0 deletions dist/other/rjsf/templates/ObjectFieldTemplate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable react/no-array-index-key */
import Box from "@mui/material/Box";
import Grid from "@mui/material/Grid";
import { canExpand, descriptionId, getTemplate, getUiOptions, titleId, } from "@rjsf/utils";
import React from "react";
export default function ObjectFieldTemplate(props) {
const { description, title, properties, required, disabled, readonly, uiSchema, idSchema, schema, formData, onAddClick, registry, } = props;
const uiOptions = getUiOptions(uiSchema);
const TitleFieldTemplate = getTemplate("TitleFieldTemplate", registry, uiOptions);
const DescriptionFieldTemplate = getTemplate("DescriptionFieldTemplate", registry, uiOptions);
// Button templates are not overridden in the uiSchema
const { ButtonTemplates: { AddButton }, } = registry.templates;
return (React.createElement(Box, { className: "ObjectFieldTemplate" },
title && (React.createElement(TitleFieldTemplate, { id: titleId(idSchema), title: title, required: required, schema: schema, uiSchema: uiSchema, registry: registry })),
description && (React.createElement(DescriptionFieldTemplate, { id: descriptionId(idSchema), description: description, schema: schema, uiSchema: uiSchema, registry: registry })),
React.createElement(Grid, { container: true, spacing: 2, style: { marginTop: "10px" } },
properties.map((element, index) =>
// Remove the <Grid> if the inner element is hidden as the <Grid>
// itself would otherwise still take up space.
element.hidden ? (element.content) : (React.createElement(Grid, { item: true, xs: 12, sm: 4,
// md={4}
key: index, style: { marginBottom: "10px" } }, element.content))),
canExpand(schema, uiSchema, formData) && (React.createElement(Grid, { container: true, justifyContent: "flex-end" },
React.createElement(Grid, { item: true },
React.createElement(AddButton, { className: "object-property-expand", onClick: onAddClick(schema), disabled: disabled || readonly, uiSchema: uiSchema, registry: registry })))))));
}
3 changes: 3 additions & 0 deletions dist/other/rjsf/templates/TitleFieldTemplate.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { FormContextType, RJSFSchema, StrictRJSFSchema, TitleFieldProps } from "@rjsf/utils";
import React from "react";
export default function TitleFieldTemplate<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({ id, title }: TitleFieldProps<T, S, F>): React.JSX.Element;
7 changes: 7 additions & 0 deletions dist/other/rjsf/templates/TitleFieldTemplate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import Typography from "@mui/material/Typography";
import React from "react";
export default function TitleFieldTemplate({ id, title }) {
return (React.createElement(Typography, { id: id, variant: "caption", className: "TitleFieldTemplate" },
React.createElement("b", null, title)));
}
5 changes: 4 additions & 1 deletion dist/other/rjsf/widgets/PositionInfoPopover.styled.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
export declare const PositionInfoPopover: StyledComponent<ComponentProps, SpecificComponentProps, JSXProps>;
/// <reference types="react" />
export declare const PositionInfoPopover: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material/styles").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
3 changes: 3 additions & 0 deletions dist/other/rjsf/widgets/SelectWidget.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { BaseInputTemplateProps } from "@rjsf/utils";
import React from "react";
export default function SelectWidget(props: BaseInputTemplateProps): React.JSX.Element;
6 changes: 6 additions & 0 deletions dist/other/rjsf/widgets/SelectWidget.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* eslint-disable react/jsx-props-no-spreading */
import { Widgets } from "@rjsf/mui";
import React from "react";
export default function SelectWidget(props) {
return React.createElement(Widgets.SelectWidget, { ...props, size: "small" });
}
Loading

0 comments on commit f4633ac

Please sign in to comment.