@bigbinary/neeto-molecules 1.1.10 → 1.1.11

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 (474) hide show
  1. package/dist/AutoSaveInput/autosaveinput.scss +15 -0
  2. package/dist/AutoSaveInput/constants.js +13 -0
  3. package/dist/AutoSaveInput/index.js +124 -0
  4. package/dist/AutoSaveInput/utils.js +10 -0
  5. package/dist/Breadcrumbs/breadcrumbs.scss +33 -0
  6. package/dist/Breadcrumbs/index.js +31 -0
  7. package/dist/BrowserSupport/Callout.js +15 -0
  8. package/dist/BrowserSupport/ContactUs.js +21 -0
  9. package/dist/BrowserSupport/DownloadLink.js +17 -0
  10. package/dist/BrowserSupport/PartialSupportedBrowserVersion.js +17 -0
  11. package/dist/BrowserSupport/UnknownBrowser.js +13 -0
  12. package/dist/BrowserSupport/UnsupportedBrowser.js +24 -0
  13. package/dist/BrowserSupport/UnsupportedBrowserMessage.js +22 -0
  14. package/dist/BrowserSupport/UnsupportedBrowserVersion.js +27 -0
  15. package/dist/BrowserSupport/UnsupportedVersionMessage.js +30 -0
  16. package/dist/BrowserSupport/browsersupport.scss +71 -0
  17. package/dist/BrowserSupport/constants.js +63 -0
  18. package/dist/BrowserSupport/index.js +58 -0
  19. package/dist/BrowserSupport/utils.js +32 -0
  20. package/dist/CalendarView/CustomDatePicker.js +87 -0
  21. package/dist/CalendarView/Header.js +53 -0
  22. package/dist/CalendarView/constants.js +19 -0
  23. package/dist/CalendarView/index.js +83 -0
  24. package/dist/CalendarView/utils.js +50 -0
  25. package/dist/Codeblock/index.js +30 -0
  26. package/dist/{Columns.js → Columns/index.js} +13 -130
  27. package/dist/Columns/utils.js +20 -0
  28. package/dist/ConfirmationModal/constants.js +3 -0
  29. package/dist/{ConfirmationModal.js → ConfirmationModal/index.js} +7 -23
  30. package/dist/ConfirmationModal/utils.js +10 -0
  31. package/dist/Container/container.scss +21 -0
  32. package/dist/Container/index.js +23 -0
  33. package/dist/CopyToClipboardButton/constants.js +13 -0
  34. package/dist/CopyToClipboardButton/copyToClipboard.scss +22 -0
  35. package/dist/CopyToClipboardButton/index.js +59 -0
  36. package/dist/CustomDomain/index.js +98 -0
  37. package/dist/CustomDomainDashboard/DeleteAlert.js +28 -0
  38. package/dist/CustomDomainDashboard/Header.js +32 -0
  39. package/dist/CustomDomainDashboard/Manage/Record.js +42 -0
  40. package/dist/CustomDomainDashboard/Manage/StatusInfo.js +21 -0
  41. package/dist/CustomDomainDashboard/Manage/TagBlock.js +36 -0
  42. package/dist/CustomDomainDashboard/Manage/constants.js +4 -0
  43. package/dist/CustomDomainDashboard/Manage/index.js +124 -0
  44. package/dist/CustomDomainDashboard/Manage/utils.js +8 -0
  45. package/dist/CustomDomainDashboard/api.js +35 -0
  46. package/dist/CustomDomainDashboard/constants.js +2 -0
  47. package/dist/CustomDomainDashboard/index.js +118 -0
  48. package/dist/CustomDomainDashboard/useCustomDomainApi.js +71 -0
  49. package/dist/CustomDomainDashboard/utils.js +84 -0
  50. package/dist/{DateFormat.js → DateFormat/index.js} +8 -25
  51. package/dist/DateRangeFilter/index.js +60 -0
  52. package/dist/DateRangeFilter/utils.js +113 -0
  53. package/dist/DynamicVariables/dynamic-variables.scss +34 -0
  54. package/dist/DynamicVariables/index.js +59 -0
  55. package/dist/DynamicVariables/utils.js +37 -0
  56. package/dist/EmailForm/EmailForm.js +97 -0
  57. package/dist/EmailForm/EmailFormProvider.js +45 -0
  58. package/dist/EmailForm/EmailPreview.js +129 -0
  59. package/dist/EmailForm/ReplyToField.js +55 -0
  60. package/dist/EmailForm/SendToField.js +27 -0
  61. package/dist/EmailForm/SubjectField.js +64 -0
  62. package/dist/EmailForm/constants.js +33 -0
  63. package/dist/EmailForm/contexts/EmailForm.js +7 -0
  64. package/dist/EmailForm/index.js +4 -0
  65. package/dist/EmailForm/utils.js +10 -0
  66. package/dist/EmailPreview/index.js +2 -0
  67. package/dist/{ErrorPage.js → ErrorPage/constants.js} +36 -175
  68. package/dist/ErrorPage/index.js +78 -0
  69. package/dist/Header/Breadcrumbs.js +31 -0
  70. package/dist/Header/Dropdown.js +12 -0
  71. package/dist/Header/constants.js +6 -0
  72. package/dist/Header/header.scss +121 -0
  73. package/dist/Header/index.js +61 -0
  74. package/dist/IconPicker/Icon.js +34 -0
  75. package/dist/IconPicker/NoResults.js +12 -0
  76. package/dist/IconPicker/constants.js +8 -0
  77. package/dist/IconPicker/icon-picker.scss +1 -0
  78. package/dist/IconPicker/index.js +164 -0
  79. package/dist/ImageWithFallback/ImagePlaceholder.js +16 -0
  80. package/dist/ImageWithFallback/index.js +31 -0
  81. package/dist/IntegrationCard/Dropdown.js +45 -0
  82. package/dist/IntegrationCard/Status.js +25 -0
  83. package/dist/IntegrationCard/index.js +128 -0
  84. package/dist/IntegrationDisconnectAlert/index.js +36 -0
  85. package/dist/{IntegrationWalkthroughModal.js → IntegrationWalkthroughModal/index.js} +6 -8
  86. package/dist/IpRestriction/AllowedIpRanges.js +72 -0
  87. package/dist/IpRestriction/CurrentIp.js +26 -0
  88. package/dist/IpRestriction/FormRow.js +77 -0
  89. package/dist/IpRestriction/Row.js +86 -0
  90. package/dist/IpRestriction/apis/allowed_ip_ranges.js +28 -0
  91. package/dist/IpRestriction/apis/current_ip.js +11 -0
  92. package/dist/IpRestriction/apis/ip_restriction.js +16 -0
  93. package/dist/IpRestriction/constants.js +11 -0
  94. package/dist/IpRestriction/hooks/reactQuery/useAllowedIpRanges.js +34 -0
  95. package/dist/IpRestriction/hooks/reactQuery/useCurrentIp.js +10 -0
  96. package/dist/IpRestriction/hooks/reactQuery/useIpRestrictions.js +18 -0
  97. package/dist/IpRestriction/index.js +102 -0
  98. package/dist/IpRestriction/utils.js +67 -0
  99. package/dist/KeyboardShortcuts/Pane/HotKey.js +44 -0
  100. package/dist/KeyboardShortcuts/Pane/HotKeyList.js +42 -0
  101. package/dist/KeyboardShortcuts/Pane/constants.js +25 -0
  102. package/dist/KeyboardShortcuts/Pane/index.js +61 -0
  103. package/dist/KeyboardShortcuts/Pane/keyboard-shortcuts.scss +5 -0
  104. package/dist/KeyboardShortcuts/Pane/utils.js +66 -0
  105. package/dist/KeyboardShortcuts/hooks/useKeyboardShortcutsPaneState.js +31 -0
  106. package/dist/KeyboardShortcuts/index.js +9 -0
  107. package/dist/LoginPage/Form.js +57 -0
  108. package/dist/LoginPage/constants.js +12 -0
  109. package/dist/LoginPage/index.js +103 -0
  110. package/dist/MenuBar/AddNew.js +25 -0
  111. package/dist/MenuBar/Block.js +60 -0
  112. package/dist/MenuBar/Item.js +32 -0
  113. package/dist/MenuBar/Search.js +39 -0
  114. package/dist/MenuBar/SubTitle.js +23 -0
  115. package/dist/MenuBar/index.js +46 -0
  116. package/dist/MenuBar/menubar.scss +154 -0
  117. package/dist/Metadata/Block.js +30 -0
  118. package/dist/Metadata/DetailsBlock.js +86 -0
  119. package/dist/Metadata/constants.js +9 -0
  120. package/dist/Metadata/index.js +29 -0
  121. package/dist/Metadata/metadata.scss +15 -0
  122. package/dist/MoreDropdown/constants.js +25 -0
  123. package/dist/{MoreDropdown.js → MoreDropdown/index.js} +9 -102
  124. package/dist/NavigationHeader/LeftBlock.js +32 -0
  125. package/dist/NavigationHeader/Navigation.js +24 -0
  126. package/dist/NavigationHeader/RightBlock.js +68 -0
  127. package/dist/NavigationHeader/constants.js +11 -0
  128. package/dist/NavigationHeader/index.js +19 -0
  129. package/dist/NavigationHeader/navigation-header.scss +3 -0
  130. package/dist/NeetoWidget/CodeBlock.js +57 -0
  131. package/dist/NeetoWidget/CodeSnippet.js +119 -0
  132. package/dist/NeetoWidget/EmbedCode.js +281 -0
  133. package/dist/NeetoWidget/Main.js +19 -0
  134. package/dist/NeetoWidget/SelectionSwitches/TooltipSwitch.js +25 -0
  135. package/dist/NeetoWidget/SelectionSwitches/index.js +44 -0
  136. package/dist/NeetoWidget/SyntaxHighlighter.js +17 -0
  137. package/dist/NeetoWidget/api.js +20 -0
  138. package/dist/NeetoWidget/constants.js +62 -0
  139. package/dist/NeetoWidget/hooks/useForceUpdate.js +14 -0
  140. package/dist/NeetoWidget/index.js +7 -0
  141. package/dist/NeetoWidget/mutations.js +9 -0
  142. package/dist/NeetoWidget/queries.js +32 -0
  143. package/dist/NeetoWidget/utils.js +83 -0
  144. package/dist/PageLoader/index.js +81 -0
  145. package/dist/PageLoader/page-loader.scss +95 -0
  146. package/dist/PhoneNumber/CountryPicker/SingleValue.js +21 -0
  147. package/dist/PhoneNumber/CountryPicker/constants.js +26 -0
  148. package/dist/PhoneNumber/CountryPicker/index.js +59 -0
  149. package/dist/PhoneNumber/FormikPhoneNumberInput.js +21 -0
  150. package/dist/PhoneNumber/PhoneNumber.js +30 -0
  151. package/dist/PhoneNumber/PhoneNumberInput.js +79 -0
  152. package/dist/PhoneNumber/index.js +5 -0
  153. package/dist/PhoneNumber/utils.js +55 -0
  154. package/dist/PublishBlock/AlertBlock.js +14 -0
  155. package/dist/PublishBlock/index.js +100 -0
  156. package/dist/PublishBlock/publish-block.scss +25 -0
  157. package/dist/Rename/DummySpan.js +21 -0
  158. package/dist/Rename/constants.js +1 -0
  159. package/dist/Rename/index.js +191 -0
  160. package/dist/Rename/rename.scss +69 -0
  161. package/dist/Rename/utils.js +10 -0
  162. package/dist/ResponsiveDevicePicker/constants.js +19 -0
  163. package/dist/ResponsiveDevicePicker/index.js +36 -0
  164. package/dist/Schedule/DisplayAvailability.js +58 -0
  165. package/dist/Schedule/Fields.js +43 -0
  166. package/dist/Schedule/Form/ScheduleRow.js +125 -0
  167. package/dist/Schedule/Form/constants.js +20 -0
  168. package/dist/Schedule/Form/index.js +144 -0
  169. package/dist/Schedule/Form/utils.js +63 -0
  170. package/dist/Schedule/Header.js +76 -0
  171. package/dist/Schedule/ScheduleContext.js +8 -0
  172. package/dist/Schedule/constants.js +8 -0
  173. package/dist/Schedule/dayjsExtended/constants.js +1 -0
  174. package/dist/Schedule/dayjsExtended/index.js +14 -0
  175. package/dist/Schedule/dayjsExtended/range.js +73 -0
  176. package/dist/Schedule/index.js +80 -0
  177. package/dist/Schedule/utils.js +152 -0
  178. package/dist/Scrollable/constants.js +8 -0
  179. package/dist/Scrollable/index.js +26 -0
  180. package/dist/Scrollable/scrollable.scss +32 -0
  181. package/dist/Security/AllowedKeywords/Add.js +38 -0
  182. package/dist/Security/AllowedKeywords/index.js +38 -0
  183. package/dist/Security/PasswordBlock.js +31 -0
  184. package/dist/Security/RadioBlock.js +38 -0
  185. package/dist/Security/api.js +12 -0
  186. package/dist/Security/constants.js +58 -0
  187. package/dist/Security/index.js +68 -0
  188. package/dist/Security/useSecurityApi.js +22 -0
  189. package/dist/Security/utils.js +31 -0
  190. package/dist/SendToFields/FilePicker.js +34 -0
  191. package/dist/SendToFields/constants.js +6 -0
  192. package/dist/SendToFields/index.js +102 -0
  193. package/dist/SendToFields/utils.js +54 -0
  194. package/dist/Settings/Category.js +30 -0
  195. package/dist/Settings/Item.js +38 -0
  196. package/dist/Settings/index.js +37 -0
  197. package/dist/Settings/utils.js +4 -0
  198. package/dist/ShareViaEmail/EmailBodyEditor.js +22 -0
  199. package/dist/ShareViaEmail/FilePicker.js +43 -0
  200. package/dist/ShareViaEmail/Form.js +101 -0
  201. package/dist/ShareViaEmail/FormikDatePicker.js +24 -0
  202. package/dist/ShareViaEmail/constants.js +14 -0
  203. package/dist/ShareViaEmail/index.js +89 -0
  204. package/dist/ShareViaEmail/utils.js +72 -0
  205. package/dist/ShareViaLink/EditURL.js +74 -0
  206. package/dist/ShareViaLink/Link.js +105 -0
  207. package/dist/ShareViaLink/QRCode.js +41 -0
  208. package/dist/ShareViaLink/RegenerateURL.js +47 -0
  209. package/dist/ShareViaLink/SocialMedia.js +52 -0
  210. package/dist/ShareViaLink/constants.js +25 -0
  211. package/dist/ShareViaLink/edit-url.scss +8 -0
  212. package/dist/ShareViaLink/index.js +46 -0
  213. package/dist/ShareViaLink/utils.js +47 -0
  214. package/dist/Sidebar/AppSwitcher/AppLink.js +45 -0
  215. package/dist/Sidebar/AppSwitcher/Backdrop.js +13 -0
  216. package/dist/Sidebar/AppSwitcher/Body.js +65 -0
  217. package/dist/Sidebar/AppSwitcher/Portal.js +27 -0
  218. package/dist/Sidebar/AppSwitcher/appswitcher.scss +164 -0
  219. package/dist/Sidebar/AppSwitcher/index.js +47 -0
  220. package/dist/Sidebar/AppSwitcher/utils.js +25 -0
  221. package/dist/Sidebar/Chevron.js +14 -0
  222. package/dist/Sidebar/FeaturedTooltip.js +19 -0
  223. package/dist/Sidebar/Footer/AppSwitcherButton.js +48 -0
  224. package/dist/Sidebar/Footer/ProfileButton.js +30 -0
  225. package/dist/Sidebar/Footer/index.js +56 -0
  226. package/dist/Sidebar/Footer/utils.js +39 -0
  227. package/dist/Sidebar/Header.js +33 -0
  228. package/dist/Sidebar/HelpSection/HelpSectionMenu.js +52 -0
  229. package/dist/Sidebar/HelpSection/index.js +32 -0
  230. package/dist/Sidebar/Links.js +112 -0
  231. package/dist/Sidebar/NavIconWrapper.js +20 -0
  232. package/dist/Sidebar/ProfileSection/LinkSection.js +36 -0
  233. package/dist/Sidebar/ProfileSection/ProfileMenu.js +48 -0
  234. package/dist/Sidebar/ProfileSection/index.js +42 -0
  235. package/dist/Sidebar/constants.js +40 -0
  236. package/dist/Sidebar/index.js +94 -0
  237. package/dist/Sidebar/sidebar.scss +379 -0
  238. package/dist/Sidebar/utils.js +18 -0
  239. package/dist/SubHeader/RightBlock/Columns.js +35 -0
  240. package/dist/SubHeader/RightBlock/Download.js +28 -0
  241. package/dist/SubHeader/RightBlock/Filter.js +31 -0
  242. package/dist/SubHeader/RightBlock/index.js +21 -0
  243. package/dist/SubHeader/RightBlock/utils.js +13 -0
  244. package/dist/SubHeader/index.js +28 -0
  245. package/dist/SubHeader/subheader.scss +78 -0
  246. package/dist/TableWrapper/index.js +18 -0
  247. package/dist/ThemeSidebar/Customize/Logo.js +39 -0
  248. package/dist/ThemeSidebar/Customize/Properties.js +170 -0
  249. package/dist/ThemeSidebar/Customize/index.js +66 -0
  250. package/dist/ThemeSidebar/Themes/ThemeCard.js +135 -0
  251. package/dist/ThemeSidebar/Themes/index.js +110 -0
  252. package/dist/ThemeSidebar/TitleBar.js +62 -0
  253. package/dist/ThemeSidebar/constants.js +127 -0
  254. package/dist/ThemeSidebar/fields/AlignmentBlock.js +50 -0
  255. package/dist/ThemeSidebar/fields/Card.js +19 -0
  256. package/dist/ThemeSidebar/fields/ColorBlock.js +19 -0
  257. package/dist/ThemeSidebar/fields/FontPickerBlock.js +35 -0
  258. package/dist/ThemeSidebar/fields/ImageBlock/ImageUploader.js +67 -0
  259. package/dist/ThemeSidebar/fields/ImageBlock/ProgressBar.js +22 -0
  260. package/dist/ThemeSidebar/fields/ImageBlock/index.js +55 -0
  261. package/dist/ThemeSidebar/fields/SelectBlock.js +24 -0
  262. package/dist/ThemeSidebar/fields/SliderBlock.js +30 -0
  263. package/dist/ThemeSidebar/fields/SwitchBlock.js +17 -0
  264. package/dist/ThemeSidebar/fields/TextBlock.js +13 -0
  265. package/dist/ThemeSidebar/fields/slider.scss +199 -0
  266. package/dist/ThemeSidebar/hooks/useDirectUploadDropzone.js +149 -0
  267. package/dist/ThemeSidebar/index.js +118 -0
  268. package/dist/ThemeSidebar/themeSidebar.scss +45 -0
  269. package/dist/ThemeSidebar/utils.js +169 -0
  270. package/dist/TimeFormat/index.js +3 -0
  271. package/dist/TimezoneMismatchModal/apis/time_zone.js +9 -0
  272. package/dist/TimezoneMismatchModal/index.js +83 -0
  273. package/dist/TimezoneMismatchModal/useTimeZoneApi.js +10 -0
  274. package/dist/TimezoneMismatchModal/utils.js +12 -0
  275. package/dist/ToggleFeatureCard/ToolTipSwitch.js +31 -0
  276. package/dist/ToggleFeatureCard/constants.js +5 -0
  277. package/dist/ToggleFeatureCard/hooks/useScrollIntoView.js +11 -0
  278. package/dist/ToggleFeatureCard/index.js +148 -0
  279. package/dist/ToggleFeatureCard/toggleFeatureCard.scss +4 -0
  280. package/package.json +27 -34
  281. package/dist/AutoSaveInput.cjs.js +0 -724
  282. package/dist/AutoSaveInput.cjs.js.map +0 -1
  283. package/dist/AutoSaveInput.js +0 -718
  284. package/dist/AutoSaveInput.js.map +0 -1
  285. package/dist/Breadcrumbs.cjs.js +0 -44
  286. package/dist/Breadcrumbs.cjs.js.map +0 -1
  287. package/dist/Breadcrumbs.js +0 -38
  288. package/dist/Breadcrumbs.js.map +0 -1
  289. package/dist/BrowserSupport.cjs.js +0 -1731
  290. package/dist/BrowserSupport.cjs.js.map +0 -1
  291. package/dist/BrowserSupport.js +0 -1725
  292. package/dist/BrowserSupport.js.map +0 -1
  293. package/dist/CalendarView.cjs.js +0 -610
  294. package/dist/CalendarView.cjs.js.map +0 -1
  295. package/dist/CalendarView.js +0 -598
  296. package/dist/CalendarView.js.map +0 -1
  297. package/dist/Codeblock.cjs.js +0 -302
  298. package/dist/Codeblock.cjs.js.map +0 -1
  299. package/dist/Codeblock.js +0 -296
  300. package/dist/Codeblock.js.map +0 -1
  301. package/dist/Columns.cjs.js +0 -248
  302. package/dist/Columns.cjs.js.map +0 -1
  303. package/dist/Columns.js.map +0 -1
  304. package/dist/ConfirmationModal.cjs.js +0 -87
  305. package/dist/ConfirmationModal.cjs.js.map +0 -1
  306. package/dist/ConfirmationModal.js.map +0 -1
  307. package/dist/Container.cjs.js +0 -1277
  308. package/dist/Container.cjs.js.map +0 -1
  309. package/dist/Container.js +0 -1271
  310. package/dist/Container.js.map +0 -1
  311. package/dist/CopyToClipboardButton.cjs.js +0 -275
  312. package/dist/CopyToClipboardButton.cjs.js.map +0 -1
  313. package/dist/CopyToClipboardButton.js +0 -269
  314. package/dist/CopyToClipboardButton.js.map +0 -1
  315. package/dist/CustomDomain.cjs.js +0 -774
  316. package/dist/CustomDomain.cjs.js.map +0 -1
  317. package/dist/CustomDomain.js +0 -747
  318. package/dist/CustomDomain.js.map +0 -1
  319. package/dist/CustomDomainDashboard.cjs.js +0 -2370
  320. package/dist/CustomDomainDashboard.cjs.js.map +0 -1
  321. package/dist/CustomDomainDashboard.js +0 -2342
  322. package/dist/CustomDomainDashboard.js.map +0 -1
  323. package/dist/DateFormat.cjs.js +0 -51
  324. package/dist/DateFormat.cjs.js.map +0 -1
  325. package/dist/DateFormat.js.map +0 -1
  326. package/dist/DateRangeFilter.cjs.js +0 -236
  327. package/dist/DateRangeFilter.cjs.js.map +0 -1
  328. package/dist/DateRangeFilter.js +0 -229
  329. package/dist/DateRangeFilter.js.map +0 -1
  330. package/dist/DynamicVariables.cjs.js +0 -189
  331. package/dist/DynamicVariables.cjs.js.map +0 -1
  332. package/dist/DynamicVariables.js +0 -183
  333. package/dist/DynamicVariables.js.map +0 -1
  334. package/dist/EmailForm.cjs.js +0 -4295
  335. package/dist/EmailForm.cjs.js.map +0 -1
  336. package/dist/EmailForm.js +0 -4265
  337. package/dist/EmailForm.js.map +0 -1
  338. package/dist/EmailPreview.cjs.js +0 -1419
  339. package/dist/EmailPreview.cjs.js.map +0 -1
  340. package/dist/EmailPreview.js +0 -1413
  341. package/dist/EmailPreview.js.map +0 -1
  342. package/dist/ErrorPage.cjs.js +0 -226
  343. package/dist/ErrorPage.cjs.js.map +0 -1
  344. package/dist/ErrorPage.js.map +0 -1
  345. package/dist/Header.cjs.js +0 -188
  346. package/dist/Header.cjs.js.map +0 -1
  347. package/dist/Header.js +0 -182
  348. package/dist/Header.js.map +0 -1
  349. package/dist/IconPicker.cjs.js +0 -1308
  350. package/dist/IconPicker.cjs.js.map +0 -1
  351. package/dist/IconPicker.js +0 -1302
  352. package/dist/IconPicker.js.map +0 -1
  353. package/dist/ImageWithFallback.cjs.js +0 -247
  354. package/dist/ImageWithFallback.cjs.js.map +0 -1
  355. package/dist/ImageWithFallback.js +0 -241
  356. package/dist/ImageWithFallback.js.map +0 -1
  357. package/dist/IntegrationCard.cjs.js +0 -409
  358. package/dist/IntegrationCard.cjs.js.map +0 -1
  359. package/dist/IntegrationCard.js +0 -403
  360. package/dist/IntegrationCard.js.map +0 -1
  361. package/dist/IntegrationDisconnectAlert.cjs.js +0 -89
  362. package/dist/IntegrationDisconnectAlert.cjs.js.map +0 -1
  363. package/dist/IntegrationDisconnectAlert.js +0 -80
  364. package/dist/IntegrationDisconnectAlert.js.map +0 -1
  365. package/dist/IntegrationWalkthroughModal.cjs.js +0 -50
  366. package/dist/IntegrationWalkthroughModal.cjs.js.map +0 -1
  367. package/dist/IntegrationWalkthroughModal.js.map +0 -1
  368. package/dist/IpRestriction.cjs.js +0 -3931
  369. package/dist/IpRestriction.cjs.js.map +0 -1
  370. package/dist/IpRestriction.js +0 -3905
  371. package/dist/IpRestriction.js.map +0 -1
  372. package/dist/KeyboardShortcuts.cjs.js +0 -2263
  373. package/dist/KeyboardShortcuts.cjs.js.map +0 -1
  374. package/dist/KeyboardShortcuts.js +0 -2256
  375. package/dist/KeyboardShortcuts.js.map +0 -1
  376. package/dist/LoginPage.cjs.js +0 -618
  377. package/dist/LoginPage.cjs.js.map +0 -1
  378. package/dist/LoginPage.js +0 -593
  379. package/dist/LoginPage.js.map +0 -1
  380. package/dist/MenuBar.cjs.js +0 -34273
  381. package/dist/MenuBar.cjs.js.map +0 -1
  382. package/dist/MenuBar.js +0 -34267
  383. package/dist/MenuBar.js.map +0 -1
  384. package/dist/Metadata.cjs.js +0 -272
  385. package/dist/Metadata.cjs.js.map +0 -1
  386. package/dist/Metadata.js +0 -266
  387. package/dist/Metadata.js.map +0 -1
  388. package/dist/MoreDropdown.cjs.js +0 -168
  389. package/dist/MoreDropdown.cjs.js.map +0 -1
  390. package/dist/MoreDropdown.js.map +0 -1
  391. package/dist/NavigationHeader.cjs.js +0 -756
  392. package/dist/NavigationHeader.cjs.js.map +0 -1
  393. package/dist/NavigationHeader.js +0 -750
  394. package/dist/NavigationHeader.js.map +0 -1
  395. package/dist/NeetoWidget.cjs.js +0 -3375
  396. package/dist/NeetoWidget.cjs.js.map +0 -1
  397. package/dist/NeetoWidget.js +0 -3348
  398. package/dist/NeetoWidget.js.map +0 -1
  399. package/dist/PageLoader.cjs.js +0 -158
  400. package/dist/PageLoader.cjs.js.map +0 -1
  401. package/dist/PageLoader.js +0 -134
  402. package/dist/PageLoader.js.map +0 -1
  403. package/dist/PhoneNumber.cjs.js +0 -7021
  404. package/dist/PhoneNumber.cjs.js.map +0 -1
  405. package/dist/PhoneNumber.js +0 -6989
  406. package/dist/PhoneNumber.js.map +0 -1
  407. package/dist/PublishBlock.cjs.js +0 -224
  408. package/dist/PublishBlock.cjs.js.map +0 -1
  409. package/dist/PublishBlock.js +0 -218
  410. package/dist/PublishBlock.js.map +0 -1
  411. package/dist/Rename.cjs.js +0 -516
  412. package/dist/Rename.cjs.js.map +0 -1
  413. package/dist/Rename.js +0 -510
  414. package/dist/Rename.js.map +0 -1
  415. package/dist/ResponsiveDevicePicker.cjs.js +0 -260
  416. package/dist/ResponsiveDevicePicker.cjs.js.map +0 -1
  417. package/dist/ResponsiveDevicePicker.js +0 -254
  418. package/dist/ResponsiveDevicePicker.js.map +0 -1
  419. package/dist/Schedule.cjs.js +0 -1077
  420. package/dist/Schedule.cjs.js.map +0 -1
  421. package/dist/Schedule.js +0 -1046
  422. package/dist/Schedule.js.map +0 -1
  423. package/dist/Scrollable.cjs.js +0 -188
  424. package/dist/Scrollable.cjs.js.map +0 -1
  425. package/dist/Scrollable.js +0 -182
  426. package/dist/Scrollable.js.map +0 -1
  427. package/dist/Security.cjs.js +0 -1921
  428. package/dist/Security.cjs.js.map +0 -1
  429. package/dist/Security.js +0 -1895
  430. package/dist/Security.js.map +0 -1
  431. package/dist/SendToFields.cjs.js +0 -2524
  432. package/dist/SendToFields.cjs.js.map +0 -1
  433. package/dist/SendToFields.js +0 -2517
  434. package/dist/SendToFields.js.map +0 -1
  435. package/dist/Settings.cjs.js +0 -501
  436. package/dist/Settings.cjs.js.map +0 -1
  437. package/dist/Settings.js +0 -495
  438. package/dist/Settings.js.map +0 -1
  439. package/dist/ShareViaEmail.cjs.js +0 -4272
  440. package/dist/ShareViaEmail.cjs.js.map +0 -1
  441. package/dist/ShareViaEmail.js +0 -4246
  442. package/dist/ShareViaEmail.js.map +0 -1
  443. package/dist/ShareViaLink.cjs.js +0 -1512
  444. package/dist/ShareViaLink.cjs.js.map +0 -1
  445. package/dist/ShareViaLink.js +0 -1486
  446. package/dist/ShareViaLink.js.map +0 -1
  447. package/dist/Sidebar.cjs.js +0 -34985
  448. package/dist/Sidebar.cjs.js.map +0 -1
  449. package/dist/Sidebar.js +0 -34959
  450. package/dist/Sidebar.js.map +0 -1
  451. package/dist/SubHeader.cjs.js +0 -283
  452. package/dist/SubHeader.cjs.js.map +0 -1
  453. package/dist/SubHeader.js +0 -276
  454. package/dist/SubHeader.js.map +0 -1
  455. package/dist/TableWrapper.cjs.js +0 -87
  456. package/dist/TableWrapper.cjs.js.map +0 -1
  457. package/dist/TableWrapper.js +0 -81
  458. package/dist/TableWrapper.js.map +0 -1
  459. package/dist/ThemeSidebar.cjs.js +0 -13705
  460. package/dist/ThemeSidebar.cjs.js.map +0 -1
  461. package/dist/ThemeSidebar.js +0 -13680
  462. package/dist/ThemeSidebar.js.map +0 -1
  463. package/dist/TimeFormat.cjs.js +0 -53
  464. package/dist/TimeFormat.cjs.js.map +0 -1
  465. package/dist/TimeFormat.js +0 -47
  466. package/dist/TimeFormat.js.map +0 -1
  467. package/dist/TimezoneMismatchModal.cjs.js +0 -176
  468. package/dist/TimezoneMismatchModal.cjs.js.map +0 -1
  469. package/dist/TimezoneMismatchModal.js +0 -168
  470. package/dist/TimezoneMismatchModal.js.map +0 -1
  471. package/dist/ToggleFeatureCard.cjs.js +0 -389
  472. package/dist/ToggleFeatureCard.cjs.js.map +0 -1
  473. package/dist/ToggleFeatureCard.js +0 -383
  474. package/dist/ToggleFeatureCard.js.map +0 -1
@@ -1,4295 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var React = require('react');
6
- var formik = require('formik');
7
- var neetoEditor = require('@bigbinary/neeto-editor');
8
- var neetoui = require('@bigbinary/neetoui');
9
- var formik$1 = require('@bigbinary/neetoui/formik');
10
- var reactI18next = require('react-i18next');
11
- var i18next = require('i18next');
12
- var ramda = require('ramda');
13
- var yup = require('yup');
14
- var pure = require('@bigbinary/neeto-commons-frontend/pure');
15
- var neetoIcons = require('@bigbinary/neeto-icons');
16
- var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
17
- var require$$0 = require('stream');
18
- var utils = require('@bigbinary/neeto-commons-frontend/utils');
19
- var DynamicVariables = require('@bigbinary/neeto-molecules/DynamicVariables');
20
-
21
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
-
23
- function _interopNamespace(e) {
24
- if (e && e.__esModule) return e;
25
- var n = Object.create(null);
26
- if (e) {
27
- Object.keys(e).forEach(function (k) {
28
- if (k !== 'default') {
29
- var d = Object.getOwnPropertyDescriptor(e, k);
30
- Object.defineProperty(n, k, d.get ? d : {
31
- enumerable: true,
32
- get: function () { return e[k]; }
33
- });
34
- }
35
- });
36
- }
37
- n["default"] = e;
38
- return Object.freeze(n);
39
- }
40
-
41
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
42
- var yup__namespace = /*#__PURE__*/_interopNamespace(yup);
43
- var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
44
- var DynamicVariables__default = /*#__PURE__*/_interopDefaultLegacy(DynamicVariables);
45
-
46
- function _typeof$1(obj) {
47
- "@babel/helpers - typeof";
48
-
49
- return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
50
- return typeof obj;
51
- } : function (obj) {
52
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
53
- }, _typeof$1(obj);
54
- }
55
-
56
- function _toPrimitive(input, hint) {
57
- if (_typeof$1(input) !== "object" || input === null) return input;
58
- var prim = input[Symbol.toPrimitive];
59
- if (prim !== undefined) {
60
- var res = prim.call(input, hint || "default");
61
- if (_typeof$1(res) !== "object") return res;
62
- throw new TypeError("@@toPrimitive must return a primitive value.");
63
- }
64
- return (hint === "string" ? String : Number)(input);
65
- }
66
-
67
- function _toPropertyKey(arg) {
68
- var key = _toPrimitive(arg, "string");
69
- return _typeof$1(key) === "symbol" ? key : String(key);
70
- }
71
-
72
- function _defineProperty(obj, key, value) {
73
- key = _toPropertyKey(key);
74
- if (key in obj) {
75
- Object.defineProperty(obj, key, {
76
- value: value,
77
- enumerable: true,
78
- configurable: true,
79
- writable: true
80
- });
81
- } else {
82
- obj[key] = value;
83
- }
84
- return obj;
85
- }
86
-
87
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
88
-
89
- var classnames$1 = {exports: {}};
90
-
91
- /*!
92
- Copyright (c) 2018 Jed Watson.
93
- Licensed under the MIT License (MIT), see
94
- http://jedwatson.github.io/classnames
95
- */
96
-
97
- (function (module) {
98
- /* global define */
99
-
100
- (function () {
101
-
102
- var hasOwn = {}.hasOwnProperty;
103
-
104
- function classNames() {
105
- var classes = [];
106
-
107
- for (var i = 0; i < arguments.length; i++) {
108
- var arg = arguments[i];
109
- if (!arg) continue;
110
-
111
- var argType = typeof arg;
112
-
113
- if (argType === 'string' || argType === 'number') {
114
- classes.push(arg);
115
- } else if (Array.isArray(arg)) {
116
- if (arg.length) {
117
- var inner = classNames.apply(null, arg);
118
- if (inner) {
119
- classes.push(inner);
120
- }
121
- }
122
- } else if (argType === 'object') {
123
- if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
124
- classes.push(arg.toString());
125
- continue;
126
- }
127
-
128
- for (var key in arg) {
129
- if (hasOwn.call(arg, key) && arg[key]) {
130
- classes.push(key);
131
- }
132
- }
133
- }
134
- }
135
-
136
- return classes.join(' ');
137
- }
138
-
139
- if (module.exports) {
140
- classNames.default = classNames;
141
- module.exports = classNames;
142
- } else {
143
- window.classNames = classNames;
144
- }
145
- }());
146
- } (classnames$1));
147
-
148
- var classnames = classnames$1.exports;
149
-
150
- var INITIAL_FORM_VALUES = {
151
- sendTo: [],
152
- sendToCc: [],
153
- sendToBcc: [],
154
- replyTo: "",
155
- showCopyEmails: false,
156
- subject: "",
157
- message: ""
158
- };
159
- var EMAIL_FORM_VALIDATION_SCHEMA = yup__namespace.object({
160
- subject: yup__namespace.string().required(i18next.t("neetoMolecules.emailForm.errors.subjectRequired")),
161
- message: yup__namespace.string().test("message", i18next.t("neetoMolecules.emailForm.errors.messageRequired"), function (value) {
162
- return !neetoEditor.isEditorEmpty(value);
163
- })
164
- });
165
- var SEND_TO_FIELD_VALIDATION = yup__namespace.object({
166
- sendTo: yup__namespace.array().min(1, i18next.t("neetoMolecules.emailForm.errors.required", {
167
- entity: i18next.t("neetoMolecules.emailForm.fields.sendToEmailAddress")
168
- })).test("all-emails-valid", i18next.t("neetoMolecules.emailForm.errors.invalidEmailAddress"), function (emails) {
169
- return emails === null || emails === void 0 ? void 0 : emails.every(ramda.prop("valid"));
170
- }).nullable()
171
- });
172
- var REPLY_TO_FIELD_VALIDATION = yup__namespace.object({
173
- replyTo: yup__namespace.string().nullable().email(i18next.t("neetoMolecules.emailForm.errors.invalidEmailAddress")).required(i18next.t("neetoMolecules.emailForm.errors.required", {
174
- entity: i18next.t("neetoMolecules.emailForm.fields.replyToEmailAddress")
175
- }))
176
- });
177
- var EDITOR_ADDONS = ["highlight", "emoji", "code-block", "block-quote", "image-upload", "divider", "video-embed"];
178
-
179
- /* eslint-disable @bigbinary/neeto/use-zustand-for-global-state-management */
180
- var EmailFormContext = /*#__PURE__*/React__default["default"].createContext({
181
- showSendToField: false,
182
- showReplyToField: false
183
- });
184
-
185
- var ReplyToField = function ReplyToField(_ref) {
186
- var _helpIconProps2;
187
- var replyToOptions = _ref.replyToOptions;
188
- var _useTranslation = reactI18next.useTranslation(),
189
- t = _useTranslation.t;
190
- var isDropdownField = pure.isNotEmpty(replyToOptions);
191
- var _useFormikContext = formik.useFormikContext(),
192
- setFieldValue = _useFormikContext.setFieldValue;
193
- if (isDropdownField) {
194
- var _helpIconProps;
195
- return /*#__PURE__*/React__default["default"].createElement(formik$1.Select, {
196
- className: "w-full",
197
- "data-testid": "replyToOptions",
198
- label: t("neetoMolecules.emailForm.labels.replyTo"),
199
- name: "replyTo",
200
- options: replyToOptions,
201
- labelProps: {
202
- helpIconProps: (_helpIconProps = {
203
- icon: neetoIcons.Info
204
- }, _defineProperty(_helpIconProps, "data-testid", "reply-to-tooltip"), _defineProperty(_helpIconProps, "tooltipProps", {
205
- content: t("neetoMolecules.emailForm.tooltips.replyTo")
206
- }), _helpIconProps)
207
- },
208
- onChange: function onChange(_ref2) {
209
- var value = _ref2.value;
210
- return setFieldValue("replyTo", value);
211
- }
212
- });
213
- }
214
- return /*#__PURE__*/React__default["default"].createElement(formik$1.Input, {
215
- autoFocus: true,
216
- required: true,
217
- className: "w-full",
218
- "data-testid": "replyToInput",
219
- label: t("neetoMolecules.emailForm.labels.replyTo"),
220
- name: "replyTo",
221
- placeholder: t("neetoMolecules.emailForm.placeholders.emailPlaceholder"),
222
- size: "large",
223
- labelProps: {
224
- helpIconProps: (_helpIconProps2 = {
225
- icon: neetoIcons.Info
226
- }, _defineProperty(_helpIconProps2, "data-testid", "reply-to-tooltip"), _defineProperty(_helpIconProps2, "tooltipProps", {
227
- content: t("neetoMolecules.emailForm.tooltips.replyTo")
228
- }), _helpIconProps2)
229
- }
230
- });
231
- };
232
-
233
- function _extends() {
234
- _extends = Object.assign ? Object.assign.bind() : function (target) {
235
- for (var i = 1; i < arguments.length; i++) {
236
- var source = arguments[i];
237
- for (var key in source) {
238
- if (Object.prototype.hasOwnProperty.call(source, key)) {
239
- target[key] = source[key];
240
- }
241
- }
242
- }
243
- return target;
244
- };
245
- return _extends.apply(this, arguments);
246
- }
247
-
248
- function _arrayLikeToArray(arr, len) {
249
- if (len == null || len > arr.length) len = arr.length;
250
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
251
- return arr2;
252
- }
253
-
254
- function _arrayWithoutHoles(arr) {
255
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
256
- }
257
-
258
- function _iterableToArray(iter) {
259
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
260
- }
261
-
262
- function _unsupportedIterableToArray(o, minLen) {
263
- if (!o) return;
264
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
265
- var n = Object.prototype.toString.call(o).slice(8, -1);
266
- if (n === "Object" && o.constructor) n = o.constructor.name;
267
- if (n === "Map" || n === "Set") return Array.from(o);
268
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
269
- }
270
-
271
- function _nonIterableSpread() {
272
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
273
- }
274
-
275
- function _toConsumableArray(arr) {
276
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
277
- }
278
-
279
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
280
- try {
281
- var info = gen[key](arg);
282
- var value = info.value;
283
- } catch (error) {
284
- reject(error);
285
- return;
286
- }
287
- if (info.done) {
288
- resolve(value);
289
- } else {
290
- Promise.resolve(value).then(_next, _throw);
291
- }
292
- }
293
- function _asyncToGenerator(fn) {
294
- return function () {
295
- var self = this,
296
- args = arguments;
297
- return new Promise(function (resolve, reject) {
298
- var gen = fn.apply(self, args);
299
- function _next(value) {
300
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
301
- }
302
- function _throw(err) {
303
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
304
- }
305
- _next(undefined);
306
- });
307
- };
308
- }
309
-
310
- var regeneratorRuntime$1 = {exports: {}};
311
-
312
- var _typeof = {exports: {}};
313
-
314
- (function (module) {
315
- function _typeof(obj) {
316
- "@babel/helpers - typeof";
317
-
318
- return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
319
- return typeof obj;
320
- } : function (obj) {
321
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
322
- }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
323
- }
324
- module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
325
- } (_typeof));
326
-
327
- (function (module) {
328
- var _typeof$1 = _typeof.exports["default"];
329
- function _regeneratorRuntime() {
330
- module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
331
- return exports;
332
- }, module.exports.__esModule = true, module.exports["default"] = module.exports;
333
- var exports = {},
334
- Op = Object.prototype,
335
- hasOwn = Op.hasOwnProperty,
336
- defineProperty = Object.defineProperty || function (obj, key, desc) {
337
- obj[key] = desc.value;
338
- },
339
- $Symbol = "function" == typeof Symbol ? Symbol : {},
340
- iteratorSymbol = $Symbol.iterator || "@@iterator",
341
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
342
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
343
- function define(obj, key, value) {
344
- return Object.defineProperty(obj, key, {
345
- value: value,
346
- enumerable: !0,
347
- configurable: !0,
348
- writable: !0
349
- }), obj[key];
350
- }
351
- try {
352
- define({}, "");
353
- } catch (err) {
354
- define = function define(obj, key, value) {
355
- return obj[key] = value;
356
- };
357
- }
358
- function wrap(innerFn, outerFn, self, tryLocsList) {
359
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
360
- generator = Object.create(protoGenerator.prototype),
361
- context = new Context(tryLocsList || []);
362
- return defineProperty(generator, "_invoke", {
363
- value: makeInvokeMethod(innerFn, self, context)
364
- }), generator;
365
- }
366
- function tryCatch(fn, obj, arg) {
367
- try {
368
- return {
369
- type: "normal",
370
- arg: fn.call(obj, arg)
371
- };
372
- } catch (err) {
373
- return {
374
- type: "throw",
375
- arg: err
376
- };
377
- }
378
- }
379
- exports.wrap = wrap;
380
- var ContinueSentinel = {};
381
- function Generator() {}
382
- function GeneratorFunction() {}
383
- function GeneratorFunctionPrototype() {}
384
- var IteratorPrototype = {};
385
- define(IteratorPrototype, iteratorSymbol, function () {
386
- return this;
387
- });
388
- var getProto = Object.getPrototypeOf,
389
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
390
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
391
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
392
- function defineIteratorMethods(prototype) {
393
- ["next", "throw", "return"].forEach(function (method) {
394
- define(prototype, method, function (arg) {
395
- return this._invoke(method, arg);
396
- });
397
- });
398
- }
399
- function AsyncIterator(generator, PromiseImpl) {
400
- function invoke(method, arg, resolve, reject) {
401
- var record = tryCatch(generator[method], generator, arg);
402
- if ("throw" !== record.type) {
403
- var result = record.arg,
404
- value = result.value;
405
- return value && "object" == _typeof$1(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
406
- invoke("next", value, resolve, reject);
407
- }, function (err) {
408
- invoke("throw", err, resolve, reject);
409
- }) : PromiseImpl.resolve(value).then(function (unwrapped) {
410
- result.value = unwrapped, resolve(result);
411
- }, function (error) {
412
- return invoke("throw", error, resolve, reject);
413
- });
414
- }
415
- reject(record.arg);
416
- }
417
- var previousPromise;
418
- defineProperty(this, "_invoke", {
419
- value: function value(method, arg) {
420
- function callInvokeWithMethodAndArg() {
421
- return new PromiseImpl(function (resolve, reject) {
422
- invoke(method, arg, resolve, reject);
423
- });
424
- }
425
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
426
- }
427
- });
428
- }
429
- function makeInvokeMethod(innerFn, self, context) {
430
- var state = "suspendedStart";
431
- return function (method, arg) {
432
- if ("executing" === state) throw new Error("Generator is already running");
433
- if ("completed" === state) {
434
- if ("throw" === method) throw arg;
435
- return doneResult();
436
- }
437
- for (context.method = method, context.arg = arg;;) {
438
- var delegate = context.delegate;
439
- if (delegate) {
440
- var delegateResult = maybeInvokeDelegate(delegate, context);
441
- if (delegateResult) {
442
- if (delegateResult === ContinueSentinel) continue;
443
- return delegateResult;
444
- }
445
- }
446
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
447
- if ("suspendedStart" === state) throw state = "completed", context.arg;
448
- context.dispatchException(context.arg);
449
- } else "return" === context.method && context.abrupt("return", context.arg);
450
- state = "executing";
451
- var record = tryCatch(innerFn, self, context);
452
- if ("normal" === record.type) {
453
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
454
- return {
455
- value: record.arg,
456
- done: context.done
457
- };
458
- }
459
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
460
- }
461
- };
462
- }
463
- function maybeInvokeDelegate(delegate, context) {
464
- var methodName = context.method,
465
- method = delegate.iterator[methodName];
466
- if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
467
- var record = tryCatch(method, delegate.iterator, context.arg);
468
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
469
- var info = record.arg;
470
- return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
471
- }
472
- function pushTryEntry(locs) {
473
- var entry = {
474
- tryLoc: locs[0]
475
- };
476
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
477
- }
478
- function resetTryEntry(entry) {
479
- var record = entry.completion || {};
480
- record.type = "normal", delete record.arg, entry.completion = record;
481
- }
482
- function Context(tryLocsList) {
483
- this.tryEntries = [{
484
- tryLoc: "root"
485
- }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
486
- }
487
- function values(iterable) {
488
- if (iterable) {
489
- var iteratorMethod = iterable[iteratorSymbol];
490
- if (iteratorMethod) return iteratorMethod.call(iterable);
491
- if ("function" == typeof iterable.next) return iterable;
492
- if (!isNaN(iterable.length)) {
493
- var i = -1,
494
- next = function next() {
495
- for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
496
- return next.value = undefined, next.done = !0, next;
497
- };
498
- return next.next = next;
499
- }
500
- }
501
- return {
502
- next: doneResult
503
- };
504
- }
505
- function doneResult() {
506
- return {
507
- value: undefined,
508
- done: !0
509
- };
510
- }
511
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
512
- value: GeneratorFunctionPrototype,
513
- configurable: !0
514
- }), defineProperty(GeneratorFunctionPrototype, "constructor", {
515
- value: GeneratorFunction,
516
- configurable: !0
517
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
518
- var ctor = "function" == typeof genFun && genFun.constructor;
519
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
520
- }, exports.mark = function (genFun) {
521
- return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
522
- }, exports.awrap = function (arg) {
523
- return {
524
- __await: arg
525
- };
526
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
527
- return this;
528
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
529
- void 0 === PromiseImpl && (PromiseImpl = Promise);
530
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
531
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
532
- return result.done ? result.value : iter.next();
533
- });
534
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
535
- return this;
536
- }), define(Gp, "toString", function () {
537
- return "[object Generator]";
538
- }), exports.keys = function (val) {
539
- var object = Object(val),
540
- keys = [];
541
- for (var key in object) keys.push(key);
542
- return keys.reverse(), function next() {
543
- for (; keys.length;) {
544
- var key = keys.pop();
545
- if (key in object) return next.value = key, next.done = !1, next;
546
- }
547
- return next.done = !0, next;
548
- };
549
- }, exports.values = values, Context.prototype = {
550
- constructor: Context,
551
- reset: function reset(skipTempReset) {
552
- if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
553
- },
554
- stop: function stop() {
555
- this.done = !0;
556
- var rootRecord = this.tryEntries[0].completion;
557
- if ("throw" === rootRecord.type) throw rootRecord.arg;
558
- return this.rval;
559
- },
560
- dispatchException: function dispatchException(exception) {
561
- if (this.done) throw exception;
562
- var context = this;
563
- function handle(loc, caught) {
564
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
565
- }
566
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
567
- var entry = this.tryEntries[i],
568
- record = entry.completion;
569
- if ("root" === entry.tryLoc) return handle("end");
570
- if (entry.tryLoc <= this.prev) {
571
- var hasCatch = hasOwn.call(entry, "catchLoc"),
572
- hasFinally = hasOwn.call(entry, "finallyLoc");
573
- if (hasCatch && hasFinally) {
574
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
575
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
576
- } else if (hasCatch) {
577
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
578
- } else {
579
- if (!hasFinally) throw new Error("try statement without catch or finally");
580
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
581
- }
582
- }
583
- }
584
- },
585
- abrupt: function abrupt(type, arg) {
586
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
587
- var entry = this.tryEntries[i];
588
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
589
- var finallyEntry = entry;
590
- break;
591
- }
592
- }
593
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
594
- var record = finallyEntry ? finallyEntry.completion : {};
595
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
596
- },
597
- complete: function complete(record, afterLoc) {
598
- if ("throw" === record.type) throw record.arg;
599
- return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
600
- },
601
- finish: function finish(finallyLoc) {
602
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
603
- var entry = this.tryEntries[i];
604
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
605
- }
606
- },
607
- "catch": function _catch(tryLoc) {
608
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
609
- var entry = this.tryEntries[i];
610
- if (entry.tryLoc === tryLoc) {
611
- var record = entry.completion;
612
- if ("throw" === record.type) {
613
- var thrown = record.arg;
614
- resetTryEntry(entry);
615
- }
616
- return thrown;
617
- }
618
- }
619
- throw new Error("illegal catch attempt");
620
- },
621
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
622
- return this.delegate = {
623
- iterator: values(iterable),
624
- resultName: resultName,
625
- nextLoc: nextLoc
626
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
627
- }
628
- }, exports;
629
- }
630
- module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
631
- } (regeneratorRuntime$1));
632
-
633
- // TODO(Babel 8): Remove this file.
634
-
635
- var runtime = regeneratorRuntime$1.exports();
636
- var regenerator = runtime;
637
-
638
- // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
639
- try {
640
- regeneratorRuntime = runtime;
641
- } catch (accidentalStrictMode) {
642
- if (typeof globalThis === "object") {
643
- globalThis.regeneratorRuntime = runtime;
644
- } else {
645
- Function("r", "regeneratorRuntime = r")(runtime);
646
- }
647
- }
648
-
649
- var ALLOWED_FILE_PICKER_TYPES = [".csv"];
650
-
651
- var FilePicker = function FilePicker(_ref) {
652
- var _ref$types = _ref.types,
653
- types = _ref$types === void 0 ? [] : _ref$types,
654
- onChange = _ref.onChange,
655
- children = _ref.children;
656
- var inputRef = React.useRef();
657
- var accept = types.reduce(function (acc, ext) {
658
- return "".concat(acc, ", ").concat(ext);
659
- }, "");
660
- var handleInputChange = function handleInputChange(_ref2) {
661
- var target = _ref2.target;
662
- if (!target.files) return;
663
- onChange(target.files);
664
-
665
- // This will trigger handleClick when same file is uploaded again.
666
- inputRef.current.value = "";
667
- handleClick();
668
- };
669
- var handleClick = function handleClick() {
670
- if (!inputRef.current) return;
671
- inputRef.current.click();
672
- };
673
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
674
- onClick: handleClick
675
- }, children), /*#__PURE__*/React__default["default"].createElement("input", {
676
- accept: accept,
677
- className: "hidden",
678
- ref: inputRef,
679
- type: "file",
680
- onChange: handleInputChange
681
- }));
682
- };
683
-
684
- var papaparse = {exports: {}};
685
-
686
- /* @license
687
- Papa Parse
688
- v5.4.0
689
- https://github.com/mholt/PapaParse
690
- License: MIT
691
- */
692
-
693
- (function (module, exports) {
694
- (function(root, factory)
695
- {
696
- /* globals define */
697
- {
698
- // Node. Does not work with strict CommonJS, but
699
- // only CommonJS-like environments that support module.exports,
700
- // like Node.
701
- module.exports = factory();
702
- }
703
- // in strict mode we cannot access arguments.callee, so we need a named reference to
704
- // stringify the factory method for the blob worker
705
- // eslint-disable-next-line func-name
706
- }(commonjsGlobal, function moduleFactory()
707
- {
708
-
709
- var global = (function() {
710
- // alternative method, similar to `Function('return this')()`
711
- // but without using `eval` (which is disabled when
712
- // using Content Security Policy).
713
-
714
- if (typeof self !== 'undefined') { return self; }
715
- if (typeof window !== 'undefined') { return window; }
716
- if (typeof global !== 'undefined') { return global; }
717
-
718
- // When running tests none of the above have been defined
719
- return {};
720
- })();
721
-
722
-
723
- function getWorkerBlob() {
724
- var URL = global.URL || global.webkitURL || null;
725
- var code = moduleFactory.toString();
726
- return Papa.BLOB_URL || (Papa.BLOB_URL = URL.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ", '(', code, ')();'], {type: 'text/javascript'})));
727
- }
728
-
729
- var IS_WORKER = !global.document && !!global.postMessage,
730
- IS_PAPA_WORKER = global.IS_PAPA_WORKER || false;
731
-
732
- var workers = {}, workerIdCounter = 0;
733
-
734
- var Papa = {};
735
-
736
- Papa.parse = CsvToJson;
737
- Papa.unparse = JsonToCsv;
738
-
739
- Papa.RECORD_SEP = String.fromCharCode(30);
740
- Papa.UNIT_SEP = String.fromCharCode(31);
741
- Papa.BYTE_ORDER_MARK = '\ufeff';
742
- Papa.BAD_DELIMITERS = ['\r', '\n', '"', Papa.BYTE_ORDER_MARK];
743
- Papa.WORKERS_SUPPORTED = !IS_WORKER && !!global.Worker;
744
- Papa.NODE_STREAM_INPUT = 1;
745
-
746
- // Configurable chunk sizes for local and remote files, respectively
747
- Papa.LocalChunkSize = 1024 * 1024 * 10; // 10 MB
748
- Papa.RemoteChunkSize = 1024 * 1024 * 5; // 5 MB
749
- Papa.DefaultDelimiter = ','; // Used if not specified and detection fails
750
-
751
- // Exposed for testing and development only
752
- Papa.Parser = Parser;
753
- Papa.ParserHandle = ParserHandle;
754
- Papa.NetworkStreamer = NetworkStreamer;
755
- Papa.FileStreamer = FileStreamer;
756
- Papa.StringStreamer = StringStreamer;
757
- Papa.ReadableStreamStreamer = ReadableStreamStreamer;
758
- if (typeof PAPA_BROWSER_CONTEXT === 'undefined') {
759
- Papa.DuplexStreamStreamer = DuplexStreamStreamer;
760
- }
761
-
762
- if (global.jQuery)
763
- {
764
- var $ = global.jQuery;
765
- $.fn.parse = function(options)
766
- {
767
- var config = options.config || {};
768
- var queue = [];
769
-
770
- this.each(function(idx)
771
- {
772
- var supported = $(this).prop('tagName').toUpperCase() === 'INPUT'
773
- && $(this).attr('type').toLowerCase() === 'file'
774
- && global.FileReader;
775
-
776
- if (!supported || !this.files || this.files.length === 0)
777
- return true; // continue to next input element
778
-
779
- for (var i = 0; i < this.files.length; i++)
780
- {
781
- queue.push({
782
- file: this.files[i],
783
- inputElem: this,
784
- instanceConfig: $.extend({}, config)
785
- });
786
- }
787
- });
788
-
789
- parseNextFile(); // begin parsing
790
- return this; // maintains chainability
791
-
792
-
793
- function parseNextFile()
794
- {
795
- if (queue.length === 0)
796
- {
797
- if (isFunction(options.complete))
798
- options.complete();
799
- return;
800
- }
801
-
802
- var f = queue[0];
803
-
804
- if (isFunction(options.before))
805
- {
806
- var returned = options.before(f.file, f.inputElem);
807
-
808
- if (typeof returned === 'object')
809
- {
810
- if (returned.action === 'abort')
811
- {
812
- error('AbortError', f.file, f.inputElem, returned.reason);
813
- return; // Aborts all queued files immediately
814
- }
815
- else if (returned.action === 'skip')
816
- {
817
- fileComplete(); // parse the next file in the queue, if any
818
- return;
819
- }
820
- else if (typeof returned.config === 'object')
821
- f.instanceConfig = $.extend(f.instanceConfig, returned.config);
822
- }
823
- else if (returned === 'skip')
824
- {
825
- fileComplete(); // parse the next file in the queue, if any
826
- return;
827
- }
828
- }
829
-
830
- // Wrap up the user's complete callback, if any, so that ours also gets executed
831
- var userCompleteFunc = f.instanceConfig.complete;
832
- f.instanceConfig.complete = function(results)
833
- {
834
- if (isFunction(userCompleteFunc))
835
- userCompleteFunc(results, f.file, f.inputElem);
836
- fileComplete();
837
- };
838
-
839
- Papa.parse(f.file, f.instanceConfig);
840
- }
841
-
842
- function error(name, file, elem, reason)
843
- {
844
- if (isFunction(options.error))
845
- options.error({name: name}, file, elem, reason);
846
- }
847
-
848
- function fileComplete()
849
- {
850
- queue.splice(0, 1);
851
- parseNextFile();
852
- }
853
- };
854
- }
855
-
856
-
857
- if (IS_PAPA_WORKER)
858
- {
859
- global.onmessage = workerThreadReceivedMessage;
860
- }
861
-
862
-
863
-
864
-
865
- function CsvToJson(_input, _config)
866
- {
867
- _config = _config || {};
868
- var dynamicTyping = _config.dynamicTyping || false;
869
- if (isFunction(dynamicTyping)) {
870
- _config.dynamicTypingFunction = dynamicTyping;
871
- // Will be filled on first row call
872
- dynamicTyping = {};
873
- }
874
- _config.dynamicTyping = dynamicTyping;
875
-
876
- _config.transform = isFunction(_config.transform) ? _config.transform : false;
877
-
878
- if (_config.worker && Papa.WORKERS_SUPPORTED)
879
- {
880
- var w = newWorker();
881
-
882
- w.userStep = _config.step;
883
- w.userChunk = _config.chunk;
884
- w.userComplete = _config.complete;
885
- w.userError = _config.error;
886
-
887
- _config.step = isFunction(_config.step);
888
- _config.chunk = isFunction(_config.chunk);
889
- _config.complete = isFunction(_config.complete);
890
- _config.error = isFunction(_config.error);
891
- delete _config.worker; // prevent infinite loop
892
-
893
- w.postMessage({
894
- input: _input,
895
- config: _config,
896
- workerId: w.id
897
- });
898
-
899
- return;
900
- }
901
-
902
- var streamer = null;
903
- if (_input === Papa.NODE_STREAM_INPUT && typeof PAPA_BROWSER_CONTEXT === 'undefined')
904
- {
905
- // create a node Duplex stream for use
906
- // with .pipe
907
- streamer = new DuplexStreamStreamer(_config);
908
- return streamer.getStream();
909
- }
910
- else if (typeof _input === 'string')
911
- {
912
- _input = stripBom(_input);
913
- if (_config.download)
914
- streamer = new NetworkStreamer(_config);
915
- else
916
- streamer = new StringStreamer(_config);
917
- }
918
- else if (_input.readable === true && isFunction(_input.read) && isFunction(_input.on))
919
- {
920
- streamer = new ReadableStreamStreamer(_config);
921
- }
922
- else if ((global.File && _input instanceof File) || _input instanceof Object) // ...Safari. (see issue #106)
923
- streamer = new FileStreamer(_config);
924
-
925
- return streamer.stream(_input);
926
-
927
- // Strip character from UTF-8 BOM encoded files that cause issue parsing the file
928
- function stripBom(string) {
929
- if (string.charCodeAt(0) === 0xfeff) {
930
- return string.slice(1);
931
- }
932
- return string;
933
- }
934
- }
935
-
936
-
937
-
938
-
939
-
940
-
941
- function JsonToCsv(_input, _config)
942
- {
943
- // Default configuration
944
-
945
- /** whether to surround every datum with quotes */
946
- var _quotes = false;
947
-
948
- /** whether to write headers */
949
- var _writeHeader = true;
950
-
951
- /** delimiting character(s) */
952
- var _delimiter = ',';
953
-
954
- /** newline character(s) */
955
- var _newline = '\r\n';
956
-
957
- /** quote character */
958
- var _quoteChar = '"';
959
-
960
- /** escaped quote character, either "" or <config.escapeChar>" */
961
- var _escapedQuote = _quoteChar + _quoteChar;
962
-
963
- /** whether to skip empty lines */
964
- var _skipEmptyLines = false;
965
-
966
- /** the columns (keys) we expect when we unparse objects */
967
- var _columns = null;
968
-
969
- /** whether to prevent outputting cells that can be parsed as formulae by spreadsheet software (Excel and LibreOffice) */
970
- var _escapeFormulae = false;
971
-
972
- unpackConfig();
973
-
974
- var quoteCharRegex = new RegExp(escapeRegExp(_quoteChar), 'g');
975
-
976
- if (typeof _input === 'string')
977
- _input = JSON.parse(_input);
978
-
979
- if (Array.isArray(_input))
980
- {
981
- if (!_input.length || Array.isArray(_input[0]))
982
- return serialize(null, _input, _skipEmptyLines);
983
- else if (typeof _input[0] === 'object')
984
- return serialize(_columns || Object.keys(_input[0]), _input, _skipEmptyLines);
985
- }
986
- else if (typeof _input === 'object')
987
- {
988
- if (typeof _input.data === 'string')
989
- _input.data = JSON.parse(_input.data);
990
-
991
- if (Array.isArray(_input.data))
992
- {
993
- if (!_input.fields)
994
- _input.fields = _input.meta && _input.meta.fields || _columns;
995
-
996
- if (!_input.fields)
997
- _input.fields = Array.isArray(_input.data[0])
998
- ? _input.fields
999
- : typeof _input.data[0] === 'object'
1000
- ? Object.keys(_input.data[0])
1001
- : [];
1002
-
1003
- if (!(Array.isArray(_input.data[0])) && typeof _input.data[0] !== 'object')
1004
- _input.data = [_input.data]; // handles input like [1,2,3] or ['asdf']
1005
- }
1006
-
1007
- return serialize(_input.fields || [], _input.data || [], _skipEmptyLines);
1008
- }
1009
-
1010
- // Default (any valid paths should return before this)
1011
- throw new Error('Unable to serialize unrecognized input');
1012
-
1013
-
1014
- function unpackConfig()
1015
- {
1016
- if (typeof _config !== 'object')
1017
- return;
1018
-
1019
- if (typeof _config.delimiter === 'string'
1020
- && !Papa.BAD_DELIMITERS.filter(function(value) { return _config.delimiter.indexOf(value) !== -1; }).length)
1021
- {
1022
- _delimiter = _config.delimiter;
1023
- }
1024
-
1025
- if (typeof _config.quotes === 'boolean'
1026
- || typeof _config.quotes === 'function'
1027
- || Array.isArray(_config.quotes))
1028
- _quotes = _config.quotes;
1029
-
1030
- if (typeof _config.skipEmptyLines === 'boolean'
1031
- || typeof _config.skipEmptyLines === 'string')
1032
- _skipEmptyLines = _config.skipEmptyLines;
1033
-
1034
- if (typeof _config.newline === 'string')
1035
- _newline = _config.newline;
1036
-
1037
- if (typeof _config.quoteChar === 'string')
1038
- _quoteChar = _config.quoteChar;
1039
-
1040
- if (typeof _config.header === 'boolean')
1041
- _writeHeader = _config.header;
1042
-
1043
- if (Array.isArray(_config.columns)) {
1044
-
1045
- if (_config.columns.length === 0) throw new Error('Option columns is empty');
1046
-
1047
- _columns = _config.columns;
1048
- }
1049
-
1050
- if (_config.escapeChar !== undefined) {
1051
- _escapedQuote = _config.escapeChar + _quoteChar;
1052
- }
1053
-
1054
- if (typeof _config.escapeFormulae === 'boolean' || _config.escapeFormulae instanceof RegExp) {
1055
- _escapeFormulae = _config.escapeFormulae instanceof RegExp ? _config.escapeFormulae : /^[=+\-@\t\r].*$/;
1056
- }
1057
- }
1058
-
1059
- /** The double for loop that iterates the data and writes out a CSV string including header row */
1060
- function serialize(fields, data, skipEmptyLines)
1061
- {
1062
- var csv = '';
1063
-
1064
- if (typeof fields === 'string')
1065
- fields = JSON.parse(fields);
1066
- if (typeof data === 'string')
1067
- data = JSON.parse(data);
1068
-
1069
- var hasHeader = Array.isArray(fields) && fields.length > 0;
1070
- var dataKeyedByField = !(Array.isArray(data[0]));
1071
-
1072
- // If there a header row, write it first
1073
- if (hasHeader && _writeHeader)
1074
- {
1075
- for (var i = 0; i < fields.length; i++)
1076
- {
1077
- if (i > 0)
1078
- csv += _delimiter;
1079
- csv += safe(fields[i], i);
1080
- }
1081
- if (data.length > 0)
1082
- csv += _newline;
1083
- }
1084
-
1085
- // Then write out the data
1086
- for (var row = 0; row < data.length; row++)
1087
- {
1088
- var maxCol = hasHeader ? fields.length : data[row].length;
1089
-
1090
- var emptyLine = false;
1091
- var nullLine = hasHeader ? Object.keys(data[row]).length === 0 : data[row].length === 0;
1092
- if (skipEmptyLines && !hasHeader)
1093
- {
1094
- emptyLine = skipEmptyLines === 'greedy' ? data[row].join('').trim() === '' : data[row].length === 1 && data[row][0].length === 0;
1095
- }
1096
- if (skipEmptyLines === 'greedy' && hasHeader) {
1097
- var line = [];
1098
- for (var c = 0; c < maxCol; c++) {
1099
- var cx = dataKeyedByField ? fields[c] : c;
1100
- line.push(data[row][cx]);
1101
- }
1102
- emptyLine = line.join('').trim() === '';
1103
- }
1104
- if (!emptyLine)
1105
- {
1106
- for (var col = 0; col < maxCol; col++)
1107
- {
1108
- if (col > 0 && !nullLine)
1109
- csv += _delimiter;
1110
- var colIdx = hasHeader && dataKeyedByField ? fields[col] : col;
1111
- csv += safe(data[row][colIdx], col);
1112
- }
1113
- if (row < data.length - 1 && (!skipEmptyLines || (maxCol > 0 && !nullLine)))
1114
- {
1115
- csv += _newline;
1116
- }
1117
- }
1118
- }
1119
- return csv;
1120
- }
1121
-
1122
- /** Encloses a value around quotes if needed (makes a value safe for CSV insertion) */
1123
- function safe(str, col)
1124
- {
1125
- if (typeof str === 'undefined' || str === null)
1126
- return '';
1127
-
1128
- if (str.constructor === Date)
1129
- return JSON.stringify(str).slice(1, 25);
1130
-
1131
- var needsQuotes = false;
1132
-
1133
- if (_escapeFormulae && typeof str === "string" && _escapeFormulae.test(str)) {
1134
- str = "'" + str;
1135
- needsQuotes = true;
1136
- }
1137
-
1138
- var escapedQuoteStr = str.toString().replace(quoteCharRegex, _escapedQuote);
1139
-
1140
- needsQuotes = needsQuotes
1141
- || _quotes === true
1142
- || (typeof _quotes === 'function' && _quotes(str, col))
1143
- || (Array.isArray(_quotes) && _quotes[col])
1144
- || hasAny(escapedQuoteStr, Papa.BAD_DELIMITERS)
1145
- || escapedQuoteStr.indexOf(_delimiter) > -1
1146
- || escapedQuoteStr.charAt(0) === ' '
1147
- || escapedQuoteStr.charAt(escapedQuoteStr.length - 1) === ' ';
1148
-
1149
- return needsQuotes ? _quoteChar + escapedQuoteStr + _quoteChar : escapedQuoteStr;
1150
- }
1151
-
1152
- function hasAny(str, substrings)
1153
- {
1154
- for (var i = 0; i < substrings.length; i++)
1155
- if (str.indexOf(substrings[i]) > -1)
1156
- return true;
1157
- return false;
1158
- }
1159
- }
1160
-
1161
- /** ChunkStreamer is the base prototype for various streamer implementations. */
1162
- function ChunkStreamer(config)
1163
- {
1164
- this._handle = null;
1165
- this._finished = false;
1166
- this._completed = false;
1167
- this._halted = false;
1168
- this._input = null;
1169
- this._baseIndex = 0;
1170
- this._partialLine = '';
1171
- this._rowCount = 0;
1172
- this._start = 0;
1173
- this._nextChunk = null;
1174
- this.isFirstChunk = true;
1175
- this._completeResults = {
1176
- data: [],
1177
- errors: [],
1178
- meta: {}
1179
- };
1180
- replaceConfig.call(this, config);
1181
-
1182
- this.parseChunk = function(chunk, isFakeChunk)
1183
- {
1184
- // First chunk pre-processing
1185
- if (this.isFirstChunk && isFunction(this._config.beforeFirstChunk))
1186
- {
1187
- var modifiedChunk = this._config.beforeFirstChunk(chunk);
1188
- if (modifiedChunk !== undefined)
1189
- chunk = modifiedChunk;
1190
- }
1191
- this.isFirstChunk = false;
1192
- this._halted = false;
1193
-
1194
- // Rejoin the line we likely just split in two by chunking the file
1195
- var aggregate = this._partialLine + chunk;
1196
- this._partialLine = '';
1197
-
1198
- var results = this._handle.parse(aggregate, this._baseIndex, !this._finished);
1199
-
1200
- if (this._handle.paused() || this._handle.aborted()) {
1201
- this._halted = true;
1202
- return;
1203
- }
1204
-
1205
- var lastIndex = results.meta.cursor;
1206
-
1207
- if (!this._finished)
1208
- {
1209
- this._partialLine = aggregate.substring(lastIndex - this._baseIndex);
1210
- this._baseIndex = lastIndex;
1211
- }
1212
-
1213
- if (results && results.data)
1214
- this._rowCount += results.data.length;
1215
-
1216
- var finishedIncludingPreview = this._finished || (this._config.preview && this._rowCount >= this._config.preview);
1217
-
1218
- if (IS_PAPA_WORKER)
1219
- {
1220
- global.postMessage({
1221
- results: results,
1222
- workerId: Papa.WORKER_ID,
1223
- finished: finishedIncludingPreview
1224
- });
1225
- }
1226
- else if (isFunction(this._config.chunk) && !isFakeChunk)
1227
- {
1228
- this._config.chunk(results, this._handle);
1229
- if (this._handle.paused() || this._handle.aborted()) {
1230
- this._halted = true;
1231
- return;
1232
- }
1233
- results = undefined;
1234
- this._completeResults = undefined;
1235
- }
1236
-
1237
- if (!this._config.step && !this._config.chunk) {
1238
- this._completeResults.data = this._completeResults.data.concat(results.data);
1239
- this._completeResults.errors = this._completeResults.errors.concat(results.errors);
1240
- this._completeResults.meta = results.meta;
1241
- }
1242
-
1243
- if (!this._completed && finishedIncludingPreview && isFunction(this._config.complete) && (!results || !results.meta.aborted)) {
1244
- this._config.complete(this._completeResults, this._input);
1245
- this._completed = true;
1246
- }
1247
-
1248
- if (!finishedIncludingPreview && (!results || !results.meta.paused))
1249
- this._nextChunk();
1250
-
1251
- return results;
1252
- };
1253
-
1254
- this._sendError = function(error)
1255
- {
1256
- if (isFunction(this._config.error))
1257
- this._config.error(error);
1258
- else if (IS_PAPA_WORKER && this._config.error)
1259
- {
1260
- global.postMessage({
1261
- workerId: Papa.WORKER_ID,
1262
- error: error,
1263
- finished: false
1264
- });
1265
- }
1266
- };
1267
-
1268
- function replaceConfig(config)
1269
- {
1270
- // Deep-copy the config so we can edit it
1271
- var configCopy = copy(config);
1272
- configCopy.chunkSize = parseInt(configCopy.chunkSize); // parseInt VERY important so we don't concatenate strings!
1273
- if (!config.step && !config.chunk)
1274
- configCopy.chunkSize = null; // disable Range header if not streaming; bad values break IIS - see issue #196
1275
- this._handle = new ParserHandle(configCopy);
1276
- this._handle.streamer = this;
1277
- this._config = configCopy; // persist the copy to the caller
1278
- }
1279
- }
1280
-
1281
-
1282
- function NetworkStreamer(config)
1283
- {
1284
- config = config || {};
1285
- if (!config.chunkSize)
1286
- config.chunkSize = Papa.RemoteChunkSize;
1287
- ChunkStreamer.call(this, config);
1288
-
1289
- var xhr;
1290
-
1291
- if (IS_WORKER)
1292
- {
1293
- this._nextChunk = function()
1294
- {
1295
- this._readChunk();
1296
- this._chunkLoaded();
1297
- };
1298
- }
1299
- else
1300
- {
1301
- this._nextChunk = function()
1302
- {
1303
- this._readChunk();
1304
- };
1305
- }
1306
-
1307
- this.stream = function(url)
1308
- {
1309
- this._input = url;
1310
- this._nextChunk(); // Starts streaming
1311
- };
1312
-
1313
- this._readChunk = function()
1314
- {
1315
- if (this._finished)
1316
- {
1317
- this._chunkLoaded();
1318
- return;
1319
- }
1320
-
1321
- xhr = new XMLHttpRequest();
1322
-
1323
- if (this._config.withCredentials)
1324
- {
1325
- xhr.withCredentials = this._config.withCredentials;
1326
- }
1327
-
1328
- if (!IS_WORKER)
1329
- {
1330
- xhr.onload = bindFunction(this._chunkLoaded, this);
1331
- xhr.onerror = bindFunction(this._chunkError, this);
1332
- }
1333
-
1334
- xhr.open(this._config.downloadRequestBody ? 'POST' : 'GET', this._input, !IS_WORKER);
1335
- // Headers can only be set when once the request state is OPENED
1336
- if (this._config.downloadRequestHeaders)
1337
- {
1338
- var headers = this._config.downloadRequestHeaders;
1339
-
1340
- for (var headerName in headers)
1341
- {
1342
- xhr.setRequestHeader(headerName, headers[headerName]);
1343
- }
1344
- }
1345
-
1346
- if (this._config.chunkSize)
1347
- {
1348
- var end = this._start + this._config.chunkSize - 1; // minus one because byte range is inclusive
1349
- xhr.setRequestHeader('Range', 'bytes=' + this._start + '-' + end);
1350
- }
1351
-
1352
- try {
1353
- xhr.send(this._config.downloadRequestBody);
1354
- }
1355
- catch (err) {
1356
- this._chunkError(err.message);
1357
- }
1358
-
1359
- if (IS_WORKER && xhr.status === 0)
1360
- this._chunkError();
1361
- };
1362
-
1363
- this._chunkLoaded = function()
1364
- {
1365
- if (xhr.readyState !== 4)
1366
- return;
1367
-
1368
- if (xhr.status < 200 || xhr.status >= 400)
1369
- {
1370
- this._chunkError();
1371
- return;
1372
- }
1373
-
1374
- // Use chunckSize as it may be a diference on reponse lentgh due to characters with more than 1 byte
1375
- this._start += this._config.chunkSize ? this._config.chunkSize : xhr.responseText.length;
1376
- this._finished = !this._config.chunkSize || this._start >= getFileSize(xhr);
1377
- this.parseChunk(xhr.responseText);
1378
- };
1379
-
1380
- this._chunkError = function(errorMessage)
1381
- {
1382
- var errorText = xhr.statusText || errorMessage;
1383
- this._sendError(new Error(errorText));
1384
- };
1385
-
1386
- function getFileSize(xhr)
1387
- {
1388
- var contentRange = xhr.getResponseHeader('Content-Range');
1389
- if (contentRange === null) { // no content range, then finish!
1390
- return -1;
1391
- }
1392
- return parseInt(contentRange.substring(contentRange.lastIndexOf('/') + 1));
1393
- }
1394
- }
1395
- NetworkStreamer.prototype = Object.create(ChunkStreamer.prototype);
1396
- NetworkStreamer.prototype.constructor = NetworkStreamer;
1397
-
1398
-
1399
- function FileStreamer(config)
1400
- {
1401
- config = config || {};
1402
- if (!config.chunkSize)
1403
- config.chunkSize = Papa.LocalChunkSize;
1404
- ChunkStreamer.call(this, config);
1405
-
1406
- var reader, slice;
1407
-
1408
- // FileReader is better than FileReaderSync (even in worker) - see http://stackoverflow.com/q/24708649/1048862
1409
- // But Firefox is a pill, too - see issue #76: https://github.com/mholt/PapaParse/issues/76
1410
- var usingAsyncReader = typeof FileReader !== 'undefined'; // Safari doesn't consider it a function - see issue #105
1411
-
1412
- this.stream = function(file)
1413
- {
1414
- this._input = file;
1415
- slice = file.slice || file.webkitSlice || file.mozSlice;
1416
-
1417
- if (usingAsyncReader)
1418
- {
1419
- reader = new FileReader(); // Preferred method of reading files, even in workers
1420
- reader.onload = bindFunction(this._chunkLoaded, this);
1421
- reader.onerror = bindFunction(this._chunkError, this);
1422
- }
1423
- else
1424
- reader = new FileReaderSync(); // Hack for running in a web worker in Firefox
1425
-
1426
- this._nextChunk(); // Starts streaming
1427
- };
1428
-
1429
- this._nextChunk = function()
1430
- {
1431
- if (!this._finished && (!this._config.preview || this._rowCount < this._config.preview))
1432
- this._readChunk();
1433
- };
1434
-
1435
- this._readChunk = function()
1436
- {
1437
- var input = this._input;
1438
- if (this._config.chunkSize)
1439
- {
1440
- var end = Math.min(this._start + this._config.chunkSize, this._input.size);
1441
- input = slice.call(input, this._start, end);
1442
- }
1443
- var txt = reader.readAsText(input, this._config.encoding);
1444
- if (!usingAsyncReader)
1445
- this._chunkLoaded({ target: { result: txt } }); // mimic the async signature
1446
- };
1447
-
1448
- this._chunkLoaded = function(event)
1449
- {
1450
- // Very important to increment start each time before handling results
1451
- this._start += this._config.chunkSize;
1452
- this._finished = !this._config.chunkSize || this._start >= this._input.size;
1453
- this.parseChunk(event.target.result);
1454
- };
1455
-
1456
- this._chunkError = function()
1457
- {
1458
- this._sendError(reader.error);
1459
- };
1460
-
1461
- }
1462
- FileStreamer.prototype = Object.create(ChunkStreamer.prototype);
1463
- FileStreamer.prototype.constructor = FileStreamer;
1464
-
1465
-
1466
- function StringStreamer(config)
1467
- {
1468
- config = config || {};
1469
- ChunkStreamer.call(this, config);
1470
-
1471
- var remaining;
1472
- this.stream = function(s)
1473
- {
1474
- remaining = s;
1475
- return this._nextChunk();
1476
- };
1477
- this._nextChunk = function()
1478
- {
1479
- if (this._finished) return;
1480
- var size = this._config.chunkSize;
1481
- var chunk;
1482
- if(size) {
1483
- chunk = remaining.substring(0, size);
1484
- remaining = remaining.substring(size);
1485
- } else {
1486
- chunk = remaining;
1487
- remaining = '';
1488
- }
1489
- this._finished = !remaining;
1490
- return this.parseChunk(chunk);
1491
- };
1492
- }
1493
- StringStreamer.prototype = Object.create(StringStreamer.prototype);
1494
- StringStreamer.prototype.constructor = StringStreamer;
1495
-
1496
-
1497
- function ReadableStreamStreamer(config)
1498
- {
1499
- config = config || {};
1500
-
1501
- ChunkStreamer.call(this, config);
1502
-
1503
- var queue = [];
1504
- var parseOnData = true;
1505
- var streamHasEnded = false;
1506
-
1507
- this.pause = function()
1508
- {
1509
- ChunkStreamer.prototype.pause.apply(this, arguments);
1510
- this._input.pause();
1511
- };
1512
-
1513
- this.resume = function()
1514
- {
1515
- ChunkStreamer.prototype.resume.apply(this, arguments);
1516
- this._input.resume();
1517
- };
1518
-
1519
- this.stream = function(stream)
1520
- {
1521
- this._input = stream;
1522
-
1523
- this._input.on('data', this._streamData);
1524
- this._input.on('end', this._streamEnd);
1525
- this._input.on('error', this._streamError);
1526
- };
1527
-
1528
- this._checkIsFinished = function()
1529
- {
1530
- if (streamHasEnded && queue.length === 1) {
1531
- this._finished = true;
1532
- }
1533
- };
1534
-
1535
- this._nextChunk = function()
1536
- {
1537
- this._checkIsFinished();
1538
- if (queue.length)
1539
- {
1540
- this.parseChunk(queue.shift());
1541
- }
1542
- else
1543
- {
1544
- parseOnData = true;
1545
- }
1546
- };
1547
-
1548
- this._streamData = bindFunction(function(chunk)
1549
- {
1550
- try
1551
- {
1552
- queue.push(typeof chunk === 'string' ? chunk : chunk.toString(this._config.encoding));
1553
-
1554
- if (parseOnData)
1555
- {
1556
- parseOnData = false;
1557
- this._checkIsFinished();
1558
- this.parseChunk(queue.shift());
1559
- }
1560
- }
1561
- catch (error)
1562
- {
1563
- this._streamError(error);
1564
- }
1565
- }, this);
1566
-
1567
- this._streamError = bindFunction(function(error)
1568
- {
1569
- this._streamCleanUp();
1570
- this._sendError(error);
1571
- }, this);
1572
-
1573
- this._streamEnd = bindFunction(function()
1574
- {
1575
- this._streamCleanUp();
1576
- streamHasEnded = true;
1577
- this._streamData('');
1578
- }, this);
1579
-
1580
- this._streamCleanUp = bindFunction(function()
1581
- {
1582
- this._input.removeListener('data', this._streamData);
1583
- this._input.removeListener('end', this._streamEnd);
1584
- this._input.removeListener('error', this._streamError);
1585
- }, this);
1586
- }
1587
- ReadableStreamStreamer.prototype = Object.create(ChunkStreamer.prototype);
1588
- ReadableStreamStreamer.prototype.constructor = ReadableStreamStreamer;
1589
-
1590
-
1591
- function DuplexStreamStreamer(_config) {
1592
- var Duplex = require$$0__default["default"].Duplex;
1593
- var config = copy(_config);
1594
- var parseOnWrite = true;
1595
- var writeStreamHasFinished = false;
1596
- var parseCallbackQueue = [];
1597
- var stream = null;
1598
-
1599
- this._onCsvData = function(results)
1600
- {
1601
- var data = results.data;
1602
- if (!stream.push(data) && !this._handle.paused()) {
1603
- // the writeable consumer buffer has filled up
1604
- // so we need to pause until more items
1605
- // can be processed
1606
- this._handle.pause();
1607
- }
1608
- };
1609
-
1610
- this._onCsvComplete = function()
1611
- {
1612
- // node will finish the read stream when
1613
- // null is pushed
1614
- stream.push(null);
1615
- };
1616
-
1617
- config.step = bindFunction(this._onCsvData, this);
1618
- config.complete = bindFunction(this._onCsvComplete, this);
1619
- ChunkStreamer.call(this, config);
1620
-
1621
- this._nextChunk = function()
1622
- {
1623
- if (writeStreamHasFinished && parseCallbackQueue.length === 1) {
1624
- this._finished = true;
1625
- }
1626
- if (parseCallbackQueue.length) {
1627
- parseCallbackQueue.shift()();
1628
- } else {
1629
- parseOnWrite = true;
1630
- }
1631
- };
1632
-
1633
- this._addToParseQueue = function(chunk, callback)
1634
- {
1635
- // add to queue so that we can indicate
1636
- // completion via callback
1637
- // node will automatically pause the incoming stream
1638
- // when too many items have been added without their
1639
- // callback being invoked
1640
- parseCallbackQueue.push(bindFunction(function() {
1641
- this.parseChunk(typeof chunk === 'string' ? chunk : chunk.toString(config.encoding));
1642
- if (isFunction(callback)) {
1643
- return callback();
1644
- }
1645
- }, this));
1646
- if (parseOnWrite) {
1647
- parseOnWrite = false;
1648
- this._nextChunk();
1649
- }
1650
- };
1651
-
1652
- this._onRead = function()
1653
- {
1654
- if (this._handle.paused()) {
1655
- // the writeable consumer can handle more data
1656
- // so resume the chunk parsing
1657
- this._handle.resume();
1658
- }
1659
- };
1660
-
1661
- this._onWrite = function(chunk, encoding, callback)
1662
- {
1663
- this._addToParseQueue(chunk, callback);
1664
- };
1665
-
1666
- this._onWriteComplete = function()
1667
- {
1668
- writeStreamHasFinished = true;
1669
- // have to write empty string
1670
- // so parser knows its done
1671
- this._addToParseQueue('');
1672
- };
1673
-
1674
- this.getStream = function()
1675
- {
1676
- return stream;
1677
- };
1678
- stream = new Duplex({
1679
- readableObjectMode: true,
1680
- decodeStrings: false,
1681
- read: bindFunction(this._onRead, this),
1682
- write: bindFunction(this._onWrite, this)
1683
- });
1684
- stream.once('finish', bindFunction(this._onWriteComplete, this));
1685
- }
1686
- if (typeof PAPA_BROWSER_CONTEXT === 'undefined') {
1687
- DuplexStreamStreamer.prototype = Object.create(ChunkStreamer.prototype);
1688
- DuplexStreamStreamer.prototype.constructor = DuplexStreamStreamer;
1689
- }
1690
-
1691
-
1692
- // Use one ParserHandle per entire CSV file or string
1693
- function ParserHandle(_config)
1694
- {
1695
- // One goal is to minimize the use of regular expressions...
1696
- var MAX_FLOAT = Math.pow(2, 53);
1697
- var MIN_FLOAT = -MAX_FLOAT;
1698
- var FLOAT = /^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/;
1699
- var ISO_DATE = /^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/;
1700
- var self = this;
1701
- var _stepCounter = 0; // Number of times step was called (number of rows parsed)
1702
- var _rowCounter = 0; // Number of rows that have been parsed so far
1703
- var _input; // The input being parsed
1704
- var _parser; // The core parser being used
1705
- var _paused = false; // Whether we are paused or not
1706
- var _aborted = false; // Whether the parser has aborted or not
1707
- var _delimiterError; // Temporary state between delimiter detection and processing results
1708
- var _fields = []; // Fields are from the header row of the input, if there is one
1709
- var _results = { // The last results returned from the parser
1710
- data: [],
1711
- errors: [],
1712
- meta: {}
1713
- };
1714
-
1715
- if (isFunction(_config.step))
1716
- {
1717
- var userStep = _config.step;
1718
- _config.step = function(results)
1719
- {
1720
- _results = results;
1721
-
1722
- if (needsHeaderRow())
1723
- processResults();
1724
- else // only call user's step function after header row
1725
- {
1726
- processResults();
1727
-
1728
- // It's possbile that this line was empty and there's no row here after all
1729
- if (_results.data.length === 0)
1730
- return;
1731
-
1732
- _stepCounter += results.data.length;
1733
- if (_config.preview && _stepCounter > _config.preview)
1734
- _parser.abort();
1735
- else {
1736
- _results.data = _results.data[0];
1737
- userStep(_results, self);
1738
- }
1739
- }
1740
- };
1741
- }
1742
-
1743
- /**
1744
- * Parses input. Most users won't need, and shouldn't mess with, the baseIndex
1745
- * and ignoreLastRow parameters. They are used by streamers (wrapper functions)
1746
- * when an input comes in multiple chunks, like from a file.
1747
- */
1748
- this.parse = function(input, baseIndex, ignoreLastRow)
1749
- {
1750
- var quoteChar = _config.quoteChar || '"';
1751
- if (!_config.newline)
1752
- _config.newline = guessLineEndings(input, quoteChar);
1753
-
1754
- _delimiterError = false;
1755
- if (!_config.delimiter)
1756
- {
1757
- var delimGuess = guessDelimiter(input, _config.newline, _config.skipEmptyLines, _config.comments, _config.delimitersToGuess);
1758
- if (delimGuess.successful)
1759
- _config.delimiter = delimGuess.bestDelimiter;
1760
- else
1761
- {
1762
- _delimiterError = true; // add error after parsing (otherwise it would be overwritten)
1763
- _config.delimiter = Papa.DefaultDelimiter;
1764
- }
1765
- _results.meta.delimiter = _config.delimiter;
1766
- }
1767
- else if(isFunction(_config.delimiter))
1768
- {
1769
- _config.delimiter = _config.delimiter(input);
1770
- _results.meta.delimiter = _config.delimiter;
1771
- }
1772
-
1773
- var parserConfig = copy(_config);
1774
- if (_config.preview && _config.header)
1775
- parserConfig.preview++; // to compensate for header row
1776
-
1777
- _input = input;
1778
- _parser = new Parser(parserConfig);
1779
- _results = _parser.parse(_input, baseIndex, ignoreLastRow);
1780
- processResults();
1781
- return _paused ? { meta: { paused: true } } : (_results || { meta: { paused: false } });
1782
- };
1783
-
1784
- this.paused = function()
1785
- {
1786
- return _paused;
1787
- };
1788
-
1789
- this.pause = function()
1790
- {
1791
- _paused = true;
1792
- _parser.abort();
1793
-
1794
- // If it is streaming via "chunking", the reader will start appending correctly already so no need to substring,
1795
- // otherwise we can get duplicate content within a row
1796
- _input = isFunction(_config.chunk) ? "" : _input.substring(_parser.getCharIndex());
1797
- };
1798
-
1799
- this.resume = function()
1800
- {
1801
- if(self.streamer._halted) {
1802
- _paused = false;
1803
- self.streamer.parseChunk(_input, true);
1804
- } else {
1805
- // Bugfix: #636 In case the processing hasn't halted yet
1806
- // wait for it to halt in order to resume
1807
- setTimeout(self.resume, 3);
1808
- }
1809
- };
1810
-
1811
- this.aborted = function()
1812
- {
1813
- return _aborted;
1814
- };
1815
-
1816
- this.abort = function()
1817
- {
1818
- _aborted = true;
1819
- _parser.abort();
1820
- _results.meta.aborted = true;
1821
- if (isFunction(_config.complete))
1822
- _config.complete(_results);
1823
- _input = '';
1824
- };
1825
-
1826
- function testEmptyLine(s) {
1827
- return _config.skipEmptyLines === 'greedy' ? s.join('').trim() === '' : s.length === 1 && s[0].length === 0;
1828
- }
1829
-
1830
- function testFloat(s) {
1831
- if (FLOAT.test(s)) {
1832
- var floatValue = parseFloat(s);
1833
- if (floatValue > MIN_FLOAT && floatValue < MAX_FLOAT) {
1834
- return true;
1835
- }
1836
- }
1837
- return false;
1838
- }
1839
-
1840
- function processResults()
1841
- {
1842
- if (_results && _delimiterError)
1843
- {
1844
- addError('Delimiter', 'UndetectableDelimiter', 'Unable to auto-detect delimiting character; defaulted to \'' + Papa.DefaultDelimiter + '\'');
1845
- _delimiterError = false;
1846
- }
1847
-
1848
- if (_config.skipEmptyLines)
1849
- {
1850
- _results.data = _results.data.filter(function(d) {
1851
- return !testEmptyLine(d);
1852
- });
1853
- }
1854
-
1855
- if (needsHeaderRow())
1856
- fillHeaderFields();
1857
-
1858
- return applyHeaderAndDynamicTypingAndTransformation();
1859
- }
1860
-
1861
- function needsHeaderRow()
1862
- {
1863
- return _config.header && _fields.length === 0;
1864
- }
1865
-
1866
- function fillHeaderFields()
1867
- {
1868
- if (!_results)
1869
- return;
1870
-
1871
- function addHeader(header, i)
1872
- {
1873
- if (isFunction(_config.transformHeader))
1874
- header = _config.transformHeader(header, i);
1875
-
1876
- _fields.push(header);
1877
- }
1878
-
1879
- if (Array.isArray(_results.data[0]))
1880
- {
1881
- for (var i = 0; needsHeaderRow() && i < _results.data.length; i++)
1882
- _results.data[i].forEach(addHeader);
1883
-
1884
- _results.data.splice(0, 1);
1885
- }
1886
- // if _results.data[0] is not an array, we are in a step where _results.data is the row.
1887
- else
1888
- _results.data.forEach(addHeader);
1889
- }
1890
-
1891
- function shouldApplyDynamicTyping(field) {
1892
- // Cache function values to avoid calling it for each row
1893
- if (_config.dynamicTypingFunction && _config.dynamicTyping[field] === undefined) {
1894
- _config.dynamicTyping[field] = _config.dynamicTypingFunction(field);
1895
- }
1896
- return (_config.dynamicTyping[field] || _config.dynamicTyping) === true;
1897
- }
1898
-
1899
- function parseDynamic(field, value)
1900
- {
1901
- if (shouldApplyDynamicTyping(field))
1902
- {
1903
- if (value === 'true' || value === 'TRUE')
1904
- return true;
1905
- else if (value === 'false' || value === 'FALSE')
1906
- return false;
1907
- else if (testFloat(value))
1908
- return parseFloat(value);
1909
- else if (ISO_DATE.test(value))
1910
- return new Date(value);
1911
- else
1912
- return (value === '' ? null : value);
1913
- }
1914
- return value;
1915
- }
1916
-
1917
- function applyHeaderAndDynamicTypingAndTransformation()
1918
- {
1919
- if (!_results || (!_config.header && !_config.dynamicTyping && !_config.transform))
1920
- return _results;
1921
-
1922
- function processRow(rowSource, i)
1923
- {
1924
- var row = _config.header ? {} : [];
1925
-
1926
- var j;
1927
- for (j = 0; j < rowSource.length; j++)
1928
- {
1929
- var field = j;
1930
- var value = rowSource[j];
1931
-
1932
- if (_config.header)
1933
- field = j >= _fields.length ? '__parsed_extra' : _fields[j];
1934
-
1935
- if (_config.transform)
1936
- value = _config.transform(value,field);
1937
-
1938
- value = parseDynamic(field, value);
1939
-
1940
- if (field === '__parsed_extra')
1941
- {
1942
- row[field] = row[field] || [];
1943
- row[field].push(value);
1944
- }
1945
- else
1946
- row[field] = value;
1947
- }
1948
-
1949
-
1950
- if (_config.header)
1951
- {
1952
- if (j > _fields.length)
1953
- addError('FieldMismatch', 'TooManyFields', 'Too many fields: expected ' + _fields.length + ' fields but parsed ' + j, _rowCounter + i);
1954
- else if (j < _fields.length)
1955
- addError('FieldMismatch', 'TooFewFields', 'Too few fields: expected ' + _fields.length + ' fields but parsed ' + j, _rowCounter + i);
1956
- }
1957
-
1958
- return row;
1959
- }
1960
-
1961
- var incrementBy = 1;
1962
- if (!_results.data.length || Array.isArray(_results.data[0]))
1963
- {
1964
- _results.data = _results.data.map(processRow);
1965
- incrementBy = _results.data.length;
1966
- }
1967
- else
1968
- _results.data = processRow(_results.data, 0);
1969
-
1970
-
1971
- if (_config.header && _results.meta)
1972
- _results.meta.fields = _fields;
1973
-
1974
- _rowCounter += incrementBy;
1975
- return _results;
1976
- }
1977
-
1978
- function guessDelimiter(input, newline, skipEmptyLines, comments, delimitersToGuess) {
1979
- var bestDelim, bestDelta, fieldCountPrevRow, maxFieldCount;
1980
-
1981
- delimitersToGuess = delimitersToGuess || [',', '\t', '|', ';', Papa.RECORD_SEP, Papa.UNIT_SEP];
1982
-
1983
- for (var i = 0; i < delimitersToGuess.length; i++) {
1984
- var delim = delimitersToGuess[i];
1985
- var delta = 0, avgFieldCount = 0, emptyLinesCount = 0;
1986
- fieldCountPrevRow = undefined;
1987
-
1988
- var preview = new Parser({
1989
- comments: comments,
1990
- delimiter: delim,
1991
- newline: newline,
1992
- preview: 10
1993
- }).parse(input);
1994
-
1995
- for (var j = 0; j < preview.data.length; j++) {
1996
- if (skipEmptyLines && testEmptyLine(preview.data[j])) {
1997
- emptyLinesCount++;
1998
- continue;
1999
- }
2000
- var fieldCount = preview.data[j].length;
2001
- avgFieldCount += fieldCount;
2002
-
2003
- if (typeof fieldCountPrevRow === 'undefined') {
2004
- fieldCountPrevRow = fieldCount;
2005
- continue;
2006
- }
2007
- else if (fieldCount > 0) {
2008
- delta += Math.abs(fieldCount - fieldCountPrevRow);
2009
- fieldCountPrevRow = fieldCount;
2010
- }
2011
- }
2012
-
2013
- if (preview.data.length > 0)
2014
- avgFieldCount /= (preview.data.length - emptyLinesCount);
2015
-
2016
- if ((typeof bestDelta === 'undefined' || delta <= bestDelta)
2017
- && (typeof maxFieldCount === 'undefined' || avgFieldCount > maxFieldCount) && avgFieldCount > 1.99) {
2018
- bestDelta = delta;
2019
- bestDelim = delim;
2020
- maxFieldCount = avgFieldCount;
2021
- }
2022
- }
2023
-
2024
- _config.delimiter = bestDelim;
2025
-
2026
- return {
2027
- successful: !!bestDelim,
2028
- bestDelimiter: bestDelim
2029
- };
2030
- }
2031
-
2032
- function guessLineEndings(input, quoteChar)
2033
- {
2034
- input = input.substring(0, 1024 * 1024); // max length 1 MB
2035
- // Replace all the text inside quotes
2036
- var re = new RegExp(escapeRegExp(quoteChar) + '([^]*?)' + escapeRegExp(quoteChar), 'gm');
2037
- input = input.replace(re, '');
2038
-
2039
- var r = input.split('\r');
2040
-
2041
- var n = input.split('\n');
2042
-
2043
- var nAppearsFirst = (n.length > 1 && n[0].length < r[0].length);
2044
-
2045
- if (r.length === 1 || nAppearsFirst)
2046
- return '\n';
2047
-
2048
- var numWithN = 0;
2049
- for (var i = 0; i < r.length; i++)
2050
- {
2051
- if (r[i][0] === '\n')
2052
- numWithN++;
2053
- }
2054
-
2055
- return numWithN >= r.length / 2 ? '\r\n' : '\r';
2056
- }
2057
-
2058
- function addError(type, code, msg, row)
2059
- {
2060
- var error = {
2061
- type: type,
2062
- code: code,
2063
- message: msg
2064
- };
2065
- if(row !== undefined) {
2066
- error.row = row;
2067
- }
2068
- _results.errors.push(error);
2069
- }
2070
- }
2071
-
2072
- /** https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions */
2073
- function escapeRegExp(string)
2074
- {
2075
- return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
2076
- }
2077
-
2078
- /** The core parser implements speedy and correct CSV parsing */
2079
- function Parser(config)
2080
- {
2081
- // Unpack the config object
2082
- config = config || {};
2083
- var delim = config.delimiter;
2084
- var newline = config.newline;
2085
- var comments = config.comments;
2086
- var step = config.step;
2087
- var preview = config.preview;
2088
- var fastMode = config.fastMode;
2089
- var quoteChar;
2090
- if (config.quoteChar === undefined || config.quoteChar === null) {
2091
- quoteChar = '"';
2092
- } else {
2093
- quoteChar = config.quoteChar;
2094
- }
2095
- var escapeChar = quoteChar;
2096
- if (config.escapeChar !== undefined) {
2097
- escapeChar = config.escapeChar;
2098
- }
2099
-
2100
- // Delimiter must be valid
2101
- if (typeof delim !== 'string'
2102
- || Papa.BAD_DELIMITERS.indexOf(delim) > -1)
2103
- delim = ',';
2104
-
2105
- // Comment character must be valid
2106
- if (comments === delim)
2107
- throw new Error('Comment character same as delimiter');
2108
- else if (comments === true)
2109
- comments = '#';
2110
- else if (typeof comments !== 'string'
2111
- || Papa.BAD_DELIMITERS.indexOf(comments) > -1)
2112
- comments = false;
2113
-
2114
- // Newline must be valid: \r, \n, or \r\n
2115
- if (newline !== '\n' && newline !== '\r' && newline !== '\r\n')
2116
- newline = '\n';
2117
-
2118
- // We're gonna need these at the Parser scope
2119
- var cursor = 0;
2120
- var aborted = false;
2121
-
2122
- this.parse = function(input, baseIndex, ignoreLastRow)
2123
- {
2124
- // For some reason, in Chrome, this speeds things up (!?)
2125
- if (typeof input !== 'string')
2126
- throw new Error('Input must be a string');
2127
-
2128
- // We don't need to compute some of these every time parse() is called,
2129
- // but having them in a more local scope seems to perform better
2130
- var inputLen = input.length,
2131
- delimLen = delim.length,
2132
- newlineLen = newline.length,
2133
- commentsLen = comments.length;
2134
- var stepIsFunction = isFunction(step);
2135
-
2136
- // Establish starting state
2137
- cursor = 0;
2138
- var data = [], errors = [], row = [], lastCursor = 0;
2139
-
2140
- if (!input)
2141
- return returnable();
2142
-
2143
- // Rename headers if there are duplicates
2144
- if (config.header)
2145
- {
2146
- var firstLine = input.split(newline)[0];
2147
- var headers = firstLine.split(delim);
2148
- var separator = '_';
2149
- var headerMap = [];
2150
- var headerCount = {};
2151
- var duplicateHeaders = false;
2152
-
2153
- for (var j in headers) {
2154
- var header = headers[j];
2155
- if (isFunction(config.transformHeader))
2156
- header = config.transformHeader(header, j);
2157
- var headerName = header;
2158
-
2159
- var count = headerCount[header] || 0;
2160
- if (count > 0) {
2161
- duplicateHeaders = true;
2162
- headerName = header + separator + count;
2163
- }
2164
- headerCount[header] = count + 1;
2165
-
2166
- headerMap.push(headerName);
2167
- }
2168
- if (duplicateHeaders) {
2169
- var editedInput = input.split(newline);
2170
- editedInput[0] = headerMap.join(delim);
2171
- input = editedInput.join(newline);
2172
- }
2173
- }
2174
- if (fastMode || (fastMode !== false && input.indexOf(quoteChar) === -1))
2175
- {
2176
- var rows = input.split(newline);
2177
- for (var i = 0; i < rows.length; i++)
2178
- {
2179
- row = rows[i];
2180
- cursor += row.length;
2181
- if (i !== rows.length - 1)
2182
- cursor += newline.length;
2183
- else if (ignoreLastRow)
2184
- return returnable();
2185
- if (comments && row.substring(0, commentsLen) === comments)
2186
- continue;
2187
- if (stepIsFunction)
2188
- {
2189
- data = [];
2190
- pushRow(row.split(delim));
2191
- doStep();
2192
- if (aborted)
2193
- return returnable();
2194
- }
2195
- else
2196
- pushRow(row.split(delim));
2197
- if (preview && i >= preview)
2198
- {
2199
- data = data.slice(0, preview);
2200
- return returnable(true);
2201
- }
2202
- }
2203
- return returnable();
2204
- }
2205
-
2206
- var nextDelim = input.indexOf(delim, cursor);
2207
- var nextNewline = input.indexOf(newline, cursor);
2208
- var quoteCharRegex = new RegExp(escapeRegExp(escapeChar) + escapeRegExp(quoteChar), 'g');
2209
- var quoteSearch = input.indexOf(quoteChar, cursor);
2210
-
2211
- // Parser loop
2212
- for (;;)
2213
- {
2214
- // Field has opening quote
2215
- if (input[cursor] === quoteChar)
2216
- {
2217
- // Start our search for the closing quote where the cursor is
2218
- quoteSearch = cursor;
2219
-
2220
- // Skip the opening quote
2221
- cursor++;
2222
-
2223
- for (;;)
2224
- {
2225
- // Find closing quote
2226
- quoteSearch = input.indexOf(quoteChar, quoteSearch + 1);
2227
-
2228
- //No other quotes are found - no other delimiters
2229
- if (quoteSearch === -1)
2230
- {
2231
- if (!ignoreLastRow) {
2232
- // No closing quote... what a pity
2233
- errors.push({
2234
- type: 'Quotes',
2235
- code: 'MissingQuotes',
2236
- message: 'Quoted field unterminated',
2237
- row: data.length, // row has yet to be inserted
2238
- index: cursor
2239
- });
2240
- }
2241
- return finish();
2242
- }
2243
-
2244
- // Closing quote at EOF
2245
- if (quoteSearch === inputLen - 1)
2246
- {
2247
- var value = input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar);
2248
- return finish(value);
2249
- }
2250
-
2251
- // If this quote is escaped, it's part of the data; skip it
2252
- // If the quote character is the escape character, then check if the next character is the escape character
2253
- if (quoteChar === escapeChar && input[quoteSearch + 1] === escapeChar)
2254
- {
2255
- quoteSearch++;
2256
- continue;
2257
- }
2258
-
2259
- // If the quote character is not the escape character, then check if the previous character was the escape character
2260
- if (quoteChar !== escapeChar && quoteSearch !== 0 && input[quoteSearch - 1] === escapeChar)
2261
- {
2262
- continue;
2263
- }
2264
-
2265
- if(nextDelim !== -1 && nextDelim < (quoteSearch + 1)) {
2266
- nextDelim = input.indexOf(delim, (quoteSearch + 1));
2267
- }
2268
- if(nextNewline !== -1 && nextNewline < (quoteSearch + 1)) {
2269
- nextNewline = input.indexOf(newline, (quoteSearch + 1));
2270
- }
2271
- // Check up to nextDelim or nextNewline, whichever is closest
2272
- var checkUpTo = nextNewline === -1 ? nextDelim : Math.min(nextDelim, nextNewline);
2273
- var spacesBetweenQuoteAndDelimiter = extraSpaces(checkUpTo);
2274
-
2275
- // Closing quote followed by delimiter or 'unnecessary spaces + delimiter'
2276
- if (input.substr(quoteSearch + 1 + spacesBetweenQuoteAndDelimiter, delimLen) === delim)
2277
- {
2278
- row.push(input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar));
2279
- cursor = quoteSearch + 1 + spacesBetweenQuoteAndDelimiter + delimLen;
2280
-
2281
- // If char after following delimiter is not quoteChar, we find next quote char position
2282
- if (input[quoteSearch + 1 + spacesBetweenQuoteAndDelimiter + delimLen] !== quoteChar)
2283
- {
2284
- quoteSearch = input.indexOf(quoteChar, cursor);
2285
- }
2286
- nextDelim = input.indexOf(delim, cursor);
2287
- nextNewline = input.indexOf(newline, cursor);
2288
- break;
2289
- }
2290
-
2291
- var spacesBetweenQuoteAndNewLine = extraSpaces(nextNewline);
2292
-
2293
- // Closing quote followed by newline or 'unnecessary spaces + newLine'
2294
- if (input.substring(quoteSearch + 1 + spacesBetweenQuoteAndNewLine, quoteSearch + 1 + spacesBetweenQuoteAndNewLine + newlineLen) === newline)
2295
- {
2296
- row.push(input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar));
2297
- saveRow(quoteSearch + 1 + spacesBetweenQuoteAndNewLine + newlineLen);
2298
- nextDelim = input.indexOf(delim, cursor); // because we may have skipped the nextDelim in the quoted field
2299
- quoteSearch = input.indexOf(quoteChar, cursor); // we search for first quote in next line
2300
-
2301
- if (stepIsFunction)
2302
- {
2303
- doStep();
2304
- if (aborted)
2305
- return returnable();
2306
- }
2307
-
2308
- if (preview && data.length >= preview)
2309
- return returnable(true);
2310
-
2311
- break;
2312
- }
2313
-
2314
-
2315
- // Checks for valid closing quotes are complete (escaped quotes or quote followed by EOF/delimiter/newline) -- assume these quotes are part of an invalid text string
2316
- errors.push({
2317
- type: 'Quotes',
2318
- code: 'InvalidQuotes',
2319
- message: 'Trailing quote on quoted field is malformed',
2320
- row: data.length, // row has yet to be inserted
2321
- index: cursor
2322
- });
2323
-
2324
- quoteSearch++;
2325
- continue;
2326
-
2327
- }
2328
-
2329
- continue;
2330
- }
2331
-
2332
- // Comment found at start of new line
2333
- if (comments && row.length === 0 && input.substring(cursor, cursor + commentsLen) === comments)
2334
- {
2335
- if (nextNewline === -1) // Comment ends at EOF
2336
- return returnable();
2337
- cursor = nextNewline + newlineLen;
2338
- nextNewline = input.indexOf(newline, cursor);
2339
- nextDelim = input.indexOf(delim, cursor);
2340
- continue;
2341
- }
2342
-
2343
- // Next delimiter comes before next newline, so we've reached end of field
2344
- if (nextDelim !== -1 && (nextDelim < nextNewline || nextNewline === -1))
2345
- {
2346
- row.push(input.substring(cursor, nextDelim));
2347
- cursor = nextDelim + delimLen;
2348
- // we look for next delimiter char
2349
- nextDelim = input.indexOf(delim, cursor);
2350
- continue;
2351
- }
2352
-
2353
- // End of row
2354
- if (nextNewline !== -1)
2355
- {
2356
- row.push(input.substring(cursor, nextNewline));
2357
- saveRow(nextNewline + newlineLen);
2358
-
2359
- if (stepIsFunction)
2360
- {
2361
- doStep();
2362
- if (aborted)
2363
- return returnable();
2364
- }
2365
-
2366
- if (preview && data.length >= preview)
2367
- return returnable(true);
2368
-
2369
- continue;
2370
- }
2371
-
2372
- break;
2373
- }
2374
-
2375
-
2376
- return finish();
2377
-
2378
-
2379
- function pushRow(row)
2380
- {
2381
- data.push(row);
2382
- lastCursor = cursor;
2383
- }
2384
-
2385
- /**
2386
- * checks if there are extra spaces after closing quote and given index without any text
2387
- * if Yes, returns the number of spaces
2388
- */
2389
- function extraSpaces(index) {
2390
- var spaceLength = 0;
2391
- if (index !== -1) {
2392
- var textBetweenClosingQuoteAndIndex = input.substring(quoteSearch + 1, index);
2393
- if (textBetweenClosingQuoteAndIndex && textBetweenClosingQuoteAndIndex.trim() === '') {
2394
- spaceLength = textBetweenClosingQuoteAndIndex.length;
2395
- }
2396
- }
2397
- return spaceLength;
2398
- }
2399
-
2400
- /**
2401
- * Appends the remaining input from cursor to the end into
2402
- * row, saves the row, calls step, and returns the results.
2403
- */
2404
- function finish(value)
2405
- {
2406
- if (ignoreLastRow)
2407
- return returnable();
2408
- if (typeof value === 'undefined')
2409
- value = input.substring(cursor);
2410
- row.push(value);
2411
- cursor = inputLen; // important in case parsing is paused
2412
- pushRow(row);
2413
- if (stepIsFunction)
2414
- doStep();
2415
- return returnable();
2416
- }
2417
-
2418
- /**
2419
- * Appends the current row to the results. It sets the cursor
2420
- * to newCursor and finds the nextNewline. The caller should
2421
- * take care to execute user's step function and check for
2422
- * preview and end parsing if necessary.
2423
- */
2424
- function saveRow(newCursor)
2425
- {
2426
- cursor = newCursor;
2427
- pushRow(row);
2428
- row = [];
2429
- nextNewline = input.indexOf(newline, cursor);
2430
- }
2431
-
2432
- /** Returns an object with the results, errors, and meta. */
2433
- function returnable(stopped)
2434
- {
2435
- return {
2436
- data: data,
2437
- errors: errors,
2438
- meta: {
2439
- delimiter: delim,
2440
- linebreak: newline,
2441
- aborted: aborted,
2442
- truncated: !!stopped,
2443
- cursor: lastCursor + (baseIndex || 0)
2444
- }
2445
- };
2446
- }
2447
-
2448
- /** Executes the user's step function and resets data & errors. */
2449
- function doStep()
2450
- {
2451
- step(returnable());
2452
- data = [];
2453
- errors = [];
2454
- }
2455
- };
2456
-
2457
- /** Sets the abort flag */
2458
- this.abort = function()
2459
- {
2460
- aborted = true;
2461
- };
2462
-
2463
- /** Gets the cursor position */
2464
- this.getCharIndex = function()
2465
- {
2466
- return cursor;
2467
- };
2468
- }
2469
-
2470
-
2471
- function newWorker()
2472
- {
2473
- if (!Papa.WORKERS_SUPPORTED)
2474
- return false;
2475
-
2476
- var workerUrl = getWorkerBlob();
2477
- var w = new global.Worker(workerUrl);
2478
- w.onmessage = mainThreadReceivedMessage;
2479
- w.id = workerIdCounter++;
2480
- workers[w.id] = w;
2481
- return w;
2482
- }
2483
-
2484
- /** Callback when main thread receives a message */
2485
- function mainThreadReceivedMessage(e)
2486
- {
2487
- var msg = e.data;
2488
- var worker = workers[msg.workerId];
2489
- var aborted = false;
2490
-
2491
- if (msg.error)
2492
- worker.userError(msg.error, msg.file);
2493
- else if (msg.results && msg.results.data)
2494
- {
2495
- var abort = function() {
2496
- aborted = true;
2497
- completeWorker(msg.workerId, { data: [], errors: [], meta: { aborted: true } });
2498
- };
2499
-
2500
- var handle = {
2501
- abort: abort,
2502
- pause: notImplemented,
2503
- resume: notImplemented
2504
- };
2505
-
2506
- if (isFunction(worker.userStep))
2507
- {
2508
- for (var i = 0; i < msg.results.data.length; i++)
2509
- {
2510
- worker.userStep({
2511
- data: msg.results.data[i],
2512
- errors: msg.results.errors,
2513
- meta: msg.results.meta
2514
- }, handle);
2515
- if (aborted)
2516
- break;
2517
- }
2518
- delete msg.results; // free memory ASAP
2519
- }
2520
- else if (isFunction(worker.userChunk))
2521
- {
2522
- worker.userChunk(msg.results, handle, msg.file);
2523
- delete msg.results;
2524
- }
2525
- }
2526
-
2527
- if (msg.finished && !aborted)
2528
- completeWorker(msg.workerId, msg.results);
2529
- }
2530
-
2531
- function completeWorker(workerId, results) {
2532
- var worker = workers[workerId];
2533
- if (isFunction(worker.userComplete))
2534
- worker.userComplete(results);
2535
- worker.terminate();
2536
- delete workers[workerId];
2537
- }
2538
-
2539
- function notImplemented() {
2540
- throw new Error('Not implemented.');
2541
- }
2542
-
2543
- /** Callback when worker thread receives a message */
2544
- function workerThreadReceivedMessage(e)
2545
- {
2546
- var msg = e.data;
2547
-
2548
- if (typeof Papa.WORKER_ID === 'undefined' && msg)
2549
- Papa.WORKER_ID = msg.workerId;
2550
-
2551
- if (typeof msg.input === 'string')
2552
- {
2553
- global.postMessage({
2554
- workerId: Papa.WORKER_ID,
2555
- results: Papa.parse(msg.input, msg.config),
2556
- finished: true
2557
- });
2558
- }
2559
- else if ((global.File && msg.input instanceof File) || msg.input instanceof Object) // thank you, Safari (see issue #106)
2560
- {
2561
- var results = Papa.parse(msg.input, msg.config);
2562
- if (results)
2563
- global.postMessage({
2564
- workerId: Papa.WORKER_ID,
2565
- results: results,
2566
- finished: true
2567
- });
2568
- }
2569
- }
2570
-
2571
- /** Makes a deep copy of an array or object (mostly) */
2572
- function copy(obj)
2573
- {
2574
- if (typeof obj !== 'object' || obj === null)
2575
- return obj;
2576
- var cpy = Array.isArray(obj) ? [] : {};
2577
- for (var key in obj)
2578
- cpy[key] = copy(obj[key]);
2579
- return cpy;
2580
- }
2581
-
2582
- function bindFunction(f, self)
2583
- {
2584
- return function() { f.apply(self, arguments); };
2585
- }
2586
-
2587
- function isFunction(func)
2588
- {
2589
- return typeof func === 'function';
2590
- }
2591
-
2592
- return Papa;
2593
- }));
2594
- } (papaparse));
2595
-
2596
- var Papa = papaparse.exports;
2597
-
2598
- var isValidEmail = function isValidEmail(email) {
2599
- return yup.string().email().isValidSync(email);
2600
- };
2601
- var createEmailOptions = function createEmailOptions() {
2602
- var emails = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
2603
- return emails.map(function (email) {
2604
- return {
2605
- label: email,
2606
- value: email,
2607
- valid: isValidEmail(email)
2608
- };
2609
- });
2610
- };
2611
- var parseCsvEmails = /*#__PURE__*/function () {
2612
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(file, onSuccess) {
2613
- return regenerator.wrap(function _callee$(_context) {
2614
- while (1) switch (_context.prev = _context.next) {
2615
- case 0:
2616
- Papa.parse(file, {
2617
- header: true,
2618
- skipEmptyLines: true,
2619
- transformHeader: function transformHeader(h) {
2620
- return h.toLowerCase().replace(/\W/g, "");
2621
- },
2622
- complete: function complete(results) {
2623
- var _results$meta$fields;
2624
- var isEmailFieldPresent = (_results$meta$fields = results.meta.fields) === null || _results$meta$fields === void 0 ? void 0 : _results$meta$fields.includes("email");
2625
- if (isEmailFieldPresent) {
2626
- var emails = results.data.filter(ramda.prop("email")).map(function (item) {
2627
- return item.email.trim();
2628
- });
2629
- onSuccess(createEmailOptions(emails));
2630
- } else {
2631
- neetoui.Toastr.error(i18next.t("neetoMolecules.sendToFields.errors.invalidCsv"));
2632
- }
2633
- }
2634
- });
2635
- case 1:
2636
- case "end":
2637
- return _context.stop();
2638
- }
2639
- }, _callee);
2640
- }));
2641
- return function parseCsvEmails(_x, _x2) {
2642
- return _ref.apply(this, arguments);
2643
- };
2644
- }();
2645
-
2646
- var SendToFields = function SendToFields(_ref) {
2647
- var emailInputProps = _ref.emailInputProps,
2648
- ccInputProps = _ref.ccInputProps,
2649
- bccInputProps = _ref.bccInputProps,
2650
- _ref$showUploadCsvBut = _ref.showUploadCsvButton,
2651
- showUploadCsvButton = _ref$showUploadCsvBut === void 0 ? false : _ref$showUploadCsvBut,
2652
- _ref$showCcBccButton = _ref.showCcBccButton,
2653
- showCcBccButton = _ref$showCcBccButton === void 0 ? false : _ref$showCcBccButton;
2654
- var sendToFieldRef = React.useRef();
2655
- var _useFormikContext = formik.useFormikContext(),
2656
- _useFormikContext$val = _useFormikContext.values,
2657
- showCopyEmails = _useFormikContext$val.showCopyEmails,
2658
- existingSendToEmails = _useFormikContext$val[emailInputProps.name || "sendTo"],
2659
- setFieldValue = _useFormikContext.setFieldValue;
2660
- var _useTranslation = reactI18next.useTranslation(),
2661
- t = _useTranslation.t;
2662
- var handleCSVFile = /*#__PURE__*/function () {
2663
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(files) {
2664
- var _sendToFieldRef$curre, onSuccess;
2665
- return regenerator.wrap(function _callee$(_context) {
2666
- while (1) switch (_context.prev = _context.next) {
2667
- case 0:
2668
- _context.prev = 0;
2669
- onSuccess = function onSuccess(values) {
2670
- return setFieldValue(emailInputProps.name || "sendTo", [].concat(_toConsumableArray(existingSendToEmails), _toConsumableArray(values)));
2671
- };
2672
- _context.next = 4;
2673
- return parseCsvEmails(files[0], onSuccess);
2674
- case 4:
2675
- (_sendToFieldRef$curre = sendToFieldRef.current) === null || _sendToFieldRef$curre === void 0 ? void 0 : _sendToFieldRef$curre.focus();
2676
- _context.next = 10;
2677
- break;
2678
- case 7:
2679
- _context.prev = 7;
2680
- _context.t0 = _context["catch"](0);
2681
- neetoui.Toastr.error(_context.t0);
2682
- case 10:
2683
- case "end":
2684
- return _context.stop();
2685
- }
2686
- }, _callee, null, [[0, 7]]);
2687
- }));
2688
- return function handleCSVFile(_x) {
2689
- return _ref2.apply(this, arguments);
2690
- };
2691
- }();
2692
- var handelCcBccButtonClick = function handelCcBccButtonClick(e) {
2693
- e.stopPropagation();
2694
- setFieldValue("showCopyEmails", !showCopyEmails);
2695
- };
2696
- return /*#__PURE__*/React__default["default"].createElement("div", {
2697
- className: "relative w-full flex-col gap-2"
2698
- }, showUploadCsvButton && /*#__PURE__*/React__default["default"].createElement("div", {
2699
- className: "absolute top-0 right-1"
2700
- }, /*#__PURE__*/React__default["default"].createElement(FilePicker, {
2701
- types: ALLOWED_FILE_PICKER_TYPES,
2702
- onChange: handleCSVFile
2703
- }, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
2704
- "data-cy": "upload-csv-button",
2705
- icon: neetoIcons.Upload,
2706
- label: t("neetoMolecules.emailForm.uploadCSV"),
2707
- size: "small",
2708
- style: "link",
2709
- tooltipProps: {
2710
- content: t("neetoMolecules.sendToFields.uploadCsvTooltip"),
2711
- position: "right"
2712
- }
2713
- }))), /*#__PURE__*/React__default["default"].createElement(formik$1.MultiEmailInput, _extends({
2714
- "data-testid": "emails",
2715
- name: "sendTo",
2716
- ref: sendToFieldRef
2717
- }, emailInputProps, {
2718
- suffix: showCcBccButton && /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
2719
- "data-cy": "cc-bcc-button",
2720
- "data-testid": "cc-bcc-button",
2721
- label: t("neetoMolecules.emailForm.labels.ccBcc"),
2722
- size: "small",
2723
- style: "link",
2724
- onClick: handelCcBccButtonClick
2725
- })
2726
- })), showCopyEmails && /*#__PURE__*/React__default["default"].createElement("div", {
2727
- className: "mt-5 flex w-full flex-col gap-6"
2728
- }, /*#__PURE__*/React__default["default"].createElement(formik$1.MultiEmailInput, _extends({
2729
- name: "sendToBcc"
2730
- }, ccInputProps)), /*#__PURE__*/React__default["default"].createElement(formik$1.MultiEmailInput, _extends({
2731
- name: "sendToCc"
2732
- }, bccInputProps))));
2733
- };
2734
-
2735
- var SendToField = reactUtils.withT(function (_ref) {
2736
- var t = _ref.t;
2737
- return /*#__PURE__*/React__default["default"].createElement(SendToFields, {
2738
- showCcBccButton: true,
2739
- showUploadCsvButton: true,
2740
- bccInputProps: {
2741
- label: t("neetoMolecules.emailForm.labels.bCc"),
2742
- name: "sendToBcc",
2743
- placeholder: t("neetoMolecules.emailForm.placeholders.commaSeparatedEmails")
2744
- },
2745
- ccInputProps: {
2746
- label: t("neetoMolecules.emailForm.labels.cc"),
2747
- name: "sendToCc",
2748
- placeholder: t("neetoMolecules.emailForm.placeholders.commaSeparatedEmails")
2749
- },
2750
- emailInputProps: {
2751
- id: "sendTo",
2752
- name: "sendTo",
2753
- label: t("neetoMolecules.emailForm.labels.sendTo"),
2754
- placeholder: t("neetoMolecules.emailForm.placeholders.commaSeparatedEmails")
2755
- }
2756
- });
2757
- });
2758
-
2759
- function _arrayWithHoles(arr) {
2760
- if (Array.isArray(arr)) return arr;
2761
- }
2762
-
2763
- function _iterableToArrayLimit(arr, i) {
2764
- var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
2765
- if (null != _i) {
2766
- var _s,
2767
- _e,
2768
- _x,
2769
- _r,
2770
- _arr = [],
2771
- _n = !0,
2772
- _d = !1;
2773
- try {
2774
- if (_x = (_i = _i.call(arr)).next, 0 === i) {
2775
- if (Object(_i) !== _i) return;
2776
- _n = !1;
2777
- } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
2778
- } catch (err) {
2779
- _d = !0, _e = err;
2780
- } finally {
2781
- try {
2782
- if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
2783
- } finally {
2784
- if (_d) throw _e;
2785
- }
2786
- }
2787
- return _arr;
2788
- }
2789
- }
2790
-
2791
- function _nonIterableRest() {
2792
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2793
- }
2794
-
2795
- function _slicedToArray(arr, i) {
2796
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
2797
- }
2798
-
2799
- var SubjectField = function SubjectField(_ref) {
2800
- var name = _ref.name,
2801
- text = _ref.text,
2802
- updateText = _ref.updateText,
2803
- _ref$subjectVariables = _ref.subjectVariables,
2804
- subjectVariables = _ref$subjectVariables === void 0 ? [] : _ref$subjectVariables,
2805
- error = _ref.error,
2806
- _ref$required = _ref.required,
2807
- required = _ref$required === void 0 ? false : _ref$required;
2808
- var _useState = React.useState(false),
2809
- _useState2 = _slicedToArray(_useState, 2),
2810
- isFieldFocusedOnce = _useState2[0],
2811
- setIsFieldFocusedOnce = _useState2[1];
2812
- var _useTranslation = reactI18next.useTranslation(),
2813
- t = _useTranslation.t;
2814
- var tagClickHandler = function tagClickHandler(_ref2) {
2815
- var slug = _ref2.key;
2816
- var textAreaElement = document.querySelector("textarea[name=".concat(name, "]"));
2817
- var splitIndex = isFieldFocusedOnce && textAreaElement ? textAreaElement.selectionEnd : text.length;
2818
- var updatedSubject = [text.slice(0, splitIndex), " {{".concat(slug, "}}"), text.slice(splitIndex)].join("");
2819
- updateText(updatedSubject);
2820
- };
2821
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(neetoui.Input, {
2822
- error: error,
2823
- name: name,
2824
- required: required,
2825
- label: t("neetoMolecules.emailForm.labels.subject"),
2826
- size: "large",
2827
- value: text,
2828
- suffix: /*#__PURE__*/React__default["default"].createElement(DynamicVariables__default["default"], {
2829
- variables: subjectVariables,
2830
- dropdownProps: {
2831
- className: "neeto-ui-dropdown__popup overflow-y-auto",
2832
- buttonSize: "small"
2833
- },
2834
- onVariableClick: tagClickHandler
2835
- }),
2836
- onChange: utils.withEventTargetValue(updateText),
2837
- onFocus: function onFocus() {
2838
- return setIsFieldFocusedOnce(true);
2839
- }
2840
- }), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
2841
- className: "neeto-ui-text-gray-600 mt-2",
2842
- "data-cy": "subject-input-variable-label",
2843
- style: "body3"
2844
- }, /*#__PURE__*/React__default["default"].createElement(reactI18next.Trans, {
2845
- components: {
2846
- span: /*#__PURE__*/React__default["default"].createElement("span", {
2847
- className: "font-semibold"
2848
- })
2849
- },
2850
- i18nKey: "neetoMolecules.emailForm.helpText",
2851
- values: {
2852
- type: "subject"
2853
- }
2854
- })));
2855
- };
2856
-
2857
- var EmailForm = function EmailForm(_ref) {
2858
- var _ref$messageVariables = _ref.messageVariables,
2859
- messageVariables = _ref$messageVariables === void 0 ? [] : _ref$messageVariables,
2860
- _ref$subjectVariables = _ref.subjectVariables,
2861
- subjectVariables = _ref$subjectVariables === void 0 ? [] : _ref$subjectVariables,
2862
- handleCancel = _ref.handleCancel,
2863
- isLoading = _ref.isLoading,
2864
- _ref$replyToOptions = _ref.replyToOptions,
2865
- replyToOptions = _ref$replyToOptions === void 0 ? [] : _ref$replyToOptions,
2866
- _ref$isUpdating = _ref.isUpdating,
2867
- isUpdating = _ref$isUpdating === void 0 ? false : _ref$isUpdating,
2868
- _ref$showFields = _ref.showFields,
2869
- showFields = _ref$showFields === void 0 ? true : _ref$showFields,
2870
- _ref$className = _ref.className,
2871
- className = _ref$className === void 0 ? "" : _ref$className;
2872
- var _useTranslation = reactI18next.useTranslation(),
2873
- t = _useTranslation.t;
2874
- var _useContext = React.useContext(EmailFormContext),
2875
- showSendToField = _useContext.showSendToField,
2876
- showReplyToField = _useContext.showReplyToField;
2877
- var _useFormikContext = formik.useFormikContext(),
2878
- setFieldValue = _useFormikContext.setFieldValue,
2879
- dirty = _useFormikContext.dirty;
2880
- return /*#__PURE__*/React__default["default"].createElement("div", {
2881
- "data-testid": "email-form",
2882
- className: classnames("flex flex-1 flex-col items-start gap-2", _defineProperty({}, className, className))
2883
- }, showFields && /*#__PURE__*/React__default["default"].createElement("div", {
2884
- className: "flex w-full flex-col items-start justify-start gap-6"
2885
- }, /*#__PURE__*/React__default["default"].createElement(formik.Field, {
2886
- name: "subject"
2887
- }, function (_ref2) {
2888
- var value = _ref2.field.value,
2889
- error = _ref2.meta.error;
2890
- return /*#__PURE__*/React__default["default"].createElement("div", {
2891
- className: "w-full"
2892
- }, /*#__PURE__*/React__default["default"].createElement(SubjectField, {
2893
- error: t(error),
2894
- name: "subject",
2895
- subjectVariables: subjectVariables,
2896
- text: value,
2897
- updateText: function updateText(text) {
2898
- return setFieldValue("subject", text);
2899
- }
2900
- }));
2901
- }), showSendToField && /*#__PURE__*/React__default["default"].createElement(SendToField, null), showReplyToField && /*#__PURE__*/React__default["default"].createElement(ReplyToField, {
2902
- replyToOptions: replyToOptions
2903
- }), /*#__PURE__*/React__default["default"].createElement("div", {
2904
- className: "w-full"
2905
- }, /*#__PURE__*/React__default["default"].createElement(neetoEditor.FormikEditor, {
2906
- required: true,
2907
- addons: EDITOR_ADDONS,
2908
- "data-cy": "message-input-field",
2909
- id: "form_message",
2910
- label: t("neetoMolecules.emailForm.labels.message"),
2911
- name: "message",
2912
- variables: messageVariables
2913
- }), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
2914
- className: "neeto-ui-text-gray-500 mt-2",
2915
- "data-cy": "message-input-variable-label",
2916
- style: "body3"
2917
- }, /*#__PURE__*/React__default["default"].createElement(reactI18next.Trans, {
2918
- i18nKey: "neetoMolecules.emailForm.helpText",
2919
- values: {
2920
- type: "message"
2921
- },
2922
- components: {
2923
- span: /*#__PURE__*/React__default["default"].createElement("span", {
2924
- className: "font-semibold"
2925
- })
2926
- }
2927
- })))), /*#__PURE__*/React__default["default"].createElement(formik$1.ActionBlock, {
2928
- className: "mt-6 w-full justify-start",
2929
- cancelButtonProps: {
2930
- disabled: false,
2931
- onClick: handleCancel,
2932
- className: "ml-3"
2933
- },
2934
- submitButtonProps: {
2935
- loading: isLoading,
2936
- disabled: !dirty || isUpdating
2937
- }
2938
- }));
2939
- };
2940
-
2941
- var getValidationSchema = function getValidationSchema(_ref) {
2942
- var showSendToField = _ref.showSendToField,
2943
- showReplyToField = _ref.showReplyToField,
2944
- customValidations = _ref.customValidations;
2945
- var schema = EMAIL_FORM_VALIDATION_SCHEMA.clone();
2946
- if (showSendToField) schema = schema.concat(SEND_TO_FIELD_VALIDATION);
2947
- if (showReplyToField) schema = schema.concat(REPLY_TO_FIELD_VALIDATION);
2948
- return schema.shape(customValidations);
2949
- };
2950
-
2951
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2952
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2953
- var EmailFormProvider = function EmailFormProvider(_ref) {
2954
- var _ref$onSubmit = _ref.onSubmit,
2955
- onSubmit = _ref$onSubmit === void 0 ? pure.noop : _ref$onSubmit,
2956
- _ref$initialValues = _ref.initialValues,
2957
- initialValues = _ref$initialValues === void 0 ? INITIAL_FORM_VALUES : _ref$initialValues,
2958
- children = _ref.children,
2959
- formikProps = _ref.formikProps,
2960
- _ref$validationSchema = _ref.validationSchema,
2961
- customValidations = _ref$validationSchema === void 0 ? {} : _ref$validationSchema,
2962
- _ref$showSendToField = _ref.showSendToField,
2963
- showSendToField = _ref$showSendToField === void 0 ? false : _ref$showSendToField,
2964
- _ref$showReplyToField = _ref.showReplyToField,
2965
- showReplyToField = _ref$showReplyToField === void 0 ? false : _ref$showReplyToField;
2966
- return /*#__PURE__*/React__default["default"].createElement("div", {
2967
- "data-testid": "email-form-provider"
2968
- }, /*#__PURE__*/React__default["default"].createElement(EmailFormContext.Provider, {
2969
- value: {
2970
- showSendToField: showSendToField,
2971
- showReplyToField: showReplyToField
2972
- }
2973
- }, /*#__PURE__*/React__default["default"].createElement(formik$1.Form, {
2974
- formikProps: _objectSpread({
2975
- enableReinitialize: true,
2976
- validationSchema: getValidationSchema({
2977
- showSendToField: showSendToField,
2978
- showReplyToField: showReplyToField,
2979
- customValidations: customValidations
2980
- }),
2981
- initialValues: _objectSpread(_objectSpread({}, initialValues), {}, {
2982
- replyTo: initialValues.replyTo || globalProps.user.email
2983
- }),
2984
- onSubmit: onSubmit
2985
- }, formikProps)
2986
- }, children)));
2987
- };
2988
-
2989
- var propTypes = {exports: {}};
2990
-
2991
- var reactIs = {exports: {}};
2992
-
2993
- var reactIs_production_min = {};
2994
-
2995
- /** @license React v16.13.1
2996
- * react-is.production.min.js
2997
- *
2998
- * Copyright (c) Facebook, Inc. and its affiliates.
2999
- *
3000
- * This source code is licensed under the MIT license found in the
3001
- * LICENSE file in the root directory of this source tree.
3002
- */
3003
-
3004
- var hasRequiredReactIs_production_min;
3005
-
3006
- function requireReactIs_production_min () {
3007
- if (hasRequiredReactIs_production_min) return reactIs_production_min;
3008
- hasRequiredReactIs_production_min = 1;
3009
- var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?
3010
- Symbol.for("react.suspense_list"):60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.block"):60121,w=b?Symbol.for("react.fundamental"):60117,x=b?Symbol.for("react.responder"):60118,y=b?Symbol.for("react.scope"):60119;
3011
- function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}reactIs_production_min.AsyncMode=l;reactIs_production_min.ConcurrentMode=m;reactIs_production_min.ContextConsumer=k;reactIs_production_min.ContextProvider=h;reactIs_production_min.Element=c;reactIs_production_min.ForwardRef=n;reactIs_production_min.Fragment=e;reactIs_production_min.Lazy=t;reactIs_production_min.Memo=r;reactIs_production_min.Portal=d;
3012
- reactIs_production_min.Profiler=g;reactIs_production_min.StrictMode=f;reactIs_production_min.Suspense=p;reactIs_production_min.isAsyncMode=function(a){return A(a)||z(a)===l};reactIs_production_min.isConcurrentMode=A;reactIs_production_min.isContextConsumer=function(a){return z(a)===k};reactIs_production_min.isContextProvider=function(a){return z(a)===h};reactIs_production_min.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};reactIs_production_min.isForwardRef=function(a){return z(a)===n};reactIs_production_min.isFragment=function(a){return z(a)===e};reactIs_production_min.isLazy=function(a){return z(a)===t};
3013
- reactIs_production_min.isMemo=function(a){return z(a)===r};reactIs_production_min.isPortal=function(a){return z(a)===d};reactIs_production_min.isProfiler=function(a){return z(a)===g};reactIs_production_min.isStrictMode=function(a){return z(a)===f};reactIs_production_min.isSuspense=function(a){return z(a)===p};
3014
- reactIs_production_min.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};reactIs_production_min.typeOf=z;
3015
- return reactIs_production_min;
3016
- }
3017
-
3018
- var reactIs_development = {};
3019
-
3020
- /** @license React v16.13.1
3021
- * react-is.development.js
3022
- *
3023
- * Copyright (c) Facebook, Inc. and its affiliates.
3024
- *
3025
- * This source code is licensed under the MIT license found in the
3026
- * LICENSE file in the root directory of this source tree.
3027
- */
3028
-
3029
- var hasRequiredReactIs_development;
3030
-
3031
- function requireReactIs_development () {
3032
- if (hasRequiredReactIs_development) return reactIs_development;
3033
- hasRequiredReactIs_development = 1;
3034
-
3035
-
3036
-
3037
- if (process.env.NODE_ENV !== "production") {
3038
- (function() {
3039
-
3040
- // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
3041
- // nor polyfill, then a plain number is used for performance.
3042
- var hasSymbol = typeof Symbol === 'function' && Symbol.for;
3043
- var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
3044
- var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
3045
- var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
3046
- var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
3047
- var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
3048
- var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
3049
- var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
3050
- // (unstable) APIs that have been removed. Can we remove the symbols?
3051
-
3052
- var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
3053
- var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
3054
- var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
3055
- var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
3056
- var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
3057
- var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
3058
- var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
3059
- var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
3060
- var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
3061
- var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
3062
- var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
3063
-
3064
- function isValidElementType(type) {
3065
- return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
3066
- type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
3067
- }
3068
-
3069
- function typeOf(object) {
3070
- if (typeof object === 'object' && object !== null) {
3071
- var $$typeof = object.$$typeof;
3072
-
3073
- switch ($$typeof) {
3074
- case REACT_ELEMENT_TYPE:
3075
- var type = object.type;
3076
-
3077
- switch (type) {
3078
- case REACT_ASYNC_MODE_TYPE:
3079
- case REACT_CONCURRENT_MODE_TYPE:
3080
- case REACT_FRAGMENT_TYPE:
3081
- case REACT_PROFILER_TYPE:
3082
- case REACT_STRICT_MODE_TYPE:
3083
- case REACT_SUSPENSE_TYPE:
3084
- return type;
3085
-
3086
- default:
3087
- var $$typeofType = type && type.$$typeof;
3088
-
3089
- switch ($$typeofType) {
3090
- case REACT_CONTEXT_TYPE:
3091
- case REACT_FORWARD_REF_TYPE:
3092
- case REACT_LAZY_TYPE:
3093
- case REACT_MEMO_TYPE:
3094
- case REACT_PROVIDER_TYPE:
3095
- return $$typeofType;
3096
-
3097
- default:
3098
- return $$typeof;
3099
- }
3100
-
3101
- }
3102
-
3103
- case REACT_PORTAL_TYPE:
3104
- return $$typeof;
3105
- }
3106
- }
3107
-
3108
- return undefined;
3109
- } // AsyncMode is deprecated along with isAsyncMode
3110
-
3111
- var AsyncMode = REACT_ASYNC_MODE_TYPE;
3112
- var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
3113
- var ContextConsumer = REACT_CONTEXT_TYPE;
3114
- var ContextProvider = REACT_PROVIDER_TYPE;
3115
- var Element = REACT_ELEMENT_TYPE;
3116
- var ForwardRef = REACT_FORWARD_REF_TYPE;
3117
- var Fragment = REACT_FRAGMENT_TYPE;
3118
- var Lazy = REACT_LAZY_TYPE;
3119
- var Memo = REACT_MEMO_TYPE;
3120
- var Portal = REACT_PORTAL_TYPE;
3121
- var Profiler = REACT_PROFILER_TYPE;
3122
- var StrictMode = REACT_STRICT_MODE_TYPE;
3123
- var Suspense = REACT_SUSPENSE_TYPE;
3124
- var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
3125
-
3126
- function isAsyncMode(object) {
3127
- {
3128
- if (!hasWarnedAboutDeprecatedIsAsyncMode) {
3129
- hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
3130
-
3131
- console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
3132
- }
3133
- }
3134
-
3135
- return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
3136
- }
3137
- function isConcurrentMode(object) {
3138
- return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
3139
- }
3140
- function isContextConsumer(object) {
3141
- return typeOf(object) === REACT_CONTEXT_TYPE;
3142
- }
3143
- function isContextProvider(object) {
3144
- return typeOf(object) === REACT_PROVIDER_TYPE;
3145
- }
3146
- function isElement(object) {
3147
- return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
3148
- }
3149
- function isForwardRef(object) {
3150
- return typeOf(object) === REACT_FORWARD_REF_TYPE;
3151
- }
3152
- function isFragment(object) {
3153
- return typeOf(object) === REACT_FRAGMENT_TYPE;
3154
- }
3155
- function isLazy(object) {
3156
- return typeOf(object) === REACT_LAZY_TYPE;
3157
- }
3158
- function isMemo(object) {
3159
- return typeOf(object) === REACT_MEMO_TYPE;
3160
- }
3161
- function isPortal(object) {
3162
- return typeOf(object) === REACT_PORTAL_TYPE;
3163
- }
3164
- function isProfiler(object) {
3165
- return typeOf(object) === REACT_PROFILER_TYPE;
3166
- }
3167
- function isStrictMode(object) {
3168
- return typeOf(object) === REACT_STRICT_MODE_TYPE;
3169
- }
3170
- function isSuspense(object) {
3171
- return typeOf(object) === REACT_SUSPENSE_TYPE;
3172
- }
3173
-
3174
- reactIs_development.AsyncMode = AsyncMode;
3175
- reactIs_development.ConcurrentMode = ConcurrentMode;
3176
- reactIs_development.ContextConsumer = ContextConsumer;
3177
- reactIs_development.ContextProvider = ContextProvider;
3178
- reactIs_development.Element = Element;
3179
- reactIs_development.ForwardRef = ForwardRef;
3180
- reactIs_development.Fragment = Fragment;
3181
- reactIs_development.Lazy = Lazy;
3182
- reactIs_development.Memo = Memo;
3183
- reactIs_development.Portal = Portal;
3184
- reactIs_development.Profiler = Profiler;
3185
- reactIs_development.StrictMode = StrictMode;
3186
- reactIs_development.Suspense = Suspense;
3187
- reactIs_development.isAsyncMode = isAsyncMode;
3188
- reactIs_development.isConcurrentMode = isConcurrentMode;
3189
- reactIs_development.isContextConsumer = isContextConsumer;
3190
- reactIs_development.isContextProvider = isContextProvider;
3191
- reactIs_development.isElement = isElement;
3192
- reactIs_development.isForwardRef = isForwardRef;
3193
- reactIs_development.isFragment = isFragment;
3194
- reactIs_development.isLazy = isLazy;
3195
- reactIs_development.isMemo = isMemo;
3196
- reactIs_development.isPortal = isPortal;
3197
- reactIs_development.isProfiler = isProfiler;
3198
- reactIs_development.isStrictMode = isStrictMode;
3199
- reactIs_development.isSuspense = isSuspense;
3200
- reactIs_development.isValidElementType = isValidElementType;
3201
- reactIs_development.typeOf = typeOf;
3202
- })();
3203
- }
3204
- return reactIs_development;
3205
- }
3206
-
3207
- var hasRequiredReactIs;
3208
-
3209
- function requireReactIs () {
3210
- if (hasRequiredReactIs) return reactIs.exports;
3211
- hasRequiredReactIs = 1;
3212
- (function (module) {
3213
-
3214
- if (process.env.NODE_ENV === 'production') {
3215
- module.exports = requireReactIs_production_min();
3216
- } else {
3217
- module.exports = requireReactIs_development();
3218
- }
3219
- } (reactIs));
3220
- return reactIs.exports;
3221
- }
3222
-
3223
- /*
3224
- object-assign
3225
- (c) Sindre Sorhus
3226
- @license MIT
3227
- */
3228
-
3229
- var objectAssign;
3230
- var hasRequiredObjectAssign;
3231
-
3232
- function requireObjectAssign () {
3233
- if (hasRequiredObjectAssign) return objectAssign;
3234
- hasRequiredObjectAssign = 1;
3235
- /* eslint-disable no-unused-vars */
3236
- var getOwnPropertySymbols = Object.getOwnPropertySymbols;
3237
- var hasOwnProperty = Object.prototype.hasOwnProperty;
3238
- var propIsEnumerable = Object.prototype.propertyIsEnumerable;
3239
-
3240
- function toObject(val) {
3241
- if (val === null || val === undefined) {
3242
- throw new TypeError('Object.assign cannot be called with null or undefined');
3243
- }
3244
-
3245
- return Object(val);
3246
- }
3247
-
3248
- function shouldUseNative() {
3249
- try {
3250
- if (!Object.assign) {
3251
- return false;
3252
- }
3253
-
3254
- // Detect buggy property enumeration order in older V8 versions.
3255
-
3256
- // https://bugs.chromium.org/p/v8/issues/detail?id=4118
3257
- var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
3258
- test1[5] = 'de';
3259
- if (Object.getOwnPropertyNames(test1)[0] === '5') {
3260
- return false;
3261
- }
3262
-
3263
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
3264
- var test2 = {};
3265
- for (var i = 0; i < 10; i++) {
3266
- test2['_' + String.fromCharCode(i)] = i;
3267
- }
3268
- var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
3269
- return test2[n];
3270
- });
3271
- if (order2.join('') !== '0123456789') {
3272
- return false;
3273
- }
3274
-
3275
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
3276
- var test3 = {};
3277
- 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
3278
- test3[letter] = letter;
3279
- });
3280
- if (Object.keys(Object.assign({}, test3)).join('') !==
3281
- 'abcdefghijklmnopqrst') {
3282
- return false;
3283
- }
3284
-
3285
- return true;
3286
- } catch (err) {
3287
- // We don't expect any of the above to throw, but better to be safe.
3288
- return false;
3289
- }
3290
- }
3291
-
3292
- objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
3293
- var from;
3294
- var to = toObject(target);
3295
- var symbols;
3296
-
3297
- for (var s = 1; s < arguments.length; s++) {
3298
- from = Object(arguments[s]);
3299
-
3300
- for (var key in from) {
3301
- if (hasOwnProperty.call(from, key)) {
3302
- to[key] = from[key];
3303
- }
3304
- }
3305
-
3306
- if (getOwnPropertySymbols) {
3307
- symbols = getOwnPropertySymbols(from);
3308
- for (var i = 0; i < symbols.length; i++) {
3309
- if (propIsEnumerable.call(from, symbols[i])) {
3310
- to[symbols[i]] = from[symbols[i]];
3311
- }
3312
- }
3313
- }
3314
- }
3315
-
3316
- return to;
3317
- };
3318
- return objectAssign;
3319
- }
3320
-
3321
- /**
3322
- * Copyright (c) 2013-present, Facebook, Inc.
3323
- *
3324
- * This source code is licensed under the MIT license found in the
3325
- * LICENSE file in the root directory of this source tree.
3326
- */
3327
-
3328
- var ReactPropTypesSecret_1;
3329
- var hasRequiredReactPropTypesSecret;
3330
-
3331
- function requireReactPropTypesSecret () {
3332
- if (hasRequiredReactPropTypesSecret) return ReactPropTypesSecret_1;
3333
- hasRequiredReactPropTypesSecret = 1;
3334
-
3335
- var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
3336
-
3337
- ReactPropTypesSecret_1 = ReactPropTypesSecret;
3338
- return ReactPropTypesSecret_1;
3339
- }
3340
-
3341
- var has;
3342
- var hasRequiredHas;
3343
-
3344
- function requireHas () {
3345
- if (hasRequiredHas) return has;
3346
- hasRequiredHas = 1;
3347
- has = Function.call.bind(Object.prototype.hasOwnProperty);
3348
- return has;
3349
- }
3350
-
3351
- /**
3352
- * Copyright (c) 2013-present, Facebook, Inc.
3353
- *
3354
- * This source code is licensed under the MIT license found in the
3355
- * LICENSE file in the root directory of this source tree.
3356
- */
3357
-
3358
- var checkPropTypes_1;
3359
- var hasRequiredCheckPropTypes;
3360
-
3361
- function requireCheckPropTypes () {
3362
- if (hasRequiredCheckPropTypes) return checkPropTypes_1;
3363
- hasRequiredCheckPropTypes = 1;
3364
-
3365
- var printWarning = function() {};
3366
-
3367
- if (process.env.NODE_ENV !== 'production') {
3368
- var ReactPropTypesSecret = requireReactPropTypesSecret();
3369
- var loggedTypeFailures = {};
3370
- var has = requireHas();
3371
-
3372
- printWarning = function(text) {
3373
- var message = 'Warning: ' + text;
3374
- if (typeof console !== 'undefined') {
3375
- console.error(message);
3376
- }
3377
- try {
3378
- // --- Welcome to debugging React ---
3379
- // This error was thrown as a convenience so that you can use this stack
3380
- // to find the callsite that caused this warning to fire.
3381
- throw new Error(message);
3382
- } catch (x) { /**/ }
3383
- };
3384
- }
3385
-
3386
- /**
3387
- * Assert that the values match with the type specs.
3388
- * Error messages are memorized and will only be shown once.
3389
- *
3390
- * @param {object} typeSpecs Map of name to a ReactPropType
3391
- * @param {object} values Runtime values that need to be type-checked
3392
- * @param {string} location e.g. "prop", "context", "child context"
3393
- * @param {string} componentName Name of the component for error messages.
3394
- * @param {?Function} getStack Returns the component stack.
3395
- * @private
3396
- */
3397
- function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
3398
- if (process.env.NODE_ENV !== 'production') {
3399
- for (var typeSpecName in typeSpecs) {
3400
- if (has(typeSpecs, typeSpecName)) {
3401
- var error;
3402
- // Prop type validation may throw. In case they do, we don't want to
3403
- // fail the render phase where it didn't fail before. So we log it.
3404
- // After these have been cleaned up, we'll let them throw.
3405
- try {
3406
- // This is intentionally an invariant that gets caught. It's the same
3407
- // behavior as without this statement except with a better message.
3408
- if (typeof typeSpecs[typeSpecName] !== 'function') {
3409
- var err = Error(
3410
- (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
3411
- 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' +
3412
- 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'
3413
- );
3414
- err.name = 'Invariant Violation';
3415
- throw err;
3416
- }
3417
- error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
3418
- } catch (ex) {
3419
- error = ex;
3420
- }
3421
- if (error && !(error instanceof Error)) {
3422
- printWarning(
3423
- (componentName || 'React class') + ': type specification of ' +
3424
- location + ' `' + typeSpecName + '` is invalid; the type checker ' +
3425
- 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
3426
- 'You may have forgotten to pass an argument to the type checker ' +
3427
- 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
3428
- 'shape all require an argument).'
3429
- );
3430
- }
3431
- if (error instanceof Error && !(error.message in loggedTypeFailures)) {
3432
- // Only monitor this failure once because there tends to be a lot of the
3433
- // same error.
3434
- loggedTypeFailures[error.message] = true;
3435
-
3436
- var stack = getStack ? getStack() : '';
3437
-
3438
- printWarning(
3439
- 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
3440
- );
3441
- }
3442
- }
3443
- }
3444
- }
3445
- }
3446
-
3447
- /**
3448
- * Resets warning cache when testing.
3449
- *
3450
- * @private
3451
- */
3452
- checkPropTypes.resetWarningCache = function() {
3453
- if (process.env.NODE_ENV !== 'production') {
3454
- loggedTypeFailures = {};
3455
- }
3456
- };
3457
-
3458
- checkPropTypes_1 = checkPropTypes;
3459
- return checkPropTypes_1;
3460
- }
3461
-
3462
- /**
3463
- * Copyright (c) 2013-present, Facebook, Inc.
3464
- *
3465
- * This source code is licensed under the MIT license found in the
3466
- * LICENSE file in the root directory of this source tree.
3467
- */
3468
-
3469
- var factoryWithTypeCheckers;
3470
- var hasRequiredFactoryWithTypeCheckers;
3471
-
3472
- function requireFactoryWithTypeCheckers () {
3473
- if (hasRequiredFactoryWithTypeCheckers) return factoryWithTypeCheckers;
3474
- hasRequiredFactoryWithTypeCheckers = 1;
3475
-
3476
- var ReactIs = requireReactIs();
3477
- var assign = requireObjectAssign();
3478
-
3479
- var ReactPropTypesSecret = requireReactPropTypesSecret();
3480
- var has = requireHas();
3481
- var checkPropTypes = requireCheckPropTypes();
3482
-
3483
- var printWarning = function() {};
3484
-
3485
- if (process.env.NODE_ENV !== 'production') {
3486
- printWarning = function(text) {
3487
- var message = 'Warning: ' + text;
3488
- if (typeof console !== 'undefined') {
3489
- console.error(message);
3490
- }
3491
- try {
3492
- // --- Welcome to debugging React ---
3493
- // This error was thrown as a convenience so that you can use this stack
3494
- // to find the callsite that caused this warning to fire.
3495
- throw new Error(message);
3496
- } catch (x) {}
3497
- };
3498
- }
3499
-
3500
- function emptyFunctionThatReturnsNull() {
3501
- return null;
3502
- }
3503
-
3504
- factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
3505
- /* global Symbol */
3506
- var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
3507
- var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
3508
-
3509
- /**
3510
- * Returns the iterator method function contained on the iterable object.
3511
- *
3512
- * Be sure to invoke the function with the iterable as context:
3513
- *
3514
- * var iteratorFn = getIteratorFn(myIterable);
3515
- * if (iteratorFn) {
3516
- * var iterator = iteratorFn.call(myIterable);
3517
- * ...
3518
- * }
3519
- *
3520
- * @param {?object} maybeIterable
3521
- * @return {?function}
3522
- */
3523
- function getIteratorFn(maybeIterable) {
3524
- var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
3525
- if (typeof iteratorFn === 'function') {
3526
- return iteratorFn;
3527
- }
3528
- }
3529
-
3530
- /**
3531
- * Collection of methods that allow declaration and validation of props that are
3532
- * supplied to React components. Example usage:
3533
- *
3534
- * var Props = require('ReactPropTypes');
3535
- * var MyArticle = React.createClass({
3536
- * propTypes: {
3537
- * // An optional string prop named "description".
3538
- * description: Props.string,
3539
- *
3540
- * // A required enum prop named "category".
3541
- * category: Props.oneOf(['News','Photos']).isRequired,
3542
- *
3543
- * // A prop named "dialog" that requires an instance of Dialog.
3544
- * dialog: Props.instanceOf(Dialog).isRequired
3545
- * },
3546
- * render: function() { ... }
3547
- * });
3548
- *
3549
- * A more formal specification of how these methods are used:
3550
- *
3551
- * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
3552
- * decl := ReactPropTypes.{type}(.isRequired)?
3553
- *
3554
- * Each and every declaration produces a function with the same signature. This
3555
- * allows the creation of custom validation functions. For example:
3556
- *
3557
- * var MyLink = React.createClass({
3558
- * propTypes: {
3559
- * // An optional string or URI prop named "href".
3560
- * href: function(props, propName, componentName) {
3561
- * var propValue = props[propName];
3562
- * if (propValue != null && typeof propValue !== 'string' &&
3563
- * !(propValue instanceof URI)) {
3564
- * return new Error(
3565
- * 'Expected a string or an URI for ' + propName + ' in ' +
3566
- * componentName
3567
- * );
3568
- * }
3569
- * }
3570
- * },
3571
- * render: function() {...}
3572
- * });
3573
- *
3574
- * @internal
3575
- */
3576
-
3577
- var ANONYMOUS = '<<anonymous>>';
3578
-
3579
- // Important!
3580
- // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
3581
- var ReactPropTypes = {
3582
- array: createPrimitiveTypeChecker('array'),
3583
- bigint: createPrimitiveTypeChecker('bigint'),
3584
- bool: createPrimitiveTypeChecker('boolean'),
3585
- func: createPrimitiveTypeChecker('function'),
3586
- number: createPrimitiveTypeChecker('number'),
3587
- object: createPrimitiveTypeChecker('object'),
3588
- string: createPrimitiveTypeChecker('string'),
3589
- symbol: createPrimitiveTypeChecker('symbol'),
3590
-
3591
- any: createAnyTypeChecker(),
3592
- arrayOf: createArrayOfTypeChecker,
3593
- element: createElementTypeChecker(),
3594
- elementType: createElementTypeTypeChecker(),
3595
- instanceOf: createInstanceTypeChecker,
3596
- node: createNodeChecker(),
3597
- objectOf: createObjectOfTypeChecker,
3598
- oneOf: createEnumTypeChecker,
3599
- oneOfType: createUnionTypeChecker,
3600
- shape: createShapeTypeChecker,
3601
- exact: createStrictShapeTypeChecker,
3602
- };
3603
-
3604
- /**
3605
- * inlined Object.is polyfill to avoid requiring consumers ship their own
3606
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
3607
- */
3608
- /*eslint-disable no-self-compare*/
3609
- function is(x, y) {
3610
- // SameValue algorithm
3611
- if (x === y) {
3612
- // Steps 1-5, 7-10
3613
- // Steps 6.b-6.e: +0 != -0
3614
- return x !== 0 || 1 / x === 1 / y;
3615
- } else {
3616
- // Step 6.a: NaN == NaN
3617
- return x !== x && y !== y;
3618
- }
3619
- }
3620
- /*eslint-enable no-self-compare*/
3621
-
3622
- /**
3623
- * We use an Error-like object for backward compatibility as people may call
3624
- * PropTypes directly and inspect their output. However, we don't use real
3625
- * Errors anymore. We don't inspect their stack anyway, and creating them
3626
- * is prohibitively expensive if they are created too often, such as what
3627
- * happens in oneOfType() for any type before the one that matched.
3628
- */
3629
- function PropTypeError(message, data) {
3630
- this.message = message;
3631
- this.data = data && typeof data === 'object' ? data: {};
3632
- this.stack = '';
3633
- }
3634
- // Make `instanceof Error` still work for returned errors.
3635
- PropTypeError.prototype = Error.prototype;
3636
-
3637
- function createChainableTypeChecker(validate) {
3638
- if (process.env.NODE_ENV !== 'production') {
3639
- var manualPropTypeCallCache = {};
3640
- var manualPropTypeWarningCount = 0;
3641
- }
3642
- function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
3643
- componentName = componentName || ANONYMOUS;
3644
- propFullName = propFullName || propName;
3645
-
3646
- if (secret !== ReactPropTypesSecret) {
3647
- if (throwOnDirectAccess) {
3648
- // New behavior only for users of `prop-types` package
3649
- var err = new Error(
3650
- 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
3651
- 'Use `PropTypes.checkPropTypes()` to call them. ' +
3652
- 'Read more at http://fb.me/use-check-prop-types'
3653
- );
3654
- err.name = 'Invariant Violation';
3655
- throw err;
3656
- } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
3657
- // Old behavior for people using React.PropTypes
3658
- var cacheKey = componentName + ':' + propName;
3659
- if (
3660
- !manualPropTypeCallCache[cacheKey] &&
3661
- // Avoid spamming the console because they are often not actionable except for lib authors
3662
- manualPropTypeWarningCount < 3
3663
- ) {
3664
- printWarning(
3665
- 'You are manually calling a React.PropTypes validation ' +
3666
- 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
3667
- 'and will throw in the standalone `prop-types` package. ' +
3668
- 'You may be seeing this warning due to a third-party PropTypes ' +
3669
- 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
3670
- );
3671
- manualPropTypeCallCache[cacheKey] = true;
3672
- manualPropTypeWarningCount++;
3673
- }
3674
- }
3675
- }
3676
- if (props[propName] == null) {
3677
- if (isRequired) {
3678
- if (props[propName] === null) {
3679
- return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
3680
- }
3681
- return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
3682
- }
3683
- return null;
3684
- } else {
3685
- return validate(props, propName, componentName, location, propFullName);
3686
- }
3687
- }
3688
-
3689
- var chainedCheckType = checkType.bind(null, false);
3690
- chainedCheckType.isRequired = checkType.bind(null, true);
3691
-
3692
- return chainedCheckType;
3693
- }
3694
-
3695
- function createPrimitiveTypeChecker(expectedType) {
3696
- function validate(props, propName, componentName, location, propFullName, secret) {
3697
- var propValue = props[propName];
3698
- var propType = getPropType(propValue);
3699
- if (propType !== expectedType) {
3700
- // `propValue` being instance of, say, date/regexp, pass the 'object'
3701
- // check, but we can offer a more precise error message here rather than
3702
- // 'of type `object`'.
3703
- var preciseType = getPreciseType(propValue);
3704
-
3705
- return new PropTypeError(
3706
- 'Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'),
3707
- {expectedType: expectedType}
3708
- );
3709
- }
3710
- return null;
3711
- }
3712
- return createChainableTypeChecker(validate);
3713
- }
3714
-
3715
- function createAnyTypeChecker() {
3716
- return createChainableTypeChecker(emptyFunctionThatReturnsNull);
3717
- }
3718
-
3719
- function createArrayOfTypeChecker(typeChecker) {
3720
- function validate(props, propName, componentName, location, propFullName) {
3721
- if (typeof typeChecker !== 'function') {
3722
- return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
3723
- }
3724
- var propValue = props[propName];
3725
- if (!Array.isArray(propValue)) {
3726
- var propType = getPropType(propValue);
3727
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
3728
- }
3729
- for (var i = 0; i < propValue.length; i++) {
3730
- var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
3731
- if (error instanceof Error) {
3732
- return error;
3733
- }
3734
- }
3735
- return null;
3736
- }
3737
- return createChainableTypeChecker(validate);
3738
- }
3739
-
3740
- function createElementTypeChecker() {
3741
- function validate(props, propName, componentName, location, propFullName) {
3742
- var propValue = props[propName];
3743
- if (!isValidElement(propValue)) {
3744
- var propType = getPropType(propValue);
3745
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
3746
- }
3747
- return null;
3748
- }
3749
- return createChainableTypeChecker(validate);
3750
- }
3751
-
3752
- function createElementTypeTypeChecker() {
3753
- function validate(props, propName, componentName, location, propFullName) {
3754
- var propValue = props[propName];
3755
- if (!ReactIs.isValidElementType(propValue)) {
3756
- var propType = getPropType(propValue);
3757
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
3758
- }
3759
- return null;
3760
- }
3761
- return createChainableTypeChecker(validate);
3762
- }
3763
-
3764
- function createInstanceTypeChecker(expectedClass) {
3765
- function validate(props, propName, componentName, location, propFullName) {
3766
- if (!(props[propName] instanceof expectedClass)) {
3767
- var expectedClassName = expectedClass.name || ANONYMOUS;
3768
- var actualClassName = getClassName(props[propName]);
3769
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
3770
- }
3771
- return null;
3772
- }
3773
- return createChainableTypeChecker(validate);
3774
- }
3775
-
3776
- function createEnumTypeChecker(expectedValues) {
3777
- if (!Array.isArray(expectedValues)) {
3778
- if (process.env.NODE_ENV !== 'production') {
3779
- if (arguments.length > 1) {
3780
- printWarning(
3781
- 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
3782
- 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
3783
- );
3784
- } else {
3785
- printWarning('Invalid argument supplied to oneOf, expected an array.');
3786
- }
3787
- }
3788
- return emptyFunctionThatReturnsNull;
3789
- }
3790
-
3791
- function validate(props, propName, componentName, location, propFullName) {
3792
- var propValue = props[propName];
3793
- for (var i = 0; i < expectedValues.length; i++) {
3794
- if (is(propValue, expectedValues[i])) {
3795
- return null;
3796
- }
3797
- }
3798
-
3799
- var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
3800
- var type = getPreciseType(value);
3801
- if (type === 'symbol') {
3802
- return String(value);
3803
- }
3804
- return value;
3805
- });
3806
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
3807
- }
3808
- return createChainableTypeChecker(validate);
3809
- }
3810
-
3811
- function createObjectOfTypeChecker(typeChecker) {
3812
- function validate(props, propName, componentName, location, propFullName) {
3813
- if (typeof typeChecker !== 'function') {
3814
- return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
3815
- }
3816
- var propValue = props[propName];
3817
- var propType = getPropType(propValue);
3818
- if (propType !== 'object') {
3819
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
3820
- }
3821
- for (var key in propValue) {
3822
- if (has(propValue, key)) {
3823
- var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
3824
- if (error instanceof Error) {
3825
- return error;
3826
- }
3827
- }
3828
- }
3829
- return null;
3830
- }
3831
- return createChainableTypeChecker(validate);
3832
- }
3833
-
3834
- function createUnionTypeChecker(arrayOfTypeCheckers) {
3835
- if (!Array.isArray(arrayOfTypeCheckers)) {
3836
- process.env.NODE_ENV !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
3837
- return emptyFunctionThatReturnsNull;
3838
- }
3839
-
3840
- for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
3841
- var checker = arrayOfTypeCheckers[i];
3842
- if (typeof checker !== 'function') {
3843
- printWarning(
3844
- 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
3845
- 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
3846
- );
3847
- return emptyFunctionThatReturnsNull;
3848
- }
3849
- }
3850
-
3851
- function validate(props, propName, componentName, location, propFullName) {
3852
- var expectedTypes = [];
3853
- for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
3854
- var checker = arrayOfTypeCheckers[i];
3855
- var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret);
3856
- if (checkerResult == null) {
3857
- return null;
3858
- }
3859
- if (checkerResult.data && has(checkerResult.data, 'expectedType')) {
3860
- expectedTypes.push(checkerResult.data.expectedType);
3861
- }
3862
- }
3863
- var expectedTypesMessage = (expectedTypes.length > 0) ? ', expected one of type [' + expectedTypes.join(', ') + ']': '';
3864
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.'));
3865
- }
3866
- return createChainableTypeChecker(validate);
3867
- }
3868
-
3869
- function createNodeChecker() {
3870
- function validate(props, propName, componentName, location, propFullName) {
3871
- if (!isNode(props[propName])) {
3872
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
3873
- }
3874
- return null;
3875
- }
3876
- return createChainableTypeChecker(validate);
3877
- }
3878
-
3879
- function invalidValidatorError(componentName, location, propFullName, key, type) {
3880
- return new PropTypeError(
3881
- (componentName || 'React class') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' +
3882
- 'it must be a function, usually from the `prop-types` package, but received `' + type + '`.'
3883
- );
3884
- }
3885
-
3886
- function createShapeTypeChecker(shapeTypes) {
3887
- function validate(props, propName, componentName, location, propFullName) {
3888
- var propValue = props[propName];
3889
- var propType = getPropType(propValue);
3890
- if (propType !== 'object') {
3891
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
3892
- }
3893
- for (var key in shapeTypes) {
3894
- var checker = shapeTypes[key];
3895
- if (typeof checker !== 'function') {
3896
- return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
3897
- }
3898
- var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
3899
- if (error) {
3900
- return error;
3901
- }
3902
- }
3903
- return null;
3904
- }
3905
- return createChainableTypeChecker(validate);
3906
- }
3907
-
3908
- function createStrictShapeTypeChecker(shapeTypes) {
3909
- function validate(props, propName, componentName, location, propFullName) {
3910
- var propValue = props[propName];
3911
- var propType = getPropType(propValue);
3912
- if (propType !== 'object') {
3913
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
3914
- }
3915
- // We need to check all keys in case some are required but missing from props.
3916
- var allKeys = assign({}, props[propName], shapeTypes);
3917
- for (var key in allKeys) {
3918
- var checker = shapeTypes[key];
3919
- if (has(shapeTypes, key) && typeof checker !== 'function') {
3920
- return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
3921
- }
3922
- if (!checker) {
3923
- return new PropTypeError(
3924
- 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
3925
- '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
3926
- '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
3927
- );
3928
- }
3929
- var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
3930
- if (error) {
3931
- return error;
3932
- }
3933
- }
3934
- return null;
3935
- }
3936
-
3937
- return createChainableTypeChecker(validate);
3938
- }
3939
-
3940
- function isNode(propValue) {
3941
- switch (typeof propValue) {
3942
- case 'number':
3943
- case 'string':
3944
- case 'undefined':
3945
- return true;
3946
- case 'boolean':
3947
- return !propValue;
3948
- case 'object':
3949
- if (Array.isArray(propValue)) {
3950
- return propValue.every(isNode);
3951
- }
3952
- if (propValue === null || isValidElement(propValue)) {
3953
- return true;
3954
- }
3955
-
3956
- var iteratorFn = getIteratorFn(propValue);
3957
- if (iteratorFn) {
3958
- var iterator = iteratorFn.call(propValue);
3959
- var step;
3960
- if (iteratorFn !== propValue.entries) {
3961
- while (!(step = iterator.next()).done) {
3962
- if (!isNode(step.value)) {
3963
- return false;
3964
- }
3965
- }
3966
- } else {
3967
- // Iterator will provide entry [k,v] tuples rather than values.
3968
- while (!(step = iterator.next()).done) {
3969
- var entry = step.value;
3970
- if (entry) {
3971
- if (!isNode(entry[1])) {
3972
- return false;
3973
- }
3974
- }
3975
- }
3976
- }
3977
- } else {
3978
- return false;
3979
- }
3980
-
3981
- return true;
3982
- default:
3983
- return false;
3984
- }
3985
- }
3986
-
3987
- function isSymbol(propType, propValue) {
3988
- // Native Symbol.
3989
- if (propType === 'symbol') {
3990
- return true;
3991
- }
3992
-
3993
- // falsy value can't be a Symbol
3994
- if (!propValue) {
3995
- return false;
3996
- }
3997
-
3998
- // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
3999
- if (propValue['@@toStringTag'] === 'Symbol') {
4000
- return true;
4001
- }
4002
-
4003
- // Fallback for non-spec compliant Symbols which are polyfilled.
4004
- if (typeof Symbol === 'function' && propValue instanceof Symbol) {
4005
- return true;
4006
- }
4007
-
4008
- return false;
4009
- }
4010
-
4011
- // Equivalent of `typeof` but with special handling for array and regexp.
4012
- function getPropType(propValue) {
4013
- var propType = typeof propValue;
4014
- if (Array.isArray(propValue)) {
4015
- return 'array';
4016
- }
4017
- if (propValue instanceof RegExp) {
4018
- // Old webkits (at least until Android 4.0) return 'function' rather than
4019
- // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
4020
- // passes PropTypes.object.
4021
- return 'object';
4022
- }
4023
- if (isSymbol(propType, propValue)) {
4024
- return 'symbol';
4025
- }
4026
- return propType;
4027
- }
4028
-
4029
- // This handles more types than `getPropType`. Only used for error messages.
4030
- // See `createPrimitiveTypeChecker`.
4031
- function getPreciseType(propValue) {
4032
- if (typeof propValue === 'undefined' || propValue === null) {
4033
- return '' + propValue;
4034
- }
4035
- var propType = getPropType(propValue);
4036
- if (propType === 'object') {
4037
- if (propValue instanceof Date) {
4038
- return 'date';
4039
- } else if (propValue instanceof RegExp) {
4040
- return 'regexp';
4041
- }
4042
- }
4043
- return propType;
4044
- }
4045
-
4046
- // Returns a string that is postfixed to a warning about an invalid type.
4047
- // For example, "undefined" or "of type array"
4048
- function getPostfixForTypeWarning(value) {
4049
- var type = getPreciseType(value);
4050
- switch (type) {
4051
- case 'array':
4052
- case 'object':
4053
- return 'an ' + type;
4054
- case 'boolean':
4055
- case 'date':
4056
- case 'regexp':
4057
- return 'a ' + type;
4058
- default:
4059
- return type;
4060
- }
4061
- }
4062
-
4063
- // Returns class name of the object, if any.
4064
- function getClassName(propValue) {
4065
- if (!propValue.constructor || !propValue.constructor.name) {
4066
- return ANONYMOUS;
4067
- }
4068
- return propValue.constructor.name;
4069
- }
4070
-
4071
- ReactPropTypes.checkPropTypes = checkPropTypes;
4072
- ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
4073
- ReactPropTypes.PropTypes = ReactPropTypes;
4074
-
4075
- return ReactPropTypes;
4076
- };
4077
- return factoryWithTypeCheckers;
4078
- }
4079
-
4080
- /**
4081
- * Copyright (c) 2013-present, Facebook, Inc.
4082
- *
4083
- * This source code is licensed under the MIT license found in the
4084
- * LICENSE file in the root directory of this source tree.
4085
- */
4086
-
4087
- var factoryWithThrowingShims;
4088
- var hasRequiredFactoryWithThrowingShims;
4089
-
4090
- function requireFactoryWithThrowingShims () {
4091
- if (hasRequiredFactoryWithThrowingShims) return factoryWithThrowingShims;
4092
- hasRequiredFactoryWithThrowingShims = 1;
4093
-
4094
- var ReactPropTypesSecret = requireReactPropTypesSecret();
4095
-
4096
- function emptyFunction() {}
4097
- function emptyFunctionWithReset() {}
4098
- emptyFunctionWithReset.resetWarningCache = emptyFunction;
4099
-
4100
- factoryWithThrowingShims = function() {
4101
- function shim(props, propName, componentName, location, propFullName, secret) {
4102
- if (secret === ReactPropTypesSecret) {
4103
- // It is still safe when called from React.
4104
- return;
4105
- }
4106
- var err = new Error(
4107
- 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
4108
- 'Use PropTypes.checkPropTypes() to call them. ' +
4109
- 'Read more at http://fb.me/use-check-prop-types'
4110
- );
4111
- err.name = 'Invariant Violation';
4112
- throw err;
4113
- } shim.isRequired = shim;
4114
- function getShim() {
4115
- return shim;
4116
- } // Important!
4117
- // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
4118
- var ReactPropTypes = {
4119
- array: shim,
4120
- bigint: shim,
4121
- bool: shim,
4122
- func: shim,
4123
- number: shim,
4124
- object: shim,
4125
- string: shim,
4126
- symbol: shim,
4127
-
4128
- any: shim,
4129
- arrayOf: getShim,
4130
- element: shim,
4131
- elementType: shim,
4132
- instanceOf: getShim,
4133
- node: shim,
4134
- objectOf: getShim,
4135
- oneOf: getShim,
4136
- oneOfType: getShim,
4137
- shape: getShim,
4138
- exact: getShim,
4139
-
4140
- checkPropTypes: emptyFunctionWithReset,
4141
- resetWarningCache: emptyFunction
4142
- };
4143
-
4144
- ReactPropTypes.PropTypes = ReactPropTypes;
4145
-
4146
- return ReactPropTypes;
4147
- };
4148
- return factoryWithThrowingShims;
4149
- }
4150
-
4151
- /**
4152
- * Copyright (c) 2013-present, Facebook, Inc.
4153
- *
4154
- * This source code is licensed under the MIT license found in the
4155
- * LICENSE file in the root directory of this source tree.
4156
- */
4157
-
4158
- if (process.env.NODE_ENV !== 'production') {
4159
- var ReactIs = requireReactIs();
4160
-
4161
- // By explicitly using `prop-types` you are opting into new development behavior.
4162
- // http://fb.me/prop-types-in-prod
4163
- var throwOnDirectAccess = true;
4164
- propTypes.exports = requireFactoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess);
4165
- } else {
4166
- // By explicitly using `prop-types` you are opting into new production behavior.
4167
- // http://fb.me/prop-types-in-prod
4168
- propTypes.exports = requireFactoryWithThrowingShims()();
4169
- }
4170
-
4171
- var MemoizedEditorContent = /*#__PURE__*/React__default["default"].memo(neetoEditor.EditorContent);
4172
- var EmailPreview = reactUtils.withT(function (_ref) {
4173
- var t = _ref.t,
4174
- _ref$to = _ref.to,
4175
- to = _ref$to === void 0 ? [] : _ref$to,
4176
- from = _ref.from,
4177
- subject = _ref.subject,
4178
- body = _ref.body,
4179
- productName = _ref.productName,
4180
- actionButtonText = _ref.actionButtonText,
4181
- logo = _ref.logo,
4182
- _ref$className = _ref.className,
4183
- className = _ref$className === void 0 ? "" : _ref$className;
4184
- return /*#__PURE__*/React__default["default"].createElement("div", {
4185
- "data-cy": "email-preview-card",
4186
- "data-testid": "email-preview",
4187
- className: classnames("neeto-ui-border-gray-300 neeto-ui-shadow-m neeto-ui-bg-white flex flex-1 flex-col border", _defineProperty({}, className, className))
4188
- }, /*#__PURE__*/React__default["default"].createElement("div", {
4189
- className: "neeto-ui-border-gray-300 space-y-3 divide-y divide-gray-200 border-b p-6"
4190
- }, /*#__PURE__*/React__default["default"].createElement("div", {
4191
- className: "flex gap-2",
4192
- "data-cy": "email-send-to-preview",
4193
- "data-testid": "email-to-block"
4194
- }, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
4195
- className: "neeto-ui-text-gray-500",
4196
- lineHeight: "normal",
4197
- style: "body2"
4198
- }, t("neetoMolecules.emailPreview.to"), ":"), pure.isPresent(to) && pure.isNotEmpty(to) ? /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
4199
- className: "neeto-ui-text-gray-800 min-w-0 flex-grow break-words",
4200
- lineHeight: "normal",
4201
- style: "body2"
4202
- }, to.join(", ")) : /*#__PURE__*/React__default["default"].createElement("div", {
4203
- className: "neeto-ui-bg-gray-300 neeto-ui-rounded-full mt-2 h-2 w-40"
4204
- })), from && /*#__PURE__*/React__default["default"].createElement("div", {
4205
- className: "flex items-center gap-2 pt-3"
4206
- }, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
4207
- className: "neeto-ui-text-gray-500",
4208
- lineHeight: "normal",
4209
- style: "body2"
4210
- }, t("neetoMolecules.emailPreview.from"), ":"), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
4211
- className: "neeto-ui-text-gray-800 min-w-0 flex-grow break-words",
4212
- "data-cy": "email-send-from-preview",
4213
- lineHeight: "normal",
4214
- style: "body2"
4215
- }, from)), /*#__PURE__*/React__default["default"].createElement("div", {
4216
- className: "flex items-center gap-2 pt-3"
4217
- }, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
4218
- className: "neeto-ui-text-gray-500",
4219
- lineHeight: "normal",
4220
- style: "body2"
4221
- }, t("neetoMolecules.emailPreview.subject"), ":"), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
4222
- className: "neeto-ui-text-gray-800 min-w-0 flex-grow break-words",
4223
- "data-cy": "email-subject-preview",
4224
- lineHeight: "normal",
4225
- style: "body2"
4226
- }, subject || /*#__PURE__*/React__default["default"].createElement("span", {
4227
- className: "neeto-ui-bg-gray-300 neeto-ui-rounded-full h-2 w-40"
4228
- })))), /*#__PURE__*/React__default["default"].createElement("div", {
4229
- className: "neeto-ui-text-gray-800 flex flex-1 flex-col justify-between space-y-6 p-6 pr-10 text-base leading-relaxed",
4230
- "data-cy": "email-body-preview-container"
4231
- }, body ? /*#__PURE__*/React__default["default"].createElement(MemoizedEditorContent, {
4232
- content: body
4233
- }) : /*#__PURE__*/React__default["default"].createElement("div", {
4234
- className: "space-y-4"
4235
- }, /*#__PURE__*/React__default["default"].createElement("div", {
4236
- className: "neeto-ui-bg-gray-300 neeto-ui-rounded-full h-2 w-80"
4237
- }), /*#__PURE__*/React__default["default"].createElement("div", {
4238
- className: "neeto-ui-bg-gray-300 neeto-ui-rounded-full h-2 w-72"
4239
- }), /*#__PURE__*/React__default["default"].createElement("div", {
4240
- className: "neeto-ui-bg-gray-300 neeto-ui-rounded-full h-2 w-80"
4241
- })), actionButtonText && /*#__PURE__*/React__default["default"].createElement("div", {
4242
- className: "mt-6 flex w-full items-center justify-center"
4243
- }, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
4244
- className: "pointer-events-none",
4245
- label: actionButtonText
4246
- })), logo && /*#__PURE__*/React__default["default"].createElement("img", {
4247
- alt: t("neetoMolecules.emailPreview.logoAltText"),
4248
- className: "h-20 w-36 object-cover",
4249
- "data-cy": "company-logo-preview",
4250
- src: logo
4251
- })), productName && /*#__PURE__*/React__default["default"].createElement("div", {
4252
- className: "neeto-ui-bg-gray-100 mt-auto p-2",
4253
- "data-testid": "product-name-block"
4254
- }, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
4255
- className: "neeto-ui-text-gray-600 text-center leading-6",
4256
- style: "body3"
4257
- }, t("neetoMolecules.emailPreview.poweredBy"), /*#__PURE__*/React__default["default"].createElement("span", {
4258
- className: "neeto-ui-text-gray-800 font-medium"
4259
- }, productName))));
4260
- });
4261
- EmailPreview.propTypes = {
4262
- /**
4263
- * The value of the send-to field.
4264
- */
4265
- to: propTypes.exports.arrayOf(propTypes.exports.string),
4266
- /**
4267
- * The value of the send-from field.
4268
- */
4269
- from: propTypes.exports.string,
4270
- /**
4271
- * The subject of the email.
4272
- */
4273
- subject: propTypes.exports.string,
4274
- /**
4275
- * The body of the email.
4276
- */
4277
- body: propTypes.exports.string,
4278
- /**
4279
- * The name of the neeto product to be previewed.
4280
- */
4281
- productName: propTypes.exports.string,
4282
- /**
4283
- * The text to be shown in the action button.
4284
- */
4285
- actionButtonText: propTypes.exports.string,
4286
- /**
4287
- * Source link for the company logo.
4288
- */
4289
- logo: propTypes.exports.string
4290
- };
4291
-
4292
- exports.EmailForm = EmailForm;
4293
- exports.EmailFormProvider = EmailFormProvider;
4294
- exports.EmailPreview = EmailPreview;
4295
- //# sourceMappingURL=EmailForm.cjs.js.map