@mycause/ui 0.0.0-cb5efc7a → 0.0.0-cbbae7b8

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 (343) hide show
  1. package/CHANGELOG.md +328 -0
  2. package/README.md +9 -0
  3. package/dist/components/button-select/button-select.d.ts +12 -0
  4. package/dist/components/{phone-number-input/phone-number-field.stories.d.ts → button-select/button-select.stories.d.ts} +1 -1
  5. package/dist/components/button-select/index.d.ts +1 -0
  6. package/dist/components/campaign-card/campaign-card.d.ts +9 -0
  7. package/dist/components/campaign-card/campaign-card.stories.d.ts +14 -0
  8. package/dist/components/campaign-card/index.d.ts +1 -0
  9. package/dist/components/campaign-of-month/campaign-of-month.d.ts +15 -0
  10. package/dist/components/campaign-of-month/campaign-of-month.stories.d.ts +14 -0
  11. package/dist/components/campaign-of-month/index.d.ts +1 -0
  12. package/dist/components/charity-card/charity-card.d.ts +7 -0
  13. package/dist/components/charity-card/charity-card.stories.d.ts +14 -0
  14. package/dist/components/charity-card/index.d.ts +1 -0
  15. package/dist/components/combo-field/combo-field.d.ts +4 -1
  16. package/dist/components/comment-section/comment-section-v2/comment-section-v2.d.ts +31 -0
  17. package/dist/components/comment-section/comment-section-v2/sub-comments-v2.d.ts +11 -0
  18. package/dist/components/comment-section/comment-section.d.ts +24 -0
  19. package/dist/components/comment-section/comment-section.stories.d.ts +19 -0
  20. package/dist/components/comment-section/index.d.ts +2 -0
  21. package/dist/components/comment-section/sub-comments.d.ts +6 -0
  22. package/dist/components/cropper/cropper.d.ts +4 -4
  23. package/dist/components/cropper/cropper.stories.d.ts +1 -2
  24. package/dist/components/date-picker/date-picker.stories.d.ts +6 -0
  25. package/dist/components/date-picker/index.d.ts +1 -0
  26. package/dist/components/date-picker/single-date-picker-custom-header.d.ts +32 -0
  27. package/dist/components/date-picker/single-date-picker.d.ts +3 -2
  28. package/dist/components/donate-card/donate-card.d.ts +8 -0
  29. package/dist/components/donate-card/donate-card.stories.d.ts +14 -0
  30. package/dist/components/donate-card/index.d.ts +1 -0
  31. package/dist/components/donation-form/donation-details.d.ts +12 -0
  32. package/dist/components/donation-form/donation-form-v2/donation-form-v2.d.ts +13 -0
  33. package/dist/components/donation-form/donation-form.d.ts +64 -0
  34. package/dist/components/donation-form/donation-form.stories.d.ts +18 -0
  35. package/dist/components/donation-form/donation-payment.d.ts +13 -0
  36. package/dist/components/donation-form/donation-select.d.ts +13 -0
  37. package/dist/components/donation-form/index.d.ts +2 -0
  38. package/dist/components/elevation/elevation.d.ts +2 -1
  39. package/dist/components/favorite-charity-item/favorite-charity-item.d.ts +15 -0
  40. package/dist/components/favorite-charity-item/favorite-charity-item.stories.d.ts +15 -0
  41. package/dist/components/favorite-charity-item/index.d.ts +1 -0
  42. package/dist/components/featured-campaign-card/featured-campaign-card.d.ts +17 -0
  43. package/dist/components/featured-campaign-card/featured-campaign-card.stories.d.ts +14 -0
  44. package/dist/components/featured-campaign-card/index.d.ts +1 -0
  45. package/dist/components/field-helpers/field-label.d.ts +2 -1
  46. package/dist/components/footerV2/footerV2.d.ts +35 -0
  47. package/dist/components/footerV2/footerV2.stories.d.ts +15 -0
  48. package/dist/components/footerV2/index.d.ts +1 -0
  49. package/dist/components/fundraising-section/fundraising-section.d.ts +9 -0
  50. package/dist/components/fundraising-section/fundraising-section.stories.d.ts +14 -0
  51. package/dist/components/fundraising-section/index.d.ts +1 -0
  52. package/dist/components/hero-banner/hero-banner.d.ts +9 -0
  53. package/dist/components/hero-banner/hero-banner.stories.d.ts +14 -0
  54. package/dist/components/hero-banner/index.d.ts +1 -0
  55. package/dist/components/horizontalbar/horizontalbar.d.ts +11 -0
  56. package/dist/components/horizontalbar/horizontalbar.stories.d.ts +26 -0
  57. package/dist/components/horizontalbar/index.d.ts +1 -0
  58. package/dist/components/icon/{toggle-button.d.ts → heart-toggle.d.ts} +3 -3
  59. package/dist/components/icon/{toggle-button.stories.d.ts → heart-toggle.stories.d.ts} +1 -1
  60. package/dist/components/icon/index.d.ts +1 -1
  61. package/dist/components/index.d.ts +35 -0
  62. package/dist/components/info-represent-campaign/index.d.ts +1 -0
  63. package/dist/components/info-represent-campaign/info-represent-campaign.d.ts +11 -0
  64. package/dist/components/info-represent-campaign/info-represent-campaign.stories.d.ts +12 -0
  65. package/dist/components/input/InputDefault.d.ts +13 -0
  66. package/dist/components/input/index.d.ts +1 -0
  67. package/dist/components/input/input.stories.d.ts +24 -0
  68. package/dist/components/list/list.d.ts +29 -14
  69. package/dist/components/list/list.stories.d.ts +8 -2
  70. package/dist/components/login/index.d.ts +1 -0
  71. package/dist/components/login/login.d.ts +15 -0
  72. package/dist/components/login/login.stories.d.ts +19 -0
  73. package/dist/components/logo/logo-type.d.ts +2 -1
  74. package/dist/components/modal/index.d.ts +1 -0
  75. package/dist/components/modal/modal-image.d.ts +8 -0
  76. package/dist/components/modal/modal.d.ts +7 -3
  77. package/dist/components/modal/modal.stories.d.ts +18 -0
  78. package/dist/components/my-account-choose-charity-card/index.d.ts +1 -0
  79. package/dist/components/my-account-choose-charity-card/my-account-choose-charity-card.d.ts +11 -0
  80. package/dist/components/my-account-choose-charity-card/my-account-choose-charity-card.stories.d.ts +14 -0
  81. package/dist/components/my-account-frp-closed/Icon.d.ts +5 -0
  82. package/dist/components/my-account-frp-closed/frp-closed-img.d.ts +9 -0
  83. package/dist/components/my-account-frp-closed/frp-information.d.ts +13 -0
  84. package/dist/components/my-account-frp-closed/index.d.ts +1 -0
  85. package/dist/components/my-account-frp-closed/my-account-frp-closed.d.ts +17 -0
  86. package/dist/components/my-account-frp-closed/my-account-frp-closed.stories.d.ts +24 -0
  87. package/dist/components/my-account-frp-preview/Icon.d.ts +5 -0
  88. package/dist/components/my-account-frp-preview/frp-information.d.ts +13 -0
  89. package/dist/components/my-account-frp-preview/frp-preview-img.d.ts +9 -0
  90. package/dist/components/my-account-frp-preview/index.d.ts +1 -0
  91. package/dist/components/my-account-frp-preview/my-account-frp-preview.d.ts +17 -0
  92. package/dist/components/my-account-frp-preview/my-account-frp-preview.stories.d.ts +24 -0
  93. package/dist/components/my-account-sidebar/Icon.d.ts +15 -0
  94. package/dist/components/my-account-sidebar/index.d.ts +1 -0
  95. package/dist/components/my-account-sidebar/my-account-sidebar.d.ts +18 -0
  96. package/dist/components/{phone-number-field/phone-number-field.stories.d.ts → my-account-sidebar/my-account-sidebar.stories.d.ts} +1 -1
  97. package/dist/components/my-account-start-fundraise-card/index.d.ts +1 -0
  98. package/dist/components/my-account-start-fundraise-card/my-account-start-fundraise-card.d.ts +13 -0
  99. package/dist/components/my-account-start-fundraise-card/my-account-start-fundraise-card.stories.d.ts +20 -0
  100. package/dist/components/my-account-stats-donated/index.d.ts +1 -0
  101. package/dist/components/my-account-stats-donated/my-account-stats-donated.d.ts +8 -0
  102. package/dist/components/my-account-stats-donated/my-account-stats-donated.stories.d.ts +12 -0
  103. package/dist/components/my-account-stats-raised/index.d.ts +1 -0
  104. package/dist/components/my-account-stats-raised/my-account-stats-raised.d.ts +7 -0
  105. package/dist/components/my-account-stats-raised/my-account-stats-raised.stories.d.ts +12 -0
  106. package/dist/components/nav/icons/IconBigger.d.ts +5 -0
  107. package/dist/components/nav/icons/IconSmaller.d.ts +5 -0
  108. package/dist/components/nav/index.d.ts +2 -0
  109. package/dist/components/nav/nav-actions.d.ts +5 -0
  110. package/dist/components/nav/nav-bar.d.ts +7 -0
  111. package/dist/components/nav/nav-call-to-action.d.ts +5 -0
  112. package/dist/components/nav/nav-expanded-charity.d.ts +14 -0
  113. package/dist/components/nav/nav-expanded.d.ts +14 -0
  114. package/dist/components/nav/nav-list.d.ts +29 -0
  115. package/dist/components/nav/nav-menu-control.d.ts +8 -0
  116. package/dist/components/nav/nav-menu.d.ts +12 -0
  117. package/dist/components/nav/nav-myaccount.d.ts +22 -0
  118. package/dist/components/nav/nav-search-control.d.ts +8 -0
  119. package/dist/components/nav/nav-search.d.ts +10 -0
  120. package/dist/components/nav/nav-sign-in-control.d.ts +12 -0
  121. package/dist/components/nav/nav-user-menu-items.d.ts +20 -0
  122. package/dist/components/nav/nav-user-menu.d.ts +18 -0
  123. package/dist/components/nav/nav.d.ts +57 -0
  124. package/dist/components/nav/nav.stories.d.ts +17 -0
  125. package/dist/components/navigation/navigation-list.d.ts +3 -1
  126. package/dist/components/navigation/navigation-menu.d.ts +2 -1
  127. package/dist/components/navigation/navigation-sign-in-control.d.ts +6 -3
  128. package/dist/components/navigation/navigation.d.ts +12 -1
  129. package/dist/components/navigation/navigation.stories.d.ts +3 -21
  130. package/dist/components/partner-chart-stats/index.d.ts +1 -0
  131. package/dist/components/partner-chart-stats/partner-chart-stats.d.ts +11 -0
  132. package/dist/components/partner-chart-stats/partner-chart-stats.stories.d.ts +18 -0
  133. package/dist/components/partner-monthly-donations/index.d.ts +1 -0
  134. package/dist/components/partner-monthly-donations/partner-monthly-donations.d.ts +8 -0
  135. package/dist/components/partner-monthly-donations/partner-monthly-donations.stories.d.ts +12 -0
  136. package/dist/components/partner-monthly-stats/index.d.ts +1 -0
  137. package/dist/components/partner-monthly-stats/partner-monthly-stats.d.ts +7 -0
  138. package/dist/components/partner-monthly-stats/partner-monthly-stats.stories.d.ts +12 -0
  139. package/dist/components/partner-toggle-button/index.d.ts +2 -0
  140. package/dist/components/partner-toggle-button/partner-toggle-button-block.d.ts +11 -0
  141. package/dist/components/partner-toggle-button/partner-toggle-button-block.stories.d.ts +12 -0
  142. package/dist/components/partner-toggle-button/partner-toggle-button.d.ts +8 -0
  143. package/dist/components/phone-number-input/index.d.ts +2 -1
  144. package/dist/components/{phone-number-field/phone-number-field.d.ts → phone-number-input/phone-number-input-v1.d.ts} +5 -3
  145. package/dist/components/phone-number-input/phone-number-input-v2.d.ts +19 -0
  146. package/dist/components/phone-number-input/phone-number-input.d.ts +21 -10
  147. package/dist/components/phone-number-input/phone-number-input.stories.d.ts +37 -0
  148. package/dist/components/popup/index.d.ts +1 -0
  149. package/dist/components/popup/popup.d.ts +8 -0
  150. package/dist/components/popup/popup.stories.d.ts +14 -0
  151. package/dist/components/progressbar/index.d.ts +1 -0
  152. package/dist/components/progressbar/progress-bar-circle.d.ts +10 -0
  153. package/dist/components/progressbar/progressbar.d.ts +8 -0
  154. package/dist/components/progressbar/progressbar.stories.d.ts +20 -0
  155. package/dist/components/select/SelectV2.d.ts +24 -0
  156. package/dist/components/select/index.d.ts +2 -0
  157. package/dist/components/select/select-enhanced.d.ts +23 -0
  158. package/dist/components/select/select-v2.d.ts +26 -0
  159. package/dist/components/select/select.d.ts +5 -2
  160. package/dist/components/select/select.stories.d.ts +12 -0
  161. package/dist/components/spinner/index.d.ts +1 -0
  162. package/dist/components/spinner/spinner.d.ts +8 -0
  163. package/dist/components/spinner/spinner.stories.d.ts +13 -0
  164. package/dist/components/start-campaign-card/index.d.ts +1 -0
  165. package/dist/components/start-campaign-card/start-campaign-card.d.ts +8 -0
  166. package/dist/components/start-campaign-card/start-campaign-card.stories.d.ts +14 -0
  167. package/dist/components/statistics/statistics.d.ts +2 -1
  168. package/dist/components/table/index.d.ts +1 -0
  169. package/dist/components/table/partner-monthly-table.d.ts +17 -0
  170. package/dist/components/table/partner-monthly-table.stories.d.ts +18 -0
  171. package/dist/components/tabs/nav-tabs.d.ts +18 -0
  172. package/dist/components/tabs/tabs.d.ts +3 -1
  173. package/dist/components/text/text.d.ts +1 -1
  174. package/dist/components/text-field/index.d.ts +1 -0
  175. package/dist/components/text-field/text-field-search.d.ts +9 -0
  176. package/dist/components/text-field/text-field.d.ts +1 -0
  177. package/dist/components/text-field/text-field.stories.d.ts +6 -0
  178. package/dist/components/this-month-card/index.d.ts +1 -0
  179. package/dist/components/this-month-card/this-month-card.d.ts +15 -0
  180. package/dist/components/this-month-card/this-month-card.stories.d.ts +12 -0
  181. package/dist/components/toast/Icons.d.ts +7 -0
  182. package/dist/components/toast/index.d.ts +1 -0
  183. package/dist/components/toast/toast.d.ts +8 -0
  184. package/dist/components/toast/toast.stories.d.ts +12 -0
  185. package/dist/components/transaction-card/Dot.d.ts +6 -0
  186. package/dist/components/transaction-card/index.d.ts +1 -0
  187. package/dist/components/transaction-card/transaction-card.d.ts +14 -0
  188. package/dist/components/transaction-card/transaction-card.stories.d.ts +14 -0
  189. package/dist/index.esm.js +34049 -6491
  190. package/dist/index.js +34109 -6505
  191. package/dist/theme/theme.d.ts +4 -0
  192. package/dist/utils/parse-numbers.d.ts +2 -0
  193. package/package.json +5 -2
  194. package/styles/index.css +5 -1
  195. package/dist/components/anchor/anchor.jsx +0 -35
  196. package/dist/components/anchor/anchor.stories.jsx +0 -12
  197. package/dist/components/anchor/bold-anchor.jsx +0 -33
  198. package/dist/components/anchor/bold-anchor.stories.jsx +0 -11
  199. package/dist/components/anchor/index.js +0 -2
  200. package/dist/components/avatar/avatar.jsx +0 -14
  201. package/dist/components/avatar/avatar.stories.jsx +0 -17
  202. package/dist/components/avatar/image-avatar.jsx +0 -29
  203. package/dist/components/avatar/index.js +0 -1
  204. package/dist/components/avatar/text-avatar.jsx +0 -47
  205. package/dist/components/button/button.jsx +0 -85
  206. package/dist/components/button/button.stories.jsx +0 -118
  207. package/dist/components/button/index.js +0 -1
  208. package/dist/components/checkbox/checkbox.jsx +0 -39
  209. package/dist/components/checkbox/checkbox.stories.jsx +0 -42
  210. package/dist/components/checkbox/index.js +0 -1
  211. package/dist/components/chips/chip.jsx +0 -30
  212. package/dist/components/chips/chips.jsx +0 -16
  213. package/dist/components/chips/chips.stories.jsx +0 -35
  214. package/dist/components/chips/index.js +0 -3
  215. package/dist/components/chips/input-chips.jsx +0 -16
  216. package/dist/components/chips/input-chips.stories.jsx +0 -39
  217. package/dist/components/combo-field/combo-field-expander.jsx +0 -23
  218. package/dist/components/combo-field/combo-field.jsx +0 -93
  219. package/dist/components/combo-field/combo-field.stories.jsx +0 -62
  220. package/dist/components/combo-field/index.js +0 -2
  221. package/dist/components/cropper/cropper.jsx +0 -15
  222. package/dist/components/cropper/cropper.stories.jsx +0 -18
  223. package/dist/components/cropper/index.js +0 -1
  224. package/dist/components/date-picker/date-picker.jsx +0 -74
  225. package/dist/components/date-picker/date-picker.stories.jsx +0 -46
  226. package/dist/components/date-picker/index.js +0 -2
  227. package/dist/components/date-picker/single-date-picker.jsx +0 -81
  228. package/dist/components/elevation/elevation.jsx +0 -19
  229. package/dist/components/elevation/elevation.stories.jsx +0 -31
  230. package/dist/components/elevation/index.js +0 -1
  231. package/dist/components/field-helpers/field-helper-text.jsx +0 -42
  232. package/dist/components/field-helpers/field-label.jsx +0 -29
  233. package/dist/components/field-helpers/index.js +0 -2
  234. package/dist/components/icon/btn_google_light_normal_ios.svg.jsx +0 -21
  235. package/dist/components/icon/facebook_6.svg.jsx +0 -13
  236. package/dist/components/icon/icon-button-group.jsx +0 -51
  237. package/dist/components/icon/icon-button-group.stories.jsx +0 -26
  238. package/dist/components/icon/icon-button.jsx +0 -48
  239. package/dist/components/icon/icon-button.stories.jsx +0 -33
  240. package/dist/components/icon/icon.jsx +0 -49
  241. package/dist/components/icon/icon.stories.jsx +0 -78
  242. package/dist/components/icon/index.js +0 -4
  243. package/dist/components/icon/material-icon.jsx +0 -18
  244. package/dist/components/icon/toggle-button.jsx +0 -29
  245. package/dist/components/icon/toggle-button.stories.jsx +0 -16
  246. package/dist/components/index.js +0 -27
  247. package/dist/components/layout/box.jsx +0 -58
  248. package/dist/components/layout/flex.jsx +0 -55
  249. package/dist/components/layout/flex.stories.jsx +0 -44
  250. package/dist/components/layout/grid.jsx +0 -19
  251. package/dist/components/layout/grid.stories.jsx +0 -29
  252. package/dist/components/layout/index.js +0 -4
  253. package/dist/components/layout/stack.jsx +0 -33
  254. package/dist/components/layout/stack.stories.jsx +0 -40
  255. package/dist/components/list/index.js +0 -1
  256. package/dist/components/list/list.jsx +0 -52
  257. package/dist/components/list/list.stories.jsx +0 -135
  258. package/dist/components/logo/index.js +0 -1
  259. package/dist/components/logo/logo-type.jsx +0 -65
  260. package/dist/components/menu/index.js +0 -8
  261. package/dist/components/menu/menu-list-divider.jsx +0 -2
  262. package/dist/components/menu/menu-list-item-graphic.jsx +0 -2
  263. package/dist/components/menu/menu-list-item-meta.jsx +0 -2
  264. package/dist/components/menu/menu-list-item-text.jsx +0 -2
  265. package/dist/components/menu/menu-list-item.jsx +0 -11
  266. package/dist/components/menu/menu-list.jsx +0 -18
  267. package/dist/components/menu/menu-surface.jsx +0 -4
  268. package/dist/components/menu/menu.jsx +0 -2
  269. package/dist/components/menu/menu.stories.jsx +0 -42
  270. package/dist/components/modal/index.js +0 -1
  271. package/dist/components/modal/modal.jsx +0 -49
  272. package/dist/components/modal/modal.stories.jsx +0 -47
  273. package/dist/components/navigation/index.js +0 -1
  274. package/dist/components/navigation/navigation-actions.jsx +0 -8
  275. package/dist/components/navigation/navigation-bar.jsx +0 -42
  276. package/dist/components/navigation/navigation-call-to-action.jsx +0 -6
  277. package/dist/components/navigation/navigation-expanded.jsx +0 -165
  278. package/dist/components/navigation/navigation-list.jsx +0 -126
  279. package/dist/components/navigation/navigation-menu-control.jsx +0 -25
  280. package/dist/components/navigation/navigation-menu.jsx +0 -103
  281. package/dist/components/navigation/navigation-search-control.jsx +0 -8
  282. package/dist/components/navigation/navigation-search.jsx +0 -63
  283. package/dist/components/navigation/navigation-sign-in-control.jsx +0 -14
  284. package/dist/components/navigation/navigation-user-menu-items.jsx +0 -36
  285. package/dist/components/navigation/navigation-user-menu.jsx +0 -121
  286. package/dist/components/navigation/navigation.jsx +0 -137
  287. package/dist/components/navigation/navigation.stories.jsx +0 -260
  288. package/dist/components/phone-number-field/index.d.ts +0 -2
  289. package/dist/components/phone-number-field/index.js +0 -2
  290. package/dist/components/phone-number-field/phone-number-field.jsx +0 -50
  291. package/dist/components/phone-number-field/phone-number-field.stories.jsx +0 -23
  292. package/dist/components/phone-number-field/util.d.ts +0 -2
  293. package/dist/components/phone-number-field/util.js +0 -19
  294. package/dist/components/phone-number-input/index.js +0 -3
  295. package/dist/components/phone-number-input/phone-number-field.d.ts +0 -23
  296. package/dist/components/phone-number-input/phone-number-field.jsx +0 -50
  297. package/dist/components/phone-number-input/phone-number-field.stories.jsx +0 -16
  298. package/dist/components/phone-number-input/phone-number-input.jsx +0 -48
  299. package/dist/components/phone-number-input/util.js +0 -19
  300. package/dist/components/radio/index.js +0 -2
  301. package/dist/components/radio/radio-group.jsx +0 -9
  302. package/dist/components/radio/radio-group.stories.jsx +0 -21
  303. package/dist/components/radio/radio.jsx +0 -31
  304. package/dist/components/radio/radio.stories.jsx +0 -44
  305. package/dist/components/select/index.js +0 -2
  306. package/dist/components/select/select-helper-text.jsx +0 -6
  307. package/dist/components/select/select.jsx +0 -152
  308. package/dist/components/select/select.stories.jsx +0 -40
  309. package/dist/components/statistics/index.js +0 -1
  310. package/dist/components/statistics/statistics.jsx +0 -61
  311. package/dist/components/statistics/statistics.stories.jsx +0 -34
  312. package/dist/components/switch/index.js +0 -1
  313. package/dist/components/switch/switch.jsx +0 -32
  314. package/dist/components/switch/switch.stories.jsx +0 -41
  315. package/dist/components/tabs/index.js +0 -1
  316. package/dist/components/tabs/tab-bar.jsx +0 -35
  317. package/dist/components/tabs/tab-text-label.jsx +0 -5
  318. package/dist/components/tabs/tab.jsx +0 -50
  319. package/dist/components/tabs/tabs.jsx +0 -65
  320. package/dist/components/tabs/tabs.stories.jsx +0 -27
  321. package/dist/components/text/index.js +0 -1
  322. package/dist/components/text/text.jsx +0 -138
  323. package/dist/components/text/text.stories.jsx +0 -262
  324. package/dist/components/text-field/index.js +0 -2
  325. package/dist/components/text-field/text-field-helper-text.jsx +0 -8
  326. package/dist/components/text-field/text-field.jsx +0 -124
  327. package/dist/components/text-field/text-field.stories.jsx +0 -32
  328. package/dist/components/uploader/index.js +0 -1
  329. package/dist/components/uploader/uploader.jsx +0 -96
  330. package/dist/input.d.ts +0 -1
  331. package/dist/input.js +0 -4
  332. package/dist/input.jsx +0 -4
  333. package/dist/theme/colors.js +0 -9
  334. package/dist/theme/index.js +0 -2
  335. package/dist/theme/mycause-theme.js +0 -33
  336. package/dist/theme/theme.jsx +0 -36
  337. package/dist/utils/browser.js +0 -19
  338. package/dist/utils/center-decorator.jsx +0 -15
  339. package/dist/utils/component-matrix.jsx +0 -39
  340. package/dist/utils/flags.js +0 -18
  341. package/dist/utils/grid-decorator.jsx +0 -27
  342. package/dist/utils/tap-event.js +0 -11
  343. package/dist/utils/wrap.js +0 -8
@@ -1,137 +0,0 @@
1
- import React, { useState } from "react";
2
- import useMedia from "use-media";
3
- import { WHITE } from "../../theme/colors";
4
- import Tabs from "../tabs/tabs";
5
- import NavigationMenu from "./navigation-menu";
6
- import NavigationBar from "./navigation-bar";
7
- import NavigationExpanded from "./navigation-expanded";
8
- import { Statistics } from "../statistics";
9
- import NavigationActions from "./navigation-actions";
10
- import NavigationSearch from "./navigation-search";
11
- import NavigationSearchControl from "./navigation-search-control";
12
- import NavigationSignInControl from "./navigation-sign-in-control";
13
- import NavigationCallToAction from "./navigation-call-to-action";
14
- import NavigationMenuControl from "./navigation-menu-control";
15
- import NavigationUserMenu from "./navigation-user-menu";
16
- function Navigation({ logo, menus, links, stats, cta, user, userMenu, search, login, isSticky, isCompactHeight, }) {
17
- const [isSearchOpen, setSearchOpen] = useState(false);
18
- const [isUserMenuOpen, setUserMenuOpen] = useState();
19
- const [query, setQuery] = useState("");
20
- const [active, setActive] = useState([null, null]);
21
- const isCompact = useMedia("screen and (max-width: 720px)");
22
- const isMedium = useMedia("screen and (max-width: 960px)");
23
- const menu = active[0] && menus ? menus.find(menu => menu.id === active[0]) : null;
24
- const submenu = active[1]
25
- ? menu.items.find(item => "id" in item && item.id === active[1]) &&
26
- menu.items.find(item => "id" in item && item.id === active[1]).submenu
27
- : null;
28
- const handleChangeMenuOpen = (isOpen) => {
29
- if (isOpen) {
30
- setActive(replace(active, 0, menus[0].id));
31
- }
32
- else {
33
- setActive([null, null]);
34
- }
35
- };
36
- return (<nav className="navigation">
37
- <NavigationBar isCompactHeight={isCompactHeight}>
38
- {!(isCompact && isSearchOpen) ? (<div className="logo-wrap">{logo}</div>) : null}
39
- {isSearchOpen && search ? (<>
40
- <NavigationSearch value={query} onChange={setQuery} onSubmit={() => search.onSearch(query)} onCancel={() => setSearchOpen(false)}/>
41
- </>) : (<>
42
- <div className="desktop-tabs">
43
- <Tabs tabs={menus
44
- ? menus.map(item => ({
45
- key: item.id,
46
- label: item.label,
47
- analyticsId: item.analyticsId,
48
- }))
49
- : []} active={active[0]} isCompactHeight={isCompactHeight} onActiveUpdate={id => setActive(replace(active, 0, id))} isMinWidth isMinWidthIndicator large/>
50
- </div>
51
- <NavigationActions>
52
- {search && (<NavigationSearchControl onChangeSearchOpen={setSearchOpen} analyticsId={search.analyticsId}/>)}
53
- {user ? (<NavigationUserMenu user={user} items={userMenu} isOpen={isUserMenuOpen} onChangeOpen={setUserMenuOpen} isCompact={isCompact}/>) : (login && (<NavigationSignInControl compact={isCompact} onRequestSignIn={login.onLogin} analyticsId={login.analyticsId}/>))}
54
- {!isMedium && cta ? <NavigationCallToAction {...cta}/> : null}
55
- {isMedium && menus ? (<NavigationMenuControl isMenuOpen={!!menu} onChangeMenuOpen={handleChangeMenuOpen}/>) : null}
56
- </NavigationActions>
57
- </>)}
58
- </NavigationBar>
59
- {menu ? (<NavigationExpanded links={links} onRequestClose={() => setActive([null, null])} className="navigation-float" banner={stats ? (<Statistics stats={stats} title="We support your cause"/>) : null}>
60
- <div className="mobile-tabs">
61
- <Tabs tabs={menus
62
- ? menus.map(item => ({ key: item.id, label: item.label }))
63
- : []} active={active[0]} onActiveUpdate={id => setActive(replace(active, 0, id))}/>
64
- </div>
65
- <NavigationMenu key={menu.id} links={menu.items.map(item => ({
66
- ...item,
67
- more: !!item.submenu,
68
- }))} sublinks={submenu || null} action={menu.action || null} active={active[1]} onClickItem={id => setActive(() => {
69
- if (active[1])
70
- return [active[0], null];
71
- else
72
- return replace(active, 1, id);
73
- })}/>
74
- </NavigationExpanded>) : null}
75
- <style jsx>{`
76
- .navigation {
77
- background-color: ${WHITE};
78
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12),
79
- 0 1px 4px rgba(0, 0, 0, 0.24);
80
- top: 0;
81
- z-index: 10;
82
- position: ${isSticky ? "fixed" : "relative"};
83
- width: 100%;
84
- }
85
-
86
- .logo-wrap {
87
- display: flex;
88
- align-items: center;
89
- justify-content: center;
90
- margin-right: 1rem;
91
- }
92
-
93
- .desktop-tabs {
94
- margin-left: 1rem;
95
- display: none;
96
- }
97
-
98
- .mobile-tabs {
99
- margin: 0 -1rem;
100
- }
101
-
102
- .navigation :global(.navigation-float) {
103
- position: absolute;
104
- top: 100%;
105
- left: 0;
106
- right: 0;
107
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12),
108
- 0 1px 4px rgba(0, 0, 0, 0.24);
109
- }
110
-
111
- @media (min-width: 960px) {
112
- .navigation {
113
- position: relative;
114
- }
115
-
116
- .mobile-tabs {
117
- display: none;
118
- }
119
-
120
- .desktop-tabs {
121
- display: block;
122
- }
123
- }
124
- `}</style>
125
- </nav>);
126
- }
127
- function replace(arr, x, val) {
128
- return arr.map((item, i) => {
129
- if (i === x)
130
- return val;
131
- if (x > 0)
132
- return item;
133
- else
134
- return null;
135
- });
136
- }
137
- export default Navigation;
@@ -1,260 +0,0 @@
1
- import React, { useState } from "react";
2
- import { action } from "@storybook/addon-actions";
3
- import useMedia from "use-media";
4
- import { LogoType } from "../logo";
5
- import Navigation from "./navigation";
6
- import NavigationList from "./navigation-list";
7
- import NavigationMenu from "./navigation-menu";
8
- import NavigationExpanded from "./navigation-expanded";
9
- import NavigationSearch from "./navigation-search";
10
- import avatar from "../avatar/ipet-photo-CfDAo3C3bvQ-unsplash.jpg";
11
- import circle from "../statistics/circle.svg";
12
- function Logo() {
13
- return (<LogoType size={useMedia("screen and (min-width: 720px") ? "large" : undefined}/>);
14
- }
15
- function BackgroundContainer({ children }) {
16
- return (<div className="container">
17
- <div className="content">{children}</div>
18
- <style jsx>{`
19
- .container {
20
- min-height: 100vh;
21
- display: flex;
22
- align-items: center;
23
- justify-content: center;
24
- }
25
-
26
- .content {
27
- width: 100%;
28
- max-width: 1024px;
29
- padding: 2rem 1rem;
30
- background-color: rgba(0, 0, 0, 0.01);
31
- }
32
-
33
- @media (min-width: 720px) {
34
- .content {
35
- padding: 4rem;
36
- }
37
- }
38
- `}</style>
39
- </div>);
40
- }
41
- export default {
42
- title: "Navigation",
43
- };
44
- function NavigationSearchDemo() {
45
- const [value, setValue] = useState("");
46
- return (<NavigationSearch value={value} onChange={setValue} onSubmit={action("search")} onCancel={action("cancel")}/>);
47
- }
48
- function NavigationDemo() {
49
- const [isSignedIn, setSignedIn] = useState(false);
50
- return (<Navigation logo={<Logo />} isSticky={true} menus={[
51
- {
52
- label: "Fundraise",
53
- id: "fundraise",
54
- analyticsId: "fundraise",
55
- items: [
56
- { label: "For a person", id: "person", analyticsId: "person" },
57
- { label: "For a charity", id: "charity" },
58
- { label: "Find a charity", id: "find_charity" },
59
- {
60
- label: "Fundraising ideas",
61
- id: "fundraising_ideas",
62
- submenu: [
63
- { label: "Schools", id: "schools" },
64
- { label: "Cancer", id: "cancer" },
65
- { label: "Pets & animals", id: "pets_animals" },
66
- { label: "Help a friend", id: "help_friend" },
67
- { label: "Marathon runs", id: "marathon" },
68
- { label: "See all fundraising ideas", id: "see all" },
69
- ],
70
- },
71
- { label: "Team fundraising", id: "team_fundraising" },
72
- { label: "How it works", id: "how_it_works" },
73
- ],
74
- },
75
- {
76
- label: "Donate",
77
- id: "donate",
78
- analyticsId: "donate",
79
- items: [
80
- { label: "Donate to a charity", id: "donate" },
81
- { label: "Send a gift card/voucher", id: "gift_card" },
82
- { label: "Pledge your birthday", id: "birthday" },
83
- { label: "Start a giving portfolio", id: "giving_portfolio" },
84
- ],
85
- },
86
- {
87
- label: "Organisation",
88
- id: "organisation",
89
- analyticsId: "organisation",
90
- items: [
91
- {
92
- label: "For your organisation",
93
- id: "organisation",
94
- submenu: [
95
- { label: "Schools", id: "schools" },
96
- { label: "Clubs", id: "clubs" },
97
- { label: "Charity", id: "charity" },
98
- { label: "Event manager", id: "event_manager" },
99
- { label: "Corporate", id: "corporate" },
100
- ],
101
- },
102
- { label: "Fundraising events", id: "events" },
103
- { label: "Donating services", id: "donating_services" },
104
- { label: "Giving days", id: "giving_days" },
105
- { label: "Crowdfunding & appeals", id: "crowdfunding" },
106
- { label: "Peer 2 peer fundraising", id: "peer_fundraising" },
107
- ],
108
- action: {
109
- label: "Become a partner (free)",
110
- id: "become_a_partner",
111
- analyticsId: "becomeAPartner",
112
- },
113
- },
114
- ]} links={[
115
- { label: "About", id: "about" },
116
- { label: "Help", id: "help" },
117
- { label: "Blog & Press", id: "blog-press" },
118
- ]} stats={[
119
- {
120
- label: "Members",
121
- id: "nav-expand-members",
122
- value: "302, 657",
123
- logo: circle,
124
- },
125
- {
126
- label: "Causes",
127
- id: "nav-expand-causes",
128
- value: "68, 553",
129
- logo: circle,
130
- },
131
- {
132
- label: "Raised",
133
- id: "nav-expand-raised",
134
- value: "$100 Million +",
135
- logo: circle,
136
- },
137
- ]} cta={{
138
- color: "primary",
139
- onClick: action("onClick"),
140
- children: "Start fundraising",
141
- analyticsId: "startFundraising",
142
- }} user={isSignedIn
143
- ? {
144
- name: "Adorable Puppy",
145
- avatar: {
146
- src: avatar,
147
- },
148
- }
149
- : null} search={{ onSearch: action("search") }} login={{ onLogin: () => setSignedIn(true) }} userMenu={[
150
- {
151
- icon: { icon: "perm_identity" },
152
- label: "My dashboard",
153
- onClick: action("dashboard"),
154
- },
155
- {
156
- icon: { icon: "favorite_border" },
157
- label: "Activity",
158
- onClick: action("activity"),
159
- submenu: [
160
- {
161
- label: "Fundraising pages",
162
- },
163
- {
164
- label: "Favourite charities",
165
- },
166
- ],
167
- },
168
- {
169
- icon: { icon: "favorite_border" },
170
- label: "My campaigns",
171
- onClick: action("my campaigns"),
172
- },
173
- {
174
- icon: { icon: "settings", iconSet: "material-icons-outlined" },
175
- label: "Account settings",
176
- onClick: action("settings"),
177
- submenu: [
178
- {
179
- label: "Profile",
180
- },
181
- {
182
- label: "Manage Connections",
183
- },
184
- ],
185
- },
186
- {
187
- icon: { icon: "exit_to_app" },
188
- label: "Sign out",
189
- onClick: () => setSignedIn(false),
190
- },
191
- ]}/>);
192
- }
193
- export const full = () => <NavigationDemo />;
194
- full.story = {
195
- name: "full navigation",
196
- };
197
- export const list = () => (<BackgroundContainer>
198
- <NavigationList items={[
199
- { label: "Schools", id: "schools" },
200
- { label: "Cancer", id: "cancer" },
201
- { label: "Pets & animals", id: "pets_animals" },
202
- { label: "Help a friend", id: "help_friend" },
203
- { label: "Marathon runs", id: "marathon" },
204
- { label: "See all fundraising ideas", id: "see all" },
205
- ].map(item => ({ ...item, onClick: () => action("click")(item.id) }))}/>
206
- </BackgroundContainer>);
207
- list.story = {
208
- name: "navigation list",
209
- };
210
- export const listLarge = () => (<BackgroundContainer>
211
- <NavigationList size="large" items={[
212
- { label: "Schools", id: "schools" },
213
- { label: "Cancer", id: "cancer" },
214
- { label: "Pets & animals", id: "pets_animals" },
215
- { label: "Help a friend", id: "help_friend" },
216
- { label: "Marathon runs", id: "marathon" },
217
- { label: "See all fundraising ideas", id: "see all" },
218
- ].map(item => ({ ...item, onClick: () => action("click")(item.id) }))}/>
219
- </BackgroundContainer>);
220
- listLarge.story = {
221
- name: "navigation list (large)",
222
- };
223
- export const menu = () => (<BackgroundContainer>
224
- <NavigationMenu links={[
225
- { label: "For a person", id: "person" },
226
- { label: "For a charity", id: "charity" },
227
- { label: "Find a charity", id: "find_charity" },
228
- { label: "Fundraising ideas", id: "fundraising_ideas", more: true },
229
- { label: "Team fundraising", id: "team_fundraising" },
230
- { label: "How it works", id: "how_it_works" },
231
- ].map(link => ({ ...link, onClick: () => action("click")(link.id) }))} sublinks={[
232
- { label: "Schools", id: "schools" },
233
- { label: "Cancer", id: "cancer" },
234
- { label: "Pets & animals", id: "pets_animals" },
235
- { label: "Help a friend", id: "help_friend" },
236
- { label: "Marathon runs", id: "marathon" },
237
- { label: "See all fundraising ideas", id: "see all" },
238
- ].map(link => ({ ...link, onClick: () => action("click")(link.id) }))} action={{
239
- label: "Start fundraising",
240
- id: "start_fundraising",
241
- onClick: () => action("click")("start_fundraising"),
242
- }} active="fundraising_ideas" onClickItem={action("click")}/>
243
- </BackgroundContainer>);
244
- menu.story = {
245
- name: "navigation menu",
246
- };
247
- export const expanded = () => (<NavigationExpanded links={[
248
- { label: "About", id: "about" },
249
- { label: "Help", id: "help" },
250
- { label: "Blog & Press", id: "blog-press" },
251
- ].map(link => ({ ...link, onClick: () => action("click")(link.id) }))} onRequestClose={() => { }}/>);
252
- expanded.story = {
253
- name: "navigation expanded",
254
- };
255
- export const search = () => (<BackgroundContainer>
256
- <NavigationSearchDemo />
257
- </BackgroundContainer>);
258
- search.story = {
259
- name: "navigation search",
260
- };
@@ -1,2 +0,0 @@
1
- export { default as PhoneNumberField } from "./phone-number-field";
2
- export * from "./util";
@@ -1,2 +0,0 @@
1
- export { default as PhoneNumberField } from "./phone-number-field";
2
- export * from "./util";
@@ -1,50 +0,0 @@
1
- import React from "react";
2
- import countries from "i18n-iso-countries";
3
- import en from "i18n-iso-countries/langs/en.json";
4
- import { AsYouType } from "libphonenumber-js";
5
- import { FieldLabel, FieldHelperText } from "../field-helpers";
6
- import { ComboField, ComboFieldExpander } from "../combo-field";
7
- import { Box } from "../layout";
8
- import { Select } from "../select";
9
- import { TextField } from "../text-field";
10
- countries.registerLocale(en);
11
- const COUNTRY_CODES = Object.keys(countries.getAlpha2Codes()).sort();
12
- function PhoneNumberField({ onChange, values, names = {
13
- number: "number",
14
- countryCallingCode: "countryCallingCode",
15
- country: "country",
16
- }, error, onBlur, helperText, label, required, defaultCountry = "AU", }) {
17
- const format = (text, c) => {
18
- const typer = new AsYouType(c || defaultCountry);
19
- const formatted = typer.input(text);
20
- let result = typer.getNumber();
21
- if (result && result.isValid()) {
22
- // When the user has typed in a full valid number,
23
- // emit the country calling code and set the country explicitly
24
- onChange(result.country, names.country);
25
- onChange(result.format("NATIONAL"), names.number);
26
- onChange(result.countryCallingCode, names.countryCallingCode);
27
- }
28
- else {
29
- onChange(formatted, names.number);
30
- }
31
- };
32
- const handleCountryChange = (e) => {
33
- onChange(e.target.value || "", names.country);
34
- format(values.number, e.target.value);
35
- };
36
- const handleTextChange = (e) => {
37
- format(e.target.value, values.country);
38
- };
39
- return (<Box>
40
- {label ? <FieldLabel required={required}>{label}</FieldLabel> : null}
41
- <ComboField>
42
- <Select options={COUNTRY_CODES} value={values.country} onChange={handleCountryChange} noArrow onBlur={onBlur} required={required}/>
43
- <ComboFieldExpander>
44
- <TextField type="tel" value={values.number} onChange={handleTextChange} name={names.number} onBlur={onBlur} error={!!error} required={required}/>
45
- </ComboFieldExpander>
46
- </ComboField>
47
- {helperText ? (<FieldHelperText error={error}>{helperText}</FieldHelperText>) : null}
48
- </Box>);
49
- }
50
- export default PhoneNumberField;
@@ -1,23 +0,0 @@
1
- import React, { useState } from "react";
2
- import { withKnobs, boolean, text } from "@storybook/addon-knobs";
3
- import CenterDecorator from "../../utils/center-decorator";
4
- import PhoneNumberField from "./phone-number-field";
5
- export default {
6
- title: "PhoneNumberField",
7
- decorators: [CenterDecorator, withKnobs],
8
- };
9
- export const PhoneNumberFieldStory = () => {
10
- const [values, setValues] = useState({
11
- number: "",
12
- countryCallingCode: "",
13
- country: "",
14
- });
15
- const label = text("Label", "Phone number");
16
- const required = boolean("Required", false);
17
- const helperText = text("Helper Text", "Enter an Australian or international phone number.");
18
- const error = text("Error text", "");
19
- return (<PhoneNumberField values={values} onChange={(value, name) => setValues(values => ({ ...values, [name]: value }))} label={label} helperText={helperText} required={required} error={error || null}/>);
20
- };
21
- PhoneNumberFieldStory.story = {
22
- name: "default",
23
- };
@@ -1,2 +0,0 @@
1
- import { PhoneNumber, CountryCode } from "libphonenumber-js";
2
- export declare function parseNationalPhoneNumber(phoneNumber: string, countryCallingCode: string, defaultCountry?: CountryCode): PhoneNumber | null;
@@ -1,19 +0,0 @@
1
- import { parsePhoneNumberFromString, } from "libphonenumber-js";
2
- export function parseNationalPhoneNumber(phoneNumber, countryCallingCode, defaultCountry) {
3
- let number;
4
- // Try with the country code
5
- if (countryCallingCode) {
6
- number = parsePhoneNumberFromString("+" + countryCallingCode + phoneNumber, defaultCountry);
7
- if (number && number.isValid())
8
- return number;
9
- }
10
- // Try clipping the intital "0" from the number, if there is one
11
- if ((countryCallingCode && phoneNumber.startsWith("0"), defaultCountry)) {
12
- number = parsePhoneNumberFromString("+" + countryCallingCode + phoneNumber.substr(1));
13
- if (number && number.isValid())
14
- return number;
15
- }
16
- // Finally just try the number by itself
17
- number = parsePhoneNumberFromString(phoneNumber, defaultCountry);
18
- return number || null;
19
- }
@@ -1,3 +0,0 @@
1
- export { default as PhoneNumberInput } from "./phone-number-input";
2
- export { default as PhoneNumberField } from "./phone-number-field";
3
- export * from "./util";
@@ -1,23 +0,0 @@
1
- import React from "react";
2
- import { CountryCode } from "libphonenumber-js";
3
- declare type PhoneNumberFieldProps = {
4
- values: {
5
- number: string;
6
- countryCallingCode: string;
7
- country: string;
8
- };
9
- names?: {
10
- number: string;
11
- countryCallingCode: string;
12
- country: string;
13
- };
14
- onChange: (value: string, name: string) => void;
15
- label?: React.ReactNode;
16
- error?: string | null;
17
- onBlur?: (e: React.FocusEvent) => void;
18
- helperText?: React.ReactNode;
19
- required?: boolean;
20
- defaultCountry?: CountryCode;
21
- };
22
- declare function PhoneNumberField({ onChange, values, names, error, onBlur, helperText, label, required, defaultCountry, }: PhoneNumberFieldProps): JSX.Element;
23
- export default PhoneNumberField;
@@ -1,50 +0,0 @@
1
- import React from "react";
2
- import countries from "i18n-iso-countries";
3
- import en from "i18n-iso-countries/langs/en.json";
4
- import { AsYouType } from "libphonenumber-js";
5
- import { FieldLabel, FieldHelperText } from "../field-helpers";
6
- import { ComboField, ComboFieldExpander } from "../combo-field";
7
- import { Box } from "../layout";
8
- import { Select } from "../select";
9
- import { TextField } from "../text-field";
10
- countries.registerLocale(en);
11
- const COUNTRY_CODES = Object.keys(countries.getAlpha2Codes()).sort();
12
- function PhoneNumberField({ onChange, values, names = {
13
- number: "number",
14
- countryCallingCode: "countryCallingCode",
15
- country: "country",
16
- }, error, onBlur, helperText, label, required, defaultCountry = "AU", }) {
17
- const format = (text, c) => {
18
- const typer = new AsYouType(c || defaultCountry);
19
- const formatted = typer.input(text);
20
- let result = typer.getNumber();
21
- if (result && result.isValid()) {
22
- // When the user has typed in a full valid number,
23
- // emit the country calling code and set the country explicitly
24
- onChange(result.country, names.country);
25
- onChange(result.format("NATIONAL"), names.number);
26
- onChange(result.countryCallingCode, names.countryCallingCode);
27
- }
28
- else {
29
- onChange(formatted, names.number);
30
- }
31
- };
32
- const handleCountryChange = (e) => {
33
- onChange(e.target.value || "", names.country);
34
- format(values.number, e.target.value);
35
- };
36
- const handleTextChange = (e) => {
37
- format(e.target.value, values.country);
38
- };
39
- return (<Box>
40
- {label ? <FieldLabel required={required}>{label}</FieldLabel> : null}
41
- <ComboField>
42
- <Select options={COUNTRY_CODES} value={values.country} onChange={handleCountryChange} noArrow onBlur={onBlur} required={required}/>
43
- <ComboFieldExpander>
44
- <TextField type="tel" value={values.number} onChange={handleTextChange} name={names.number} onBlur={onBlur} error={!!error} required={required}/>
45
- </ComboFieldExpander>
46
- </ComboField>
47
- {helperText ? (<FieldHelperText error={error}>{helperText}</FieldHelperText>) : null}
48
- </Box>);
49
- }
50
- export default PhoneNumberField;
@@ -1,16 +0,0 @@
1
- import React, { useState } from "react";
2
- import CenterDecorator from "../../utils/center-decorator";
3
- import PhoneNumberInput from "./phone-number-input";
4
- export default {
5
- title: "PhoneNumberInput",
6
- decorators: [CenterDecorator],
7
- };
8
- export const PhoneNumberInputStory = () => {
9
- const [values, setValues] = useState("");
10
- return (<div style={{ width: "313px" }}>
11
- <PhoneNumberInput value={values} onChange={setValues} preferredCountries={["au"]} label="Phone number" placeholder="Enter phone number" helperText="Enter an Australian or international phone number."/>
12
- </div>);
13
- };
14
- PhoneNumberInputStory.story = {
15
- name: "default",
16
- };
@@ -1,48 +0,0 @@
1
- import React, { Fragment } from "react";
2
- import classnames from "classnames";
3
- import { FieldLabel, FieldHelperText } from "../field-helpers";
4
- import { useTheme, getColorToken } from "../../theme/theme";
5
- import PhoneInput from "react-phone-input-2";
6
- const PhoneNumberInput = ({ value, onChange, buttonClass, inputClass, preferredCountries, label, placeholder, required, helperText, error, }) => {
7
- const theme = useTheme();
8
- const setColor = getColorToken(theme, "foreground", "primary");
9
- return (<Fragment>
10
- {label ? <FieldLabel required={required}>{label}</FieldLabel> : null}
11
- <PhoneInput inputClass={classnames("number-custom-input", inputClass)} buttonClass={classnames("number-custom-button", buttonClass)} placeholder={placeholder} value={value} onChange={(res) => onChange(res)} preferredCountries={preferredCountries}/>
12
- {helperText ? (<FieldHelperText error={error}>{helperText}</FieldHelperText>) : (<FieldHelperText error={error}/>)}
13
- <style jsx>{`
14
- :global(.number-custom-input) {
15
- height: 48px !important;
16
- padding-left: 66px !important;
17
- font-family: ${theme.typography.fontFamily.brand};
18
- border: ${error && "1px solid #b00020 !important"};
19
- }
20
- :global(.number-custom-input:hover) {
21
- border: 1px solid black !important;
22
- }
23
- :global(.number-custom-input:focus) {
24
- border: 2px solid ${setColor} !important;
25
- }
26
-
27
- :global(.number-custom-button) {
28
- background: none !important;
29
- padding-right: 14px !important;
30
- border: ${error && "1px solid #b00020 !important"};
31
- }
32
- :global(.number-custom-button:hover) {
33
- border: 1px solid black !important;
34
- }
35
- :global(.number-custom-button:focus) {
36
- border: 2px solid ${setColor} !important;
37
- }
38
- :global(.selected-flag) {
39
- padding: 0px 0px 0 16px !important;
40
- background: none !important;
41
- }
42
- :global(.dial-code, .divider) {
43
- display: none;
44
- }
45
- `}</style>
46
- </Fragment>);
47
- };
48
- export default PhoneNumberInput;
@@ -1,19 +0,0 @@
1
- import { parsePhoneNumberFromString, } from "libphonenumber-js";
2
- export function parseNationalPhoneNumber(phoneNumber, countryCallingCode, defaultCountry) {
3
- let number;
4
- // Try with the country code
5
- if (countryCallingCode) {
6
- number = parsePhoneNumberFromString("+" + countryCallingCode + phoneNumber, defaultCountry);
7
- if (number && number.isValid())
8
- return number;
9
- }
10
- // Try clipping the intital "0" from the number, if there is one
11
- if ((countryCallingCode && phoneNumber.startsWith("0"), defaultCountry)) {
12
- number = parsePhoneNumberFromString("+" + countryCallingCode + phoneNumber.substr(1));
13
- if (number && number.isValid())
14
- return number;
15
- }
16
- // Finally just try the number by itself
17
- number = parsePhoneNumberFromString(phoneNumber, defaultCountry);
18
- return number || null;
19
- }