Skip to content

Commit

Permalink
chore: split rjsf files in folders, update widget types
Browse files Browse the repository at this point in the history
  • Loading branch information
zoomchik committed Sep 7, 2023
1 parent d8a45c0 commit eb3e14a
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
/* eslint-disable react/jsx-props-no-spreading */
import Typography from "@mui/material/Typography";
import { Templates } from "@rjsf/mui";
import { WidgetProps } from "@rjsf/utils";
import React from "react";

import InfoPopover, {
InfoPopoverProps,
} from "../../mui/components/popover/info-popover/InfoPopover";
import InfoPopover from "../../../mui/components/popover/info-popover/InfoPopover";
import { PositionInfoPopover } from "./PositionInfoPopover.styled";
import { WidgetWithInfoPopoverProps } from "./types";

const { BaseInputTemplate } = Templates;

type InfoPopoverOptions = InfoPopoverProps & { content: string };

export default function InputWithInfoPopover(props: WidgetProps) {
const { uiSchema } = props;
const infoPopover = (uiSchema ? uiSchema["ui:options"]?.infoPopover : {}) as InfoPopoverOptions;
export default function InputWithInfoPopover(props: WidgetWithInfoPopoverProps) {
const { uiSchema = {} } = props;
const infoPopover = uiSchema["ui:options"] && uiSchema["ui:options"].infoPopover;

if (!BaseInputTemplate) return null;

Expand All @@ -27,7 +23,7 @@ export default function InputWithInfoPopover(props: WidgetProps) {
<Typography
variant="body2"
pb={2}
dangerouslySetInnerHTML={{ __html: infoPopover?.content }}
dangerouslySetInnerHTML={{ __html: infoPopover?.content || "" }}
/>
</InfoPopover>
</PositionInfoPopover>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
/* eslint-disable react/jsx-props-no-spreading */
import Typography from "@mui/material/Typography";
import { Widgets } from "@rjsf/mui";
import { WidgetProps } from "@rjsf/utils";
import React from "react";

import InfoPopover, {
InfoPopoverProps,
} from "../../mui/components/popover/info-popover/InfoPopover";
import InfoPopover from "../../../mui/components/popover/info-popover/InfoPopover";
import { PositionInfoPopover } from "./PositionInfoPopover.styled";
import { WidgetWithInfoPopoverProps } from "./types";

const { SelectWidget } = Widgets;

type InfoPopoverOptions = InfoPopoverProps & { content: string };

export default function SelectWithInfoPopover(props: WidgetProps) {
const { uiSchema } = props;

const infoPopover = (uiSchema ? uiSchema["ui:options"]?.infoPopover : {}) as InfoPopoverOptions;
export default function SelectWithInfoPopover(props: WidgetWithInfoPopoverProps) {
const { uiSchema = {} } = props;
const infoPopover = uiSchema["ui:options"] && uiSchema["ui:options"].infoPopover;

return (
<>
Expand All @@ -26,7 +21,7 @@ export default function SelectWithInfoPopover(props: WidgetProps) {
<Typography
variant="body2"
pb={2}
dangerouslySetInnerHTML={{ __html: infoPopover?.content }}
dangerouslySetInnerHTML={{ __html: infoPopover?.content || "" }}
/>
</InfoPopover>
</PositionInfoPopover>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@ import Typography from "@mui/material/Typography";
import { AdapterMoment } from "@mui/x-date-pickers/AdapterMoment";
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
import { TimePicker as MuiTimePicker } from "@mui/x-date-pickers/TimePicker";
import { WidgetProps } from "@rjsf/utils";
import moment from "moment";
import React from "react";

import InfoPopover, {
InfoPopoverProps,
} from "../../mui/components/popover/info-popover/InfoPopover";
import InfoPopover from "../../../mui/components/popover/info-popover/InfoPopover";
import { PositionInfoPopover } from "./PositionInfoPopover.styled";
import { WidgetWithInfoPopoverProps } from "./types";

type InfoPopoverOptions = InfoPopoverProps & { content: string };

export default function TimePicker(props: WidgetProps<InfoPopoverOptions>) {
export default function TimePicker(props: WidgetWithInfoPopoverProps) {
const { onChange, value, label } = props;
const { uiSchema, options } = props;
const infoPopover = (uiSchema ? uiSchema["ui:options"]?.infoPopover : {}) as InfoPopoverOptions;
const { uiSchema = {}, options } = props;
const infoPopover = uiSchema["ui:options"] && uiSchema["ui:options"].infoPopover;

return (
<LocalizationProvider dateAdapter={AdapterMoment}>
Expand All @@ -40,7 +36,7 @@ export default function TimePicker(props: WidgetProps<InfoPopoverOptions>) {
<Typography
variant="body2"
pb={2}
dangerouslySetInnerHTML={{ __html: infoPopover?.content }}
dangerouslySetInnerHTML={{ __html: infoPopover?.content || "" }}
/>
</InfoPopover>
</PositionInfoPopover>
Expand Down
13 changes: 13 additions & 0 deletions src/other/rjsf/widgets/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { WidgetProps } from "@rjsf/utils";

export type InfoPopoverOptions = { title: string; content: string };

type InfoPopoverUISchema = {
"ui:options"?: {
infoPopover?: InfoPopoverOptions;
};
};

export type WidgetWithInfoPopoverProps = WidgetProps & {
uiSchema?: InfoPopoverUISchema;
};

0 comments on commit eb3e14a

Please sign in to comment.