fix
This commit is contained in:
parent
5d0056e394
commit
107fe48f79
|
|
@ -103,6 +103,8 @@ export const FieldInput: FC<{
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// console.log(prefix, suffix);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cx(
|
className={cx(
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,14 @@ export const newField = async (
|
||||||
label: formatName(field.name),
|
label: formatName(field.name),
|
||||||
ext__show_label: show ? "y" : "n",
|
ext__show_label: show ? "y" : "n",
|
||||||
ext__required: field.optional ? "n" : "y",
|
ext__required: field.optional ? "n" : "y",
|
||||||
|
opt__on_load: [
|
||||||
|
`() => {
|
||||||
|
return [
|
||||||
|
{ label: "No", value: false },
|
||||||
|
{ label: "Yes", value: true },
|
||||||
|
];
|
||||||
|
}`,
|
||||||
|
],
|
||||||
type: "single-option",
|
type: "single-option",
|
||||||
sub_type: "toogle",
|
sub_type: "toogle",
|
||||||
ext__on_change: opt.on_change
|
ext__on_change: opt.on_change
|
||||||
|
|
|
||||||
|
|
@ -110,9 +110,9 @@ export const generateForm = async (
|
||||||
align: "top-left",
|
align: "top-left",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const existing_childs = (
|
// const existing_childs = (
|
||||||
(item.component?.props.body as any)?.content as IItem
|
// (item.component?.props.body as any)?.content as IItem
|
||||||
)?.childs;
|
// )?.childs;
|
||||||
|
|
||||||
let new_body = createItem({
|
let new_body = createItem({
|
||||||
name: "item",
|
name: "item",
|
||||||
|
|
@ -143,9 +143,9 @@ export const generateForm = async (
|
||||||
].filter((e) => e),
|
].filter((e) => e),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Array.isArray(existing_childs) && existing_childs.length > 0) {
|
// if (Array.isArray(existing_childs) && existing_childs.length > 0) {
|
||||||
walkGenForm(new_body, existing_childs as any);
|
// walkGenForm(new_body, existing_childs as any);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// const prop_item = propFromItem(item);
|
// const prop_item = propFromItem(item);
|
||||||
// const current_body = prop_item?.body?.value as IItem;
|
// const current_body = prop_item?.body?.value as IItem;
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ async (arg: {
|
||||||
(await call_prasi_events("field", "relation_load", [fm, arg.field]) || {}) as Prisma.${table}WhereInput;
|
(await call_prasi_events("field", "relation_load", [fm, arg.field]) || {}) as Prisma.${table}WhereInput;
|
||||||
|
|
||||||
if (typeof opt__load_trigger === "object" && typeof opt__load_trigger?.on_change === "function") {
|
if (typeof opt__load_trigger === "object" && typeof opt__load_trigger?.on_change === "function") {
|
||||||
const trigger = await opt__load_trigger.on_change({ md, fm, where });
|
const trigger = await opt__load_trigger.on_change({ md: typeof md !== 'undefined' ? md : undefined, fm, where });
|
||||||
if (trigger.hidden) {
|
if (trigger.hidden) {
|
||||||
done([]);
|
done([]);
|
||||||
arg.field.hidden = true;
|
arg.field.hidden = true;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,11 @@ export const validate = (field: FieldLocal, fm: FMLocal, record?: any) => {
|
||||||
if (field.required) {
|
if (field.required) {
|
||||||
const data = record || fm.data;
|
const data = record || fm.data;
|
||||||
const error_msg = msg(field.label);
|
const error_msg = msg(field.label);
|
||||||
if (!data[field.name]) {
|
if (
|
||||||
|
data[field.name] === undefined ||
|
||||||
|
data[field.name] === null ||
|
||||||
|
data[field.name] === ""
|
||||||
|
) {
|
||||||
fm.error.set(field.name, [error_msg]);
|
fm.error.set(field.name, [error_msg]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -820,7 +820,7 @@ export const TableList: FC<TableListProp> = ({
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
) : (
|
) : (
|
||||||
<>No Data</>
|
<>No Data asf as</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
import * as React from "react"
|
||||||
|
import { OTPInput, OTPInputContext } from "input-otp"
|
||||||
|
import { Dot } from "lucide-react"
|
||||||
|
|
||||||
|
import { cn } from "@/utils"
|
||||||
|
|
||||||
|
const InputOTP = React.forwardRef<
|
||||||
|
React.ElementRef<typeof OTPInput>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof OTPInput>
|
||||||
|
>(({ className, containerClassName, ...props }, ref) => (
|
||||||
|
<OTPInput
|
||||||
|
ref={ref}
|
||||||
|
containerClassName={cn(
|
||||||
|
"flex items-center gap-2 has-[:disabled]:opacity-50",
|
||||||
|
containerClassName
|
||||||
|
)}
|
||||||
|
className={cn("disabled:c-cursor-not-allowed", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
InputOTP.displayName = "InputOTP"
|
||||||
|
|
||||||
|
const InputOTPGroup = React.forwardRef<
|
||||||
|
React.ElementRef<"div">,
|
||||||
|
React.ComponentPropsWithoutRef<"div">
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<div ref={ref} className={cn("c-flex c-items-center", className)} {...props} />
|
||||||
|
))
|
||||||
|
InputOTPGroup.displayName = "InputOTPGroup"
|
||||||
|
|
||||||
|
const InputOTPSlot = React.forwardRef<
|
||||||
|
React.ElementRef<"div">,
|
||||||
|
React.ComponentPropsWithoutRef<"div"> & { index: number }
|
||||||
|
>(({ index, className, ...props }, ref) => {
|
||||||
|
const inputOTPContext = React.useContext(OTPInputContext)
|
||||||
|
const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index]
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"c-relative c-flex c-h-10 c-w-10 c-items-center c-justify-center c-border-y c-border-r c-border-input c-text-sm c-transition-all first:c-rounded-l-md first:c-border-l last:c-rounded-r-md",
|
||||||
|
isActive && "c-z-10 c-ring-2 c-ring-ring c-ring-offset-background",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{char}
|
||||||
|
{hasFakeCaret && (
|
||||||
|
<div className="c-pointer-events-none c-absolute c-inset-0 c-flex c-items-center c-justify-center">
|
||||||
|
<div className="c-h-4 c-w-px c-animate-caret-blink c-bg-foreground c-duration-1000" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
InputOTPSlot.displayName = "InputOTPSlot"
|
||||||
|
|
||||||
|
const InputOTPSeparator = React.forwardRef<
|
||||||
|
React.ElementRef<"div">,
|
||||||
|
React.ComponentPropsWithoutRef<"div">
|
||||||
|
>(({ ...props }, ref) => (
|
||||||
|
<div ref={ref} role="separator" {...props}>
|
||||||
|
<Dot />
|
||||||
|
</div>
|
||||||
|
))
|
||||||
|
InputOTPSeparator.displayName = "InputOTPSeparator"
|
||||||
|
|
||||||
|
export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator }
|
||||||
Loading…
Reference in New Issue