UNPKG

mistui-kit

Version:

**πŸ‘‰ [Try MistUi Live](https://gilded-tanuki-0eb52b.netlify.app/) β€” interactive playground & docs**

47 lines (46 loc) β€’ 1.94 kB
import type { BaseProps, NumberInputProps, SelectInputProps, SliderInputProps, SwitchBoxInputProps, FileInputProps, AutoInputProps, CheckBoxInputProps } from '../inputs'; import type { ToggleButtonGroupProps, FilterToggleButtonGroupProps } from '../buttons'; import type { DividerProps } from '../utils/types'; export type TypeSchema = 'text' | 'textArea' | 'number' | 'date' | 'color' | 'time' | 'slider' | 'file' | 'radio' | 'switch' | 'toggle' | 'select' | 'checkbox' | 'autocomplete' | 'divider' | 'groupButton' | 'groupButtonFiltre' | 'custom'; interface BaseSchema<T = any> { /** ΡƒΠ½ΠΈΠΊΠ°Π»ΡŒΠ½Ρ‹ΠΉ ΠΊΠ»ΡŽΡ‡ */ id: string; type: TypeSchema; position?: 'left' | 'top' | 'right'; label?: string | React.ReactElement; value?: any; onChange?: (value: T) => void; } interface TypeToSchemaMap { text: BaseProps; textArea: BaseProps; number: NumberInputProps; date: BaseProps; time: BaseProps; color: SelectInputProps; slider: SliderInputProps; file: FileInputProps; switch: SwitchBoxInputProps; radio: CheckBoxInputProps; toggle: ToggleButtonGroupProps; checkbox: CheckBoxInputProps; select: SelectInputProps; autocomplete: AutoInputProps; groupButton: ToggleButtonGroupProps; groupButtonFiltre: FilterToggleButtonGroupProps; divider: DividerProps; custom: { render: (props: any) => React.ReactElement; }; } export type Schema<T extends TypeSchema = TypeSchema> = BaseSchema & { type: T; } & TypeToSchemaMap[T]; export type FormProps = { scheme: Schema[]; /** всС Π΄Π°Π½Π½Ρ‹Π΅ Ρ„ΠΎΡ€ΠΌ ΠΏΡ€ΠΈ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΠΈ Π΄Π°Π½Π½Ρ‹Ρ… */ onChange?: (id: string | number, value: any) => void; /** Π΅Π΄ΠΈΠ½Ρ‹ΠΉ алиас Π½Π° ΠΏΠΎΠ·ΠΈΡ†ΠΈΡŽ Π»Π΅ΠΉΠ±Π»ΠΎΠ² ΠΈΠ½ΠΏΡƒΡ‚ΠΎΠ² (Ρ‡Ρ‚ΠΎ Π±Ρ‹ ΠΊΠ°ΠΆΠ΄ΠΎΠΌΡƒ Π² Ρ€ΡƒΡ‡Π½ΡƒΡŽ Π½Π΅ ΠΏΡ€ΠΎΠΏΠΈΡΡ‹Π²Π°Ρ‚ΡŒ) */ labelPosition?: "left" | "right" | "top"; }; export {};