@ovok/native 1.8.3 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/lib/commonjs/modules/auth/default-translation.js +8 -0
  2. package/lib/commonjs/modules/auth/default-translation.js.map +1 -1
  3. package/lib/commonjs/modules/auth/profile/components/form-phone-field.js +163 -0
  4. package/lib/commonjs/modules/auth/profile/components/form-phone-field.js.map +1 -0
  5. package/lib/commonjs/modules/auth/profile/components/profile-form-choice-field.js +64 -0
  6. package/lib/commonjs/modules/auth/profile/components/profile-form-choice-field.js.map +1 -0
  7. package/lib/commonjs/modules/auth/profile/components/profile-form-field-component.js +46 -9
  8. package/lib/commonjs/modules/auth/profile/components/profile-form-field-component.js.map +1 -1
  9. package/lib/commonjs/modules/auth/profile/components/profile-form-provider.js +31 -11
  10. package/lib/commonjs/modules/auth/profile/components/profile-form-provider.js.map +1 -1
  11. package/lib/commonjs/modules/auth/profile/utils/phone.js +31 -0
  12. package/lib/commonjs/modules/auth/profile/utils/phone.js.map +1 -0
  13. package/lib/commonjs/modules/auth/register/components/form/inputs.js +32 -4
  14. package/lib/commonjs/modules/auth/register/components/form/inputs.js.map +1 -1
  15. package/lib/commonjs/modules/auth/register/components/form/register-form-provider.js +18 -4
  16. package/lib/commonjs/modules/auth/register/components/form/register-form-provider.js.map +1 -1
  17. package/lib/commonjs/modules/auth/register/contexts/register-form-context.js.map +1 -1
  18. package/lib/commonjs/modules/auth/register/utils/create-register-validation-schema.js +23 -3
  19. package/lib/commonjs/modules/auth/register/utils/create-register-validation-schema.js.map +1 -1
  20. package/lib/commonjs/modules/bt-management/hooks/use-nearby-device-offer.js +172 -0
  21. package/lib/commonjs/modules/bt-management/hooks/use-nearby-device-offer.js.map +1 -0
  22. package/lib/commonjs/modules/bt-management/hooks/use-paired-devices.js +3 -2
  23. package/lib/commonjs/modules/bt-management/hooks/use-paired-devices.js.map +1 -1
  24. package/lib/commonjs/modules/bt-management/index.js +12 -0
  25. package/lib/commonjs/modules/bt-management/index.js.map +1 -1
  26. package/lib/commonjs/modules/helpers/form-items/form-date-field.js +27 -4
  27. package/lib/commonjs/modules/helpers/form-items/form-date-field.js.map +1 -1
  28. package/lib/commonjs/modules/helpers/form-items/form-field.js +2 -1
  29. package/lib/commonjs/modules/helpers/form-items/form-field.js.map +1 -1
  30. package/lib/commonjs/modules/ui/components/nearby-device-prompt.js +150 -0
  31. package/lib/commonjs/modules/ui/components/nearby-device-prompt.js.map +1 -0
  32. package/lib/commonjs/modules/ui/components/pairing-error-message.js +14 -0
  33. package/lib/commonjs/modules/ui/components/pairing-error-message.js.map +1 -0
  34. package/lib/commonjs/modules/ui/components/pairing-flow.js +3 -8
  35. package/lib/commonjs/modules/ui/components/pairing-flow.js.map +1 -1
  36. package/lib/commonjs/modules/ui/index.js +11 -0
  37. package/lib/commonjs/modules/ui/index.js.map +1 -1
  38. package/lib/module/modules/auth/default-translation.js +8 -0
  39. package/lib/module/modules/auth/default-translation.js.map +1 -1
  40. package/lib/module/modules/auth/profile/components/form-phone-field.js +157 -0
  41. package/lib/module/modules/auth/profile/components/form-phone-field.js.map +1 -0
  42. package/lib/module/modules/auth/profile/components/profile-form-choice-field.js +58 -0
  43. package/lib/module/modules/auth/profile/components/profile-form-choice-field.js.map +1 -0
  44. package/lib/module/modules/auth/profile/components/profile-form-field-component.js +46 -9
  45. package/lib/module/modules/auth/profile/components/profile-form-field-component.js.map +1 -1
  46. package/lib/module/modules/auth/profile/components/profile-form-provider.js +31 -11
  47. package/lib/module/modules/auth/profile/components/profile-form-provider.js.map +1 -1
  48. package/lib/module/modules/auth/profile/utils/phone.js +25 -0
  49. package/lib/module/modules/auth/profile/utils/phone.js.map +1 -0
  50. package/lib/module/modules/auth/register/components/form/inputs.js +32 -4
  51. package/lib/module/modules/auth/register/components/form/inputs.js.map +1 -1
  52. package/lib/module/modules/auth/register/components/form/register-form-provider.js +18 -4
  53. package/lib/module/modules/auth/register/components/form/register-form-provider.js.map +1 -1
  54. package/lib/module/modules/auth/register/contexts/register-form-context.js.map +1 -1
  55. package/lib/module/modules/auth/register/utils/create-register-validation-schema.js +23 -3
  56. package/lib/module/modules/auth/register/utils/create-register-validation-schema.js.map +1 -1
  57. package/lib/module/modules/bt-management/hooks/use-nearby-device-offer.js +166 -0
  58. package/lib/module/modules/bt-management/hooks/use-nearby-device-offer.js.map +1 -0
  59. package/lib/module/modules/bt-management/hooks/use-paired-devices.js +2 -1
  60. package/lib/module/modules/bt-management/hooks/use-paired-devices.js.map +1 -1
  61. package/lib/module/modules/bt-management/index.js +1 -0
  62. package/lib/module/modules/bt-management/index.js.map +1 -1
  63. package/lib/module/modules/helpers/form-items/form-date-field.js +27 -4
  64. package/lib/module/modules/helpers/form-items/form-date-field.js.map +1 -1
  65. package/lib/module/modules/helpers/form-items/form-field.js +2 -1
  66. package/lib/module/modules/helpers/form-items/form-field.js.map +1 -1
  67. package/lib/module/modules/ui/components/nearby-device-prompt.js +145 -0
  68. package/lib/module/modules/ui/components/nearby-device-prompt.js.map +1 -0
  69. package/lib/module/modules/ui/components/pairing-error-message.js +9 -0
  70. package/lib/module/modules/ui/components/pairing-error-message.js.map +1 -0
  71. package/lib/module/modules/ui/components/pairing-flow.js +3 -8
  72. package/lib/module/modules/ui/components/pairing-flow.js.map +1 -1
  73. package/lib/module/modules/ui/index.js +1 -0
  74. package/lib/module/modules/ui/index.js.map +1 -1
  75. package/lib/typescript/commonjs/src/modules/auth/default-translation.d.ts +8 -0
  76. package/lib/typescript/commonjs/src/modules/auth/default-translation.d.ts.map +1 -1
  77. package/lib/typescript/commonjs/src/modules/auth/profile/components/form-phone-field.d.ts +13 -0
  78. package/lib/typescript/commonjs/src/modules/auth/profile/components/form-phone-field.d.ts.map +1 -0
  79. package/lib/typescript/commonjs/src/modules/auth/profile/components/profile-form-choice-field.d.ts +14 -0
  80. package/lib/typescript/commonjs/src/modules/auth/profile/components/profile-form-choice-field.d.ts.map +1 -0
  81. package/lib/typescript/commonjs/src/modules/auth/profile/components/profile-form-field-component.d.ts.map +1 -1
  82. package/lib/typescript/commonjs/src/modules/auth/profile/components/profile-form-provider.d.ts.map +1 -1
  83. package/lib/typescript/commonjs/src/modules/auth/profile/types/profile-form-field.d.ts +35 -3
  84. package/lib/typescript/commonjs/src/modules/auth/profile/types/profile-form-field.d.ts.map +1 -1
  85. package/lib/typescript/commonjs/src/modules/auth/profile/types/profile-form-props.d.ts +3 -8
  86. package/lib/typescript/commonjs/src/modules/auth/profile/types/profile-form-props.d.ts.map +1 -1
  87. package/lib/typescript/commonjs/src/modules/auth/profile/utils/phone.d.ts +6 -0
  88. package/lib/typescript/commonjs/src/modules/auth/profile/utils/phone.d.ts.map +1 -0
  89. package/lib/typescript/commonjs/src/modules/auth/register/components/form/inputs.d.ts.map +1 -1
  90. package/lib/typescript/commonjs/src/modules/auth/register/components/form/register-form-provider.d.ts.map +1 -1
  91. package/lib/typescript/commonjs/src/modules/auth/register/contexts/register-form-context.d.ts +6 -0
  92. package/lib/typescript/commonjs/src/modules/auth/register/contexts/register-form-context.d.ts.map +1 -1
  93. package/lib/typescript/commonjs/src/modules/auth/register/hooks/use-register-form.d.ts +5 -0
  94. package/lib/typescript/commonjs/src/modules/auth/register/hooks/use-register-form.d.ts.map +1 -1
  95. package/lib/typescript/commonjs/src/modules/auth/register/types/register-form-props.d.ts +16 -3
  96. package/lib/typescript/commonjs/src/modules/auth/register/types/register-form-props.d.ts.map +1 -1
  97. package/lib/typescript/commonjs/src/modules/auth/register/types/register-form-values.d.ts +1 -0
  98. package/lib/typescript/commonjs/src/modules/auth/register/types/register-form-values.d.ts.map +1 -1
  99. package/lib/typescript/commonjs/src/modules/auth/register/utils/create-register-validation-schema.d.ts +10 -3
  100. package/lib/typescript/commonjs/src/modules/auth/register/utils/create-register-validation-schema.d.ts.map +1 -1
  101. package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-nearby-device-offer.d.ts +21 -0
  102. package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-nearby-device-offer.d.ts.map +1 -0
  103. package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-paired-devices.d.ts +1 -0
  104. package/lib/typescript/commonjs/src/modules/bt-management/hooks/use-paired-devices.d.ts.map +1 -1
  105. package/lib/typescript/commonjs/src/modules/bt-management/index.d.ts +1 -0
  106. package/lib/typescript/commonjs/src/modules/bt-management/index.d.ts.map +1 -1
  107. package/lib/typescript/commonjs/src/modules/helpers/form-items/form-date-field.d.ts +11 -2
  108. package/lib/typescript/commonjs/src/modules/helpers/form-items/form-date-field.d.ts.map +1 -1
  109. package/lib/typescript/commonjs/src/modules/helpers/form-items/form-field.d.ts +2 -1
  110. package/lib/typescript/commonjs/src/modules/helpers/form-items/form-field.d.ts.map +1 -1
  111. package/lib/typescript/commonjs/src/modules/ui/components/nearby-device-prompt.d.ts +15 -0
  112. package/lib/typescript/commonjs/src/modules/ui/components/nearby-device-prompt.d.ts.map +1 -0
  113. package/lib/typescript/commonjs/src/modules/ui/components/pairing-error-message.d.ts +2 -0
  114. package/lib/typescript/commonjs/src/modules/ui/components/pairing-error-message.d.ts.map +1 -0
  115. package/lib/typescript/commonjs/src/modules/ui/components/pairing-flow.d.ts.map +1 -1
  116. package/lib/typescript/commonjs/src/modules/ui/index.d.ts +1 -0
  117. package/lib/typescript/commonjs/src/modules/ui/index.d.ts.map +1 -1
  118. package/lib/typescript/module/src/modules/auth/default-translation.d.ts +8 -0
  119. package/lib/typescript/module/src/modules/auth/default-translation.d.ts.map +1 -1
  120. package/lib/typescript/module/src/modules/auth/profile/components/form-phone-field.d.ts +13 -0
  121. package/lib/typescript/module/src/modules/auth/profile/components/form-phone-field.d.ts.map +1 -0
  122. package/lib/typescript/module/src/modules/auth/profile/components/profile-form-choice-field.d.ts +14 -0
  123. package/lib/typescript/module/src/modules/auth/profile/components/profile-form-choice-field.d.ts.map +1 -0
  124. package/lib/typescript/module/src/modules/auth/profile/components/profile-form-field-component.d.ts.map +1 -1
  125. package/lib/typescript/module/src/modules/auth/profile/components/profile-form-provider.d.ts.map +1 -1
  126. package/lib/typescript/module/src/modules/auth/profile/types/profile-form-field.d.ts +35 -3
  127. package/lib/typescript/module/src/modules/auth/profile/types/profile-form-field.d.ts.map +1 -1
  128. package/lib/typescript/module/src/modules/auth/profile/types/profile-form-props.d.ts +3 -8
  129. package/lib/typescript/module/src/modules/auth/profile/types/profile-form-props.d.ts.map +1 -1
  130. package/lib/typescript/module/src/modules/auth/profile/utils/phone.d.ts +6 -0
  131. package/lib/typescript/module/src/modules/auth/profile/utils/phone.d.ts.map +1 -0
  132. package/lib/typescript/module/src/modules/auth/register/components/form/inputs.d.ts.map +1 -1
  133. package/lib/typescript/module/src/modules/auth/register/components/form/register-form-provider.d.ts.map +1 -1
  134. package/lib/typescript/module/src/modules/auth/register/contexts/register-form-context.d.ts +6 -0
  135. package/lib/typescript/module/src/modules/auth/register/contexts/register-form-context.d.ts.map +1 -1
  136. package/lib/typescript/module/src/modules/auth/register/hooks/use-register-form.d.ts +5 -0
  137. package/lib/typescript/module/src/modules/auth/register/hooks/use-register-form.d.ts.map +1 -1
  138. package/lib/typescript/module/src/modules/auth/register/types/register-form-props.d.ts +16 -3
  139. package/lib/typescript/module/src/modules/auth/register/types/register-form-props.d.ts.map +1 -1
  140. package/lib/typescript/module/src/modules/auth/register/types/register-form-values.d.ts +1 -0
  141. package/lib/typescript/module/src/modules/auth/register/types/register-form-values.d.ts.map +1 -1
  142. package/lib/typescript/module/src/modules/auth/register/utils/create-register-validation-schema.d.ts +10 -3
  143. package/lib/typescript/module/src/modules/auth/register/utils/create-register-validation-schema.d.ts.map +1 -1
  144. package/lib/typescript/module/src/modules/bt-management/hooks/use-nearby-device-offer.d.ts +21 -0
  145. package/lib/typescript/module/src/modules/bt-management/hooks/use-nearby-device-offer.d.ts.map +1 -0
  146. package/lib/typescript/module/src/modules/bt-management/hooks/use-paired-devices.d.ts +1 -0
  147. package/lib/typescript/module/src/modules/bt-management/hooks/use-paired-devices.d.ts.map +1 -1
  148. package/lib/typescript/module/src/modules/bt-management/index.d.ts +1 -0
  149. package/lib/typescript/module/src/modules/bt-management/index.d.ts.map +1 -1
  150. package/lib/typescript/module/src/modules/helpers/form-items/form-date-field.d.ts +11 -2
  151. package/lib/typescript/module/src/modules/helpers/form-items/form-date-field.d.ts.map +1 -1
  152. package/lib/typescript/module/src/modules/helpers/form-items/form-field.d.ts +2 -1
  153. package/lib/typescript/module/src/modules/helpers/form-items/form-field.d.ts.map +1 -1
  154. package/lib/typescript/module/src/modules/ui/components/nearby-device-prompt.d.ts +15 -0
  155. package/lib/typescript/module/src/modules/ui/components/nearby-device-prompt.d.ts.map +1 -0
  156. package/lib/typescript/module/src/modules/ui/components/pairing-error-message.d.ts +2 -0
  157. package/lib/typescript/module/src/modules/ui/components/pairing-error-message.d.ts.map +1 -0
  158. package/lib/typescript/module/src/modules/ui/components/pairing-flow.d.ts.map +1 -1
  159. package/lib/typescript/module/src/modules/ui/index.d.ts +1 -0
  160. package/lib/typescript/module/src/modules/ui/index.d.ts.map +1 -1
  161. package/package.json +4 -2
@@ -16,12 +16,20 @@ const defaultTranslation = exports.defaultTranslation = {
16
16
  delete: "Delete"
17
17
  },
18
18
  profile: {
19
+ form: {
20
+ phone: {
21
+ country: "Country",
22
+ invalid: "Enter a valid phone number for the selected country.",
23
+ searchCountry: "Search countries"
24
+ }
25
+ },
19
26
  save: "Save"
20
27
  },
21
28
  register: {
22
29
  "already-have-account": "Already have an account? <login/>",
23
30
  button: "Create account",
24
31
  name: "First name",
32
+ "full-name": "Full name",
25
33
  "or-register-with": "Or register with",
26
34
  "password-confirm": "Confirm password",
27
35
  subtitle: "Create your account",
@@ -1 +1 @@
1
- {"version":3,"names":["_i18next","_interopRequireDefault","require","e","__esModule","default","defaultTranslation","exports","auth","common","cancel","delete","profile","save","register","button","name","subtitle","surname","title","accountType","email","patient","practitioner","settings","logout","apple","footer","google","mfa","code","verify","password","errors","unavailable","network","generic","i18n","addResourceBundle","resources","options","englishResources","Object","assign","en","existingTranslation","translation"],"sourceRoot":"../../../../src","sources":["modules/auth/default-translation.ts"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA2B,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE3B;AACO,MAAMG,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG;EAChCE,IAAI,EAAE;IAAE,YAAY,EAAE;EAAsD,CAAC;EAC7EC,MAAM,EAAE;IAAEC,MAAM,EAAE,QAAQ;IAAEC,MAAM,EAAE;EAAS,CAAC;EAC9CC,OAAO,EAAE;IAAEC,IAAI,EAAE;EAAO,CAAC;EACzBC,QAAQ,EAAE;IACR,sBAAsB,EAAE,mCAAmC;IAC3DC,MAAM,EAAE,gBAAgB;IACxBC,IAAI,EAAE,YAAY;IAClB,kBAAkB,EAAE,kBAAkB;IACtC,kBAAkB,EAAE,kBAAkB;IACtCC,QAAQ,EAAE,qBAAqB;IAC/BC,OAAO,EAAE,WAAW;IACpBC,KAAK,EAAE;EACT,CAAC;EACD,gBAAgB,EAAE;IAChBC,WAAW,EAAE,cAAc;IAC3BC,KAAK,EAAE,OAAO;IACdC,OAAO,EAAE,SAAS;IAClBC,YAAY,EAAE,cAAc;IAC5B,gBAAgB,EAAE,gBAAgB;IAClCN,QAAQ,EAAE,+BAA+B;IACzCE,KAAK,EAAE;EACT,CAAC;EACDK,QAAQ,EAAE;IACR,gBAAgB,EAAE,gBAAgB;IAClC,6BAA6B,EAC3B,+CAA+C;IACjDC,MAAM,EAAE,UAAU;IAClB,aAAa,EAAE,oBAAoB;IACnC,wBAAwB,EAAE;EAC5B,CAAC;EACD,SAAS,EAAE;IACTC,KAAK,EAAE,qBAAqB;IAC5BX,MAAM,EAAE,SAAS;IACjB,mBAAmB,EAAE,oCAAoC;IACzDM,KAAK,EAAE,OAAO;IACd,iBAAiB,EAAE,kBAAkB;IACrCM,MAAM,EAAE,wCAAwC;IAChDC,MAAM,EAAE,sBAAsB;IAC9BC,GAAG,EAAE;MAAEC,IAAI,EAAE,mBAAmB;MAAEC,MAAM,EAAE;IAAS,CAAC;IACpD,eAAe,EAAE,iBAAiB;IAClCC,QAAQ,EAAE,UAAU;IACpBC,MAAM,EAAE;MACN,qBAAqB,EAAE,qCAAqC;MAC5DC,WAAW,EAAE,4DAA4D;MACzEC,OAAO,EAAE,yDAAyD;MAClEC,OAAO,EAAE;IACX,CAAC;IACDnB,QAAQ,EAAE,qBAAqB;IAC/BE,KAAK,EAAE;EACT;AACF,CAAC;AAED,IAAI,OAAOkB,gBAAI,CAACC,iBAAiB,KAAK,UAAU,EAAE;EAChDD,gBAAI,CAACC,iBAAiB,CAAC,IAAI,EAAE,aAAa,EAAEhC,kBAAkB,EAAE,IAAI,EAAE,KAAK,CAAC;AAC9E,CAAC,MAAM;EACL,MAAMiC,SAAS,GAAGF,gBAAI,CAACG,OAAO,CAACD,SAAS,IAAI,CAAC,CAAC;EAE9C,MAAME,gBAAgB,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEJ,SAAS,CAACK,EAAE,CAGtD;EAED,MAAMC,mBAAmB,GAAGH,MAAM,CAACC,MAAM,CACvC,CAAC,CAAC,EACFF,gBAAgB,CAACK,WACnB,CAA4B;EAE5BT,gBAAI,CAACG,OAAO,CAACD,SAAS,GAAGG,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEJ,SAAS,EAAE;IACpDK,EAAE,EAAEF,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEF,gBAAgB,EAAE;MACtCK,WAAW,EAAEJ,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAErC,kBAAkB,EAAEuC,mBAAmB;IACxE,CAAC;EACH,CAAC,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["_i18next","_interopRequireDefault","require","e","__esModule","default","defaultTranslation","exports","auth","common","cancel","delete","profile","form","phone","country","invalid","searchCountry","save","register","button","name","subtitle","surname","title","accountType","email","patient","practitioner","settings","logout","apple","footer","google","mfa","code","verify","password","errors","unavailable","network","generic","i18n","addResourceBundle","resources","options","englishResources","Object","assign","en","existingTranslation","translation"],"sourceRoot":"../../../../src","sources":["modules/auth/default-translation.ts"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA2B,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE3B;AACO,MAAMG,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG;EAChCE,IAAI,EAAE;IAAE,YAAY,EAAE;EAAsD,CAAC;EAC7EC,MAAM,EAAE;IAAEC,MAAM,EAAE,QAAQ;IAAEC,MAAM,EAAE;EAAS,CAAC;EAC9CC,OAAO,EAAE;IACPC,IAAI,EAAE;MACJC,KAAK,EAAE;QACLC,OAAO,EAAE,SAAS;QAClBC,OAAO,EAAE,sDAAsD;QAC/DC,aAAa,EAAE;MACjB;IACF,CAAC;IACDC,IAAI,EAAE;EACR,CAAC;EACDC,QAAQ,EAAE;IACR,sBAAsB,EAAE,mCAAmC;IAC3DC,MAAM,EAAE,gBAAgB;IACxBC,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,WAAW;IACxB,kBAAkB,EAAE,kBAAkB;IACtC,kBAAkB,EAAE,kBAAkB;IACtCC,QAAQ,EAAE,qBAAqB;IAC/BC,OAAO,EAAE,WAAW;IACpBC,KAAK,EAAE;EACT,CAAC;EACD,gBAAgB,EAAE;IAChBC,WAAW,EAAE,cAAc;IAC3BC,KAAK,EAAE,OAAO;IACdC,OAAO,EAAE,SAAS;IAClBC,YAAY,EAAE,cAAc;IAC5B,gBAAgB,EAAE,gBAAgB;IAClCN,QAAQ,EAAE,+BAA+B;IACzCE,KAAK,EAAE;EACT,CAA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C,EAAEJ,SAAS,EAAE;IACpDK,EAAE,EAAEF,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEF,gBAAgB,EAAE;MACtCK,WAAW,EAAEJ,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAE1C,kBAAkB,EAAE4C,mBAAmB;IACxE,CAAC;EACH,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.FormPhoneField = void 0;
7
+ var _countriesList = require("countries-list");
8
+ var _formik = require("formik");
9
+ var _libphonenumberJs = require("libphonenumber-js");
10
+ var React = _interopRequireWildcard(require("react"));
11
+ var _reactI18next = require("react-i18next");
12
+ var _reactNative = require("react-native");
13
+ var _reactNativeElementDropdown = require("react-native-element-dropdown");
14
+ var _reactNativePaper = require("react-native-paper");
15
+ var _index = require("../../../theme/index.js");
16
+ var _profileFormContext = require("../contexts/profile-form-context.js");
17
+ var _phone = require("../utils/phone.js");
18
+ var _jsxRuntime = require("react/jsx-runtime");
19
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
20
+ const phoneCountries = (0, _libphonenumberJs.getCountries)().filter(code => Boolean(_countriesList.countries[code])).map(code => ({
21
+ value: code,
22
+ label: `${_countriesList.countries[code].name} (+${(0, _libphonenumberJs.getCountryCallingCode)(code)})`
23
+ })).sort((first, second) => first.label.localeCompare(second.label));
24
+ const FormPhoneField = ({
25
+ name,
26
+ fieldName,
27
+ label,
28
+ defaultCountry,
29
+ disabled = false,
30
+ testID
31
+ }) => {
32
+ const {
33
+ t
34
+ } = (0, _reactI18next.useTranslation)();
35
+ const theme = (0, _index.useAppTheme)();
36
+ const {
37
+ values,
38
+ errors,
39
+ touched,
40
+ setFieldValue,
41
+ setFieldTouched
42
+ } = React.useContext(_profileFormContext.ProfileFormContext);
43
+ const storedValue = (0, _formik.getIn)(values, name) ?? "";
44
+ const countryFieldName = (0, _phone.phoneCountryFieldName)(fieldName);
45
+ const storedCountry = values[countryFieldName];
46
+ const parsedStoredValue = (0, _libphonenumberJs.parsePhoneNumberFromString)(storedValue);
47
+ const parsedStoredNational = parsedStoredValue?.formatNational();
48
+ const [country, setCountry] = React.useState(storedCountry ?? parsedStoredValue?.country ?? defaultCountry);
49
+ const [draft, setDraft] = React.useState(() => {
50
+ if (!storedValue) {
51
+ return "";
52
+ }
53
+ return parsedStoredNational ?? storedValue;
54
+ });
55
+ const lastInputValue = React.useRef(storedValue);
56
+ const error = (0, _formik.getIn)(touched, name) && (0, _formik.getIn)(errors, name);
57
+ React.useEffect(() => {
58
+ if (storedCountry && storedCountry !== country) {
59
+ setCountry(storedCountry);
60
+ }
61
+ }, [country, storedCountry]);
62
+ React.useEffect(() => {
63
+ if (storedValue === lastInputValue.current) {
64
+ return;
65
+ }
66
+ lastInputValue.current = storedValue;
67
+ if (!storedValue) {
68
+ setDraft("");
69
+ return;
70
+ }
71
+ setDraft(parsedStoredNational ?? storedValue);
72
+ }, [parsedStoredNational, storedValue]);
73
+ const handlePhoneChange = value => {
74
+ setDraft(value);
75
+ const e164Value = (0, _phone.toPhoneE164)(value, country);
76
+ lastInputValue.current = e164Value;
77
+ void setFieldValue(name, e164Value);
78
+ };
79
+ const handleCountryChange = item => {
80
+ setCountry(item.value);
81
+ void setFieldValue(countryFieldName, item.value);
82
+ const e164Value = (0, _phone.toPhoneE164)(draft, item.value);
83
+ lastInputValue.current = e164Value;
84
+ void setFieldValue(name, e164Value);
85
+ };
86
+ const handleBlur = () => {
87
+ void setFieldTouched(name, true);
88
+ const parsed = (0, _libphonenumberJs.parsePhoneNumberFromString)(draft, country);
89
+ if (parsed) {
90
+ setDraft(parsed.formatNational());
91
+ lastInputValue.current = parsed.number;
92
+ void setFieldValue(name, parsed.number);
93
+ }
94
+ };
95
+ const countryLabel = phoneCountries.find(item => item.value === country)?.label ?? country;
96
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
97
+ style: {
98
+ gap: theme.spacing(1.5)
99
+ },
100
+ testID: testID,
101
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
102
+ style: {
103
+ flexDirection: "row",
104
+ gap: theme.spacing(1.5)
105
+ },
106
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeElementDropdown.Dropdown, {
107
+ accessibilityLabel: t("profile.form.phone.country"),
108
+ data: phoneCountries,
109
+ labelField: "label",
110
+ valueField: "value",
111
+ value: country,
112
+ search: true,
113
+ disable: disabled,
114
+ testID: testID ? `${testID}-country` : undefined,
115
+ searchPlaceholder: t("profile.form.phone.searchCountry"),
116
+ maxHeight: 300,
117
+ onChange: handleCountryChange,
118
+ style: {
119
+ width: 150,
120
+ borderWidth: 1,
121
+ borderColor: theme.colors.outline,
122
+ borderRadius: theme.borderRadius(2),
123
+ paddingHorizontal: theme.spacing(2)
124
+ },
125
+ selectedTextStyle: {
126
+ color: theme.colors.onSurface
127
+ },
128
+ itemTextStyle: {
129
+ color: theme.colors.onSurface
130
+ },
131
+ containerStyle: {
132
+ backgroundColor: theme.colors.background,
133
+ borderColor: theme.colors.outline,
134
+ borderRadius: theme.spacing(2.5)
135
+ }
136
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativePaper.TextInput, {
137
+ mode: "outlined",
138
+ label: label,
139
+ value: draft,
140
+ editable: !disabled,
141
+ keyboardType: "phone-pad",
142
+ autoCapitalize: "none",
143
+ error: !!error,
144
+ testID: testID ? `${testID}-input` : undefined,
145
+ accessibilityLabel: label,
146
+ onChangeText: handlePhoneChange,
147
+ onBlur: handleBlur,
148
+ theme: {
149
+ roundness: theme.borderRadius(2)
150
+ },
151
+ style: {
152
+ flex: 1
153
+ },
154
+ accessibilityHint: countryLabel
155
+ })]
156
+ }), error ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativePaper.HelperText, {
157
+ type: "error",
158
+ children: t(error)
159
+ }) : null]
160
+ });
161
+ };
162
+ exports.FormPhoneField = FormPhoneField;
163
+ //# sourceMappingURL=form-phone-field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_countriesList","require","_formik","_libphonenumberJs","React","_interopRequireWildcard","_reactI18next","_reactNative","_reactNativeElementDropdown","_reactNativePaper","_index","_profileFormContext","_phone","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","phoneCountries","getCountries","filter","code","Boolean","countries","map","value","label","name","getCountryCallingCode","sort","first","second","localeCompare","FormPhoneField","fieldName","defaultCountry","disabled","testID","useTranslation","theme","useAppTheme","values","errors","touched","setFieldValue","setFieldTouched","useContext","ProfileFormContext","storedValue","getIn","countryFieldName","phoneCountryFieldName","storedCountry","parsedStoredValue","parsePhoneNumberFromString","parsedStoredNational","formatNational","country","setCountry","useState","draft","setDraft","lastInputValue","useRef","error","useEffect","current","handlePhoneChange","e164Value","toPhoneE164","handleCountryChange","item","handleBlur","parsed","number","countryLabel","find","jsxs","View","style","gap","spacing","children","flexDirection","jsx","Dropdown","accessibilityLabel","data","labelField","valueField","search","disable","undefined","searchPlaceholder","maxHeight","onChange","width","borderWidth","borderColor","colors","outline","borderRadius","paddingHorizontal","selectedTextStyle","color","onSurface","itemTextStyle","containerStyle","backgroundColor","background","TextInput","mode","editable","keyboardType","autoCapitalize","onChangeText","onBlur","roundness","flex","accessibilityHint","HelperText","type","exports"],"sourceRoot":"../../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CACH,CAAC,eACF,IAAAnF,WAAA,CAAAsF,GAAA,EAAC1F,iBAAA,CAAAoH,SAAS;QACRC,IAAI,EAAC,UAAU;QACfrF,KAAK,EAAEA,KAAM;QACbD,KAAK,EAAEmC,KAAM;QACboD,QAAQ,EAAE,CAAC5E,QAAS;QACpB6E,YAAY,EAAC,WAAW;QACxBC,cAAc,EAAC,MAAM;QACrBlD,KAAK,EAAE,CAAC,CAACA,KAAM;QACf3B,MAAM,EAAEA,MAAM,GAAG,GAAGA,MAAM,QAAQ,GAAGuD,SAAU;QAC/CN,kBAAkB,EAAE5D,KAAM;QAC1ByF,YAAY,EAAEhD,iBAAkB;QAChCiD,MAAM,EAAE5C,UAAW;QACnBjC,KAAK,EAAE;UAAE8E,SAAS,EAAE9E,KAAK,CAAC8D,YAAY,CAAC,CAAC;QAAE,CAAE;QAC5CtB,KAAK,EAAE;UAAEuC,IAAI,EAAE;QAAE,CAAE;QACnBC,iBAAiB,EAAE5C;MAAa,CACjC,CAAC;IAAA,CACE,CAAC,EACNX,KAAK,gBAAG,IAAAlE,WAAA,CAAAsF,GAAA,EAAC1F,iBAAA,CAAA8H,UAAU;MAACC,IAAI,EAAC,OAAO;MAAAvC,QAAA,EAAElF,CAAC,CAACgE,KAAK;IAAC,CAAa,CAAC,GAAG,IAAI;EAAA,CAC5D,CAAC;AAEX,CAAC;AAAC0D,OAAA,CAAAzF,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ProfileFormChoiceField = void 0;
7
+ var _formik = require("formik");
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _reactI18next = require("react-i18next");
10
+ var _reactNative = require("react-native");
11
+ var _reactNativePaper = require("react-native-paper");
12
+ var _index = require("../../../theme/index.js");
13
+ var _profileFormContext = require("../contexts/profile-form-context.js");
14
+ var _jsxRuntime = require("react/jsx-runtime");
15
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
16
+ const ProfileFormChoiceField = ({
17
+ name,
18
+ label,
19
+ options,
20
+ disabled = false,
21
+ testID
22
+ }) => {
23
+ const theme = (0, _index.useAppTheme)();
24
+ const {
25
+ t
26
+ } = (0, _reactI18next.useTranslation)();
27
+ const {
28
+ values,
29
+ errors,
30
+ touched,
31
+ setFieldValue,
32
+ setFieldTouched
33
+ } = React.useContext(_profileFormContext.ProfileFormContext);
34
+ const value = (0, _formik.getIn)(values, name) ?? "";
35
+ const error = (0, _formik.getIn)(touched, name) && (0, _formik.getIn)(errors, name);
36
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
37
+ testID: testID,
38
+ style: {
39
+ gap: theme.spacing(1)
40
+ },
41
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativePaper.Text, {
42
+ variant: "labelLarge",
43
+ children: label
44
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativePaper.RadioButton.Group, {
45
+ value: value,
46
+ onValueChange: nextValue => {
47
+ void setFieldValue(name, nextValue);
48
+ void setFieldTouched(name, true);
49
+ },
50
+ children: options.map(option => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativePaper.RadioButton.Item, {
51
+ label: option.label,
52
+ value: option.value,
53
+ disabled: disabled,
54
+ testID: testID ? `${testID}-${option.value}` : undefined,
55
+ position: "leading"
56
+ }, option.value))
57
+ }), error ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativePaper.HelperText, {
58
+ type: "error",
59
+ children: t(error)
60
+ }) : null]
61
+ });
62
+ };
63
+ exports.ProfileFormChoiceField = ProfileFormChoiceField;
64
+ //# sourceMappingURL=profile-form-choice-field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_formik","require","React","_interopRequireWildcard","_reactI18next","_reactNative","_reactNativePaper","_index","_profileFormContext","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ProfileFormChoiceField","name","label","options","disabled","testID","theme","useAppTheme","useTranslation","values","errors","touched","setFieldValue","setFieldTouched","useContext","ProfileFormContext","value","getIn","error","jsxs","View","style","gap","spacing","children","jsx","Text","variant","RadioButton","Group","onValueChange","nextValue","map","option","Item","undefined","position","HelperText","type","exports"],"sourceRoot":"../../../../../../src","sources":["modules/auth/profile/components/profile-form-choice-field.tsx"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,mBAAA,GAAAP,OAAA;AAAsE,IAAAQ,WAAA,GAAAR,OAAA;AAAA,SAAAE,wBAAAO,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAT,uBAAA,YAAAA,CAAAO,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CA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));
8
8
  var _index = require("../../../helpers/index.js");
9
9
  var _formDateField = require("../../../helpers/form-items/form-date-field.js");
10
10
  var _profileFormContext = require("../contexts/profile-form-context.js");
11
+ var _formPhoneField = require("./form-phone-field.js");
12
+ var _profileFormChoiceField = require("./profile-form-choice-field.js");
11
13
  var _jsxRuntime = require("react/jsx-runtime");
12
14
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
13
15
  const ProfileFormFieldComponent = ({
@@ -15,26 +17,61 @@ const ProfileFormFieldComponent = ({
15
17
  }) => {
16
18
  if (field.type === "text") {
17
19
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.FormField, {
18
- ...field,
20
+ ...field.inputProps,
19
21
  name: `['${field.name}']`,
20
- context: _profileFormContext.ProfileFormContext
21
- }, field.name);
22
+ context: _profileFormContext.ProfileFormContext,
23
+ label: field.label,
24
+ testID: field.testID,
25
+ editable: field.disabled ? false : field.inputProps?.editable,
26
+ keyboardType: field.keyboardType ?? field.inputProps?.keyboardType
27
+ });
22
28
  }
23
29
  if (field.type === "date") {
24
30
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_formDateField.FormDateField, {
25
- ...field,
26
31
  name: `['${field.name}']`,
27
- context: _profileFormContext.ProfileFormContext
28
- }, field.name);
32
+ context: _profileFormContext.ProfileFormContext,
33
+ label: field.label,
34
+ testID: field.testID,
35
+ disabled: field.disabled,
36
+ mode: field.mode,
37
+ initialDate: field.initialDate,
38
+ minimumDate: field.minimumDate,
39
+ maximumDate: field.maximumDate,
40
+ display: field.display,
41
+ locale: field.locale,
42
+ formatValue: field.formatValue
43
+ });
29
44
  }
30
45
  if (field.type === "select") {
31
46
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.FormSelect, {
32
- ...field,
33
47
  context: _profileFormContext.ProfileFormContext,
34
48
  labelField: "label",
35
49
  valueField: "value",
36
- name: `['${field.name}']`
37
- }, field.name);
50
+ name: `['${field.name}']`,
51
+ label: field.label,
52
+ options: field.options,
53
+ testID: field.testID,
54
+ disable: field.disabled
55
+ });
56
+ }
57
+ if (field.type === "choice") {
58
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_profileFormChoiceField.ProfileFormChoiceField, {
59
+ name: `['${field.name}']`,
60
+ label: field.label,
61
+ options: field.options,
62
+ disabled: field.disabled,
63
+ testID: field.testID
64
+ });
65
+ }
66
+ if (field.type === "phone") {
67
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_formPhoneField.FormPhoneField, {
68
+ name: `['${field.name}']`,
69
+ fieldName: field.name,
70
+ label: field.label,
71
+ defaultCountry: field.defaultCountry,
72
+ disabled: field.disabled,
73
+ testID: field.testID
74
+ });
38
75
  }
39
76
  return null;
40
77
  };
@@ -1 +1 @@
1
- {"version":3,"names":["React","_interopRequireWildcard","require","_index","_formDateField","_profileFormContext","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ProfileFormFieldComponent","field","type","jsx","FormField","name","context","ProfileFormContext","FormDateField","FormSelect","labelField","valueField","exports"],"sourceRoot":"../../../../../../src","sources":["modules/auth/profile/components/profile-form-field-component.tsx"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AAAsE,IAAAI,WAAA,GAAAJ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AmB,GAHvBN,KAAK,CAACI,IAIZ,CAAC;EAEN;EAEA,IAAIJ,KAAK,CAACC,IAAI,KAAK,MAAM,EAAE;IACzB,oBACE,IAAAtB,WAAA,CAAAuB,GAAA,EAACzB,cAAA,CAAA8B,aAAa;MAAA,GAERP,KAAK;MACTI,IAAI,EAAE,KAAKJ,KAAK,CAACI,IAAI,IAAK;MAC1BC,OAAO,EAAEC;IAAmB,GAHvBN,KAAK,CAACI,IAIZ,CAAC;EAEN;EAEA,IAAIJ,KAAK,CAACC,IAAI,KAAK,QAAQ,EAAE;IAC3B,oBACE,IAAAtB,WAAA,CAAAuB,GAAA,EAAC1B,MAAA,CAAAgC,UAAU;MAAA,GAELR,KAAK;MACTK,OAAO,EAAEC,sCAAmB;MAC5BG,UAAU,EAAC,OAAO;MAClBC,UAAU,EAAC,OAAO;MAClBN,IAAI,EAAE,KAAKJ,KAAK,CAACI,IAAI;IAAK,GALrBJ,KAAK,CAACI,IAMZ,CAAC;EAEN;EAEA,OAAO,IAAI;AACb,CAAC;AAACO,OAAA,CAAAZ,yBAAA,GAAAA,yBAAA","ignoreList":[]}
1
+ {"version":3,"names":["React","_interopRequireWildcard","require","_index","_formDateField","_profileFormContext","_formPhoneField","_profileFormChoiceField","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ProfileFormFieldComponent","field","type","jsx","FormField","inputProps","name","context","ProfileFormContext","label","testID","editable","disabled","keyboardType","FormDateField","mode","initialDate","minimumDate","maximumDate","display","locale","formatValue","FormSelect","labelField","valueField","options","disable","ProfileFormChoiceField","FormPhoneField","fieldName","defaultCountry","exports"],"sourceRoot":"../../../../../../src","sources":["modules/auth/profile/components/profile-form-field-component.tsx"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA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AO;MAClBlB,IAAI,EAAE,KAAKL,KAAK,CAACK,IAAI,IAAK;MAC1BG,KAAK,EAAER,KAAK,CAACQ,KAAM;MACnBgB,OAAO,EAAExB,KAAK,CAACwB,OAAQ;MACvBf,MAAM,EAAET,KAAK,CAACS,MAAO;MACrBgB,OAAO,EAAEzB,KAAK,CAACW;IAAS,CACzB,CAAC;EAEN;EAEA,IAAIX,KAAK,CAACC,IAAI,KAAK,QAAQ,EAAE;IAC3B,oBACE,IAAAtB,WAAA,CAAAuB,GAAA,EAACxB,uBAAA,CAAAgD,sBAAsB;MACrBrB,IAAI,EAAE,KAAKL,KAAK,CAACK,IAAI,IAAK;MAC1BG,KAAK,EAAER,KAAK,CAACQ,KAAM;MACnBgB,OAAO,EAAExB,KAAK,CAACwB,OAAQ;MACvBb,QAAQ,EAAEX,KAAK,CAACW,QAAS;MACzBF,MAAM,EAAET,KAAK,CAACS;IAAO,CACtB,CAAC;EAEN;EAEA,IAAIT,KAAK,CAACC,IAAI,KAAK,OAAO,EAAE;IAC1B,oBACE,IAAAtB,WAAA,CAAAuB,GAAA,EAACzB,eAAA,CAAAkD,cAAc;MACbtB,IAAI,EAAE,KAAKL,KAAK,CAACK,IAAI,IAAK;MAC1BuB,SAAS,EAAE5B,KAAK,CAACK,IAAK;MACtBG,KAAK,EAAER,KAAK,CAACQ,KAAM;MACnBqB,cAAc,EAAE7B,KAAK,CAAC6B,cAAe;MACrClB,QAAQ,EAAEX,KAAK,CAACW,QAAS;MACzBF,MAAM,EAAET,KAAK,CAACS;IAAO,CACtB,CAAC;EAEN;EAEA,OAAO,IAAI;AACb,CAAC;AAACqB,OAAA,CAAA/B,yBAAA,GAAAA,yBAAA","ignoreList":[]}
@@ -6,10 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.ProfileFormProvider = void 0;
7
7
  var _core = require("@ovok/core");
8
8
  var _formik = require("formik");
9
+ var _libphonenumberJs = require("libphonenumber-js");
9
10
  var _react = _interopRequireDefault(require("react"));
10
11
  var Yup = _interopRequireWildcard(require("yup"));
11
12
  var _useShallowStableValue = require("../../../helpers/hooks/use-shallow-stable-value.js");
12
13
  var _profileFormContext = require("../contexts/profile-form-context.js");
14
+ var _phone = require("../utils/phone.js");
13
15
  var _jsxRuntime = require("react/jsx-runtime");
14
16
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
15
17
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -22,7 +24,11 @@ const ProfileFormProvider = ({
22
24
  const client = (0, _core.useClient)();
23
25
  const initialValues = _react.default.useMemo(() => {
24
26
  const values = fields.reduce((acc, field) => {
25
- acc[field.name] = field.value ?? "";
27
+ const value = field.type === "phone" ? (0, _phone.toPhoneE164)(field.value ?? "", field.defaultCountry) : field.value ?? "";
28
+ acc[field.name] = value;
29
+ if (field.type === "phone") {
30
+ acc[(0, _phone.phoneCountryFieldName)(field.name)] = (0, _libphonenumberJs.parsePhoneNumberFromString)(value)?.country ?? field.defaultCountry;
31
+ }
26
32
  return acc;
27
33
  }, {});
28
34
  return {
@@ -32,7 +38,14 @@ const ProfileFormProvider = ({
32
38
  }, [fields]);
33
39
  const validationSchema = _react.default.useMemo(() => {
34
40
  const fieldRules = fields.reduce((acc, field) => {
35
- acc[field.name] = field.validation ?? Yup.string();
41
+ const validation = field.validation ?? Yup.string();
42
+ acc[field.name] = field.type === "phone" ? validation.test("phone-country", "profile.form.phone.invalid", function validatePhone(value) {
43
+ if (!value) {
44
+ return true;
45
+ }
46
+ const country = this.parent[(0, _phone.phoneCountryFieldName)(field.name)] ?? field.defaultCountry;
47
+ return (0, _phone.isPhoneValidForCountry)(value, country);
48
+ }) : validation;
36
49
  return acc;
37
50
  }, {});
38
51
  return Yup.object().shape(fieldRules);
@@ -43,32 +56,39 @@ const ProfileFormProvider = ({
43
56
  validateOnBlur: true,
44
57
  validationSchema,
45
58
  onSubmit: async (values, formikHelpers) => {
59
+ const submittedValues = fields.reduce((submitted, field) => {
60
+ submitted[field.name] = values[field.name] ?? "";
61
+ return submitted;
62
+ }, {});
46
63
  if (onSubmit) {
47
- return onSubmit(values, formikHelpers);
64
+ return onSubmit(submittedValues, formikHelpers);
48
65
  }
49
66
  try {
50
- const operations = fields.map(field => {
67
+ const activeProfile = await client.getProfileAsync();
68
+ const patient = activeProfile;
69
+ const operations = fields.flatMap(field => {
51
70
  const value = values[field.name];
71
+ if (field.toPatch) {
72
+ return field.toPatch(value ?? "", patient);
73
+ }
52
74
  const initialValue = initialValues[field.name];
53
75
  const op = (0, _core.getPatchOperationType)(initialValue, value);
54
76
  if (!op) {
55
- return undefined;
77
+ return [];
56
78
  }
57
79
  let path = `/${field.name}`;
58
80
  if (field.name.includes("[")) {
59
81
  path = `/${field.name.split(/[[\].]/).filter(Boolean).join("/")}`;
60
82
  }
61
- return {
83
+ return [{
62
84
  op,
63
85
  path,
64
86
  value
65
- };
87
+ }];
66
88
  });
67
- const filteredOperations = operations.filter(op => Boolean(op) && op?.path !== "/submit");
68
- const activeProfile = await client.getProfileAsync();
69
- const response = await client.patchResource("Patient", activeProfile?.id ?? "", filteredOperations);
89
+ const response = await client.patchResource("Patient", activeProfile?.id ?? "", operations.filter(op => op.path !== "/submit"));
70
90
  client.refetchProfile();
71
- onSuccess?.(response);
91
+ onSuccess?.(response, submittedValues);
72
92
  } catch (error) {
73
93
  if (error instanceof Error) {
74
94
  formikHelpers.setFieldError("submit", error.message);
@@ -1 +1 @@
1
- {"version":3,"names":["_core","require","_formik","_react","_interopRequireDefault","Yup","_interopRequireWildcard","_useShallowStableValue","_profileFormContext","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ProfileFormProvider","children","fields","onSubmit","onSuccess","client","useClient","initialValues","React","useMemo","values","reduce","acc","field","name","value","submit","validationSchema","fieldRules","validation","string","object","shape","formik","useFormik","enableReinitialize","validateOnBlur","formikHelpers","operations","map","initialValue","op","getPatchOperationType","undefined","path","includes","split","filter","Boolean","join","filteredOperations","activeProfile","getProfileAsync","response","patchResource","id","refetchProfile","error","Error","setFieldError","message","contextValue","useShallowStableValue","jsx","ProfileFormContext","Provider","exports"],"sourceRoot":"../../../../../../src","sources":["modules/auth/profile/components/profile-form-provider.tsx"],"mappings":";;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,GAAA,GAAAC,uBAAA,CAAAL,OAAA;AAEA,IAAAM,sBAAA,GAAAN,OAAA;AACA,IAAAO,mBAAA,GAAAP,OAAA;AAAsE,IAAAQ,WAAA,GAAAR,OAAA;AAAA,SAAAK,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CA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ChB;UAEA,OAAO;YACLR,EAAE;YACFG,IAAI;YACJnB;UACF,CAAC;QACH,CAAC,CAAC;QAEF,MAAMyB,kBAAkB,GAAGZ,UAAU,CAACS,MAAM,CACzCN,EAAE,IAAKO,OAAO,CAACP,EAAE,CAAC,IAAIA,EAAE,EAAEG,IAAI,KAAK,SACtC,CAAqB;QAErB,MAAMO,aAAa,GAAG,MAAMpC,MAAM,CAACqC,eAAe,CAAC,CAAC;QAEpD,MAAMC,QAAQ,GAAG,MAAMtC,MAAM,CAACuC,aAAa,CACzC,SAAS,EACTH,aAAa,EAAEI,EAAE,IAAI,EAAE,EACvBL,kBACF,CAAC;QAEDnC,MAAM,CAACyC,cAAc,CAAC,CAAC;QAEvB1C,SAAS,GAAGuC,QAAmB,CAAC;MAClC,CAAC,CAAC,OAAOI,KAAK,EAAE;QACd,IAAIA,KAAK,YAAYC,KAAK,EAAE;UAC1BrB,aAAa,CAACsB,aAAa,CAAC,QAAQ,EAAEF,KAAK,CAACG,OAAO,CAAC;UAEpD;QACF;QAEAvB,aAAa,CAACsB,aAAa,CAAC,QAAQ,EAAE,4BAA4B,CAAC;MACrE;IACF;EACF,CAAC,CAAC;EAEF,MAAME,YAAY,GAAG,IAAAC,4CAAqB,EAAC;IAAE,GAAG7B;EAAO,CAAC,CAAC;EAEzD,oBACE,IAAA3C,WAAA,CAAAyE,GAAA,EAAC1E,mBAAA,CAAA2E,kBAAkB,CAACC,QAAQ;IAACxC,KAAK,EAAEoC,YAAa;IAAAlD,QAAA,EAC9CA;EAAQ,CACkB,CAAC;AAElC,CAAC;AAACuD,OAAA,CAAAxD,mBAAA,GAAAA,mBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_core","require","_formik","_libphonenumberJs","_react","_interopRequireDefault","Yup","_interopRequireWildcard","_useShallowStableValue","_profileFormContext","_phone","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ProfileFormProvider","children","fields","onSubmit","onSuccess","client","useClient","initialValues","React","useMemo","values","reduce","acc","field","value","type","toPhoneE164","defaultCountry","name","phoneCountryFieldName","parsePhoneNumberFromString","country","submit","validationSchema","fieldRules","validation","string","test","validatePhone","parent","isPhoneValidForCountry","object","shape","formik","useFormik","enableReinitialize","validateOnBlur","formikHelpers","submittedValues","submitted","activeProfile","getProfileAsync","patient","operations","flatMap","toPatch","initialValue","op","getPatchOperationType","path","includes","split","filter","Boolean","join","response","patchResource","id","refetchProfile","error","Error","setFieldError","message","contextValue","useShallowStableValue","jsx","ProfileFormContext","Provider","exports"],"sourceRoot":"../../../../../../src","sources":["modules/auth/profile/components/profile-form-provider.tsx"],"mappings":";;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,GAAA,GAAAC,uBAAA,CAAAN,OAAA;AAEA,IAAAO,sBAAA,GAAAP,OAAA;AACA,IAAAQ,mBAAA,GAAAR,OAAA;AAGA,IAAAS,MAAA,GAAAT,OAAA;AAIwB,IAAAU,WAAA,GAAAV,OAAA;AAAA,SAAAM,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,CAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CA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,IAAI,CAAC,GAAG,CAAC,EAAE;UAChB;UAEA,OAAO,CACL;YACEP,EAAE;YACFE,IAAI;YACJnC;UACF,CAAC,CACF;QACH,CAAC,CAAC;QAEF,MAAMyC,QAAQ,GAAG,MAAMlD,MAAM,CAACmD,aAAa,CACzC,SAAS,EACThB,aAAa,EAAEiB,EAAE,IAAI,EAAE,EACvBd,UAAU,CAACS,MAAM,CAAEL,EAAE,IAAKA,EAAE,CAACE,IAAI,KAAK,SAAS,CACjD,CAAC;QAED5C,MAAM,CAACqD,cAAc,CAAC,CAAC;QAEvBtD,SAAS,GAAGmD,QAAQ,EAAajB,eAAe,CAAC;MACnD,CAAC,CAAC,OAAOqB,KAAK,EAAE;QACd,IAAIA,KAAK,YAAYC,KAAK,EAAE;UAC1BvB,aAAa,CAACwB,aAAa,CAAC,QAAQ,EAAEF,KAAK,CAACG,OAAO,CAAC;UAEpD;QACF;QAEAzB,aAAa,CAACwB,aAAa,CAAC,QAAQ,EAAE,4BAA4B,CAAC;MACrE;IACF;EACF,CAAC,CAAC;EAEF,MAAME,YAAY,GAAG,IAAAC,4CAAqB,EAAC;IAAE,GAAG/B;EAAO,CAAC,CAAC;EAEzD,oBACE,IAAArD,WAAA,CAAAqF,GAAA,EAACvF,mBAAA,CAAAwF,kBAAkB,CAACC,QAAQ;IAACrD,KAAK,EAAEiD,YAAa;IAAA9D,QAAA,EAC9CA;EAAQ,CACkB,CAAC;AAElC,CAAC;AAACmE,OAAA,CAAApE,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.toPhoneE164 = exports.phoneCountryFieldName = exports.isPhoneValidForCountry = void 0;
7
+ var _libphonenumberJs = require("libphonenumber-js");
8
+ const phoneCountryFieldName = name => `__profileFormPhoneCountry__${encodeURIComponent(name).replace(/\./g, "%2E")}`;
9
+ exports.phoneCountryFieldName = phoneCountryFieldName;
10
+ const toPhoneE164 = (value, country) => {
11
+ const input = value.trim();
12
+ if (!input) {
13
+ return "";
14
+ }
15
+ const parsed = (0, _libphonenumberJs.parsePhoneNumberFromString)(input, country);
16
+ if (parsed) {
17
+ return parsed.number;
18
+ }
19
+ if (input.startsWith("+")) {
20
+ return input;
21
+ }
22
+ const digits = input.replace(/\D/g, "");
23
+ return digits ? `+${(0, _libphonenumberJs.getCountryCallingCode)(country)}${digits}` : "";
24
+ };
25
+ exports.toPhoneE164 = toPhoneE164;
26
+ const isPhoneValidForCountry = (value, country) => {
27
+ const parsed = (0, _libphonenumberJs.parsePhoneNumberFromString)(value);
28
+ return parsed?.isValid() === true && parsed.country === country;
29
+ };
30
+ exports.isPhoneValidForCountry = isPhoneValidForCountry;
31
+ //# sourceMappingURL=phone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_libphonenumberJs","require","phoneCountryFieldName","name","encodeURIComponent","replace","exports","toPhoneE164","value","country","input","trim","parsed","parsePhoneNumberFromString","number","startsWith","digits","getCountryCallingCode","isPhoneValidForCountry","isValid"],"sourceRoot":"../../../../../../src","sources":["modules/auth/profile/utils/phone.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAMA,MAAMC,qBAAqB,GAAIC,IAAY,IACzC,8BAA8BC,kBAAkB,CAACD,IAAI,CAAC,CAACE,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE;AAACC,OAAA,CAAAJ,qBAAA,GAAAA,qBAAA;AAEjF,MAAMK,WAAW,GAAGA,CAACC,KAAa,EAAEC,OAAoB,KAAK;EAC3D,MAAMC,KAAK,GAAGF,KAAK,CAACG,IAAI,CAAC,CAAC;EAE1B,IAAI,CAACD,KAAK,EAAE;IACV,OAAO,EAAE;EACX;EAEA,MAAME,MAAM,GAAG,IAAAC,4CAA0B,EAACH,KAAK,EAAED,OAAO,CAAC;EAEzD,IAAIG,MAAM,EAAE;IACV,OAAOA,MAAM,CAACE,MAAM;EACtB;EAEA,IAAIJ,KAAK,CAACK,UAAU,CAAC,GAAG,CAAC,EAAE;IACzB,OAAOL,KAAK;EACd;EAEA,MAAMM,MAAM,GAAGN,KAAK,CAACL,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;EAEvC,OAAOW,MAAM,GAAG,IAAI,IAAAC,uCAAqB,EAACR,OAAO,CAAC,GAAGO,MAAM,EAAE,GAAG,EAAE;AACpE,CAAC;AAACV,OAAA,CAAAC,WAAA,GAAAA,WAAA;AAEF,MAAMW,sBAAsB,GAAGA,CAACV,KAAa,EAAEC,OAAoB,KAAK;EACtE,MAAMG,MAAM,GAAG,IAAAC,4CAA0B,EAACL,KAAK,CAAC;EAEhD,OAAOI,MAAM,EAAEO,OAAO,CAAC,CAAC,KAAK,IAAI,IAAIP,MAAM,CAACH,OAAO,KAAKA,OAAO;AACjE,CAAC;AAACH,OAAA,CAAAY,sBAAA,GAAAA,sBAAA","ignoreList":[]}
@@ -26,11 +26,15 @@ const Inputs = ({
26
26
  const theme = (0, _index2.useAppTheme)();
27
27
  const {
28
28
  defaultValues,
29
- handleSubmit
29
+ handleSubmit,
30
+ setFieldValue,
31
+ nameField,
32
+ toRegisterNames
30
33
  } = (0, _useRegisterForm.useRegisterForm)();
31
34
  const [showPassword, setShowPassword] = React.useState(false);
32
35
  const [showPasswordConfirm, setShowPasswordConfirm] = React.useState(false);
33
36
  const nameRef = React.useRef(null);
37
+ const fullNameRef = React.useRef(null);
34
38
  const surnameRef = React.useRef(null);
35
39
  const emailRef = React.useRef(null);
36
40
  const passwordRef = React.useRef(null);
@@ -49,7 +53,31 @@ const Inputs = ({
49
53
  }, style],
50
54
  testID: testID,
51
55
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Conditional, {
52
- condition: !defaultValues?.name,
56
+ condition: nameField === "single" && !defaultValues?.fullName && !(defaultValues?.name && defaultValues?.surname),
57
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.FormField, {
58
+ label: t("register.full-name"),
59
+ name: "fullName",
60
+ context: _registerFormContext.RegisterFormContext,
61
+ ...inputProps,
62
+ inputRef: fullNameRef,
63
+ autoFocus: inputProps?.autoFocus ?? true,
64
+ returnKeyType: inputProps?.returnKeyType ?? "next",
65
+ onChangeText: fullName => {
66
+ void setFieldValue("fullName", fullName);
67
+ const names = toRegisterNames?.(fullName);
68
+ if (names) {
69
+ void setFieldValue("name", names.name);
70
+ void setFieldValue("surname", names.surname);
71
+ }
72
+ },
73
+ onSubmitEditing: event => {
74
+ inputProps?.onSubmitEditing?.(event);
75
+ submitOrFocus(emailRef, passwordRef, passwordConfirmRef);
76
+ },
77
+ style: inputProps?.containerStyle
78
+ })
79
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Conditional, {
80
+ condition: nameField !== "single" && !defaultValues?.name,
53
81
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.FormField, {
54
82
  label: t("register.name"),
55
83
  name: "name",
@@ -65,7 +93,7 @@ const Inputs = ({
65
93
  style: inputProps?.containerStyle
66
94
  })
67
95
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Conditional, {
68
- condition: !defaultValues?.surname,
96
+ condition: nameField !== "single" && !defaultValues?.surname,
69
97
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.FormField, {
70
98
  label: t("register.surname"),
71
99
  name: "surname",
@@ -90,7 +118,7 @@ const Inputs = ({
90
118
  context: _registerFormContext.RegisterFormContext,
91
119
  ...inputProps,
92
120
  inputRef: emailRef,
93
- autoFocus: inputProps?.autoFocus ?? (!!defaultValues?.name && !!defaultValues?.surname),
121
+ autoFocus: inputProps?.autoFocus ?? (nameField === "single" ? !!defaultValues?.fullName || !!defaultValues?.name && !!defaultValues?.surname : !!defaultValues?.name && !!defaultValues?.surname),
94
122
  returnKeyType: inputProps?.returnKeyType ?? "next",
95
123
  onSubmitEditing: event => {
96
124
  inputProps?.onSubmitEditing?.(event);