@pisell/private-materials 6.3.29 → 6.3.31

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 (313) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +9 -1
  6. package/build/lowcode/preview.js +144 -144
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +9 -9
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +9 -9
  11. package/es/components/appointmentBooking/components/Cart/Item/index.js +3 -2
  12. package/es/components/appointmentBooking/components/ConfirmInformation/index.js +267 -76
  13. package/es/components/appointmentBooking/components/ConfirmInformation/index.less +15 -0
  14. package/es/components/appointmentBooking/hooks.js +30 -30
  15. package/es/components/appointmentBooking/locales.js +9 -6
  16. package/es/components/booking/components/TabProduct/index.d.ts +1 -0
  17. package/es/components/booking/components/footer/index.d.ts +1 -0
  18. package/es/components/booking/components/footer/index.js +4 -1
  19. package/es/components/booking/components/footer/utils.js +62 -46
  20. package/es/components/booking/components/formItemChildrenWrap/index.d.ts +1 -0
  21. package/es/components/booking/forms/table/index.d.ts +1 -0
  22. package/es/components/booking/info/clientVariant/hooks/useClientFn.js +2 -2
  23. package/es/components/booking/info/clientVariant/hooks/useIsLowSpeedNetwork.d.ts +1 -0
  24. package/es/components/booking/info/clientVariant/vertical/index.js +1 -1
  25. package/es/components/booking/info/main.js +3 -2
  26. package/es/components/booking/info/model.js +5 -0
  27. package/es/components/booking/info/service/like/index.d.ts +1 -0
  28. package/es/components/booking/info2/index.js +3 -2
  29. package/es/components/booking/info2/service/contactInfoMode/index.js +93 -0
  30. package/es/components/booking/locales.js +9 -3
  31. package/es/components/booking/model.js +3 -0
  32. package/es/components/eftpos/deviceList/index.d.ts +1 -0
  33. package/es/components/eftpos/form/index.d.ts +1 -0
  34. package/es/components/eftpos/group/index.d.ts +1 -0
  35. package/es/components/eftpos/hooks.d.ts +1 -0
  36. package/es/components/eftpos/icon/apiKey.d.ts +1 -0
  37. package/es/components/eftpos/icon/device.d.ts +1 -0
  38. package/es/components/eftpos/receipt/index.d.ts +1 -0
  39. package/es/components/eftposPay/component/alert/warn.d.ts +1 -0
  40. package/es/components/eftposPay/component/header/titlebar.d.ts +1 -0
  41. package/es/components/eftposPay/component/step/index.d.ts +1 -0
  42. package/es/components/eftposPay/component/step/step.d.ts +1 -0
  43. package/es/components/eftposPay/hooks.d.ts +1 -1
  44. package/es/components/eftposPay/store/index.d.ts +1 -1
  45. package/es/components/eftposPay/tyro/hooks.d.ts +1 -0
  46. package/es/components/eventBooking/components/Provider/Cart/Deposit/index.d.ts +1 -0
  47. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateStatus/index.d.ts +1 -0
  48. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/DayItem/index.d.ts +1 -0
  49. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/index.d.ts +1 -0
  50. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Status/index.d.ts +1 -0
  51. package/es/components/pay/toC/PaymentMethods/ApplePay/index.js +1 -1
  52. package/es/components/pay/toC/PaymentMethods/GooglePay/index.js +1 -1
  53. package/es/components/pay/toC/PaymentMethods/StripePay/Stripe/StripeSDK/index.d.ts +1 -0
  54. package/es/components/pay/toC/PaymentMethods/StripePay/Stripe/index.d.ts +1 -0
  55. package/es/components/productExtension/fields/Actor/index.d.ts +1 -0
  56. package/es/components/productExtension/fields/Forms/index.d.ts +1 -0
  57. package/es/components/schedules/calendar/calendarItem.d.ts +1 -0
  58. package/es/components/schedules/products/ProductDetailDrawer/ProductDetail/index.d.ts +1 -0
  59. package/es/components/schedules/products/ProductDetailDrawer/ProductDetailByDate/index.d.ts +1 -0
  60. package/es/components/schedules/resources/relationProduct/index.d.ts +1 -0
  61. package/es/components/shoppingCart/components/Empty/index.d.ts +1 -0
  62. package/es/components/shoppingCart/components/Render/index.d.ts +1 -0
  63. package/es/index.d.ts +3 -0
  64. package/es/index.js +4 -1
  65. package/es/plus/clientName/index.js +18 -0
  66. package/es/plus/clientName/index.less +10 -0
  67. package/es/plus/clientName/type.js +1 -0
  68. package/es/plus/clientName/utils.js +18 -0
  69. package/es/plus/contactInfo/components/Avatar/index.js +30 -0
  70. package/es/plus/contactInfo/components/SwipeAction/index.js +360 -0
  71. package/es/plus/contactInfo/components/SwipeAction/index.less +74 -0
  72. package/es/plus/contactInfo/index.js +198 -0
  73. package/es/plus/contactInfo/index.less +621 -0
  74. package/es/plus/contactInfo/locales.js +14 -0
  75. package/es/plus/contactInfo/types.js +1 -0
  76. package/es/plus/contactInfo/utils.js +50 -0
  77. package/es/plus/contactInfoModal/ContactInfoContent.js +74 -0
  78. package/es/plus/contactInfoModal/index.js +154 -0
  79. package/es/plus/contactInfoModal/index.less +19 -0
  80. package/es/plus/contactInfoModal/locales.js +65 -0
  81. package/es/pro/Login2.0/AuthModal.d.ts +143 -0
  82. package/es/pro/Login2.0/AuthModal.js +624 -0
  83. package/es/pro/Login2.0/Login2.d.ts +61 -0
  84. package/es/pro/Login2.0/Login2.js +2157 -0
  85. package/es/pro/Login2.0/Register2.d.ts +65 -0
  86. package/es/pro/Login2.0/Register2.js +1501 -0
  87. package/es/pro/Login2.0/components/ForgotPasswordFlow.js +330 -0
  88. package/es/pro/Login2.0/components/LegalTerms.d.ts +8 -0
  89. package/es/pro/Login2.0/components/LegalTerms.js +51 -0
  90. package/es/pro/Login2.0/components/LegalTerms.less +74 -0
  91. package/es/pro/Login2.0/components/LoginCodeInput.js +207 -0
  92. package/es/pro/Login2.0/components/OAuthButtonGroup.js +55 -0
  93. package/es/pro/Login2.0/components/PhoneInput.js +414 -0
  94. package/es/pro/Login2.0/components/PhoneInput.less +148 -0
  95. package/es/pro/Login2.0/components/phoneValidation.js +228 -0
  96. package/es/pro/Login2.0/hooks/index.d.ts +2 -0
  97. package/es/pro/Login2.0/hooks/index.js +1 -0
  98. package/es/pro/Login2.0/hooks/usePasswordValidationRules.js +87 -0
  99. package/es/pro/Login2.0/hooks/useRegisterFlow.d.ts +39 -0
  100. package/es/pro/Login2.0/hooks/useRegisterFlow.js +158 -0
  101. package/es/pro/Login2.0/hooks/useRegistrationMethods.d.ts +9 -0
  102. package/es/pro/Login2.0/hooks/useRegistrationMethods.js +31 -0
  103. package/es/pro/Login2.0/index.js +8 -0
  104. package/es/pro/Login2.0/index.less +993 -0
  105. package/es/pro/Login2.0/locales.js +622 -0
  106. package/es/pro/Login2.0/shared/Header.d.ts +11 -0
  107. package/es/pro/Login2.0/shared/Header.js +42 -0
  108. package/es/pro/Login2.0/shared/OAuthButtons.d.ts +11 -0
  109. package/es/pro/Login2.0/shared/OAuthButtons.js +59 -0
  110. package/es/pro/Login2.0/shared/registerFlow.js +171 -0
  111. package/es/pro/Login2.0/shared/types.d.ts +232 -0
  112. package/es/pro/Login2.0/shared/types.js +1 -0
  113. package/es/pro/Login2.0/steps/CodeInput.js +209 -0
  114. package/es/pro/Login2.0/steps/EmailAlreadyRegistered.js +35 -0
  115. package/es/pro/Login2.0/steps/EmailLinkAlreadyUsed.js +25 -0
  116. package/es/pro/Login2.0/steps/EmailLinkExpired.js +33 -0
  117. package/es/pro/Login2.0/steps/SetPassword.js +148 -0
  118. package/es/pro/Login2.0/steps/VerificationSuccess.js +35 -0
  119. package/es/pro/Login2.0/steps/VerifyingEmailLink.js +17 -0
  120. package/es/pro/Login2.0/steps/WaitEmailLink.js +54 -0
  121. package/es/pro/Login2.0/steps/index.js +11 -0
  122. package/es/pro/Login2.0/steps/steps.less +423 -0
  123. package/es/pro/Login2.0/types.js +1 -0
  124. package/lib/components/appointmentBooking/components/Cart/Item/index.js +5 -3
  125. package/lib/components/appointmentBooking/components/ConfirmInformation/index.js +151 -13
  126. package/lib/components/appointmentBooking/components/ConfirmInformation/index.less +15 -0
  127. package/lib/components/appointmentBooking/hooks.js +73 -35
  128. package/lib/components/appointmentBooking/locales.js +6 -3
  129. package/lib/components/booking/components/TabProduct/index.d.ts +1 -0
  130. package/lib/components/booking/components/footer/index.d.ts +1 -0
  131. package/lib/components/booking/components/footer/index.js +4 -1
  132. package/lib/components/booking/components/footer/utils.js +70 -38
  133. package/lib/components/booking/components/formItemChildrenWrap/index.d.ts +1 -0
  134. package/lib/components/booking/forms/table/index.d.ts +1 -0
  135. package/lib/components/booking/info/clientVariant/hooks/useClientFn.js +1 -1
  136. package/lib/components/booking/info/clientVariant/hooks/useIsLowSpeedNetwork.d.ts +1 -0
  137. package/lib/components/booking/info/clientVariant/vertical/index.js +34 -17
  138. package/lib/components/booking/info/main.js +5 -4
  139. package/lib/components/booking/info/model.js +5 -0
  140. package/lib/components/booking/info/service/like/index.d.ts +1 -0
  141. package/lib/components/booking/info2/index.js +5 -4
  142. package/lib/components/booking/info2/service/contactInfoMode/index.js +104 -0
  143. package/lib/components/booking/locales.js +9 -3
  144. package/lib/components/booking/model.js +3 -0
  145. package/lib/components/eftpos/deviceList/index.d.ts +1 -0
  146. package/lib/components/eftpos/form/index.d.ts +1 -0
  147. package/lib/components/eftpos/group/index.d.ts +1 -0
  148. package/lib/components/eftpos/hooks.d.ts +1 -0
  149. package/lib/components/eftpos/icon/apiKey.d.ts +1 -0
  150. package/lib/components/eftpos/icon/device.d.ts +1 -0
  151. package/lib/components/eftpos/receipt/index.d.ts +1 -0
  152. package/lib/components/eftposPay/component/alert/warn.d.ts +1 -0
  153. package/lib/components/eftposPay/component/header/titlebar.d.ts +1 -0
  154. package/lib/components/eftposPay/component/step/index.d.ts +1 -0
  155. package/lib/components/eftposPay/component/step/step.d.ts +1 -0
  156. package/lib/components/eftposPay/hooks.d.ts +1 -1
  157. package/lib/components/eftposPay/store/index.d.ts +1 -1
  158. package/lib/components/eftposPay/tyro/hooks.d.ts +1 -0
  159. package/lib/components/eventBooking/components/Provider/Cart/Deposit/index.d.ts +1 -0
  160. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateStatus/index.d.ts +1 -0
  161. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/DayItem/index.d.ts +1 -0
  162. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/index.d.ts +1 -0
  163. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Status/index.d.ts +1 -0
  164. package/lib/components/pay/toC/PaymentMethods/ApplePay/index.js +1 -1
  165. package/lib/components/pay/toC/PaymentMethods/GooglePay/index.js +1 -1
  166. package/lib/components/pay/toC/PaymentMethods/StripePay/Stripe/StripeSDK/index.d.ts +1 -0
  167. package/lib/components/pay/toC/PaymentMethods/StripePay/Stripe/index.d.ts +1 -0
  168. package/lib/components/productExtension/fields/Actor/index.d.ts +1 -0
  169. package/lib/components/productExtension/fields/Forms/index.d.ts +1 -0
  170. package/lib/components/schedules/calendar/calendarItem.d.ts +1 -0
  171. package/lib/components/schedules/products/ProductDetailDrawer/ProductDetail/index.d.ts +1 -0
  172. package/lib/components/schedules/products/ProductDetailDrawer/ProductDetailByDate/index.d.ts +1 -0
  173. package/lib/components/schedules/resources/relationProduct/index.d.ts +1 -0
  174. package/lib/components/shoppingCart/components/Empty/index.d.ts +1 -0
  175. package/lib/components/shoppingCart/components/Render/index.d.ts +1 -0
  176. package/lib/index.d.ts +3 -0
  177. package/lib/index.js +13 -0
  178. package/lib/plus/clientName/index.js +53 -0
  179. package/lib/plus/clientName/index.less +10 -0
  180. package/lib/plus/clientName/type.js +17 -0
  181. package/lib/plus/clientName/utils.js +43 -0
  182. package/lib/plus/contactInfo/components/Avatar/index.js +56 -0
  183. package/lib/plus/contactInfo/components/SwipeAction/index.js +373 -0
  184. package/lib/plus/contactInfo/components/SwipeAction/index.less +74 -0
  185. package/lib/plus/contactInfo/index.js +226 -0
  186. package/lib/plus/contactInfo/index.less +621 -0
  187. package/lib/plus/contactInfo/locales.js +38 -0
  188. package/lib/plus/contactInfo/types.js +17 -0
  189. package/lib/plus/contactInfo/utils.js +64 -0
  190. package/lib/plus/contactInfoModal/ContactInfoContent.js +129 -0
  191. package/lib/plus/contactInfoModal/index.js +138 -0
  192. package/lib/plus/contactInfoModal/index.less +19 -0
  193. package/lib/plus/contactInfoModal/locales.js +89 -0
  194. package/lib/pro/Login2.0/AuthModal.d.ts +143 -0
  195. package/lib/pro/Login2.0/AuthModal.js +498 -0
  196. package/lib/pro/Login2.0/Login2.d.ts +61 -0
  197. package/lib/pro/Login2.0/Login2.js +1468 -0
  198. package/lib/pro/Login2.0/Register2.d.ts +65 -0
  199. package/lib/pro/Login2.0/Register2.js +1062 -0
  200. package/lib/pro/Login2.0/components/ForgotPasswordFlow.js +213 -0
  201. package/lib/pro/Login2.0/components/LegalTerms.d.ts +8 -0
  202. package/lib/pro/Login2.0/components/LegalTerms.js +76 -0
  203. package/lib/pro/Login2.0/components/LegalTerms.less +74 -0
  204. package/lib/pro/Login2.0/components/LoginCodeInput.js +161 -0
  205. package/lib/pro/Login2.0/components/OAuthButtonGroup.js +87 -0
  206. package/lib/pro/Login2.0/components/PhoneInput.js +263 -0
  207. package/lib/pro/Login2.0/components/PhoneInput.less +148 -0
  208. package/lib/pro/Login2.0/components/phoneValidation.js +153 -0
  209. package/lib/pro/Login2.0/hooks/index.d.ts +2 -0
  210. package/lib/pro/Login2.0/hooks/index.js +29 -0
  211. package/lib/pro/Login2.0/hooks/usePasswordValidationRules.js +140 -0
  212. package/lib/pro/Login2.0/hooks/useRegisterFlow.d.ts +39 -0
  213. package/lib/pro/Login2.0/hooks/useRegisterFlow.js +149 -0
  214. package/lib/pro/Login2.0/hooks/useRegistrationMethods.d.ts +9 -0
  215. package/lib/pro/Login2.0/hooks/useRegistrationMethods.js +51 -0
  216. package/lib/pro/Login2.0/index.js +45 -0
  217. package/lib/pro/Login2.0/index.less +993 -0
  218. package/lib/pro/Login2.0/locales.js +646 -0
  219. package/lib/pro/Login2.0/shared/Header.d.ts +11 -0
  220. package/lib/pro/Login2.0/shared/Header.js +81 -0
  221. package/lib/pro/Login2.0/shared/OAuthButtons.d.ts +11 -0
  222. package/lib/pro/Login2.0/shared/OAuthButtons.js +78 -0
  223. package/lib/pro/Login2.0/shared/registerFlow.js +235 -0
  224. package/lib/pro/Login2.0/shared/types.d.ts +232 -0
  225. package/lib/pro/Login2.0/shared/types.js +17 -0
  226. package/lib/pro/Login2.0/steps/CodeInput.js +160 -0
  227. package/lib/pro/Login2.0/steps/EmailAlreadyRegistered.js +46 -0
  228. package/lib/pro/Login2.0/steps/EmailLinkAlreadyUsed.js +51 -0
  229. package/lib/pro/Login2.0/steps/EmailLinkExpired.js +51 -0
  230. package/lib/pro/Login2.0/steps/SetPassword.js +131 -0
  231. package/lib/pro/Login2.0/steps/VerificationSuccess.js +49 -0
  232. package/lib/pro/Login2.0/steps/VerifyingEmailLink.js +41 -0
  233. package/lib/pro/Login2.0/steps/WaitEmailLink.js +67 -0
  234. package/lib/pro/Login2.0/steps/index.js +60 -0
  235. package/lib/pro/Login2.0/steps/steps.less +423 -0
  236. package/lib/pro/Login2.0/types.js +17 -0
  237. package/lowcode/authmodal/meta.ts +395 -0
  238. package/lowcode/contact-info/fragments/cardStyle.ts +68 -0
  239. package/lowcode/contact-info/fragments/nameStyle.ts +33 -0
  240. package/lowcode/contact-info/fragments/pisellAvatar.ts +103 -0
  241. package/lowcode/contact-info/fragments/textStyle.ts +33 -0
  242. package/lowcode/contact-info/meta.ts +199 -0
  243. package/lowcode/contact-info-modal/meta.ts +98 -0
  244. package/lowcode/login2/CONFIG.md +447 -0
  245. package/lowcode/login2/TEST_CONFIG.md +324 -0
  246. package/lowcode/login2/VERIFICATION_METHODS.md +364 -0
  247. package/lowcode/login2/meta.ts +560 -0
  248. package/lowcode/login2/snippets.ts +124 -0
  249. package/lowcode/register2/meta.ts +562 -0
  250. package/lowcode/register2/snippets.ts +257 -0
  251. package/package.json +7 -5
  252. package/es/components/appointmentBooking/components/Cart/Item/index.d.ts +0 -3
  253. package/es/components/appointmentBooking/components/ConfirmInformation/index.d.ts +0 -4
  254. package/es/components/appointmentBooking/components/Services/index.d.ts +0 -4
  255. package/es/components/appointmentBooking/deposit/components/PolicyModal/index.d.ts +0 -3
  256. package/es/components/appointmentBooking/hooks.d.ts +0 -106
  257. package/es/components/appointmentBooking/locales.d.ts +0 -360
  258. package/es/components/booking/components/footer/utils.d.ts +0 -41
  259. package/es/components/booking/components/reloadResourceModal/index.d.ts +0 -8
  260. package/es/components/booking/components/voucher/index.d.ts +0 -3
  261. package/es/components/booking/info/clientVariant/hooks/useClientFn.d.ts +0 -43
  262. package/es/components/booking/info/clientVariant/vertical/index.d.ts +0 -8
  263. package/es/components/booking/info/main.d.ts +0 -12
  264. package/es/components/booking/info/model.d.ts +0 -14
  265. package/es/components/booking/info/service/editService/constants.d.ts +0 -1
  266. package/es/components/booking/info/service/editService/index.d.ts +0 -7
  267. package/es/components/booking/info2/index.d.ts +0 -12
  268. package/es/components/booking/info2/service/addService/index.d.ts +0 -11
  269. package/es/components/booking/locales.d.ts +0 -837
  270. package/es/components/booking/model.d.ts +0 -116
  271. package/es/components/eftposPay/component/fail/index.d.ts +0 -3
  272. package/es/components/index.d.ts +0 -22
  273. package/es/components/pay/toC/PaymentMethods/ApplePay/index.d.ts +0 -10
  274. package/es/components/pay/toC/PaymentMethods/GooglePay/index.d.ts +0 -9
  275. package/es/components/pay/toC/PaymentMethods/index.d.ts +0 -9
  276. package/es/components/ruleSetting/locales.d.ts +0 -48
  277. package/es/components/ticketBooking/components/addServiceVariant/addService.d.ts +0 -9
  278. package/es/components/ticketBooking/components/ticketBooking/index.d.ts +0 -4
  279. package/es/components/ticketBooking/components/timeBar/index.d.ts +0 -12
  280. package/es/components/ticketBooking/index.d.ts +0 -7
  281. package/es/plus/productSelect/ProductCard/index.d.ts +0 -47
  282. package/es/plus/productSelect/index.d.ts +0 -32
  283. package/lib/components/appointmentBooking/components/Cart/Item/index.d.ts +0 -3
  284. package/lib/components/appointmentBooking/components/ConfirmInformation/index.d.ts +0 -4
  285. package/lib/components/appointmentBooking/components/Services/index.d.ts +0 -4
  286. package/lib/components/appointmentBooking/deposit/components/PolicyModal/index.d.ts +0 -3
  287. package/lib/components/appointmentBooking/hooks.d.ts +0 -106
  288. package/lib/components/appointmentBooking/locales.d.ts +0 -360
  289. package/lib/components/booking/components/footer/utils.d.ts +0 -41
  290. package/lib/components/booking/components/reloadResourceModal/index.d.ts +0 -8
  291. package/lib/components/booking/components/voucher/index.d.ts +0 -3
  292. package/lib/components/booking/info/clientVariant/hooks/useClientFn.d.ts +0 -43
  293. package/lib/components/booking/info/clientVariant/vertical/index.d.ts +0 -8
  294. package/lib/components/booking/info/main.d.ts +0 -12
  295. package/lib/components/booking/info/model.d.ts +0 -14
  296. package/lib/components/booking/info/service/editService/constants.d.ts +0 -1
  297. package/lib/components/booking/info/service/editService/index.d.ts +0 -7
  298. package/lib/components/booking/info2/index.d.ts +0 -12
  299. package/lib/components/booking/info2/service/addService/index.d.ts +0 -11
  300. package/lib/components/booking/locales.d.ts +0 -837
  301. package/lib/components/booking/model.d.ts +0 -116
  302. package/lib/components/eftposPay/component/fail/index.d.ts +0 -3
  303. package/lib/components/index.d.ts +0 -22
  304. package/lib/components/pay/toC/PaymentMethods/ApplePay/index.d.ts +0 -10
  305. package/lib/components/pay/toC/PaymentMethods/GooglePay/index.d.ts +0 -9
  306. package/lib/components/pay/toC/PaymentMethods/index.d.ts +0 -9
  307. package/lib/components/ruleSetting/locales.d.ts +0 -48
  308. package/lib/components/ticketBooking/components/addServiceVariant/addService.d.ts +0 -9
  309. package/lib/components/ticketBooking/components/ticketBooking/index.d.ts +0 -4
  310. package/lib/components/ticketBooking/components/timeBar/index.d.ts +0 -12
  311. package/lib/components/ticketBooking/index.d.ts +0 -7
  312. package/lib/plus/productSelect/ProductCard/index.d.ts +0 -47
  313. package/lib/plus/productSelect/index.d.ts +0 -32
@@ -0,0 +1,207 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
4
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
5
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
+ /**
12
+ * 登录验证码输入组件
13
+ * 复用 Register2 的 CodeInput 样式和逻辑
14
+ */
15
+ import React, { useState, useRef, useEffect } from 'react';
16
+ import { Button } from '@pisell/materials';
17
+ import { locales } from '@pisell/utils';
18
+ import IconFont from '@pisell/materials/src/components/iconfont';
19
+ function LoginCodeInput(_ref) {
20
+ var account = _ref.account,
21
+ accountType = _ref.accountType,
22
+ _ref$codeLength = _ref.codeLength,
23
+ codeLength = _ref$codeLength === void 0 ? 4 : _ref$codeLength,
24
+ onSubmit = _ref.onSubmit,
25
+ onResend = _ref.onResend,
26
+ onBack = _ref.onBack,
27
+ _ref$countdown = _ref.countdown,
28
+ countdown = _ref$countdown === void 0 ? 0 : _ref$countdown,
29
+ _ref$loading = _ref.loading,
30
+ loading = _ref$loading === void 0 ? false : _ref$loading,
31
+ submitButtonText = _ref.submitButtonText,
32
+ error = _ref.error,
33
+ onClearError = _ref.onClearError;
34
+ var _useState = useState(Array(codeLength).fill('')),
35
+ _useState2 = _slicedToArray(_useState, 2),
36
+ code = _useState2[0],
37
+ setCode = _useState2[1];
38
+ var inputRefs = useRef([]);
39
+ var canResend = countdown === 0;
40
+ useEffect(function () {
41
+ var _inputRefs$current$;
42
+ // 自动聚焦第一个输入框
43
+ (_inputRefs$current$ = inputRefs.current[0]) === null || _inputRefs$current$ === void 0 || _inputRefs$current$.focus();
44
+ }, []);
45
+
46
+ // 当错误出现时,清空输入值
47
+ useEffect(function () {
48
+ if (error) {
49
+ var _inputRefs$current$2;
50
+ setCode(Array(codeLength).fill(''));
51
+ // 聚焦第一个输入框
52
+ (_inputRefs$current$2 = inputRefs.current[0]) === null || _inputRefs$current$2 === void 0 || _inputRefs$current$2.focus();
53
+ }
54
+ }, [error, codeLength]);
55
+
56
+ /**
57
+ * 处理单个输入框的值变化
58
+ * @param index 输入框索引
59
+ * @param value 输入的值
60
+ */
61
+ var handleInputChange = function handleInputChange(index, value) {
62
+ if (!/^\d*$/.test(value)) return; // 只允许数字
63
+
64
+ // 如果用户开始输入且有错误,清除错误
65
+ if (value && error && onClearError) {
66
+ onClearError();
67
+ }
68
+ var newCode = _toConsumableArray(code);
69
+ newCode[index] = value.slice(-1); // 只取最后一个字符
70
+ setCode(newCode);
71
+
72
+ // 自动跳到下一个输入框
73
+ if (value && index < codeLength - 1) {
74
+ var _inputRefs$current;
75
+ (_inputRefs$current = inputRefs.current[index + 1]) === null || _inputRefs$current === void 0 || _inputRefs$current.focus();
76
+ }
77
+
78
+ // 如果所有输入框都填满了,自动提交
79
+ if (newCode.every(function (digit) {
80
+ return digit !== '';
81
+ })) {
82
+ var fullCode = newCode.join('');
83
+ onSubmit === null || onSubmit === void 0 || onSubmit(fullCode);
84
+ }
85
+ };
86
+
87
+ /**
88
+ * 处理键盘按键事件(主要处理退格键)
89
+ * @param index 当前输入框索引
90
+ * @param e 键盘事件
91
+ */
92
+ var handleKeyDown = function handleKeyDown(index, e) {
93
+ // 当前输入框为空且按下退格键时,聚焦到前一个输入框
94
+ if (e.key === 'Backspace' && !code[index] && index > 0) {
95
+ var _inputRefs$current2;
96
+ (_inputRefs$current2 = inputRefs.current[index - 1]) === null || _inputRefs$current2 === void 0 || _inputRefs$current2.focus();
97
+ }
98
+ };
99
+
100
+ /**
101
+ * 处理粘贴事件(支持粘贴完整验证码)
102
+ * @param e 剪贴板事件
103
+ */
104
+ var handlePaste = function handlePaste(e) {
105
+ e.preventDefault();
106
+ var pastedData = e.clipboardData.getData('text').trim();
107
+ if (!/^\d+$/.test(pastedData)) return; // 只允许数字
108
+
109
+ // 如果用户粘贴且有错误,清除错误
110
+ if (pastedData && error && onClearError) {
111
+ onClearError();
112
+ }
113
+ var newCode = pastedData.slice(0, codeLength).split('');
114
+ while (newCode.length < codeLength) {
115
+ newCode.push('');
116
+ }
117
+ setCode(newCode);
118
+
119
+ // 如果粘贴的是完整验证码,自动提交
120
+ if (newCode.every(function (digit) {
121
+ return digit !== '';
122
+ })) {
123
+ onSubmit === null || onSubmit === void 0 || onSubmit(newCode.join(''));
124
+ }
125
+ };
126
+
127
+ /**
128
+ * 手动提交验证码
129
+ */
130
+ var handleSubmit = function handleSubmit() {
131
+ var fullCode = code.join('');
132
+ if (fullCode.length === codeLength) {
133
+ onSubmit === null || onSubmit === void 0 || onSubmit(fullCode);
134
+ }
135
+ };
136
+
137
+ // 根据账号类型显示不同的标题和描述
138
+ var title = accountType === 'email' ? locales.getText('pisell-login2-check-email-title') : locales.getText('pisell-login2-check-phone-title');
139
+ var description = accountType === 'email' ? locales.getText('pisell-login2-check-email-desc') : locales.getText('pisell-login2-check-phone-desc');
140
+
141
+ // 根据账号类型显示不同的"没有收到"提示
142
+ var noReceiveText = accountType === 'email' ? locales.getText('pisell-login2-no-email-received') : locales.getText('pisell-login2-no-message-received');
143
+ return /*#__PURE__*/React.createElement("div", {
144
+ className: "register-step-container code-input-page"
145
+ }, /*#__PURE__*/React.createElement("button", {
146
+ className: "back-button-top",
147
+ onClick: onBack,
148
+ "aria-label": "Go back"
149
+ }, /*#__PURE__*/React.createElement(IconFont, {
150
+ type: "pisell2-arrow-left"
151
+ })), /*#__PURE__*/React.createElement("div", {
152
+ className: "register-step-content"
153
+ }, /*#__PURE__*/React.createElement("h2", {
154
+ className: "register-step-title"
155
+ }, title), /*#__PURE__*/React.createElement("p", {
156
+ className: "register-step-desc"
157
+ }, description, /*#__PURE__*/React.createElement("br", null), account), /*#__PURE__*/React.createElement("div", {
158
+ className: "code-input-group",
159
+ onPaste: handlePaste
160
+ }, code.map(function (digit, index) {
161
+ return /*#__PURE__*/React.createElement("input", {
162
+ key: index,
163
+ ref: function ref(el) {
164
+ return inputRefs.current[index] = el;
165
+ },
166
+ type: "text",
167
+ inputMode: "numeric",
168
+ maxLength: 1,
169
+ className: "code-input-box ".concat(digit ? 'has-value' : '', " ").concat(error ? 'has-error' : ''),
170
+ value: digit,
171
+ onChange: function onChange(e) {
172
+ return handleInputChange(index, e.target.value);
173
+ },
174
+ onKeyDown: function onKeyDown(e) {
175
+ return handleKeyDown(index, e);
176
+ },
177
+ disabled: loading
178
+ });
179
+ })), error && /*#__PURE__*/React.createElement("div", {
180
+ className: "code-input-error"
181
+ }, error), /*#__PURE__*/React.createElement(Button, {
182
+ type: "primary",
183
+ size: "large",
184
+ block: true,
185
+ onClick: handleSubmit,
186
+ loading: loading,
187
+ disabled: code.some(function (digit) {
188
+ return !digit;
189
+ }),
190
+ className: "register-submit-btn"
191
+ }, submitButtonText || locales.getText('pisell-login2-login-button')), /*#__PURE__*/React.createElement(Button, {
192
+ type: "default",
193
+ size: "large",
194
+ block: true,
195
+ onClick: onBack,
196
+ className: "register-back-btn"
197
+ }, locales.getText('pisell-login2-back')), /*#__PURE__*/React.createElement("div", {
198
+ className: "register-resend-section"
199
+ }, /*#__PURE__*/React.createElement("span", {
200
+ className: "resend-text"
201
+ }, noReceiveText, " "), /*#__PURE__*/React.createElement("button", {
202
+ className: "resend-link",
203
+ onClick: onResend,
204
+ disabled: !canResend
205
+ }, locales.getText('pisell-login2-resend-code'), countdown > 0 && " (".concat(countdown, " s)")))));
206
+ }
207
+ export default LoginCodeInput;
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+ import classNames from 'classnames';
3
+ import { Button } from '@pisell/materials';
4
+ var OAuthButtonGroup = function OAuthButtonGroup(_ref) {
5
+ var providers = _ref.providers,
6
+ _ref$layout = _ref.layout,
7
+ layout = _ref$layout === void 0 ? 'vertical' : _ref$layout,
8
+ _ref$size = _ref.size,
9
+ size = _ref$size === void 0 ? 'large' : _ref$size,
10
+ _ref$block = _ref.block,
11
+ block = _ref$block === void 0 ? true : _ref$block,
12
+ wrapperClassName = _ref.wrapperClassName,
13
+ buttonClassName = _ref.buttonClassName,
14
+ _ref$gap = _ref.gap,
15
+ gap = _ref$gap === void 0 ? 12 : _ref$gap;
16
+ if (!providers.length) {
17
+ return null;
18
+ }
19
+ var isVertical = layout === 'vertical';
20
+ return /*#__PURE__*/React.createElement("div", {
21
+ className: classNames('oauth-button-group', wrapperClassName, {
22
+ 'oauth-button-group-vertical': isVertical,
23
+ 'oauth-button-group-horizontal': !isVertical
24
+ }),
25
+ style: isVertical ? {
26
+ display: 'grid',
27
+ rowGap: gap
28
+ } : {
29
+ display: 'flex',
30
+ columnGap: gap,
31
+ flexWrap: 'wrap'
32
+ }
33
+ }, providers.map(function (_ref2) {
34
+ var key = _ref2.key,
35
+ label = _ref2.label,
36
+ icon = _ref2.icon,
37
+ onClick = _ref2.onClick,
38
+ disabled = _ref2.disabled,
39
+ className = _ref2.className,
40
+ badge = _ref2.badge,
41
+ badgeClassName = _ref2.badgeClassName;
42
+ return /*#__PURE__*/React.createElement(Button, {
43
+ key: key,
44
+ size: size,
45
+ block: block,
46
+ disabled: disabled,
47
+ className: classNames(buttonClassName, className),
48
+ icon: icon,
49
+ onClick: onClick
50
+ }, badge && /*#__PURE__*/React.createElement("span", {
51
+ className: classNames('oauth-button-badge', badgeClassName)
52
+ }, badge), label);
53
+ }));
54
+ };
55
+ export default OAuthButtonGroup;
@@ -0,0 +1,414 @@
1
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function (_e) { function e(_x) { return _e.apply(this, arguments); } e.toString = function () { return _e.toString(); }; return e; }(function (e) { throw e; }), f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function (_e2) { function e(_x2) { return _e2.apply(this, arguments); } e.toString = function () { return _e2.toString(); }; return e; }(function (e) { didErr = true; err = e; }), f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
5
+ import React, { useMemo } from 'react';
6
+ import { locales } from '@pisell/utils';
7
+ import "./PhoneInput.less";
8
+
9
+ /** 国家/地区配置(后端返回格式) */
10
+
11
+ /** 手机号对象格式 */
12
+
13
+ /** 值格式类型 */
14
+
15
+ /** 手机号输入组件属性 */
16
+
17
+ /** 默认国家/地区列表 */
18
+ var DEFAULT_COUNTRIES = [{
19
+ name: 'United States',
20
+ code: 'US',
21
+ calling_code: '1',
22
+ currency_code: 'USD'
23
+ }, {
24
+ name: 'China',
25
+ code: 'CN',
26
+ calling_code: '86',
27
+ currency_code: 'CNY'
28
+ }, {
29
+ name: 'United Kingdom',
30
+ code: 'GB',
31
+ calling_code: '44',
32
+ currency_code: 'GBP'
33
+ }, {
34
+ name: 'Australia',
35
+ code: 'AU',
36
+ calling_code: '61',
37
+ currency_code: 'AUD'
38
+ }, {
39
+ name: 'Canada',
40
+ code: 'CA',
41
+ calling_code: '1',
42
+ currency_code: 'CAD'
43
+ }, {
44
+ name: 'Japan',
45
+ code: 'JP',
46
+ calling_code: '81',
47
+ currency_code: 'JPY'
48
+ }, {
49
+ name: 'South Korea',
50
+ code: 'KR',
51
+ calling_code: '82',
52
+ currency_code: 'KRW'
53
+ }, {
54
+ name: 'Singapore',
55
+ code: 'SG',
56
+ calling_code: '65',
57
+ currency_code: 'SGD'
58
+ }, {
59
+ name: 'Hong Kong',
60
+ code: 'HK',
61
+ calling_code: '852',
62
+ currency_code: 'HKD'
63
+ }, {
64
+ name: 'Taiwan',
65
+ code: 'TW',
66
+ calling_code: '886',
67
+ currency_code: 'TWD'
68
+ }, {
69
+ name: 'Malaysia',
70
+ code: 'MY',
71
+ calling_code: '60',
72
+ currency_code: 'MYR'
73
+ }, {
74
+ name: 'Thailand',
75
+ code: 'TH',
76
+ calling_code: '66',
77
+ currency_code: 'THB'
78
+ }, {
79
+ name: 'Vietnam',
80
+ code: 'VN',
81
+ calling_code: '84',
82
+ currency_code: 'VND'
83
+ }, {
84
+ name: 'Philippines',
85
+ code: 'PH',
86
+ calling_code: '63',
87
+ currency_code: 'PHP'
88
+ }, {
89
+ name: 'Indonesia',
90
+ code: 'ID',
91
+ calling_code: '62',
92
+ currency_code: 'IDR'
93
+ }, {
94
+ name: 'India',
95
+ code: 'IN',
96
+ calling_code: '91',
97
+ currency_code: 'INR'
98
+ }, {
99
+ name: 'Germany',
100
+ code: 'DE',
101
+ calling_code: '49',
102
+ currency_code: 'EUR'
103
+ }, {
104
+ name: 'France',
105
+ code: 'FR',
106
+ calling_code: '33',
107
+ currency_code: 'EUR'
108
+ }, {
109
+ name: 'Italy',
110
+ code: 'IT',
111
+ calling_code: '39',
112
+ currency_code: 'EUR'
113
+ }, {
114
+ name: 'Spain',
115
+ code: 'ES',
116
+ calling_code: '34',
117
+ currency_code: 'EUR'
118
+ }];
119
+
120
+ /**
121
+ * 从浏览器检测用户的国家/地区
122
+ * 优先级:
123
+ * 1. Intl.DateTimeFormat 的 resolvedOptions
124
+ * 2. navigator.language 的地区后缀
125
+ * 3. 返回 null(使用默认值)
126
+ */
127
+ function detectUserCountry() {
128
+ try {
129
+ // 方法 1: 使用 Intl API 获取时区对应的地区
130
+ if (typeof Intl !== 'undefined' && Intl.DateTimeFormat) {
131
+ var timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
132
+
133
+ // 常见时区到国家代码的映射
134
+ var timeZoneMap = {
135
+ 'America/New_York': 'US',
136
+ 'America/Los_Angeles': 'US',
137
+ 'America/Chicago': 'US',
138
+ 'America/Denver': 'US',
139
+ 'America/Toronto': 'CA',
140
+ 'America/Vancouver': 'CA',
141
+ 'Europe/London': 'GB',
142
+ 'Europe/Paris': 'FR',
143
+ 'Europe/Berlin': 'DE',
144
+ 'Europe/Rome': 'IT',
145
+ 'Europe/Madrid': 'ES',
146
+ 'Asia/Shanghai': 'CN',
147
+ 'Asia/Hong_Kong': 'HK',
148
+ 'Asia/Taipei': 'TW',
149
+ 'Asia/Tokyo': 'JP',
150
+ 'Asia/Seoul': 'KR',
151
+ 'Asia/Singapore': 'SG',
152
+ 'Asia/Bangkok': 'TH',
153
+ 'Asia/Kuala_Lumpur': 'MY',
154
+ 'Asia/Jakarta': 'ID',
155
+ 'Asia/Manila': 'PH',
156
+ 'Asia/Ho_Chi_Minh': 'VN',
157
+ 'Asia/Kolkata': 'IN',
158
+ 'Australia/Sydney': 'AU',
159
+ 'Australia/Melbourne': 'AU'
160
+ };
161
+ if (timeZone && timeZoneMap[timeZone]) {
162
+ return timeZoneMap[timeZone];
163
+ }
164
+ }
165
+
166
+ // 方法 2: 从 navigator.language 提取国家代码
167
+ if (typeof navigator !== 'undefined' && navigator.language) {
168
+ var lang = navigator.language;
169
+ // 格式可能是 "zh-CN", "en-US", "ja-JP" 等
170
+ var parts = lang.split('-');
171
+ if (parts.length > 1) {
172
+ var countryCode = parts[1].toUpperCase();
173
+ return countryCode;
174
+ }
175
+
176
+ // 语言到国家的映射(当只有语言代码时)
177
+ var langMap = {
178
+ 'zh': 'CN',
179
+ 'en': 'US',
180
+ 'ja': 'JP',
181
+ 'ko': 'KR',
182
+ 'de': 'DE',
183
+ 'fr': 'FR',
184
+ 'es': 'ES',
185
+ 'it': 'IT',
186
+ 'th': 'TH',
187
+ 'vi': 'VN',
188
+ 'id': 'ID',
189
+ 'ms': 'MY'
190
+ };
191
+ if (langMap[parts[0]]) {
192
+ return langMap[parts[0]];
193
+ }
194
+ }
195
+ } catch (error) {
196
+ console.warn('Failed to detect user country:', error);
197
+ }
198
+ return null;
199
+ }
200
+
201
+ /**
202
+ * 手机号输入组件
203
+ *
204
+ * 支持国际区号选择和手机号输入
205
+ * 值格式:+区号+手机号,例如:+8613800138000 或 +15551234567
206
+ */
207
+ function PhoneInput(_ref) {
208
+ var value = _ref.value,
209
+ onChange = _ref.onChange,
210
+ placeholder = _ref.placeholder,
211
+ onKeyDown = _ref.onKeyDown,
212
+ _ref$size = _ref.size,
213
+ size = _ref$size === void 0 ? 'large' : _ref$size,
214
+ _ref$disabled = _ref.disabled,
215
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
216
+ _ref$className = _ref.className,
217
+ className = _ref$className === void 0 ? '' : _ref$className,
218
+ _ref$countries = _ref.countries,
219
+ countries = _ref$countries === void 0 ? DEFAULT_COUNTRIES : _ref$countries,
220
+ defaultCountry = _ref.defaultCountry,
221
+ _ref$valueFormat = _ref.valueFormat,
222
+ valueFormat = _ref$valueFormat === void 0 ? 'string' : _ref$valueFormat;
223
+ // 使用国际化的 placeholder
224
+ var effectivePlaceholder = placeholder || locales.getText('pisell-phone-input-placeholder');
225
+ // 将输入值标准化为字符串格式(内部统一使用字符串)
226
+ var normalizedValue = useMemo(function () {
227
+ if (!value) return '';
228
+
229
+ // 如果是对象格式,转换为字符串
230
+ if (_typeof(value) === 'object' && 'phone' in value) {
231
+ var phone = value.phone,
232
+ country_calling_code = value.country_calling_code;
233
+ return "+".concat(country_calling_code).concat(phone);
234
+ }
235
+
236
+ // 已经是字符串格式
237
+ return value;
238
+ }, [value]);
239
+
240
+ // 智能确定默认国家:检测到的国家 > 传入的 defaultCountry > 美国
241
+ var effectiveDefaultCountry = useMemo(function () {
242
+ var _countries$;
243
+ var detectedCountry = detectUserCountry();
244
+
245
+ // 1. 优先使用检测到的国家(如果在列表中存在)
246
+ if (detectedCountry && countries.some(function (c) {
247
+ return c.code === detectedCountry;
248
+ })) {
249
+ console.log('PhoneInput: Auto-detected country:', detectedCountry);
250
+ return detectedCountry;
251
+ }
252
+
253
+ // 2. 使用传入的 defaultCountry(如果在列表中存在)
254
+ if (defaultCountry && countries.some(function (c) {
255
+ return c.code === defaultCountry;
256
+ })) {
257
+ return defaultCountry;
258
+ }
259
+
260
+ // 3. 默认第一个,如果没有使用 AU 澳洲
261
+ return (countries === null || countries === void 0 || (_countries$ = countries[0]) === null || _countries$ === void 0 ? void 0 : _countries$.code) || 'AU';
262
+ }, [countries, defaultCountry]);
263
+
264
+ // 解析当前值,提取区号和手机号
265
+ var _useMemo = useMemo(function () {
266
+ if (!(countries !== null && countries !== void 0 && countries.length)) {
267
+ return {
268
+ dialCode: '',
269
+ phoneNumber: ''
270
+ };
271
+ }
272
+ if (!normalizedValue || !normalizedValue.startsWith('+')) {
273
+ // 如果没有值或格式不正确,使用默认国家的区号
274
+ var _defaultCountryOption = countries.find(function (c) {
275
+ return c.code === effectiveDefaultCountry;
276
+ }) || countries[0];
277
+ return {
278
+ dialCode: "+".concat(_defaultCountryOption.calling_code),
279
+ phoneNumber: ''
280
+ };
281
+ }
282
+
283
+ // 尝试匹配区号
284
+ var _iterator = _createForOfIteratorHelper(countries),
285
+ _step;
286
+ try {
287
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
288
+ var country = _step.value;
289
+ var countryDialCode = "+".concat(country.calling_code);
290
+ if (normalizedValue.startsWith(countryDialCode)) {
291
+ return {
292
+ dialCode: countryDialCode,
293
+ phoneNumber: normalizedValue.slice(countryDialCode.length)
294
+ };
295
+ }
296
+ }
297
+
298
+ // 如果没有匹配到,使用默认国家
299
+ } catch (err) {
300
+ _iterator.e(err);
301
+ } finally {
302
+ _iterator.f();
303
+ }
304
+ var defaultCountryOption = countries.find(function (c) {
305
+ return c.code === effectiveDefaultCountry;
306
+ }) || countries[0];
307
+ return {
308
+ dialCode: "+".concat(defaultCountryOption.calling_code),
309
+ phoneNumber: normalizedValue.startsWith('+') ? normalizedValue.slice(1) : normalizedValue
310
+ };
311
+ }, [normalizedValue, countries, effectiveDefaultCountry]),
312
+ currentDialCode = _useMemo.dialCode,
313
+ currentPhoneNumber = _useMemo.phoneNumber;
314
+
315
+ // 当前选中的国家/地区
316
+ var currentCountry = useMemo(function () {
317
+ return countries.find(function (c) {
318
+ return "+".concat(c.calling_code) === currentDialCode;
319
+ }) || countries[0];
320
+ }, [currentDialCode, countries]);
321
+
322
+ // 格式化输出值(根据 valueFormat 返回字符串或对象)
323
+ var formatOutputValue = function formatOutputValue(dialCode, phoneNumber) {
324
+ var fullString = "".concat(dialCode).concat(phoneNumber);
325
+ if (valueFormat === 'object') {
326
+ // 对象格式:{ phone: "13800138000", country_calling_code: "86" }
327
+ // 确保返回的数据都是字符串格式
328
+ return {
329
+ phone: String(phoneNumber || ''),
330
+ country_calling_code: String(dialCode.replace('+', '') || '') // 去掉 + 号并确保是字符串
331
+ };
332
+ }
333
+
334
+ // 字符串格式:"+8613800138000"
335
+ return fullString;
336
+ };
337
+
338
+ // 处理区号变化
339
+ var handleDialCodeChange = function handleDialCodeChange(e) {
340
+ var newDialCode = e.target.value;
341
+ var newValue = formatOutputValue(newDialCode, currentPhoneNumber);
342
+ onChange === null || onChange === void 0 || onChange(newValue);
343
+ };
344
+
345
+ // 处理手机号输入变化
346
+ var handlePhoneNumberChange = function handlePhoneNumberChange(e) {
347
+ var inputValue = e.target.value;
348
+
349
+ // 检测输入值是否包含当前区号前缀(处理浏览器自动填充的情况)
350
+ // 情况1: 输入值以 +86 开头,当前区号也是 +86
351
+ // 情况2: 输入值以 86 开头(无+号),当前区号是 +86
352
+ var dialCodeWithoutPlus = currentDialCode.replace('+', ''); // 去掉 + 号,用于匹配
353
+
354
+ // 如果输入值以 + 号开头,检查是否以当前区号开头
355
+ if (inputValue.startsWith('+')) {
356
+ if (inputValue.startsWith(currentDialCode)) {
357
+ // 输入值以当前区号开头,去除区号部分
358
+ inputValue = inputValue.slice(currentDialCode.length);
359
+ }
360
+ } else if (inputValue.startsWith(dialCodeWithoutPlus)) {
361
+ // 输入值以区号数字开头(无+号),去除区号部分
362
+ inputValue = inputValue.slice(dialCodeWithoutPlus.length);
363
+ }
364
+
365
+ // 只保留数字
366
+ var newPhoneNumber = inputValue.replace(/[^\d]/g, '');
367
+ var newValue = formatOutputValue(currentDialCode, newPhoneNumber);
368
+ onChange === null || onChange === void 0 || onChange(newValue);
369
+ };
370
+ return /*#__PURE__*/React.createElement("div", {
371
+ className: "phone-input-wrapper ".concat(className)
372
+ }, /*#__PURE__*/React.createElement("div", {
373
+ className: "phone-input-container"
374
+ }, /*#__PURE__*/React.createElement("div", {
375
+ className: "phone-input-prefix"
376
+ }, /*#__PURE__*/React.createElement("span", {
377
+ className: "phone-input-country-display"
378
+ }, currentCountry === null || currentCountry === void 0 ? void 0 : currentCountry.code, "(", currentDialCode, ")"), /*#__PURE__*/React.createElement("select", {
379
+ className: "phone-input-select",
380
+ value: currentDialCode,
381
+ onChange: handleDialCodeChange,
382
+ disabled: disabled
383
+ }, countries.map(function (country) {
384
+ return /*#__PURE__*/React.createElement("option", {
385
+ key: country.code,
386
+ value: "+".concat(country.calling_code)
387
+ }, country.code, " +", country.calling_code);
388
+ })), /*#__PURE__*/React.createElement("svg", {
389
+ className: "phone-input-arrow",
390
+ width: "12",
391
+ height: "12",
392
+ viewBox: "0 0 12 12",
393
+ fill: "none",
394
+ xmlns: "http://www.w3.org/2000/svg"
395
+ }, /*#__PURE__*/React.createElement("path", {
396
+ d: "M3 4.5L6 7.5L9 4.5",
397
+ stroke: "currentColor",
398
+ strokeWidth: "1.5",
399
+ strokeLinecap: "round",
400
+ strokeLinejoin: "round"
401
+ }))), /*#__PURE__*/React.createElement("div", {
402
+ className: "phone-input-divider"
403
+ }), /*#__PURE__*/React.createElement("input", {
404
+ type: "tel",
405
+ className: "phone-input-field phone-input-field-".concat(size),
406
+ value: currentPhoneNumber,
407
+ onChange: handlePhoneNumberChange,
408
+ onKeyDown: onKeyDown,
409
+ placeholder: effectivePlaceholder,
410
+ disabled: disabled,
411
+ autoComplete: "tel"
412
+ })));
413
+ }
414
+ export default PhoneInput;