UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

245 lines 8.86 kB
export const useFieldPropsParameters = { value: { doc: 'Source data value for the field. Takes precedence over the path value from DataContext.', type: '{valueType}', status: 'optional' }, defaultValue: { doc: 'Default value for the field. Does not take precedence over values from DataContext.', type: '{valueType}', status: 'optional' }, path: { doc: 'JSON Pointer for the field data location in the source dataset (when using Form.Handler or DataContext).', type: 'string', status: 'optional' }, itemPath: { doc: 'Path relative to the current Iterate element. Used when the field is inside an Iterate context.', type: 'string', status: 'optional' }, emptyValue: { doc: 'The value used when emptying the field (e.g., `undefined` instead of empty string).', type: ['{valueType}', 'undefined'], status: 'optional' }, required: { doc: 'When `true`, validates that the field is not empty. When `false`, adds "(optional)" suffix to label.', type: 'boolean', status: 'optional' }, disabled: { doc: 'Disables the field, preventing value changes while still displaying it.', type: 'boolean', status: 'optional' }, readOnly: { doc: 'Makes the field read-only. Used as a fallback for `disabled` when `disabled` is not explicitly set.', type: 'boolean', status: 'optional' }, info: { doc: 'Info message shown below the field. Can be a function receiving the current value.', type: ['React.ReactNode', 'Array<React.ReactNode>', 'function'], status: 'optional' }, warning: { doc: 'Warning message shown below the field. Can be a function receiving the current value.', type: ['React.ReactNode', 'Array<React.ReactNode>', 'function'], status: 'optional' }, error: { doc: 'Error message or Error object to display. Can be a function receiving the current value.', type: ['Error', 'FormError', 'Array<Error | FormError>', 'function'], status: 'optional' }, errorMessages: { doc: 'Custom error messages keyed by error type (e.g., `Field.errorRequired`).', type: 'Record<string, React.ReactNode>', status: 'optional' }, schema: { doc: 'JSON Schema or Zod schema for validating the field value.', type: ['object', 'ZodSchema'], status: 'optional' }, validateInitially: { doc: 'Show validation errors on initial render before user interaction.', type: 'boolean', status: 'optional' }, validateUnchanged: { doc: 'Show validation errors when field is touched without value changes.', type: 'boolean', status: 'optional' }, validateContinuously: { doc: 'Show validation errors continuously while typing, not just on blur.', type: 'boolean', status: 'optional' }, onChangeValidator: { doc: "Custom validation function called on every change. Can be async. Returns Error, FormError, or array of validators. It runs during form submit by default. Use `withValidatorOptions(validator, { runOnSubmit: 'never' })` to keep it from running during form submit, or `'when-changed'` to run it only when the value has changed since the validator last ran. Object and array values are compared by reference.", type: '(value, { errorMessages, connectWithPath, validators }) => Error | undefined', status: 'optional' }, onBlurValidator: { doc: "Custom validation function called on blur. Preferred for validations with side-effects. Can be async. It runs during form submit by default. Use `withValidatorOptions(validator, { runOnSubmit: 'never' })` to keep it from running during form submit, or `'when-changed'` to run it only when the value has changed since the validator last ran. Object and array values are compared by reference.", type: '(value, { errorMessages, connectWithPath, validators }) => Error | undefined', status: 'optional' }, exportValidators: { doc: 'Object containing validators to export for use in other validators.', type: 'Record<string, function>', status: 'optional' }, validateRequired: { doc: 'Custom logic for required validation. Receives `{ value, emptyValue, required, error }`.', type: 'function', status: 'optional' }, transformIn: { doc: 'Transforms the external value before displaying in the field.', type: '(external: Value) => Value', status: 'optional' }, transformOut: { doc: 'Transforms the internal value before storing in form data or returning via onChange.', type: '(internal: Value) => Value', status: 'optional' }, toInput: { doc: 'Transforms value for input display (after transformIn).', type: '(value: Value) => Value', status: 'optional' }, fromInput: { doc: 'Transforms value from input (before transformOut).', type: '(value: Value) => Value', status: 'optional' }, toEvent: { doc: 'Transforms value before passing to event handlers.', type: '(value: Value) => Value', status: 'optional' }, fromExternal: { doc: 'Transforms external data value when reading from DataContext.', type: '(value: Value) => Value', status: 'optional' }, transformValue: { doc: 'Transforms the value during processing.', type: '(value: Value) => Value', status: 'optional' }, provideAdditionalArgs: { doc: 'Provides additional arguments to pass through event handlers.', type: '(value: Value, additionalArgs: ProvideAdditionalEventArgs) => ProvideAdditionalEventArgs', status: 'optional' }, onChange: { doc: 'Callback called when the field value changes.', type: '(value: Value, additionalArgs?: ReceiveAdditionalEventArgs) => void', status: 'optional' }, onFocus: { doc: 'Callback called when the field receives focus.', type: '(value: Value, additionalArgs?: ReceiveAdditionalEventArgs) => void', status: 'optional' }, onBlur: { doc: 'Callback called when the field loses focus.', type: '(value: Value, additionalArgs?: ReceiveAdditionalEventArgs) => void', status: 'optional' }, onStatusChange: { doc: 'Callback called when the field status changes (e.g., error, pending).', type: '(status: FieldStatus) => void', status: 'optional' } }; export const useFieldPropsReturns = { value: { doc: 'The current transformed field value, ready for display.', type: '{valueType}', status: 'required' }, isChanged: { doc: 'Whether the field value has been changed by the user.', type: 'boolean', status: 'required' }, hasError: { doc: 'Whether the field currently has a validation error.', type: 'boolean', status: 'optional' }, htmlAttributes: { doc: 'HTML attributes including aria-invalid, aria-required, aria-describedby, and data-* attributes.', type: 'AriaAttributes & DataAttributes', status: 'required' }, handleFocus: { doc: 'Handler to call when the field receives focus.', type: '() => void', status: 'required' }, handleBlur: { doc: 'Handler to call when the field loses focus. Triggers blur validation.', type: '() => void', status: 'required' }, handleChange: { doc: 'Handler to call when the field value changes. Accepts the new value and optional additional args.', type: '(value: Value, additionalArgs?: object) => void', status: 'required' }, handleError: { doc: 'Handler to manually trigger error display.', type: '() => void', status: 'required' }, updateValue: { doc: 'Programmatically update the field value without triggering change events.', type: '(value: Value) => void', status: 'required' }, setHasFocus: { doc: 'Manually set the focus state of the field.', type: '(hasFocus: boolean, overrideValue?: Value, additionalArgs?: ProvideAdditionalEventArgs) => void', status: 'required' }, setChanged: { doc: 'Manually set the changed state of the field.', type: '(state: boolean) => void', status: 'required' }, setDisplayValue: { doc: 'Set a custom display value for the field (used in summary views).', type: '(value: React.ReactNode, options?: { path?: string; type?: "field" }) => void', status: 'required' }, forceUpdate: { doc: 'Force a re-render of the field component.', type: '() => void', status: 'required' }, dataContext: { doc: 'The DataContext state object, providing access to form-level data and methods.', type: 'ContextState', status: 'required' }, fieldState: { doc: 'Current submit state of the field (pending, error, complete, etc.).', type: 'SubmitState', status: 'required' }, additionalArgs: { doc: 'Additional arguments passed through event handlers.', type: 'ReceiveAdditionalEventArgs', status: 'required' } }; //# sourceMappingURL=useFieldPropsDocs.js.map