UNPKG

@base-ui/react

Version:

Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.

39 lines 742 B
export const DEFAULT_VALIDITY_STATE = { badInput: false, customError: false, patternMismatch: false, rangeOverflow: false, rangeUnderflow: false, stepMismatch: false, tooLong: false, tooShort: false, typeMismatch: false, valid: null, valueMissing: false }; export const DEFAULT_FIELD_STATE_ATTRIBUTES = { valid: null, touched: false, dirty: false, filled: false, focused: false }; export const DEFAULT_FIELD_ROOT_STATE = { disabled: false, ...DEFAULT_FIELD_STATE_ATTRIBUTES }; export const fieldValidityMapping = { valid(value) { if (value === null) { return null; } if (value) { return { 'data-valid': '' }; } return { 'data-invalid': '' }; } };