import { Tooltip } from "@mantine/core"; import clsx from "clsx"; import { getBrowser } from "core/utils"; import type { Field } from "data/fields"; import { Switch as RadixSwitch } from "radix-ui"; import { type ComponentPropsWithoutRef, type ElementType, forwardRef, Fragment, useEffect, useImperativeHandle, useRef, useState, } from "react"; import { TbCalendar, TbChevronDown, TbEye, TbEyeOff, TbInfoCircle } from "react-icons/tb"; import { twMerge } from "tailwind-merge"; import { IconButton } from "ui/components/buttons/IconButton"; import { useEvent } from "ui/hooks/use-event"; export const Group = ({ error, as, ...props }: React.ComponentProps & { error?: boolean; as?: E }) => { const Tag = as || "div"; return ( ); }; export const formElementFactory = (element: string, props: any) => { switch (element) { case "date": return DateInput; case "boolean": return BooleanInput; case "textarea": return Textarea; default: return Input; } }; export const Label = ({ as, ...props }: React.ComponentProps & { as?: E }) => { const Tag = as || "label"; return ; }; export const Help: React.FC> = ({ className, ...props }) => (
); export const ErrorMessage: React.FC> = ({ className, ...props }) => (
); export const FieldLabel: React.FC< React.ComponentProps<"label"> & { field: Field; label?: string } > = ({ field, label, ...props }) => { const desc = field.getDescription(); const Wrapper = desc ? (p) => : (p) => ; return ( ); }; export const Input = forwardRef>((props, ref) => { const disabledOrReadonly = props.disabled || props.readOnly; return ( ); }); export const TypeAwareInput = forwardRef>( (props, ref) => { if (props.type === "password") { return ; } if ("data-type" in props) { if (props["data-type"] === "textarea") { // @ts-ignore return