{"id":14384603,"url":"https://github.com/betagouv/react-final-form-utils","last_synced_at":"2025-06-15T20:35:57.144Z","repository":{"id":34590123,"uuid":"169419161","full_name":"betagouv/react-final-form-utils","owner":"betagouv","description":"Decorators, validators and string helpers for classic email, password, loading fields in a react final form","archived":false,"fork":false,"pushed_at":"2022-12-08T20:48:14.000Z","size":1777,"stargazers_count":6,"open_issues_count":15,"forks_count":0,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-26T19:06:58.226Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/betagouv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-06T14:31:20.000Z","updated_at":"2021-11-25T10:44:42.000Z","dependencies_parsed_at":"2023-01-15T08:00:50.755Z","dependency_job_id":null,"html_url":"https://github.com/betagouv/react-final-form-utils","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/betagouv/react-final-form-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betagouv%2Freact-final-form-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betagouv%2Freact-final-form-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betagouv%2Freact-final-form-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betagouv%2Freact-final-form-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/betagouv","download_url":"https://codeload.github.com/betagouv/react-final-form-utils/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betagouv%2Freact-final-form-utils/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260046236,"owners_count":22950818,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-28T18:01:30.314Z","updated_at":"2025-06-15T20:35:57.124Z","avatar_url":"https://github.com/betagouv.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# react-final-form-utils\n\nDecorators, validators and string helpers for classic email, password, loading fields in a react final form\n\n[![CircleCI](https://circleci.com/gh/betagouv/react-final-form-utils/tree/master.svg?style=svg)](https://circleci.com/gh/betagouv/react-final-form-utils/tree/master)\n[![npm version](https://img.shields.io/npm/v/react-final-form-utils.svg?style=flat-square)](https://npmjs.org/package/react-final-form-utils)\n\n\n## Basic Usage\n\nFor a typical TextField input:\n\n```javascript\n\n/* eslint\n  react/jsx-one-expression-per-line: 0 */\nimport classnames from 'classnames'\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport { Field } from 'react-final-form'\nimport {\n  composeValidators,\n  config,\n  createParseNumberValue,\n  createValidateRequiredField\n} from 'react-final-form-utils'\n\nimport { FieldError } from '../layout'\n\nconst validateRequiredField = createValidateRequiredField(config.DEFAULT_REQUIRED_ERROR)\n\nexport const TextField = ({\n  autoComplete,\n  className,\n  disabled,\n  id,\n  label,\n  name,\n  placeholder,\n  readOnly,\n  renderInner,\n  renderValue,\n  required,\n  type,\n  validate,\n}) =\u003e {\n\n  const requiredValidate =\n    required \u0026\u0026 typeof required === 'function'\n      ? required\n      : (required \u0026\u0026 validateRequiredField) || undefined\n\n  return (\n    \u003cField\n      name={name}\n      validate={composeValidators(validate, requiredValidate)}\n      parse={createParseNumberValue(type)}\n      render={({ input, meta }) =\u003e (\n        \u003cdiv\n          className={classnames(\"field text-field\",\n            className, { readonly: readOnly })}\n          id={id}\n        \u003e\n          \u003clabel htmlFor={name} className={classnames(\"field-label\", { empty: !label })}\u003e\n            {label \u0026\u0026 (\n              \u003cspan\u003e\n                \u003cspan\u003e{label}\u003c/span\u003e\n                {required \u0026\u0026 !readOnly \u0026\u0026 \u003cspan className=\"field-asterisk\"\u003e*\u003c/span\u003e}\n              \u003c/span\u003e\n            )}\n          \u003c/label\u003e\n          \u003cdiv className=\"field-control\"\u003e\n            \u003cdiv className=\"field-value flex-columns items-center\"\u003e\n              \u003cdiv className=\"field-inner flex-columns items-center\"\u003e\n                \u003cinput\n                  {...input}\n                  autoComplete={autoComplete ? 'on' : 'off'}\n                  className={`field-input field-${type}`}\n                  disabled={disabled || readOnly}\n                  placeholder={readOnly ? '' : placeholder}\n                  readOnly={readOnly}\n                  required={!!required} // cast to boolean\n                  type={type}\n                /\u003e\n                {renderInner()}\n              \u003c/div\u003e\n              {renderValue()}\n            \u003c/div\u003e\n            \u003cFieldError meta={meta} /\u003e\n          \u003c/div\u003e\n        \u003c/div\u003e\n      )}\n    /\u003e\n  )\n}\n\nTextField.defaultProps = {\n  autoComplete: false,\n  className: '',\n  disabled: false,\n  id: null,\n  label: '',\n  placeholder: 'Please enter a value',\n  readOnly: false,\n  renderInner: () =\u003e null,\n  renderValue: () =\u003e null,\n  required: false,\n  type: 'text',\n  validate: null,\n}\n\nTextField.propTypes = {\n  autoComplete: PropTypes.bool,\n  className: PropTypes.string,\n  disabled: PropTypes.bool,\n  id: PropTypes.string,\n  label: PropTypes.string,\n  name: PropTypes.string.isRequired,\n  placeholder: PropTypes.string,\n  readOnly: PropTypes.bool,\n  renderInner: PropTypes.func,\n  renderValue: PropTypes.func,\n  required: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),\n  type: PropTypes.string,\n  validate: PropTypes.func,\n}\n\nexport default TextField\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbetagouv%2Freact-final-form-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbetagouv%2Freact-final-form-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbetagouv%2Freact-final-form-utils/lists"}