Skip to content

Commit

Permalink
feat: add loader skeleton for rich text field
Browse files Browse the repository at this point in the history
  • Loading branch information
foyarash committed Feb 3, 2025
1 parent 5989807 commit 532b469
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/silver-emus-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@premieroctet/next-admin": patch
---

feat: add loader skeleton for rich text (#462)
19 changes: 11 additions & 8 deletions packages/next-admin/src/components/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
FieldTemplateProps,
getSubmitButtonOptions,
ObjectFieldTemplateProps,
SubmitButtonProps
SubmitButtonProps,
} from "@rjsf/utils";
import validator from "@rjsf/validator-ajv8";
import clsx from "clsx";
Expand All @@ -26,7 +26,7 @@ import React, {
useEffect,
useMemo,
useRef,
useState
useState,
} from "react";
import { twMerge } from "tailwind-merge";
import ClientActionDialogProvider from "../context/ClientActionDialogContext";
Expand Down Expand Up @@ -70,6 +70,7 @@ import {

const RichTextField = dynamic(() => import("./inputs/RichText/RichTextField"), {
ssr: false,
loading: () => <div className="h-48 animate-pulse rounded bg-gray-500" />,
});

const widgets: RjsfForm["props"]["widgets"] = {
Expand Down Expand Up @@ -307,12 +308,14 @@ const Form = ({

const fields: RjsfForm["props"]["fields"] = {
ArrayField: (props: FieldProps) => {
const customInput = customInputs?.[props.name as Field<ModelName>]
const improvedCustomInput = customInput ? cloneElement(customInput, {
...customInput.props,
mode: edit ? "edit" : "create",
}) : undefined;
return ArrayField({ ...props, customInput: improvedCustomInput })
const customInput = customInputs?.[props.name as Field<ModelName>];
const improvedCustomInput = customInput
? cloneElement(customInput, {
...customInput.props,
mode: edit ? "edit" : "create",
})
: undefined;
return ArrayField({ ...props, customInput: improvedCustomInput });
},
NullField,
};
Expand Down

0 comments on commit 532b469

Please sign in to comment.