Conversation
4ecf05b to
c213619
Compare
| - run: | ||
| name: Install dependencies | ||
| command: npm ci | ||
| command: npm install |
There was a problem hiding this comment.
NPM 10 trims package-lock.json to only include optional native packages matching the current platform, whereas NPM 9 and earlier kept all platforms.
This caused npm ci to fail on linux because the lock file, generated on macOS, was missing the linux entries.
thomasreach5
left a comment
There was a problem hiding this comment.
Je ne suis pas en mesure de juger du contenu de la PR, en revanche on est d'accord que:
- il n'y a strictement aucun changement d'API visible par nos clients ?
- il n'y aura aucun problème de dépendances pour lui (s'il utilise déjà la lib sur laquelle on s'appuie maintenant.)
- si on utilisait correctement le semver, cette évolution ne nécessiterait qu'un changement de version mineure voire patch.
Oui tout à fait. J'ai fait en sorte que les changements soient totalement transparents pour l'utilisateur et l'intégrateur. |
Replace the old custom form system with react-hook-form + Shadcn UI components.
1. Form Engine (
src/lib/form.tsx,src/components/form/form.tsx)react-hook-formformComponent.tsx,formControlsComponent.tsx,formFieldFactory.ts(all deleted)src/core/validation.tsvalidator2. Field Components (
src/components/form/fields/)*Field.tsx(checkbox, date, identifier, password, phone, radiobox, select) was rewritten as a cleaner componentphone/) with context, country variant, and non-country variantrequired.tsxandinput.tsxprimitives added3. Shadcn UI Primitives (
src/components/ui/)checkbox,dropdown-menu,field,input-group,item,label,progress,radio-group,select,separator,textarea4. Form Fields Renderer (
src/components/form/FormFieldsRenderer.tsx)fieldCreator.tsxandformFieldFactory.ts5. Widget Updates (
src/widgets/*/)6. Build / Infra
rollup.config.jsupdated (likely for new entry points or externals)tailwind.config.cjsextended for Shadcncomponents.jsonupdated (Shadcn config)circleci/config.yml) switched to npm install for platform dependency compatibilityDiagram explaining the new form system architecture
flowchart TD subgraph Widget["Widget (e.g. LoginWidget, SignupWidget)"] W[Widget Component] end subgraph FormLib["src/lib/form.tsx — Field Definition Layer"] FD["FieldDefinition\n(type, key, validation, transform, ...)"] PF["predefinedFields\n(email, password, phoneNumber, birthdate, consents, ...)"] GFD["getFieldDefinitions()\nResolves Field → FieldDefinition\n• predefined lookup\n• custom fields\n• consent fields"] end subgraph FormComp["src/components/form/form.tsx — Form Orchestrator"] FP["FormProvider\n(react-hook-form context)"] UF["useForm()\ndefaultValues, state, errors"] SUB["onSubmit\n• beforeSubmit transform\n• captchaHandler\n• handler(data)\n• handleSuccess / handleError"] ERR["Error handling\nsetError on root / field\ni18n error messages"] end subgraph FFR["src/components/form/FormFieldsRenderer.tsx — Field Router"] CTRL["Controller (per field)\n• rules.required\n• rules.validate → Zod schema"] RF["renderField()\nswitch on fieldDefinition.type"] end subgraph Fields["src/components/form/fields/ — Field Components"] IF["InputField\n(string, email, number, decimal, integer)"] PWF["PasswordField\n+ PasswordPolicyRules"] CHK["CheckboxField\n(consents, booleans)"] SEL["SelectField"] RG["RadioGroupField"] DF["DateField"] PHF["PhoneNumberField\n(international / domestic)"] IDN["IdentifierField\n(email or phone or both)"] end subgraph UI["src/components/ui/ — Shadcn UI Primitives"] UIB["Button, Input, Label\nCheckbox, Select, RadioGroup\nProgress, Textarea, Field, ..."] end subgraph Validation["Validation (per field)"] ZOD["Zod schema\nbuilt at validate-time\nwith: client, config, i18n, watch"] TRANS["transform.input / transform.output\nvalue coercion (e.g. UserConsent ↔ boolean)"] end W -->|"fields: Field[]"| GFD GFD -->|"FieldDefinition[]"| FP W -->|"handler, onSuccess, onError, initialModel"| FP FP --> UF UF -->|"control, formState, handleSubmit"| FFR UF --> SUB FFR --> CTRL CTRL -->|"Zod validate"| ZOD CTRL -->|"render"| RF RF --> IF & PWF & CHK & SEL & RG & DF & PHF & IDN IF & PWF & CHK & SEL & RG & DF & PHF & IDN --> UIB CTRL -->|"transform"| TRANS TRANS -->|"input: format for display"| RF TRANS -->|"output: format for RHF"| CTRL SUB -->|"formData"| WHow it flows:
fieldsarray (strings like "email" or fullFieldDefinitionobjects) and a handler function.src/lib/form.tsx—getFieldDefinitions()resolves each field entry into a fullFieldDefinition, looking up predefined fields, custom fields from config, or consent fields. Each definition carries atype, a Zodvalidationfactory, and an optionaltransform(input/output coercion).Formcomponent (src/components/form/form.tsx) callsuseForm()from react-hook-form, wraps everything inFormProvider, and wiresonSubmit→captchaHandler→ widgethandler→ success/error callbacks.FormFieldsRendereriteratesFieldDefinition[], wrapping each in a react-hook-formController. The Controller runs the Zod schema at validation time (with live access toclient,config,i18n, andwatch), then callsrenderField()which dispatches ontypeto the right field component.fields/) are pure presentational components that consume Shadcn UI primitives. They receiveonChange/value(already coerced viatransform) anderrorsfrom the Controller.