import { Action as GlobalAction, FileBrowser, FileBrowserProps, MultiSelector as GlobalMultiSelector, MultiSelectorProps as GlobalMultiSelectorProps, Selector as GlobalSelector, SelectorProps as GlobalSelectorProps, } from "@/components"; import { ActionProps as GlobalActionProps } from "@/components/inputs/Action"; import ChipInput, { ChipInputProps } from "@/components/inputs/ChipInput"; import { useSliderMarks } from "@/utilities"; import { InputWrapper, NumberInput, NumberInputProps, PasswordInput, PasswordInputProps, Slider as MantineSlider, SliderProps as MantineSliderProps, Switch, TextInput, TextInputProps, } from "@mantine/core"; import { FunctionComponent, ReactText } from "react"; import { BaseInput, useBaseInput } from "../utilities/hooks"; export type NumberProps = BaseInput & NumberInputProps; export const Number: FunctionComponent = (props) => { const { value, update, rest } = useBaseInput(props); return ( { update(val); }} > ); }; export type TextProps = BaseInput & TextInputProps; export const Text: FunctionComponent = (props) => { const { value, update, rest } = useBaseInput(props); return ( { update(e.currentTarget.value); }} > ); }; export type PasswordProps = BaseInput & PasswordInputProps; export const Password: FunctionComponent = (props) => { const { value, update, rest } = useBaseInput(props); return ( { update(e.currentTarget.value); }} > ); }; export interface CheckProps extends BaseInput { label?: string; inline?: boolean; } export const Check: FunctionComponent = ({ label, inline, ...props }) => { const { value, update, rest } = useBaseInput(props); return ( { update(e.currentTarget.checked); }} disabled={rest.disabled} checked={value ?? false} > ); }; export type SelectorProps = BaseInput & GlobalSelectorProps; export function Selector(props: SelectorProps) { const { value, update, rest } = useBaseInput(props); return ( ); } export type MultiSelectorProps = BaseInput & GlobalMultiSelectorProps; export function MultiSelector( props: MultiSelectorProps ) { const { value, update, rest } = useBaseInput(props); return ( ); } type SliderProps = BaseInput & Omit; export const Slider: FunctionComponent = (props) => { const { value, update, rest } = useBaseInput(props); const { label, ...sliderProps } = rest; const { min = 0, max = 100 } = props; const marks = useSliderMarks([min, max]); return ( ); }; type ChipsProp = BaseInput & Omit; export const Chips: FunctionComponent = (props) => { const { value, update, rest } = useBaseInput(props); return ( ); }; type ActionProps = { onClick?: (update: (v: string) => void, value?: string) => void; } & Omit, "modification">; export const Action: FunctionComponent< Override > = (props) => { const { value, update, rest } = useBaseInput(props); return ( { props.onClick?.(update, (value as string) ?? undefined); }} > ); }; interface FileProps extends BaseInput {} export const File: FunctionComponent> = ( props ) => { const { value, update, rest } = useBaseInput(props); return ( ); };