UNPKG

amotify

Version:

UI Component for React,NextJS,esbuild

146 lines (145 loc) 5.16 kB
import { ReactElement, StyleProps } from '../../@declares'; export declare namespace InputTypes { type BoxTone = 'border' | 'cloud' | 'bottomBorder' | 'plain'; type Type = 'hidden' | 'textfield' | 'textfield.multiline' | 'select' | 'drum' | 'list.radio' | 'list.checkbox' | 'autocomplete.single' | 'autocomplete.multi' | 'time' | 'switch' | 'slider' | 'file' | 'contenteditable' | 'color' | ''; type OnUserAction<T = any> = (value: T, option: { eventType?: Validation.EventType; componentId?: string; isInspected?: boolean; isValidated?: boolean; isComposing?: boolean; isFocusing?: boolean; isPickerOpen?: boolean; }) => void; type UniInput<T = any> = { 'data-type'?: T; name?: string; form?: string; status_id?: string; componentId?: string; /** * * 'never' as default, means validation will be triggered at user action, and only when value is changed in Input Component. * force: [Deprecated] 2026/03 * beforeModified: [Deprecated] 2026/03 */ override?: 'force' | 'beforeModified' | 'never'; required?: boolean; enableFormSubmit?: boolean; showInitValidation?: boolean; onValidate?: Validation.OnValidate<T>; onValidateDelay?: number; onUpdateValue?: OnUserAction<T>; onUpdateValidValue?: OnUserAction<T>; onUserAction?: OnUserAction<T>; }; type CoreInput<T = any> = UniInput<T> & StyleProps.States & { className?: string; wrapStyles?: StyleProps.States; }; namespace Validation { type EventType = 'init' | 'update' | 'update.remote' | 'override' | 'refresh'; type Notice = { type: 'valid' | 'invalid' | 'warn'; label: ReactElement; }; type Result = { ok: boolean; notice?: Notice[]; }; type System = (props: { value: any; states: any; }) => Result; type OnValidate<T = any> = (value: T, eventType: EventType, opt: Status) => Promise<Result>; } type Status<T = any> = { componentId: string; rawValue: T; eventType: Validation.EventType; eventID: string; isValidated?: boolean; isInspected?: boolean; isFocusing?: boolean; isComposing?: boolean; isPickerOpen?: boolean; notice?: Validation.Notice[]; }; namespace Status { type Text = Status & { safeValue: any; prevValue: any; caretFrom: number; caretTo: number; }; type DigitCharacters = Status & { safeValue: any; }; type Time = Status & { safeValue: any; ranges: _Time.Range[]; }; type Slider = Status & { safeValue: number[]; ranged: boolean; trackMin?: number; min: number; max: number; step: number; }; } } import * as _Parts from './Parts'; export * from './Parts'; import _fn from './fn'; import _Plain from './Plain'; import _Hidden from './Hidden'; import _TextField from './TextField'; import _Contenteditable from './Contenteditable'; import _DigitCharacters from './DigitCharacters'; import _Time from './Time'; import _TimeSelector from './Time/Selector'; import _Drum from './Drum'; import _Select from './Select'; import _Autocomplete from './Autocomplete'; import * as _List from './List'; import _Search from './Search'; import _Filer from './Filer'; import _Slider from './Slider'; import _Switch from './Switch'; import _Checker from './Checker'; import _Segmented from './Segmented'; import _Color from './Color'; import _CollectForm from './CollectForm'; declare namespace Input { export import fn = _fn; export import Plain = _Plain; export import Hidden = _Hidden; export import TextField = _TextField; export import Contenteditable = _Contenteditable; export import DigitCharacters = _DigitCharacters; export import Time = _Time; export import TimeSelector = _TimeSelector; export import Drum = _Drum; export import Select = _Select; export import Autocomplete = _Autocomplete; export import List = _List.List; export import Radio = _List.Radio; export import Checkbox = _List.Checkbox; export import Checker = _Checker; export import Search = _Search; export import Filer = _Filer; export import Slider = _Slider; export import Switch = _Switch; export import Segmented = _Segmented; export import Color = _Color; export import LeftIcon = _Parts.LeftIcon; export import RightIcon = _Parts.RightIcon; export import LeftIndicator = _Parts.LeftIndicator; export import RightIndicator = _Parts.RightIndicator; export import RequiredSign = _Parts.RequiredSign; export import RequiredShortSign = _Parts.RequiredShortSign; export import OmitSign = _Parts.OmitSign; export import CollectForm = _CollectForm; } export { Input, Input as default };