@rh-support/components 2.0.4 → 2.0.7-beta.1

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 (286) hide show
  1. package/lib/cjs/AlertMessage/AlertMessage.js +5 -5
  2. package/lib/cjs/AlertMessage/index.d.ts +0 -1
  3. package/lib/cjs/AlertMessage/index.d.ts.map +1 -1
  4. package/lib/cjs/AlertMessage/index.js +1 -1
  5. package/lib/cjs/ConfirmationModal/ConfirmationContext.d.ts +0 -1
  6. package/lib/cjs/ConfirmationModal/ConfirmationContext.d.ts.map +1 -1
  7. package/lib/cjs/ConfirmationModal/ConfirmationContext.js +13 -41
  8. package/lib/cjs/ConfirmationModal/ConfirmationDialog.d.ts +4 -2
  9. package/lib/cjs/ConfirmationModal/ConfirmationDialog.d.ts.map +1 -1
  10. package/lib/cjs/ConfirmationModal/ConfirmationDialog.js +7 -6
  11. package/lib/cjs/ConfirmationModal/ConfirmationModal.stories.d.ts +0 -6
  12. package/lib/cjs/ConfirmationModal/ConfirmationModal.stories.d.ts.map +1 -1
  13. package/lib/cjs/ConfirmationModal/ConfirmationModal.stories.js +29 -69
  14. package/lib/cjs/CoverSpinner/CoverSpinner.d.ts +0 -1
  15. package/lib/cjs/CoverSpinner/CoverSpinner.d.ts.map +1 -1
  16. package/lib/cjs/CoverSpinner/CoverSpinner.js +1 -1
  17. package/lib/cjs/CustomContentLoader/CustomContentLoader.d.ts.map +1 -1
  18. package/lib/cjs/CustomContentLoader/CustomContentLoader.js +25 -25
  19. package/lib/cjs/CustomTextInput/CustomTextInput.d.ts +0 -1
  20. package/lib/cjs/CustomTextInput/CustomTextInput.d.ts.map +1 -1
  21. package/lib/cjs/CustomTextInput/CustomTextInput.js +10 -21
  22. package/lib/cjs/DropDownList/AsyncDropDownList.js +5 -5
  23. package/lib/cjs/DropDownList/DropDownList.d.ts +0 -1
  24. package/lib/cjs/DropDownList/DropDownList.d.ts.map +1 -1
  25. package/lib/cjs/DropDownList/DropDownList.js +45 -75
  26. package/lib/cjs/DropDownList/DropdownWrapper.js +7 -18
  27. package/lib/cjs/DropDownList/MultiSelectDropdownList.js +3 -3
  28. package/lib/cjs/DropDownList/SearchableList.d.ts +1 -0
  29. package/lib/cjs/DropDownList/SearchableList.d.ts.map +1 -1
  30. package/lib/cjs/DropDownList/SearchableList.js +45 -55
  31. package/lib/cjs/DropDownList/SelectList.js +15 -26
  32. package/lib/cjs/DropDownList/async.js +28 -38
  33. package/lib/cjs/DropDownList/dropdownList.css +1 -1
  34. package/lib/cjs/DropDownList/dropdownUtils.d.ts.map +1 -1
  35. package/lib/cjs/DropDownList/dropdownUtils.js +9 -19
  36. package/lib/cjs/DropDownList/types.d.ts +1 -0
  37. package/lib/cjs/DropDownList/types.d.ts.map +1 -1
  38. package/lib/cjs/DropDownList/withMulti.js +15 -26
  39. package/lib/cjs/ErrorBoundary/ErrorBoundary.js +18 -47
  40. package/lib/cjs/ErrorBoundary/ErrorBoundaryFallbackComponent.d.ts +0 -1
  41. package/lib/cjs/ErrorBoundary/ErrorBoundaryFallbackComponent.d.ts.map +1 -1
  42. package/lib/cjs/ErrorBoundary/ErrorBoundaryFallbackComponent.js +10 -10
  43. package/lib/cjs/ErrorPages/Generic403.d.ts +0 -1
  44. package/lib/cjs/ErrorPages/Generic403.d.ts.map +1 -1
  45. package/lib/cjs/ErrorPages/Generic403.js +2 -2
  46. package/lib/cjs/FeedbackForm/FeedbackForm.d.ts +0 -1
  47. package/lib/cjs/FeedbackForm/FeedbackForm.d.ts.map +1 -1
  48. package/lib/cjs/FeedbackForm/FeedbackForm.js +24 -52
  49. package/lib/cjs/Functional/CaseContactsSelectorExternal.d.ts.map +1 -1
  50. package/lib/cjs/Functional/CaseContactsSelectorExternal.js +81 -154
  51. package/lib/cjs/InlineEdit/InlineEdit.d.ts +1 -0
  52. package/lib/cjs/InlineEdit/InlineEdit.d.ts.map +1 -1
  53. package/lib/cjs/InlineEdit/InlineEdit.js +58 -144
  54. package/lib/cjs/InlineEdit/NewInlineEdit.d.ts +1 -0
  55. package/lib/cjs/InlineEdit/NewInlineEdit.d.ts.map +1 -1
  56. package/lib/cjs/InlineEdit/NewInlineEdit.js +62 -147
  57. package/lib/cjs/InlineEdit/inlineEdit.css +4 -0
  58. package/lib/cjs/InlineEdit/newInlineEdit.css +4 -0
  59. package/lib/cjs/LanguageSelector/LanguageSelector.d.ts +0 -1
  60. package/lib/cjs/LanguageSelector/LanguageSelector.d.ts.map +1 -1
  61. package/lib/cjs/LanguageSelector/LanguageSelector.js +10 -26
  62. package/lib/cjs/LoadingDots/LoadingDots.d.ts +0 -1
  63. package/lib/cjs/LoadingDots/LoadingDots.d.ts.map +1 -1
  64. package/lib/cjs/LoadingDots/LoadingDots.js +4 -4
  65. package/lib/cjs/LoadingDots/index.d.ts +0 -1
  66. package/lib/cjs/LoadingDots/index.d.ts.map +1 -1
  67. package/lib/cjs/LoadingDots/index.js +1 -1
  68. package/lib/cjs/LoadingIndicator/LoadingIndicator.d.ts +0 -1
  69. package/lib/cjs/LoadingIndicator/LoadingIndicator.d.ts.map +1 -1
  70. package/lib/cjs/LoadingIndicator/LoadingIndicator.js +3 -3
  71. package/lib/cjs/LoginModal/LoginModal.d.ts +0 -1
  72. package/lib/cjs/LoginModal/LoginModal.d.ts.map +1 -1
  73. package/lib/cjs/LoginModal/LoginModal.js +3 -3
  74. package/lib/cjs/MarkdownEditor/MarkdownEditor.js +113 -165
  75. package/lib/cjs/MoreOrLess/MoreOrLess.js +20 -40
  76. package/lib/cjs/PaginatedList/PaginatedList.js +15 -31
  77. package/lib/cjs/PaginationCompact/PaginationCompact.d.ts +0 -1
  78. package/lib/cjs/PaginationCompact/PaginationCompact.d.ts.map +1 -1
  79. package/lib/cjs/PaginationCompact/PaginationCompact.js +14 -31
  80. package/lib/cjs/PhoneInput/CountryData.d.ts +3 -0
  81. package/lib/cjs/PhoneInput/CountryData.d.ts.map +1 -0
  82. package/lib/cjs/PhoneInput/CountryData.js +583 -0
  83. package/lib/cjs/PhoneInput/PhoneInput.d.ts +19 -0
  84. package/lib/cjs/PhoneInput/PhoneInput.d.ts.map +1 -0
  85. package/lib/cjs/PhoneInput/PhoneInput.js +284 -0
  86. package/lib/cjs/PhoneInput/PhoneInput.scss +753 -0
  87. package/lib/cjs/PhoneInput/flags.png +0 -0
  88. package/lib/cjs/PhoneInput/index.d.ts +2 -0
  89. package/lib/cjs/PhoneInput/index.d.ts.map +1 -0
  90. package/lib/cjs/PhoneInput/index.js +13 -0
  91. package/lib/cjs/ProgressBar/CircularProgressBar/CircularProgressBar.d.ts +0 -1
  92. package/lib/cjs/ProgressBar/CircularProgressBar/CircularProgressBar.d.ts.map +1 -1
  93. package/lib/cjs/ProgressBar/CircularProgressBar/CircularProgressBar.js +14 -14
  94. package/lib/cjs/ProgressBar/CircularProgressBar/Path.js +20 -18
  95. package/lib/cjs/ProgressBar/ProgressBar.js +8 -19
  96. package/lib/cjs/PromisifyModal/PromisifyModal.js +19 -36
  97. package/lib/cjs/SubscriptionAbuse/SubscriptionAbuseModal.d.ts +0 -1
  98. package/lib/cjs/SubscriptionAbuse/SubscriptionAbuseModal.d.ts.map +1 -1
  99. package/lib/cjs/SubscriptionAbuse/SubscriptionAbuseModal.js +5 -5
  100. package/lib/cjs/SubscriptionAbuse/const.d.ts +0 -1
  101. package/lib/cjs/SubscriptionAbuse/const.d.ts.map +1 -1
  102. package/lib/cjs/SubscriptionAbuse/const.js +3 -3
  103. package/lib/cjs/SupportFeedbackForm/SupportFeedbackForm.d.ts +0 -1
  104. package/lib/cjs/SupportFeedbackForm/SupportFeedbackForm.d.ts.map +1 -1
  105. package/lib/cjs/SupportFeedbackForm/SupportFeedbackForm.js +8 -24
  106. package/lib/cjs/SupportFeedbackForm/SupportFeedbackModal.d.ts +0 -1
  107. package/lib/cjs/SupportFeedbackForm/SupportFeedbackModal.d.ts.map +1 -1
  108. package/lib/cjs/SupportFeedbackForm/SupportFeedbackModal.js +50 -120
  109. package/lib/cjs/Table/PFTable.js +52 -89
  110. package/lib/cjs/Table/Table.js +12 -29
  111. package/lib/cjs/Table/TableColumnSelector.d.ts +0 -1
  112. package/lib/cjs/Table/TableColumnSelector.d.ts.map +1 -1
  113. package/lib/cjs/Table/TableColumnSelector.js +14 -15
  114. package/lib/cjs/Table/TablePagination.d.ts +0 -1
  115. package/lib/cjs/Table/TablePagination.d.ts.map +1 -1
  116. package/lib/cjs/Table/TablePagination.js +8 -8
  117. package/lib/cjs/Table/TableProvider.js +6 -6
  118. package/lib/cjs/TermsAndConditions/AcceptTermsModal.d.ts +0 -1
  119. package/lib/cjs/TermsAndConditions/AcceptTermsModal.d.ts.map +1 -1
  120. package/lib/cjs/TermsAndConditions/AcceptTermsModal.js +46 -100
  121. package/lib/cjs/TextAreaAutosize/TextAreaAutosize.js +35 -62
  122. package/lib/cjs/TextAreaResizable/TextAreaResizable.js +12 -25
  123. package/lib/cjs/ToastNotification/ToastNotification.js +35 -70
  124. package/lib/cjs/TopContentSearch/TopContentSearch.js +48 -113
  125. package/lib/cjs/ValueChangedIcon/ValueChangedIcon.js +13 -29
  126. package/lib/cjs/helperFunctions/errorMessage.d.ts +0 -1
  127. package/lib/cjs/helperFunctions/errorMessage.d.ts.map +1 -1
  128. package/lib/cjs/helperFunctions/errorMessage.js +13 -13
  129. package/lib/cjs/hooks/useBreakpoint.js +26 -43
  130. package/lib/cjs/hooks/useCopyToClipboard.js +8 -24
  131. package/lib/cjs/hooks/useDebounce.js +13 -38
  132. package/lib/cjs/hooks/useFetch.js +47 -123
  133. package/lib/cjs/hooks/useForceUpdate.js +2 -18
  134. package/lib/cjs/hooks/useForkRef.js +3 -3
  135. package/lib/cjs/hooks/useIsMounted.js +4 -4
  136. package/lib/cjs/hooks/useLRUCache.js +11 -11
  137. package/lib/cjs/hooks/useLocalStorage.js +7 -23
  138. package/lib/cjs/hooks/useOnScreen.js +5 -24
  139. package/lib/cjs/hooks/usePolling.js +8 -30
  140. package/lib/cjs/hooks/usePrevious.js +3 -3
  141. package/lib/cjs/hooks/useTitle.js +4 -4
  142. package/lib/cjs/hooks/useUndo.js +49 -72
  143. package/lib/cjs/index.d.ts +1 -0
  144. package/lib/cjs/index.d.ts.map +1 -1
  145. package/lib/cjs/index.js +1 -0
  146. package/lib/esm/AlertMessage/AlertMessage.js +2 -2
  147. package/lib/esm/AlertMessage/index.d.ts +0 -1
  148. package/lib/esm/AlertMessage/index.d.ts.map +1 -1
  149. package/lib/esm/AlertMessage/index.js +1 -1
  150. package/lib/esm/ConfirmationModal/ConfirmationContext.d.ts +0 -1
  151. package/lib/esm/ConfirmationModal/ConfirmationContext.d.ts.map +1 -1
  152. package/lib/esm/ConfirmationModal/ConfirmationDialog.d.ts +4 -2
  153. package/lib/esm/ConfirmationModal/ConfirmationDialog.d.ts.map +1 -1
  154. package/lib/esm/ConfirmationModal/ConfirmationDialog.js +3 -2
  155. package/lib/esm/ConfirmationModal/ConfirmationModal.stories.d.ts +0 -6
  156. package/lib/esm/ConfirmationModal/ConfirmationModal.stories.d.ts.map +1 -1
  157. package/lib/esm/ConfirmationModal/ConfirmationModal.stories.js +19 -18
  158. package/lib/esm/CoverSpinner/CoverSpinner.d.ts +0 -1
  159. package/lib/esm/CoverSpinner/CoverSpinner.d.ts.map +1 -1
  160. package/lib/esm/CustomContentLoader/CustomContentLoader.d.ts.map +1 -1
  161. package/lib/esm/CustomContentLoader/CustomContentLoader.js +23 -23
  162. package/lib/esm/CustomTextInput/CustomTextInput.d.ts +0 -1
  163. package/lib/esm/CustomTextInput/CustomTextInput.d.ts.map +1 -1
  164. package/lib/esm/CustomTextInput/CustomTextInput.js +1 -1
  165. package/lib/esm/DropDownList/DropDownList.d.ts +0 -1
  166. package/lib/esm/DropDownList/DropDownList.d.ts.map +1 -1
  167. package/lib/esm/DropDownList/SearchableList.d.ts +1 -0
  168. package/lib/esm/DropDownList/SearchableList.d.ts.map +1 -1
  169. package/lib/esm/DropDownList/SearchableList.js +6 -2
  170. package/lib/esm/DropDownList/dropdownList.css +1 -1
  171. package/lib/esm/DropDownList/dropdownUtils.d.ts.map +1 -1
  172. package/lib/esm/DropDownList/dropdownUtils.js +1 -0
  173. package/lib/esm/DropDownList/types.d.ts +1 -0
  174. package/lib/esm/DropDownList/types.d.ts.map +1 -1
  175. package/lib/esm/ErrorBoundary/ErrorBoundaryFallbackComponent.d.ts +0 -1
  176. package/lib/esm/ErrorBoundary/ErrorBoundaryFallbackComponent.d.ts.map +1 -1
  177. package/lib/esm/ErrorPages/Generic403.d.ts +0 -1
  178. package/lib/esm/ErrorPages/Generic403.d.ts.map +1 -1
  179. package/lib/esm/FeedbackForm/FeedbackForm.d.ts +0 -1
  180. package/lib/esm/FeedbackForm/FeedbackForm.d.ts.map +1 -1
  181. package/lib/esm/Functional/CaseContactsSelectorExternal.d.ts.map +1 -1
  182. package/lib/esm/Functional/CaseContactsSelectorExternal.js +2 -2
  183. package/lib/esm/InlineEdit/InlineEdit.d.ts +1 -0
  184. package/lib/esm/InlineEdit/InlineEdit.d.ts.map +1 -1
  185. package/lib/esm/InlineEdit/InlineEdit.js +3 -3
  186. package/lib/esm/InlineEdit/NewInlineEdit.d.ts +1 -0
  187. package/lib/esm/InlineEdit/NewInlineEdit.d.ts.map +1 -1
  188. package/lib/esm/InlineEdit/NewInlineEdit.js +3 -3
  189. package/lib/esm/InlineEdit/inlineEdit.css +4 -0
  190. package/lib/esm/InlineEdit/newInlineEdit.css +4 -0
  191. package/lib/esm/LanguageSelector/LanguageSelector.d.ts +0 -1
  192. package/lib/esm/LanguageSelector/LanguageSelector.d.ts.map +1 -1
  193. package/lib/esm/LoadingDots/LoadingDots.d.ts +0 -1
  194. package/lib/esm/LoadingDots/LoadingDots.d.ts.map +1 -1
  195. package/lib/esm/LoadingDots/LoadingDots.js +1 -1
  196. package/lib/esm/LoadingDots/index.d.ts +0 -1
  197. package/lib/esm/LoadingDots/index.d.ts.map +1 -1
  198. package/lib/esm/LoadingDots/index.js +1 -1
  199. package/lib/esm/LoadingIndicator/LoadingIndicator.d.ts +0 -1
  200. package/lib/esm/LoadingIndicator/LoadingIndicator.d.ts.map +1 -1
  201. package/lib/esm/LoginModal/LoginModal.d.ts +0 -1
  202. package/lib/esm/LoginModal/LoginModal.d.ts.map +1 -1
  203. package/lib/esm/PaginationCompact/PaginationCompact.d.ts +0 -1
  204. package/lib/esm/PaginationCompact/PaginationCompact.d.ts.map +1 -1
  205. package/lib/esm/PhoneInput/CountryData.d.ts +3 -0
  206. package/lib/esm/PhoneInput/CountryData.d.ts.map +1 -0
  207. package/lib/esm/PhoneInput/CountryData.js +580 -0
  208. package/lib/esm/PhoneInput/PhoneInput.d.ts +19 -0
  209. package/lib/esm/PhoneInput/PhoneInput.d.ts.map +1 -0
  210. package/lib/esm/PhoneInput/PhoneInput.js +257 -0
  211. package/lib/esm/PhoneInput/PhoneInput.scss +753 -0
  212. package/lib/esm/PhoneInput/flags.png +0 -0
  213. package/lib/esm/PhoneInput/index.d.ts +2 -0
  214. package/lib/esm/PhoneInput/index.d.ts.map +1 -0
  215. package/lib/esm/PhoneInput/index.js +1 -0
  216. package/lib/esm/ProgressBar/CircularProgressBar/CircularProgressBar.d.ts +0 -1
  217. package/lib/esm/ProgressBar/CircularProgressBar/CircularProgressBar.d.ts.map +1 -1
  218. package/lib/esm/SubscriptionAbuse/SubscriptionAbuseModal.d.ts +0 -1
  219. package/lib/esm/SubscriptionAbuse/SubscriptionAbuseModal.d.ts.map +1 -1
  220. package/lib/esm/SubscriptionAbuse/const.d.ts +0 -1
  221. package/lib/esm/SubscriptionAbuse/const.d.ts.map +1 -1
  222. package/lib/esm/SupportFeedbackForm/SupportFeedbackForm.d.ts +0 -1
  223. package/lib/esm/SupportFeedbackForm/SupportFeedbackForm.d.ts.map +1 -1
  224. package/lib/esm/SupportFeedbackForm/SupportFeedbackModal.d.ts +0 -1
  225. package/lib/esm/SupportFeedbackForm/SupportFeedbackModal.d.ts.map +1 -1
  226. package/lib/esm/Table/TableColumnSelector.d.ts +0 -1
  227. package/lib/esm/Table/TableColumnSelector.d.ts.map +1 -1
  228. package/lib/esm/Table/TablePagination.d.ts +0 -1
  229. package/lib/esm/Table/TablePagination.d.ts.map +1 -1
  230. package/lib/esm/TermsAndConditions/AcceptTermsModal.d.ts +0 -1
  231. package/lib/esm/TermsAndConditions/AcceptTermsModal.d.ts.map +1 -1
  232. package/lib/esm/TextAreaResizable/TextAreaResizable.js +1 -1
  233. package/lib/esm/helperFunctions/errorMessage.d.ts +0 -1
  234. package/lib/esm/helperFunctions/errorMessage.d.ts.map +1 -1
  235. package/lib/esm/index.d.ts +1 -0
  236. package/lib/esm/index.d.ts.map +1 -1
  237. package/lib/esm/index.js +1 -0
  238. package/package.json +16 -30
  239. package/lib/cjs/AlertMessage/AlertMessage.stories.d.ts +0 -12
  240. package/lib/cjs/AlertMessage/AlertMessage.stories.d.ts.map +0 -1
  241. package/lib/cjs/AlertMessage/AlertMessage.stories.js +0 -29
  242. package/lib/cjs/DropDownList/Dropdownlist.stories.d.ts +0 -17
  243. package/lib/cjs/DropDownList/Dropdownlist.stories.d.ts.map +0 -1
  244. package/lib/cjs/DropDownList/Dropdownlist.stories.js +0 -253
  245. package/lib/cjs/LoadingDots/LoadingDots.stories.d.ts +0 -10
  246. package/lib/cjs/LoadingDots/LoadingDots.stories.d.ts.map +0 -1
  247. package/lib/cjs/LoadingDots/LoadingDots.stories.js +0 -16
  248. package/lib/cjs/LoadingIndicator/LoadingIndicator.stories.d.ts +0 -11
  249. package/lib/cjs/LoadingIndicator/LoadingIndicator.stories.d.ts.map +0 -1
  250. package/lib/cjs/LoadingIndicator/LoadingIndicator.stories.js +0 -18
  251. package/lib/cjs/Table/PFTable.stories.d.ts +0 -20
  252. package/lib/cjs/Table/PFTable.stories.d.ts.map +0 -1
  253. package/lib/cjs/Table/PFTable.stories.js +0 -81
  254. package/lib/cjs/demo/Demo.css +0 -3
  255. package/lib/cjs/demo/Demo.d.ts +0 -13
  256. package/lib/cjs/demo/Demo.d.ts.map +0 -1
  257. package/lib/cjs/demo/Demo.js +0 -42
  258. package/lib/cjs/demo/Demo.md +0 -0
  259. package/lib/cjs/demo/Demo.scss +0 -3
  260. package/lib/cjs/demo/index.d.ts +0 -3
  261. package/lib/cjs/demo/index.d.ts.map +0 -1
  262. package/lib/cjs/demo/index.js +0 -23
  263. package/lib/esm/AlertMessage/AlertMessage.stories.d.ts +0 -12
  264. package/lib/esm/AlertMessage/AlertMessage.stories.d.ts.map +0 -1
  265. package/lib/esm/AlertMessage/AlertMessage.stories.js +0 -20
  266. package/lib/esm/DropDownList/Dropdownlist.stories.d.ts +0 -17
  267. package/lib/esm/DropDownList/Dropdownlist.stories.d.ts.map +0 -1
  268. package/lib/esm/DropDownList/Dropdownlist.stories.js +0 -156
  269. package/lib/esm/LoadingDots/LoadingDots.stories.d.ts +0 -10
  270. package/lib/esm/LoadingDots/LoadingDots.stories.d.ts.map +0 -1
  271. package/lib/esm/LoadingDots/LoadingDots.stories.js +0 -8
  272. package/lib/esm/LoadingIndicator/LoadingIndicator.stories.d.ts +0 -11
  273. package/lib/esm/LoadingIndicator/LoadingIndicator.stories.d.ts.map +0 -1
  274. package/lib/esm/LoadingIndicator/LoadingIndicator.stories.js +0 -9
  275. package/lib/esm/Table/PFTable.stories.d.ts +0 -20
  276. package/lib/esm/Table/PFTable.stories.d.ts.map +0 -1
  277. package/lib/esm/Table/PFTable.stories.js +0 -73
  278. package/lib/esm/demo/Demo.css +0 -3
  279. package/lib/esm/demo/Demo.d.ts +0 -13
  280. package/lib/esm/demo/Demo.d.ts.map +0 -1
  281. package/lib/esm/demo/Demo.js +0 -26
  282. package/lib/esm/demo/Demo.md +0 -0
  283. package/lib/esm/demo/Demo.scss +0 -3
  284. package/lib/esm/demo/index.d.ts +0 -3
  285. package/lib/esm/demo/index.d.ts.map +0 -1
  286. package/lib/esm/demo/index.js +0 -2
@@ -0,0 +1,284 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.PhoneInput = exports.getPhoneObj = void 0;
26
+ require("./PhoneInput.scss");
27
+ const react_core_1 = require("@patternfly/react-core");
28
+ const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
29
+ const isEqual_1 = __importDefault(require("lodash/isEqual"));
30
+ const react_1 = __importStar(require("react"));
31
+ const react_i18next_1 = require("react-i18next");
32
+ const CountryData_1 = require("./CountryData");
33
+ const PREFIX = '+';
34
+ const DEFAULT_MASK = '... ... ... ... ..';
35
+ const ALWAYS_DEFAULT_MASK = false;
36
+ // Getting Country phone format
37
+ function getMask(prefix, dialCode, predefinedMask, defaultMask, alwaysDefaultMask) {
38
+ if (!predefinedMask || alwaysDefaultMask) {
39
+ return prefix + ''.padEnd(dialCode.length, '.') + ' ' + defaultMask;
40
+ }
41
+ else {
42
+ return prefix + ''.padEnd(dialCode.length, '.') + ' ' + predefinedMask;
43
+ }
44
+ }
45
+ const initializedCountries = CountryData_1.COUNTRY_DATA.map((country) => {
46
+ const countryItem = {
47
+ name: country[0],
48
+ regions: country[1],
49
+ iso2: country[2],
50
+ countryCode: country[3],
51
+ dialCode: country[3],
52
+ format: getMask(PREFIX, country[3], country[4], DEFAULT_MASK, ALWAYS_DEFAULT_MASK),
53
+ priority: country[5] || 0,
54
+ areaCode: country[6] || [],
55
+ };
56
+ return countryItem;
57
+ });
58
+ // Formatting phone numbers according to country
59
+ const formatNumber = (fullPhoneNumber, localFormat) => {
60
+ if (isEmpty_1.default(fullPhoneNumber))
61
+ return '';
62
+ let localPhone = fullPhoneNumber.replace(PREFIX, '');
63
+ if (isEmpty_1.default(localPhone))
64
+ return '';
65
+ // Formatting inputted number
66
+ let phone = '';
67
+ [...fullPhoneNumber].forEach((ele) => {
68
+ if (ele >= '0' && ele <= '9') {
69
+ phone = phone.concat(ele);
70
+ }
71
+ });
72
+ let pattern = '';
73
+ let i = 0;
74
+ for (let j = 0; j < (localFormat === null || localFormat === void 0 ? void 0 : localFormat.length) && i < phone.length; j++) {
75
+ if (localFormat[j] === '.') {
76
+ pattern += phone[i];
77
+ i++;
78
+ }
79
+ else {
80
+ pattern += localFormat[j];
81
+ }
82
+ }
83
+ return pattern;
84
+ };
85
+ // return phoneline and countrycode for any given phone
86
+ const getPhoneObj = (phoneNumber) => {
87
+ let localPhone = phoneNumber.replace(/[^0-9]/g, '');
88
+ let countryCode = '';
89
+ // Guessing countries according to user input
90
+ const possibleCountries = initializedCountries.filter((country) => localPhone === null || localPhone === void 0 ? void 0 : localPhone.startsWith(country.dialCode.toString()));
91
+ const exactCountry = initializedCountries.filter((country) => country.dialCode.toString() === localPhone);
92
+ if (!isEmpty_1.default(exactCountry)) {
93
+ countryCode = exactCountry[0].dialCode.toString();
94
+ }
95
+ else if (!isEmpty_1.default(possibleCountries)) {
96
+ countryCode = possibleCountries[0].dialCode.toString();
97
+ }
98
+ return {
99
+ countryCode: PREFIX + countryCode,
100
+ phoneLine: localPhone.substring(countryCode.length, localPhone.length),
101
+ };
102
+ };
103
+ exports.getPhoneObj = getPhoneObj;
104
+ function PhoneInput(props) {
105
+ const { phoneValue, countryCode, onCountryCodeChange, onPhoneValueChange, validations, setInvalid } = props;
106
+ const { t } = react_i18next_1.useTranslation();
107
+ const [isOpen, setIsOpen] = react_1.useState(false);
108
+ const [iso2, setIso2] = react_1.useState('');
109
+ const [formattedNumber, setFormattedNumber] = react_1.useState('');
110
+ const [format, setFormat] = react_1.useState('');
111
+ const [countryObj, setCountryObj] = react_1.useState({
112
+ name: '',
113
+ regions: [''],
114
+ iso2: '',
115
+ countryCode: '',
116
+ dialCode: '',
117
+ format: '',
118
+ priority: 0,
119
+ areaCode: [''], // Area codes of a country
120
+ });
121
+ const setLocalFormat = (phoneNumber) => {
122
+ let localPhone = phoneNumber.replace(PREFIX, '').trim();
123
+ localPhone = localPhone.replace('(', '').trim();
124
+ localPhone = localPhone.replace(/ +/g, '');
125
+ // if the user selects a value from the dropdown and the country code is the same as prev, iso2 values shouldn't override
126
+ if (!isEmpty_1.default(countryObj) && isEqual_1.default(localPhone, countryObj.dialCode)) {
127
+ return countryObj.format;
128
+ }
129
+ let localFormat;
130
+ // Guessing countries according to user input
131
+ const possibleCountries = initializedCountries.filter((country) => localPhone === null || localPhone === void 0 ? void 0 : localPhone.startsWith(country.dialCode.toString()));
132
+ const canadaDialCode = '1';
133
+ const canadaCountryPhone = CountryData_1.canadaAreaCodes.map((areaCode) => canadaDialCode + areaCode);
134
+ const isCountryCanada = canadaCountryPhone.filter((phone) => localPhone.startsWith(phone)); // checks if phone is Canadian
135
+ const exactCountry = initializedCountries.filter((country) => country.dialCode.toString() === localPhone);
136
+ if (!isEmpty_1.default(isCountryCanada)) {
137
+ const canadaCountryObj = initializedCountries.filter((country) => country.iso2.toString() === 'ca');
138
+ setIso2(canadaCountryObj[0].iso2.toString());
139
+ localFormat = canadaCountryObj[0].format.toString();
140
+ onCountryCodeChange && onCountryCodeChange(PREFIX + canadaCountryObj[0].dialCode.toString());
141
+ setFormat(localFormat);
142
+ }
143
+ else if (!isEmpty_1.default(exactCountry)) {
144
+ const localExactCountry = exactCountry.filter((country) => isEqual_1.default(country.priority, 0));
145
+ if (isEqual_1.default(localExactCountry[0].dialCode.toString(), countryObj.dialCode)) {
146
+ setIso2(countryObj.iso2);
147
+ onCountryCodeChange && onCountryCodeChange(PREFIX + countryObj.countryCode);
148
+ return countryObj.format;
149
+ }
150
+ setIso2(localExactCountry[0].iso2.toString());
151
+ localFormat = localExactCountry[0].format.toString();
152
+ onCountryCodeChange && onCountryCodeChange(PREFIX + localExactCountry[0].dialCode.toString());
153
+ setFormat(localFormat);
154
+ }
155
+ else if (!isEmpty_1.default(possibleCountries)) {
156
+ const localPossibleCountry = possibleCountries.filter((country) => isEqual_1.default(country.priority, 0));
157
+ if (isEqual_1.default(localPossibleCountry[0].dialCode.toString(), countryObj.dialCode)) {
158
+ setIso2(countryObj.iso2);
159
+ onCountryCodeChange && onCountryCodeChange(PREFIX + countryObj.countryCode);
160
+ return countryObj.format;
161
+ }
162
+ setIso2(localPossibleCountry[0].iso2.toString());
163
+ localFormat = localPossibleCountry[0].format.toString();
164
+ onCountryCodeChange && onCountryCodeChange(PREFIX + localPossibleCountry[0].dialCode.toString());
165
+ setFormat(localFormat);
166
+ }
167
+ else {
168
+ // if the exact and possible are not the
169
+ setIso2('');
170
+ localFormat = format;
171
+ onCountryCodeChange && onCountryCodeChange('');
172
+ }
173
+ return localFormat;
174
+ };
175
+ const onPhoneChange = (phone) => {
176
+ if (isEmpty_1.default(phone.trim()) || isEmpty_1.default(phone.replace(PREFIX, '').trim())) {
177
+ setFormattedNumber('');
178
+ onPhoneValueChange('');
179
+ setInvalid && setInvalid(false);
180
+ }
181
+ const regex = /^[\d ()+-]+$/;
182
+ if (setInvalid)
183
+ regex.test(phone) ? setInvalid(false) : setInvalid(true);
184
+ const localFormat = setLocalFormat(phone);
185
+ const _formattedNumber = formatNumber(phone, localFormat);
186
+ setFormattedNumber(_formattedNumber);
187
+ if (!phone.trim().startsWith(PREFIX) && regex.test(phone) && !isEqual_1.default(phone, '-')) {
188
+ onPhoneValueChange(PREFIX + phone.trim());
189
+ }
190
+ else {
191
+ // to allow users to edit phone from between but not from right end, 5 is max length of any country code used when local format is empty
192
+ onPhoneValueChange(phone.slice(0, localFormat.length || 5));
193
+ }
194
+ };
195
+ const onToggle = (isOpen) => {
196
+ setIsOpen(isOpen);
197
+ };
198
+ const onCountrySelect = (event, selection) => {
199
+ setCountryObj(selection);
200
+ setIsOpen(!isOpen);
201
+ };
202
+ const getOptions = (options) => {
203
+ return options.map((country) => (react_1.default.createElement(react_core_1.SelectOption, { key: country.iso2, value: country },
204
+ react_1.default.createElement("div", { className: "pf-u-display-inline-flex" },
205
+ react_1.default.createElement("div", { className: `flag ${country.iso2}`, style: { marginRight: '8px' } }),
206
+ country.name,
207
+ " (+",
208
+ country.dialCode,
209
+ ")"))));
210
+ };
211
+ const onFilter = (_, value) => {
212
+ if (!value)
213
+ return getOptions(initializedCountries);
214
+ const newOptions = initializedCountries.filter((country) => {
215
+ const countryStr = `${country.name.toString()} (+${country.countryCode.toString()})`.toLowerCase();
216
+ return countryStr.includes(value.toLowerCase());
217
+ });
218
+ return getOptions(newOptions);
219
+ };
220
+ const placeholder = (react_1.default.createElement("div", { className: "phone-number-select-placeholder" },
221
+ react_1.default.createElement("div", { className: "pf-u-display-inline-flex" },
222
+ react_1.default.createElement("div", { className: `flag ${iso2}`, style: { marginRight: '5px' } }),
223
+ iso2.toUpperCase())));
224
+ react_1.useEffect(() => {
225
+ if (isEmpty_1.default(phoneValue)) {
226
+ setInvalid && setInvalid(false);
227
+ return;
228
+ }
229
+ if (isEmpty_1.default(iso2)) {
230
+ const localFormat = setLocalFormat(phoneValue);
231
+ const _formattedNumber = formatNumber(phoneValue, localFormat);
232
+ setFormattedNumber(_formattedNumber);
233
+ }
234
+ // eslint-disable-next-line react-hooks/exhaustive-deps
235
+ }, []);
236
+ react_1.useEffect(() => {
237
+ if (!isEmpty_1.default(countryObj.iso2) && `${PREFIX}${countryObj.dialCode}` !== countryCode) {
238
+ setIso2(countryObj.iso2);
239
+ setFormat(countryObj.format);
240
+ onPhoneValueChange(`${PREFIX}${countryObj.dialCode}`);
241
+ setFormattedNumber(`${PREFIX}${countryObj.dialCode}`);
242
+ }
243
+ // eslint-disable-next-line react-hooks/exhaustive-deps
244
+ }, [countryObj]);
245
+ react_1.useEffect(() => {
246
+ // when user types +, it will be replaced by empty string
247
+ if (isEqual_1.default(phoneValue.trim(), PREFIX) && isEmpty_1.default(iso2)) {
248
+ onPhoneValueChange('');
249
+ setFormattedNumber('');
250
+ return;
251
+ }
252
+ if (isEmpty_1.default(phoneValue) && isEmpty_1.default(iso2)) {
253
+ setCountryObj({
254
+ name: '',
255
+ regions: [''],
256
+ iso2: '',
257
+ countryCode: '',
258
+ dialCode: '',
259
+ format: '',
260
+ priority: 0,
261
+ areaCode: [''],
262
+ });
263
+ }
264
+ if (isEmpty_1.default(phoneValue)) {
265
+ setIso2('');
266
+ setInvalid && setInvalid(false);
267
+ setFormattedNumber('');
268
+ onPhoneValueChange('');
269
+ }
270
+ else {
271
+ onPhoneValueChange(phoneValue);
272
+ const localFormat = setLocalFormat(phoneValue);
273
+ const _formattedNumber = formatNumber(phoneValue, localFormat);
274
+ setFormattedNumber(_formattedNumber);
275
+ }
276
+ // eslint-disable-next-line react-hooks/exhaustive-deps
277
+ }, [phoneValue]);
278
+ return (react_1.default.createElement(react_core_1.InputGroup, { className: "phone-number-input" },
279
+ react_1.default.createElement("div", null,
280
+ react_1.default.createElement(react_core_1.Select, { variant: react_core_1.SelectVariant.single, "data-tracking-id": "case-phone-number-country-code", className: "phone-number-select", onToggle: onToggle, onSelect: onCountrySelect, isOpen: isOpen, placeholderText: iso2 && phoneValue !== '' ? placeholder : 'Country Code', onFilter: onFilter, hasInlineFilter: true, inlineFilterPlaceholderText: t('Search'), isDisabled: props.isDisabled }, getOptions(initializedCountries))),
281
+ react_1.default.createElement(react_core_1.TextInput, { id: "case-phone-number", "data-tracking-id": "case-phone-number", placeholder: "55-555-5555", value: formattedNumber ? formattedNumber : phoneValue, onChange: onPhoneChange, validated: validations, isDisabled: props.isDisabled }),
282
+ props.isLoading && react_1.default.createElement(react_core_1.Spinner, { isSVG: true, size: "lg", className: "pf-u-ml-2xl pf-u-mr-xl phone-spinner" })));
283
+ }
284
+ exports.PhoneInput = PhoneInput;