@bigbinary/neeto-molecules 3.15.42 → 3.15.43

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 (426) hide show
  1. package/package.json +1 -1
  2. package/dist/AuditLogs.js +0 -539
  3. package/dist/AuditLogs.js.map +0 -1
  4. package/dist/BoardView.js +0 -394
  5. package/dist/BoardView.js.map +0 -1
  6. package/dist/Breadcrumbs.js +0 -46
  7. package/dist/Breadcrumbs.js.map +0 -1
  8. package/dist/BrowserPreview.js +0 -50
  9. package/dist/BrowserPreview.js.map +0 -1
  10. package/dist/BrowserSupport.js +0 -348
  11. package/dist/BrowserSupport.js.map +0 -1
  12. package/dist/Builder.js +0 -786
  13. package/dist/Builder.js.map +0 -1
  14. package/dist/ButtonGroup.js +0 -36
  15. package/dist/ButtonGroup.js.map +0 -1
  16. package/dist/CalendarView.js +0 -353
  17. package/dist/CalendarView.js.map +0 -1
  18. package/dist/CardLayout.js +0 -49
  19. package/dist/CardLayout.js.map +0 -1
  20. package/dist/Chevron-6dLkaXtR.js +0 -246
  21. package/dist/Chevron-6dLkaXtR.js.map +0 -1
  22. package/dist/Codeblock.js +0 -58
  23. package/dist/Codeblock.js.map +0 -1
  24. package/dist/Columns.js +0 -21
  25. package/dist/Columns.js.map +0 -1
  26. package/dist/ConfigurePageSidebar.js +0 -97
  27. package/dist/ConfigurePageSidebar.js.map +0 -1
  28. package/dist/ConfirmationModal.js +0 -110
  29. package/dist/ConfirmationModal.js.map +0 -1
  30. package/dist/Container.js +0 -38
  31. package/dist/Container.js.map +0 -1
  32. package/dist/CopyToClipboardButton.js +0 -82
  33. package/dist/CopyToClipboardButton.js.map +0 -1
  34. package/dist/Currency.js +0 -917
  35. package/dist/Currency.js.map +0 -1
  36. package/dist/DateFormat.js +0 -45
  37. package/dist/DateFormat.js.map +0 -1
  38. package/dist/DateRangeFilter.js +0 -178
  39. package/dist/DateRangeFilter.js.map +0 -1
  40. package/dist/DeleteArchiveModal.js +0 -98
  41. package/dist/DeleteArchiveModal.js.map +0 -1
  42. package/dist/DeviceIncompatibilityMessage.js +0 -95
  43. package/dist/DeviceIncompatibilityMessage.js.map +0 -1
  44. package/dist/DocumentEditor.js +0 -183
  45. package/dist/DocumentEditor.js.map +0 -1
  46. package/dist/DownloadMobileAppCallout.js +0 -40
  47. package/dist/DownloadMobileAppCallout.js.map +0 -1
  48. package/dist/DynamicVariables.js +0 -115
  49. package/dist/DynamicVariables.js.map +0 -1
  50. package/dist/EmailForm.js +0 -567
  51. package/dist/EmailForm.js.map +0 -1
  52. package/dist/EmailPreview.js +0 -140
  53. package/dist/EmailPreview.js.map +0 -1
  54. package/dist/EmojiPicker.js +0 -112
  55. package/dist/EmojiPicker.js.map +0 -1
  56. package/dist/EmojiReactions.js +0 -82
  57. package/dist/EmojiReactions.js.map +0 -1
  58. package/dist/Engagements.js +0 -292
  59. package/dist/Engagements.js.map +0 -1
  60. package/dist/ErrorPage.js +0 -1811
  61. package/dist/ErrorPage.js.map +0 -1
  62. package/dist/FileUpload.js +0 -595
  63. package/dist/FileUpload.js.map +0 -1
  64. package/dist/FinderModal.js +0 -280
  65. package/dist/FinderModal.js.map +0 -1
  66. package/dist/FloatingActionMenu.js +0 -854
  67. package/dist/FloatingActionMenu.js.map +0 -1
  68. package/dist/GoogleFontPicker.js +0 -581
  69. package/dist/GoogleFontPicker.js.map +0 -1
  70. package/dist/Header.js +0 -126
  71. package/dist/Header.js.map +0 -1
  72. package/dist/HelpPopover.js +0 -83
  73. package/dist/HelpPopover.js.map +0 -1
  74. package/dist/IconPicker.js +0 -1159
  75. package/dist/IconPicker.js.map +0 -1
  76. package/dist/ImageWithFallback.js +0 -49
  77. package/dist/ImageWithFallback.js.map +0 -1
  78. package/dist/InlineInput.js +0 -230
  79. package/dist/InlineInput.js.map +0 -1
  80. package/dist/Insights.js +0 -358
  81. package/dist/Insights.js.map +0 -1
  82. package/dist/IntegrationCard.js +0 -227
  83. package/dist/IntegrationCard.js.map +0 -1
  84. package/dist/IpRestriction.js +0 -3617
  85. package/dist/IpRestriction.js.map +0 -1
  86. package/dist/KeyboardShortcuts.js +0 -284
  87. package/dist/KeyboardShortcuts.js.map +0 -1
  88. package/dist/LoginPage.js +0 -184
  89. package/dist/LoginPage.js.map +0 -1
  90. package/dist/MadeWith.js +0 -41
  91. package/dist/MadeWith.js.map +0 -1
  92. package/dist/MenuBar.js +0 -1326
  93. package/dist/MenuBar.js.map +0 -1
  94. package/dist/Metadata.js +0 -218
  95. package/dist/Metadata.js.map +0 -1
  96. package/dist/MobilePreviewHeader.js +0 -25
  97. package/dist/MobilePreviewHeader.js.map +0 -1
  98. package/dist/MoreDropdown.js +0 -163
  99. package/dist/MoreDropdown.js.map +0 -1
  100. package/dist/NavigationHeader.js +0 -264
  101. package/dist/NavigationHeader.js.map +0 -1
  102. package/dist/NeetoWidget.js +0 -2867
  103. package/dist/NeetoWidget.js.map +0 -1
  104. package/dist/Onboarding.js +0 -246
  105. package/dist/Onboarding.js.map +0 -1
  106. package/dist/OptionFields.js +0 -717
  107. package/dist/OptionFields.js.map +0 -1
  108. package/dist/PageLoader.js +0 -40
  109. package/dist/PageLoader.js.map +0 -1
  110. package/dist/PhoneNumber.js +0 -75
  111. package/dist/PhoneNumber.js.map +0 -1
  112. package/dist/ProductEmbed.js +0 -884
  113. package/dist/ProductEmbed.js.map +0 -1
  114. package/dist/PublishBlock.js +0 -447
  115. package/dist/PublishBlock.js.map +0 -1
  116. package/dist/PublishYourItem.js +0 -58
  117. package/dist/PublishYourItem.js.map +0 -1
  118. package/dist/Rename.js +0 -366
  119. package/dist/Rename.js.map +0 -1
  120. package/dist/ResponsiveDevicePicker.js +0 -63
  121. package/dist/ResponsiveDevicePicker.js.map +0 -1
  122. package/dist/Schedule.js +0 -926
  123. package/dist/Schedule.js.map +0 -1
  124. package/dist/Scrollable.js +0 -42
  125. package/dist/Scrollable.js.map +0 -1
  126. package/dist/Search.js +0 -110
  127. package/dist/Search.js.map +0 -1
  128. package/dist/SendToFields.js +0 -2221
  129. package/dist/SendToFields.js.map +0 -1
  130. package/dist/SessionEnvironment.js +0 -431
  131. package/dist/SessionEnvironment.js.map +0 -1
  132. package/dist/Settings.js +0 -250
  133. package/dist/Settings.js.map +0 -1
  134. package/dist/ShareRecordingPane.js +0 -216
  135. package/dist/ShareRecordingPane.js.map +0 -1
  136. package/dist/ShareViaEmail.js +0 -416
  137. package/dist/ShareViaEmail.js.map +0 -1
  138. package/dist/ShareViaLink.js +0 -1556
  139. package/dist/ShareViaLink.js.map +0 -1
  140. package/dist/Sidebar.js +0 -294
  141. package/dist/Sidebar.js.map +0 -1
  142. package/dist/StatusDropdown.js +0 -109
  143. package/dist/StatusDropdown.js.map +0 -1
  144. package/dist/StickyRibbonsContainer.js +0 -131
  145. package/dist/StickyRibbonsContainer.js.map +0 -1
  146. package/dist/SubHeader.js +0 -209
  147. package/dist/SubHeader.js.map +0 -1
  148. package/dist/SubscriptionNotificationsContainer.js +0 -77
  149. package/dist/SubscriptionNotificationsContainer.js.map +0 -1
  150. package/dist/SuffixedInput.js +0 -111
  151. package/dist/SuffixedInput.js.map +0 -1
  152. package/dist/TableWrapper.js +0 -27
  153. package/dist/TableWrapper.js.map +0 -1
  154. package/dist/Taxonomy.js +0 -496
  155. package/dist/Taxonomy.js.map +0 -1
  156. package/dist/TimeFormat.js +0 -14
  157. package/dist/TimeFormat.js.map +0 -1
  158. package/dist/TimezoneMismatchModal.js +0 -138
  159. package/dist/TimezoneMismatchModal.js.map +0 -1
  160. package/dist/ToggleFeatureCard.js +0 -211
  161. package/dist/ToggleFeatureCard.js.map +0 -1
  162. package/dist/_commonjsHelpers-BFTU3MAI.js +0 -8
  163. package/dist/_commonjsHelpers-BFTU3MAI.js.map +0 -1
  164. package/dist/cjs/AuditLogs.js +0 -541
  165. package/dist/cjs/AuditLogs.js.map +0 -1
  166. package/dist/cjs/BoardView.js +0 -396
  167. package/dist/cjs/BoardView.js.map +0 -1
  168. package/dist/cjs/Breadcrumbs.js +0 -48
  169. package/dist/cjs/Breadcrumbs.js.map +0 -1
  170. package/dist/cjs/BrowserPreview.js +0 -52
  171. package/dist/cjs/BrowserPreview.js.map +0 -1
  172. package/dist/cjs/BrowserSupport.js +0 -350
  173. package/dist/cjs/BrowserSupport.js.map +0 -1
  174. package/dist/cjs/Builder.js +0 -794
  175. package/dist/cjs/Builder.js.map +0 -1
  176. package/dist/cjs/ButtonGroup.js +0 -38
  177. package/dist/cjs/ButtonGroup.js.map +0 -1
  178. package/dist/cjs/CalendarView.js +0 -355
  179. package/dist/cjs/CalendarView.js.map +0 -1
  180. package/dist/cjs/CardLayout.js +0 -51
  181. package/dist/cjs/CardLayout.js.map +0 -1
  182. package/dist/cjs/Chevron-wfVdaB4-.js +0 -256
  183. package/dist/cjs/Chevron-wfVdaB4-.js.map +0 -1
  184. package/dist/cjs/Codeblock.js +0 -60
  185. package/dist/cjs/Codeblock.js.map +0 -1
  186. package/dist/cjs/Columns.js +0 -35
  187. package/dist/cjs/Columns.js.map +0 -1
  188. package/dist/cjs/ConfigurePageSidebar.js +0 -99
  189. package/dist/cjs/ConfigurePageSidebar.js.map +0 -1
  190. package/dist/cjs/ConfirmationModal.js +0 -131
  191. package/dist/cjs/ConfirmationModal.js.map +0 -1
  192. package/dist/cjs/Container.js +0 -40
  193. package/dist/cjs/Container.js.map +0 -1
  194. package/dist/cjs/CopyToClipboardButton.js +0 -84
  195. package/dist/cjs/CopyToClipboardButton.js.map +0 -1
  196. package/dist/cjs/Currency.js +0 -920
  197. package/dist/cjs/Currency.js.map +0 -1
  198. package/dist/cjs/DateFormat.js +0 -47
  199. package/dist/cjs/DateFormat.js.map +0 -1
  200. package/dist/cjs/DateRangeFilter.js +0 -180
  201. package/dist/cjs/DateRangeFilter.js.map +0 -1
  202. package/dist/cjs/DeleteArchiveModal.js +0 -100
  203. package/dist/cjs/DeleteArchiveModal.js.map +0 -1
  204. package/dist/cjs/DeviceIncompatibilityMessage.js +0 -115
  205. package/dist/cjs/DeviceIncompatibilityMessage.js.map +0 -1
  206. package/dist/cjs/DocumentEditor.js +0 -185
  207. package/dist/cjs/DocumentEditor.js.map +0 -1
  208. package/dist/cjs/DownloadMobileAppCallout.js +0 -42
  209. package/dist/cjs/DownloadMobileAppCallout.js.map +0 -1
  210. package/dist/cjs/DynamicVariables.js +0 -117
  211. package/dist/cjs/DynamicVariables.js.map +0 -1
  212. package/dist/cjs/EmailForm.js +0 -593
  213. package/dist/cjs/EmailForm.js.map +0 -1
  214. package/dist/cjs/EmailPreview.js +0 -142
  215. package/dist/cjs/EmailPreview.js.map +0 -1
  216. package/dist/cjs/EmojiPicker.js +0 -114
  217. package/dist/cjs/EmojiPicker.js.map +0 -1
  218. package/dist/cjs/EmojiReactions.js +0 -84
  219. package/dist/cjs/EmojiReactions.js.map +0 -1
  220. package/dist/cjs/Engagements.js +0 -294
  221. package/dist/cjs/Engagements.js.map +0 -1
  222. package/dist/cjs/ErrorPage.js +0 -1831
  223. package/dist/cjs/ErrorPage.js.map +0 -1
  224. package/dist/cjs/FileUpload.js +0 -598
  225. package/dist/cjs/FileUpload.js.map +0 -1
  226. package/dist/cjs/FinderModal.js +0 -282
  227. package/dist/cjs/FinderModal.js.map +0 -1
  228. package/dist/cjs/FloatingActionMenu.js +0 -875
  229. package/dist/cjs/FloatingActionMenu.js.map +0 -1
  230. package/dist/cjs/GoogleFontPicker.js +0 -583
  231. package/dist/cjs/GoogleFontPicker.js.map +0 -1
  232. package/dist/cjs/Header.js +0 -128
  233. package/dist/cjs/Header.js.map +0 -1
  234. package/dist/cjs/HelpPopover.js +0 -85
  235. package/dist/cjs/HelpPopover.js.map +0 -1
  236. package/dist/cjs/IconPicker.js +0 -1161
  237. package/dist/cjs/IconPicker.js.map +0 -1
  238. package/dist/cjs/ImageWithFallback.js +0 -51
  239. package/dist/cjs/ImageWithFallback.js.map +0 -1
  240. package/dist/cjs/InlineInput.js +0 -233
  241. package/dist/cjs/InlineInput.js.map +0 -1
  242. package/dist/cjs/Insights.js +0 -360
  243. package/dist/cjs/Insights.js.map +0 -1
  244. package/dist/cjs/IntegrationCard.js +0 -229
  245. package/dist/cjs/IntegrationCard.js.map +0 -1
  246. package/dist/cjs/IpRestriction.js +0 -3638
  247. package/dist/cjs/IpRestriction.js.map +0 -1
  248. package/dist/cjs/KeyboardShortcuts.js +0 -286
  249. package/dist/cjs/KeyboardShortcuts.js.map +0 -1
  250. package/dist/cjs/LoginPage.js +0 -205
  251. package/dist/cjs/LoginPage.js.map +0 -1
  252. package/dist/cjs/MadeWith.js +0 -43
  253. package/dist/cjs/MadeWith.js.map +0 -1
  254. package/dist/cjs/MenuBar.js +0 -1328
  255. package/dist/cjs/MenuBar.js.map +0 -1
  256. package/dist/cjs/Metadata.js +0 -220
  257. package/dist/cjs/Metadata.js.map +0 -1
  258. package/dist/cjs/MobilePreviewHeader.js +0 -27
  259. package/dist/cjs/MobilePreviewHeader.js.map +0 -1
  260. package/dist/cjs/MoreDropdown.js +0 -165
  261. package/dist/cjs/MoreDropdown.js.map +0 -1
  262. package/dist/cjs/NavigationHeader.js +0 -266
  263. package/dist/cjs/NavigationHeader.js.map +0 -1
  264. package/dist/cjs/NeetoWidget.js +0 -2888
  265. package/dist/cjs/NeetoWidget.js.map +0 -1
  266. package/dist/cjs/Onboarding.js +0 -248
  267. package/dist/cjs/Onboarding.js.map +0 -1
  268. package/dist/cjs/OptionFields.js +0 -719
  269. package/dist/cjs/OptionFields.js.map +0 -1
  270. package/dist/cjs/PageLoader.js +0 -42
  271. package/dist/cjs/PageLoader.js.map +0 -1
  272. package/dist/cjs/PhoneNumber.js +0 -80
  273. package/dist/cjs/PhoneNumber.js.map +0 -1
  274. package/dist/cjs/ProductEmbed.js +0 -886
  275. package/dist/cjs/ProductEmbed.js.map +0 -1
  276. package/dist/cjs/PublishBlock.js +0 -449
  277. package/dist/cjs/PublishBlock.js.map +0 -1
  278. package/dist/cjs/PublishYourItem.js +0 -60
  279. package/dist/cjs/PublishYourItem.js.map +0 -1
  280. package/dist/cjs/Rename.js +0 -368
  281. package/dist/cjs/Rename.js.map +0 -1
  282. package/dist/cjs/ResponsiveDevicePicker.js +0 -65
  283. package/dist/cjs/ResponsiveDevicePicker.js.map +0 -1
  284. package/dist/cjs/Schedule.js +0 -947
  285. package/dist/cjs/Schedule.js.map +0 -1
  286. package/dist/cjs/Scrollable.js +0 -44
  287. package/dist/cjs/Scrollable.js.map +0 -1
  288. package/dist/cjs/Search.js +0 -112
  289. package/dist/cjs/Search.js.map +0 -1
  290. package/dist/cjs/SendToFields.js +0 -2223
  291. package/dist/cjs/SendToFields.js.map +0 -1
  292. package/dist/cjs/SessionEnvironment.js +0 -433
  293. package/dist/cjs/SessionEnvironment.js.map +0 -1
  294. package/dist/cjs/Settings.js +0 -252
  295. package/dist/cjs/Settings.js.map +0 -1
  296. package/dist/cjs/ShareRecordingPane.js +0 -218
  297. package/dist/cjs/ShareRecordingPane.js.map +0 -1
  298. package/dist/cjs/ShareViaEmail.js +0 -437
  299. package/dist/cjs/ShareViaEmail.js.map +0 -1
  300. package/dist/cjs/ShareViaLink.js +0 -1577
  301. package/dist/cjs/ShareViaLink.js.map +0 -1
  302. package/dist/cjs/Sidebar.js +0 -315
  303. package/dist/cjs/Sidebar.js.map +0 -1
  304. package/dist/cjs/StatusDropdown.js +0 -111
  305. package/dist/cjs/StatusDropdown.js.map +0 -1
  306. package/dist/cjs/StickyRibbonsContainer.js +0 -133
  307. package/dist/cjs/StickyRibbonsContainer.js.map +0 -1
  308. package/dist/cjs/SubHeader.js +0 -211
  309. package/dist/cjs/SubHeader.js.map +0 -1
  310. package/dist/cjs/SubscriptionNotificationsContainer.js +0 -79
  311. package/dist/cjs/SubscriptionNotificationsContainer.js.map +0 -1
  312. package/dist/cjs/SuffixedInput.js +0 -113
  313. package/dist/cjs/SuffixedInput.js.map +0 -1
  314. package/dist/cjs/TableWrapper.js +0 -29
  315. package/dist/cjs/TableWrapper.js.map +0 -1
  316. package/dist/cjs/Taxonomy.js +0 -517
  317. package/dist/cjs/Taxonomy.js.map +0 -1
  318. package/dist/cjs/TimeFormat.js +0 -16
  319. package/dist/cjs/TimeFormat.js.map +0 -1
  320. package/dist/cjs/TimezoneMismatchModal.js +0 -140
  321. package/dist/cjs/TimezoneMismatchModal.js.map +0 -1
  322. package/dist/cjs/ToggleFeatureCard.js +0 -213
  323. package/dist/cjs/ToggleFeatureCard.js.map +0 -1
  324. package/dist/cjs/_commonjsHelpers-BJu3ubxk.js +0 -11
  325. package/dist/cjs/_commonjsHelpers-BJu3ubxk.js.map +0 -1
  326. package/dist/cjs/index-JY2zVpnv.js +0 -1189
  327. package/dist/cjs/index-JY2zVpnv.js.map +0 -1
  328. package/dist/cjs/inject-css-vQvjPR2x.js +0 -6
  329. package/dist/cjs/inject-css-vQvjPR2x.js.map +0 -1
  330. package/dist/cjs/phone-number-BN-c0rfv.js +0 -320
  331. package/dist/cjs/phone-number-BN-c0rfv.js.map +0 -1
  332. package/dist/cjs/platform-BUcCb8Jx.js +0 -1254
  333. package/dist/cjs/platform-BUcCb8Jx.js.map +0 -1
  334. package/dist/cjs/useColumns-BP8c4PV-.js +0 -282
  335. package/dist/cjs/useColumns-BP8c4PV-.js.map +0 -1
  336. package/dist/index-DAYCJu79.js +0 -1187
  337. package/dist/index-DAYCJu79.js.map +0 -1
  338. package/dist/inject-css-DmrvuTKK.js +0 -4
  339. package/dist/inject-css-DmrvuTKK.js.map +0 -1
  340. package/dist/phone-number-CXCBroLh.js +0 -295
  341. package/dist/phone-number-CXCBroLh.js.map +0 -1
  342. package/dist/platform-F44zJ4Xh.js +0 -1252
  343. package/dist/platform-F44zJ4Xh.js.map +0 -1
  344. package/dist/styles/page-loader.css +0 -1
  345. package/dist/styles/page-loader.js +0 -3
  346. package/dist/useColumns-Db5uic1-.js +0 -274
  347. package/dist/useColumns-Db5uic1-.js.map +0 -1
  348. package/types/AuditLogs.d.ts +0 -22
  349. package/types/BoardView.d.ts +0 -149
  350. package/types/Breadcrumbs.d.ts +0 -30
  351. package/types/BrowserPreview.d.ts +0 -30
  352. package/types/BrowserSupport.d.ts +0 -110
  353. package/types/Builder.d.ts +0 -99
  354. package/types/ButtonGroup.d.ts +0 -45
  355. package/types/CalendarView.d.ts +0 -98
  356. package/types/CardLayout.d.ts +0 -34
  357. package/types/Codeblock.d.ts +0 -37
  358. package/types/Columns.d.ts +0 -168
  359. package/types/ConfigurePageSidebar.d.ts +0 -45
  360. package/types/ConfirmationModal.d.ts +0 -65
  361. package/types/Container.d.ts +0 -38
  362. package/types/CopyToClipboardButton.d.ts +0 -28
  363. package/types/Currency.d.ts +0 -50
  364. package/types/DateFormat.d.ts +0 -15
  365. package/types/DateRangeFilter.d.ts +0 -56
  366. package/types/DeleteArchiveModal.d.ts +0 -65
  367. package/types/DeviceIncompatibilityMessage.d.ts +0 -19
  368. package/types/DocumentEditor.d.ts +0 -61
  369. package/types/DownloadMobileAppCallout.d.ts +0 -35
  370. package/types/DynamicVariables.d.ts +0 -48
  371. package/types/EmailForm.d.ts +0 -165
  372. package/types/EmailFormProvider.d.ts +0 -48
  373. package/types/EmailPreview.d.ts +0 -43
  374. package/types/EmojiPicker.d.ts +0 -35
  375. package/types/EmojiReactions.d.ts +0 -62
  376. package/types/Engagements.d.ts +0 -131
  377. package/types/ErrorPage.d.ts +0 -22
  378. package/types/FileUpload.d.ts +0 -89
  379. package/types/FinderModal.d.ts +0 -66
  380. package/types/FloatingActionMenu.d.ts +0 -59
  381. package/types/GoogleFontPicker.d.ts +0 -68
  382. package/types/Header.d.ts +0 -37
  383. package/types/HelpPopover.d.ts +0 -45
  384. package/types/IconPicker.d.ts +0 -45
  385. package/types/ImageWithFallback.d.ts +0 -24
  386. package/types/InlineInput.d.ts +0 -87
  387. package/types/Insights.d.ts +0 -112
  388. package/types/IntegrationCard.d.ts +0 -60
  389. package/types/IpRestriction.d.ts +0 -25
  390. package/types/KeyboardShortcuts.d.ts +0 -149
  391. package/types/LoginPage.d.ts +0 -45
  392. package/types/MadeWith.d.ts +0 -18
  393. package/types/MenuBar.d.ts +0 -127
  394. package/types/Metadata.d.ts +0 -109
  395. package/types/MobilePreviewHeader.d.ts +0 -19
  396. package/types/MoreDropdown.d.ts +0 -52
  397. package/types/NavigationHeader.d.ts +0 -180
  398. package/types/NeetoWidget.d.ts +0 -43
  399. package/types/Onboarding.d.ts +0 -70
  400. package/types/OptionFields.d.ts +0 -70
  401. package/types/PageLoader.d.ts +0 -40
  402. package/types/PhoneNumber.d.ts +0 -112
  403. package/types/ProductEmbed.d.ts +0 -93
  404. package/types/PublishBlock.d.ts +0 -148
  405. package/types/Rename.d.ts +0 -73
  406. package/types/ResponsiveDevicePicker.d.ts +0 -32
  407. package/types/Schedule.d.ts +0 -146
  408. package/types/Scrollable.d.ts +0 -30
  409. package/types/Search.d.ts +0 -22
  410. package/types/SendToFields.d.ts +0 -67
  411. package/types/SessionEnvironment.d.ts +0 -170
  412. package/types/Settings.d.ts +0 -108
  413. package/types/ShareRecordingPane.d.ts +0 -85
  414. package/types/ShareViaEmail.d.ts +0 -99
  415. package/types/ShareViaLink.d.ts +0 -183
  416. package/types/Sidebar.d.ts +0 -51
  417. package/types/StatusDropdown.d.ts +0 -74
  418. package/types/StickyRibbonsContainer.d.ts +0 -28
  419. package/types/SubHeader.d.ts +0 -105
  420. package/types/SubscriptionNotificationsContainer.d.ts +0 -26
  421. package/types/SuffixedInput.d.ts +0 -45
  422. package/types/TableWrapper.d.ts +0 -40
  423. package/types/Taxonomy.d.ts +0 -59
  424. package/types/TimeFormat.d.ts +0 -13
  425. package/types/TimezoneMismatchModal.d.ts +0 -41
  426. package/types/ToggleFeatureCard.d.ts +0 -38
@@ -1,2223 +0,0 @@
1
- 'use strict';
2
-
3
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
- var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
5
- var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
6
- var React = require('react');
7
- var formik = require('formik');
8
- var Upload = require('@bigbinary/neeto-icons/Upload');
9
- var Button = require('@bigbinary/neetoui/Button');
10
- var Toastr = require('@bigbinary/neetoui/Toastr');
11
- var MultiEmailInput = require('@bigbinary/neetoui/formik/MultiEmailInput');
12
- var reactI18next = require('react-i18next');
13
- var classnames = require('classnames');
14
- var Typography = require('@bigbinary/neetoui/Typography');
15
- var Pane = require('@bigbinary/neetoui/Pane');
16
- var reactDropzone = require('react-dropzone');
17
- var withT = require('@bigbinary/neeto-commons-frontend/react-utils/withT');
18
- var Download = require('@bigbinary/neeto-icons/Download');
19
- var Callout = require('@bigbinary/neetoui/Callout');
20
- var jsxRuntime = require('react/jsx-runtime');
21
- var i18next = require('i18next');
22
- var _commonjsHelpers = require('./_commonjsHelpers-BJu3ubxk.js');
23
- var require$$0 = require('stream');
24
- var ramda = require('ramda');
25
- var yup = require('yup');
26
-
27
- var CSV_FILE_SIZE_IN_KB = 32;
28
- var ONE_KILOBYTE_IN_BYTES = 1024;
29
- var DOWNLOAD_SAMPLE_EMAIL_CSV_FILE = "https://d2v7kzglnr2dnh.cloudfront.net/others/sample-bulk-email.csv";
30
-
31
- var Requirements = withT(function (_ref) {
32
- var t = _ref.t,
33
- fileSize = _ref.fileSize;
34
- return /*#__PURE__*/jsxRuntime.jsxs(Callout, {
35
- className: "flex flex-col items-center py-6",
36
- style: "info",
37
- children: [/*#__PURE__*/jsxRuntime.jsxs("ul", {
38
- className: "list-outside list-disc space-y-1 font-normal leading-normal",
39
- children: [fileSize && /*#__PURE__*/jsxRuntime.jsx("li", {
40
- children: t("neetoMolecules.shareViaLink.requirements.fileTypeAndSize", {
41
- limit: fileSize
42
- })
43
- }), /*#__PURE__*/jsxRuntime.jsx("li", {
44
- children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
45
- components: {
46
- strong: /*#__PURE__*/jsxRuntime.jsx("strong", {
47
- className: "font-semibold"
48
- })
49
- },
50
- i18nKey: "neetoMolecules.shareViaLink.requirements.shouldContainColumns"
51
- })
52
- })]
53
- }), /*#__PURE__*/jsxRuntime.jsx(Button, {
54
- href: DOWNLOAD_SAMPLE_EMAIL_CSV_FILE,
55
- icon: Download,
56
- iconPosition: "left",
57
- label: t("neetoMolecules.shareViaLink.bulkUploadPane.downloadSampleCSV"),
58
- style: "link"
59
- })]
60
- });
61
- });
62
- var Requirements$1 = /*#__PURE__*/React.memo(Requirements);
63
-
64
- function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
65
- function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
66
- var BulkUploadPane = function BulkUploadPane(_ref) {
67
- var _fileRejections$;
68
- var isOpen = _ref.isOpen,
69
- fileSize = _ref.fileSize,
70
- onClose = _ref.onClose,
71
- handleFileSubmit = _ref.handleFileSubmit;
72
- var _useDropzone = reactDropzone.useDropzone({
73
- accept: {
74
- "text/csv": []
75
- },
76
- maxFiles: 1,
77
- maxSize: fileSize * ONE_KILOBYTE_IN_BYTES,
78
- onDrop: function onDrop(files) {
79
- return files[0] && handleFileSubmit(files[0]);
80
- }
81
- }),
82
- getRootProps = _useDropzone.getRootProps,
83
- getInputProps = _useDropzone.getInputProps,
84
- isDragActive = _useDropzone.isDragActive,
85
- fileRejections = _useDropzone.fileRejections;
86
- var errors = (_fileRejections$ = fileRejections[0]) === null || _fileRejections$ === void 0 ? void 0 : _fileRejections$.errors.map(function (_ref2) {
87
- var message = _ref2.message,
88
- code = _ref2.code;
89
- return /*#__PURE__*/jsxRuntime.jsx(Typography, {
90
- className: "neeto-ui-text-error-500 items",
91
- "data-cy": "file-input-error-message",
92
- style: "body3",
93
- children: message
94
- }, code);
95
- });
96
- var _useTranslation = reactI18next.useTranslation(),
97
- t = _useTranslation.t;
98
- return /*#__PURE__*/jsxRuntime.jsx(Pane, {
99
- isOpen: isOpen,
100
- onClose: onClose,
101
- "data-testid": "bulk-upload-pane",
102
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
103
- tabIndex: 0,
104
- children: [/*#__PURE__*/jsxRuntime.jsx(Pane.Header, {
105
- children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
106
- "data-testid": "bulk-upload-header",
107
- style: "h2",
108
- weight: "semibold",
109
- children: t("neetoMolecules.shareViaLink.bulkUpload")
110
- })
111
- }), /*#__PURE__*/jsxRuntime.jsx(Pane.Body, {
112
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
113
- className: "w-full space-y-4",
114
- children: [/*#__PURE__*/jsxRuntime.jsx(Requirements$1, {
115
- fileSize: fileSize
116
- }), /*#__PURE__*/jsxRuntime.jsxs("div", _objectSpread$1(_objectSpread$1({}, getRootProps({
117
- className: classnames("flex flex-col p-2 border neeto-ui-border-primary-500 border-dashed neeto-ui-rounded-md transition duration-500 ease-in-out hover:neeto-ui-bg-gray-100 cursor-pointer items-center", {
118
- "neeto-ui-border-gray-100": isDragActive,
119
- "neeto-ui-border-error neeto-ui-bg-pastel-red hover:neeto-ui-bg-pastel-red": fileRejections.length
120
- })
121
- })), {}, {
122
- children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
123
- className: "flex flex-col items-center space-y-3 p-4",
124
- children: [/*#__PURE__*/jsxRuntime.jsx(Upload, {
125
- className: "neeto-ui-text-primary-500",
126
- size: 32
127
- }), /*#__PURE__*/jsxRuntime.jsx("input", _objectSpread$1(_objectSpread$1({}, getInputProps()), {}, {
128
- "data-cy": "csv-upload-input",
129
- "data-testid": "csv-upload-input"
130
- })), isDragActive ? /*#__PURE__*/jsxRuntime.jsx(Typography, {
131
- style: "body2",
132
- children: t("neetoMolecules.shareViaLink.bulkUploadPane.dropFileHere")
133
- }) : /*#__PURE__*/jsxRuntime.jsxs("div", {
134
- className: "flex flex-col items-center space-y-1",
135
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
136
- className: "flex w-full items-center justify-center gap-x-1",
137
- children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
138
- i18nKey: "neetoMolecules.shareViaLink.bulkUploadPane.dragNDrop",
139
- components: {
140
- Button: /*#__PURE__*/jsxRuntime.jsx(Button, {
141
- style: "link"
142
- })
143
- }
144
- })
145
- }), /*#__PURE__*/jsxRuntime.jsxs(Typography, {
146
- className: "neeto-ui-text-gray-700",
147
- style: "body3",
148
- children: [/*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
149
- i18nKey: "neetoMolecules.shareViaLink.bulkUploadPane.supportedFormat",
150
- values: {
151
- fileType: "csv"
152
- },
153
- components: {
154
- code: /*#__PURE__*/jsxRuntime.jsx("code", {
155
- className: "neeto-ui-typography neeto-ui-text-body3 neeto-ui-bg-white m-0 border-l-0 p-0"
156
- })
157
- }
158
- }), " ", fileSize && t("neetoMolecules.shareViaLink.bulkUploadPane.supportedSize", {
159
- fileSize: fileSize
160
- })]
161
- })]
162
- })]
163
- }), errors]
164
- }))]
165
- })
166
- }), /*#__PURE__*/jsxRuntime.jsx(Pane.Footer, {
167
- className: "flex items-center space-x-2",
168
- children: /*#__PURE__*/jsxRuntime.jsx(Button, {
169
- "data-cy": "bulk-upload-cancel-button",
170
- "data-testid": "bulk-upload-cancel-button",
171
- label: t("neetoMolecules.common.actions.cancel"),
172
- style: "text",
173
- type: "reset",
174
- onClick: onClose
175
- })
176
- })]
177
- })
178
- });
179
- };
180
-
181
- var papaparse = {exports: {}};
182
-
183
- /* @license
184
- Papa Parse
185
- v5.4.1
186
- https://github.com/mholt/PapaParse
187
- License: MIT
188
- */
189
-
190
- (function (module, exports) {
191
- (function(root, factory)
192
- {
193
- /* globals define */
194
- {
195
- // Node. Does not work with strict CommonJS, but
196
- // only CommonJS-like environments that support module.exports,
197
- // like Node.
198
- module.exports = factory();
199
- }
200
- // in strict mode we cannot access arguments.callee, so we need a named reference to
201
- // stringify the factory method for the blob worker
202
- // eslint-disable-next-line func-name
203
- }(_commonjsHelpers.commonjsGlobal, function moduleFactory()
204
- {
205
-
206
- var global = (function() {
207
- // alternative method, similar to `Function('return this')()`
208
- // but without using `eval` (which is disabled when
209
- // using Content Security Policy).
210
-
211
- if (typeof self !== 'undefined') { return self; }
212
- if (typeof window !== 'undefined') { return window; }
213
- if (typeof global !== 'undefined') { return global; }
214
-
215
- // When running tests none of the above have been defined
216
- return {};
217
- })();
218
-
219
-
220
- function getWorkerBlob() {
221
- var URL = global.URL || global.webkitURL || null;
222
- var code = moduleFactory.toString();
223
- 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'})));
224
- }
225
-
226
- var IS_WORKER = !global.document && !!global.postMessage,
227
- IS_PAPA_WORKER = global.IS_PAPA_WORKER || false;
228
-
229
- var workers = {}, workerIdCounter = 0;
230
-
231
- var Papa = {};
232
-
233
- Papa.parse = CsvToJson;
234
- Papa.unparse = JsonToCsv;
235
-
236
- Papa.RECORD_SEP = String.fromCharCode(30);
237
- Papa.UNIT_SEP = String.fromCharCode(31);
238
- Papa.BYTE_ORDER_MARK = '\ufeff';
239
- Papa.BAD_DELIMITERS = ['\r', '\n', '"', Papa.BYTE_ORDER_MARK];
240
- Papa.WORKERS_SUPPORTED = !IS_WORKER && !!global.Worker;
241
- Papa.NODE_STREAM_INPUT = 1;
242
-
243
- // Configurable chunk sizes for local and remote files, respectively
244
- Papa.LocalChunkSize = 1024 * 1024 * 10; // 10 MB
245
- Papa.RemoteChunkSize = 1024 * 1024 * 5; // 5 MB
246
- Papa.DefaultDelimiter = ','; // Used if not specified and detection fails
247
-
248
- // Exposed for testing and development only
249
- Papa.Parser = Parser;
250
- Papa.ParserHandle = ParserHandle;
251
- Papa.NetworkStreamer = NetworkStreamer;
252
- Papa.FileStreamer = FileStreamer;
253
- Papa.StringStreamer = StringStreamer;
254
- Papa.ReadableStreamStreamer = ReadableStreamStreamer;
255
- if (typeof PAPA_BROWSER_CONTEXT === 'undefined') {
256
- Papa.DuplexStreamStreamer = DuplexStreamStreamer;
257
- }
258
-
259
- if (global.jQuery)
260
- {
261
- var $ = global.jQuery;
262
- $.fn.parse = function(options)
263
- {
264
- var config = options.config || {};
265
- var queue = [];
266
-
267
- this.each(function(idx)
268
- {
269
- var supported = $(this).prop('tagName').toUpperCase() === 'INPUT'
270
- && $(this).attr('type').toLowerCase() === 'file'
271
- && global.FileReader;
272
-
273
- if (!supported || !this.files || this.files.length === 0)
274
- return true; // continue to next input element
275
-
276
- for (var i = 0; i < this.files.length; i++)
277
- {
278
- queue.push({
279
- file: this.files[i],
280
- inputElem: this,
281
- instanceConfig: $.extend({}, config)
282
- });
283
- }
284
- });
285
-
286
- parseNextFile(); // begin parsing
287
- return this; // maintains chainability
288
-
289
-
290
- function parseNextFile()
291
- {
292
- if (queue.length === 0)
293
- {
294
- if (isFunction(options.complete))
295
- options.complete();
296
- return;
297
- }
298
-
299
- var f = queue[0];
300
-
301
- if (isFunction(options.before))
302
- {
303
- var returned = options.before(f.file, f.inputElem);
304
-
305
- if (typeof returned === 'object')
306
- {
307
- if (returned.action === 'abort')
308
- {
309
- error('AbortError', f.file, f.inputElem, returned.reason);
310
- return; // Aborts all queued files immediately
311
- }
312
- else if (returned.action === 'skip')
313
- {
314
- fileComplete(); // parse the next file in the queue, if any
315
- return;
316
- }
317
- else if (typeof returned.config === 'object')
318
- f.instanceConfig = $.extend(f.instanceConfig, returned.config);
319
- }
320
- else if (returned === 'skip')
321
- {
322
- fileComplete(); // parse the next file in the queue, if any
323
- return;
324
- }
325
- }
326
-
327
- // Wrap up the user's complete callback, if any, so that ours also gets executed
328
- var userCompleteFunc = f.instanceConfig.complete;
329
- f.instanceConfig.complete = function(results)
330
- {
331
- if (isFunction(userCompleteFunc))
332
- userCompleteFunc(results, f.file, f.inputElem);
333
- fileComplete();
334
- };
335
-
336
- Papa.parse(f.file, f.instanceConfig);
337
- }
338
-
339
- function error(name, file, elem, reason)
340
- {
341
- if (isFunction(options.error))
342
- options.error({name: name}, file, elem, reason);
343
- }
344
-
345
- function fileComplete()
346
- {
347
- queue.splice(0, 1);
348
- parseNextFile();
349
- }
350
- };
351
- }
352
-
353
-
354
- if (IS_PAPA_WORKER)
355
- {
356
- global.onmessage = workerThreadReceivedMessage;
357
- }
358
-
359
-
360
-
361
-
362
- function CsvToJson(_input, _config)
363
- {
364
- _config = _config || {};
365
- var dynamicTyping = _config.dynamicTyping || false;
366
- if (isFunction(dynamicTyping)) {
367
- _config.dynamicTypingFunction = dynamicTyping;
368
- // Will be filled on first row call
369
- dynamicTyping = {};
370
- }
371
- _config.dynamicTyping = dynamicTyping;
372
-
373
- _config.transform = isFunction(_config.transform) ? _config.transform : false;
374
-
375
- if (_config.worker && Papa.WORKERS_SUPPORTED)
376
- {
377
- var w = newWorker();
378
-
379
- w.userStep = _config.step;
380
- w.userChunk = _config.chunk;
381
- w.userComplete = _config.complete;
382
- w.userError = _config.error;
383
-
384
- _config.step = isFunction(_config.step);
385
- _config.chunk = isFunction(_config.chunk);
386
- _config.complete = isFunction(_config.complete);
387
- _config.error = isFunction(_config.error);
388
- delete _config.worker; // prevent infinite loop
389
-
390
- w.postMessage({
391
- input: _input,
392
- config: _config,
393
- workerId: w.id
394
- });
395
-
396
- return;
397
- }
398
-
399
- var streamer = null;
400
- if (_input === Papa.NODE_STREAM_INPUT && typeof PAPA_BROWSER_CONTEXT === 'undefined')
401
- {
402
- // create a node Duplex stream for use
403
- // with .pipe
404
- streamer = new DuplexStreamStreamer(_config);
405
- return streamer.getStream();
406
- }
407
- else if (typeof _input === 'string')
408
- {
409
- _input = stripBom(_input);
410
- if (_config.download)
411
- streamer = new NetworkStreamer(_config);
412
- else
413
- streamer = new StringStreamer(_config);
414
- }
415
- else if (_input.readable === true && isFunction(_input.read) && isFunction(_input.on))
416
- {
417
- streamer = new ReadableStreamStreamer(_config);
418
- }
419
- else if ((global.File && _input instanceof File) || _input instanceof Object) // ...Safari. (see issue #106)
420
- streamer = new FileStreamer(_config);
421
-
422
- return streamer.stream(_input);
423
-
424
- // Strip character from UTF-8 BOM encoded files that cause issue parsing the file
425
- function stripBom(string) {
426
- if (string.charCodeAt(0) === 0xfeff) {
427
- return string.slice(1);
428
- }
429
- return string;
430
- }
431
- }
432
-
433
-
434
-
435
-
436
-
437
-
438
- function JsonToCsv(_input, _config)
439
- {
440
- // Default configuration
441
-
442
- /** whether to surround every datum with quotes */
443
- var _quotes = false;
444
-
445
- /** whether to write headers */
446
- var _writeHeader = true;
447
-
448
- /** delimiting character(s) */
449
- var _delimiter = ',';
450
-
451
- /** newline character(s) */
452
- var _newline = '\r\n';
453
-
454
- /** quote character */
455
- var _quoteChar = '"';
456
-
457
- /** escaped quote character, either "" or <config.escapeChar>" */
458
- var _escapedQuote = _quoteChar + _quoteChar;
459
-
460
- /** whether to skip empty lines */
461
- var _skipEmptyLines = false;
462
-
463
- /** the columns (keys) we expect when we unparse objects */
464
- var _columns = null;
465
-
466
- /** whether to prevent outputting cells that can be parsed as formulae by spreadsheet software (Excel and LibreOffice) */
467
- var _escapeFormulae = false;
468
-
469
- unpackConfig();
470
-
471
- var quoteCharRegex = new RegExp(escapeRegExp(_quoteChar), 'g');
472
-
473
- if (typeof _input === 'string')
474
- _input = JSON.parse(_input);
475
-
476
- if (Array.isArray(_input))
477
- {
478
- if (!_input.length || Array.isArray(_input[0]))
479
- return serialize(null, _input, _skipEmptyLines);
480
- else if (typeof _input[0] === 'object')
481
- return serialize(_columns || Object.keys(_input[0]), _input, _skipEmptyLines);
482
- }
483
- else if (typeof _input === 'object')
484
- {
485
- if (typeof _input.data === 'string')
486
- _input.data = JSON.parse(_input.data);
487
-
488
- if (Array.isArray(_input.data))
489
- {
490
- if (!_input.fields)
491
- _input.fields = _input.meta && _input.meta.fields || _columns;
492
-
493
- if (!_input.fields)
494
- _input.fields = Array.isArray(_input.data[0])
495
- ? _input.fields
496
- : typeof _input.data[0] === 'object'
497
- ? Object.keys(_input.data[0])
498
- : [];
499
-
500
- if (!(Array.isArray(_input.data[0])) && typeof _input.data[0] !== 'object')
501
- _input.data = [_input.data]; // handles input like [1,2,3] or ['asdf']
502
- }
503
-
504
- return serialize(_input.fields || [], _input.data || [], _skipEmptyLines);
505
- }
506
-
507
- // Default (any valid paths should return before this)
508
- throw new Error('Unable to serialize unrecognized input');
509
-
510
-
511
- function unpackConfig()
512
- {
513
- if (typeof _config !== 'object')
514
- return;
515
-
516
- if (typeof _config.delimiter === 'string'
517
- && !Papa.BAD_DELIMITERS.filter(function(value) { return _config.delimiter.indexOf(value) !== -1; }).length)
518
- {
519
- _delimiter = _config.delimiter;
520
- }
521
-
522
- if (typeof _config.quotes === 'boolean'
523
- || typeof _config.quotes === 'function'
524
- || Array.isArray(_config.quotes))
525
- _quotes = _config.quotes;
526
-
527
- if (typeof _config.skipEmptyLines === 'boolean'
528
- || typeof _config.skipEmptyLines === 'string')
529
- _skipEmptyLines = _config.skipEmptyLines;
530
-
531
- if (typeof _config.newline === 'string')
532
- _newline = _config.newline;
533
-
534
- if (typeof _config.quoteChar === 'string')
535
- _quoteChar = _config.quoteChar;
536
-
537
- if (typeof _config.header === 'boolean')
538
- _writeHeader = _config.header;
539
-
540
- if (Array.isArray(_config.columns)) {
541
-
542
- if (_config.columns.length === 0) throw new Error('Option columns is empty');
543
-
544
- _columns = _config.columns;
545
- }
546
-
547
- if (_config.escapeChar !== undefined) {
548
- _escapedQuote = _config.escapeChar + _quoteChar;
549
- }
550
-
551
- if (typeof _config.escapeFormulae === 'boolean' || _config.escapeFormulae instanceof RegExp) {
552
- _escapeFormulae = _config.escapeFormulae instanceof RegExp ? _config.escapeFormulae : /^[=+\-@\t\r].*$/;
553
- }
554
- }
555
-
556
- /** The double for loop that iterates the data and writes out a CSV string including header row */
557
- function serialize(fields, data, skipEmptyLines)
558
- {
559
- var csv = '';
560
-
561
- if (typeof fields === 'string')
562
- fields = JSON.parse(fields);
563
- if (typeof data === 'string')
564
- data = JSON.parse(data);
565
-
566
- var hasHeader = Array.isArray(fields) && fields.length > 0;
567
- var dataKeyedByField = !(Array.isArray(data[0]));
568
-
569
- // If there a header row, write it first
570
- if (hasHeader && _writeHeader)
571
- {
572
- for (var i = 0; i < fields.length; i++)
573
- {
574
- if (i > 0)
575
- csv += _delimiter;
576
- csv += safe(fields[i], i);
577
- }
578
- if (data.length > 0)
579
- csv += _newline;
580
- }
581
-
582
- // Then write out the data
583
- for (var row = 0; row < data.length; row++)
584
- {
585
- var maxCol = hasHeader ? fields.length : data[row].length;
586
-
587
- var emptyLine = false;
588
- var nullLine = hasHeader ? Object.keys(data[row]).length === 0 : data[row].length === 0;
589
- if (skipEmptyLines && !hasHeader)
590
- {
591
- emptyLine = skipEmptyLines === 'greedy' ? data[row].join('').trim() === '' : data[row].length === 1 && data[row][0].length === 0;
592
- }
593
- if (skipEmptyLines === 'greedy' && hasHeader) {
594
- var line = [];
595
- for (var c = 0; c < maxCol; c++) {
596
- var cx = dataKeyedByField ? fields[c] : c;
597
- line.push(data[row][cx]);
598
- }
599
- emptyLine = line.join('').trim() === '';
600
- }
601
- if (!emptyLine)
602
- {
603
- for (var col = 0; col < maxCol; col++)
604
- {
605
- if (col > 0 && !nullLine)
606
- csv += _delimiter;
607
- var colIdx = hasHeader && dataKeyedByField ? fields[col] : col;
608
- csv += safe(data[row][colIdx], col);
609
- }
610
- if (row < data.length - 1 && (!skipEmptyLines || (maxCol > 0 && !nullLine)))
611
- {
612
- csv += _newline;
613
- }
614
- }
615
- }
616
- return csv;
617
- }
618
-
619
- /** Encloses a value around quotes if needed (makes a value safe for CSV insertion) */
620
- function safe(str, col)
621
- {
622
- if (typeof str === 'undefined' || str === null)
623
- return '';
624
-
625
- if (str.constructor === Date)
626
- return JSON.stringify(str).slice(1, 25);
627
-
628
- var needsQuotes = false;
629
-
630
- if (_escapeFormulae && typeof str === "string" && _escapeFormulae.test(str)) {
631
- str = "'" + str;
632
- needsQuotes = true;
633
- }
634
-
635
- var escapedQuoteStr = str.toString().replace(quoteCharRegex, _escapedQuote);
636
-
637
- needsQuotes = needsQuotes
638
- || _quotes === true
639
- || (typeof _quotes === 'function' && _quotes(str, col))
640
- || (Array.isArray(_quotes) && _quotes[col])
641
- || hasAny(escapedQuoteStr, Papa.BAD_DELIMITERS)
642
- || escapedQuoteStr.indexOf(_delimiter) > -1
643
- || escapedQuoteStr.charAt(0) === ' '
644
- || escapedQuoteStr.charAt(escapedQuoteStr.length - 1) === ' ';
645
-
646
- return needsQuotes ? _quoteChar + escapedQuoteStr + _quoteChar : escapedQuoteStr;
647
- }
648
-
649
- function hasAny(str, substrings)
650
- {
651
- for (var i = 0; i < substrings.length; i++)
652
- if (str.indexOf(substrings[i]) > -1)
653
- return true;
654
- return false;
655
- }
656
- }
657
-
658
- /** ChunkStreamer is the base prototype for various streamer implementations. */
659
- function ChunkStreamer(config)
660
- {
661
- this._handle = null;
662
- this._finished = false;
663
- this._completed = false;
664
- this._halted = false;
665
- this._input = null;
666
- this._baseIndex = 0;
667
- this._partialLine = '';
668
- this._rowCount = 0;
669
- this._start = 0;
670
- this._nextChunk = null;
671
- this.isFirstChunk = true;
672
- this._completeResults = {
673
- data: [],
674
- errors: [],
675
- meta: {}
676
- };
677
- replaceConfig.call(this, config);
678
-
679
- this.parseChunk = function(chunk, isFakeChunk)
680
- {
681
- // First chunk pre-processing
682
- if (this.isFirstChunk && isFunction(this._config.beforeFirstChunk))
683
- {
684
- var modifiedChunk = this._config.beforeFirstChunk(chunk);
685
- if (modifiedChunk !== undefined)
686
- chunk = modifiedChunk;
687
- }
688
- this.isFirstChunk = false;
689
- this._halted = false;
690
-
691
- // Rejoin the line we likely just split in two by chunking the file
692
- var aggregate = this._partialLine + chunk;
693
- this._partialLine = '';
694
-
695
- var results = this._handle.parse(aggregate, this._baseIndex, !this._finished);
696
-
697
- if (this._handle.paused() || this._handle.aborted()) {
698
- this._halted = true;
699
- return;
700
- }
701
-
702
- var lastIndex = results.meta.cursor;
703
-
704
- if (!this._finished)
705
- {
706
- this._partialLine = aggregate.substring(lastIndex - this._baseIndex);
707
- this._baseIndex = lastIndex;
708
- }
709
-
710
- if (results && results.data)
711
- this._rowCount += results.data.length;
712
-
713
- var finishedIncludingPreview = this._finished || (this._config.preview && this._rowCount >= this._config.preview);
714
-
715
- if (IS_PAPA_WORKER)
716
- {
717
- global.postMessage({
718
- results: results,
719
- workerId: Papa.WORKER_ID,
720
- finished: finishedIncludingPreview
721
- });
722
- }
723
- else if (isFunction(this._config.chunk) && !isFakeChunk)
724
- {
725
- this._config.chunk(results, this._handle);
726
- if (this._handle.paused() || this._handle.aborted()) {
727
- this._halted = true;
728
- return;
729
- }
730
- results = undefined;
731
- this._completeResults = undefined;
732
- }
733
-
734
- if (!this._config.step && !this._config.chunk) {
735
- this._completeResults.data = this._completeResults.data.concat(results.data);
736
- this._completeResults.errors = this._completeResults.errors.concat(results.errors);
737
- this._completeResults.meta = results.meta;
738
- }
739
-
740
- if (!this._completed && finishedIncludingPreview && isFunction(this._config.complete) && (!results || !results.meta.aborted)) {
741
- this._config.complete(this._completeResults, this._input);
742
- this._completed = true;
743
- }
744
-
745
- if (!finishedIncludingPreview && (!results || !results.meta.paused))
746
- this._nextChunk();
747
-
748
- return results;
749
- };
750
-
751
- this._sendError = function(error)
752
- {
753
- if (isFunction(this._config.error))
754
- this._config.error(error);
755
- else if (IS_PAPA_WORKER && this._config.error)
756
- {
757
- global.postMessage({
758
- workerId: Papa.WORKER_ID,
759
- error: error,
760
- finished: false
761
- });
762
- }
763
- };
764
-
765
- function replaceConfig(config)
766
- {
767
- // Deep-copy the config so we can edit it
768
- var configCopy = copy(config);
769
- configCopy.chunkSize = parseInt(configCopy.chunkSize); // parseInt VERY important so we don't concatenate strings!
770
- if (!config.step && !config.chunk)
771
- configCopy.chunkSize = null; // disable Range header if not streaming; bad values break IIS - see issue #196
772
- this._handle = new ParserHandle(configCopy);
773
- this._handle.streamer = this;
774
- this._config = configCopy; // persist the copy to the caller
775
- }
776
- }
777
-
778
-
779
- function NetworkStreamer(config)
780
- {
781
- config = config || {};
782
- if (!config.chunkSize)
783
- config.chunkSize = Papa.RemoteChunkSize;
784
- ChunkStreamer.call(this, config);
785
-
786
- var xhr;
787
-
788
- if (IS_WORKER)
789
- {
790
- this._nextChunk = function()
791
- {
792
- this._readChunk();
793
- this._chunkLoaded();
794
- };
795
- }
796
- else
797
- {
798
- this._nextChunk = function()
799
- {
800
- this._readChunk();
801
- };
802
- }
803
-
804
- this.stream = function(url)
805
- {
806
- this._input = url;
807
- this._nextChunk(); // Starts streaming
808
- };
809
-
810
- this._readChunk = function()
811
- {
812
- if (this._finished)
813
- {
814
- this._chunkLoaded();
815
- return;
816
- }
817
-
818
- xhr = new XMLHttpRequest();
819
-
820
- if (this._config.withCredentials)
821
- {
822
- xhr.withCredentials = this._config.withCredentials;
823
- }
824
-
825
- if (!IS_WORKER)
826
- {
827
- xhr.onload = bindFunction(this._chunkLoaded, this);
828
- xhr.onerror = bindFunction(this._chunkError, this);
829
- }
830
-
831
- xhr.open(this._config.downloadRequestBody ? 'POST' : 'GET', this._input, !IS_WORKER);
832
- // Headers can only be set when once the request state is OPENED
833
- if (this._config.downloadRequestHeaders)
834
- {
835
- var headers = this._config.downloadRequestHeaders;
836
-
837
- for (var headerName in headers)
838
- {
839
- xhr.setRequestHeader(headerName, headers[headerName]);
840
- }
841
- }
842
-
843
- if (this._config.chunkSize)
844
- {
845
- var end = this._start + this._config.chunkSize - 1; // minus one because byte range is inclusive
846
- xhr.setRequestHeader('Range', 'bytes=' + this._start + '-' + end);
847
- }
848
-
849
- try {
850
- xhr.send(this._config.downloadRequestBody);
851
- }
852
- catch (err) {
853
- this._chunkError(err.message);
854
- }
855
-
856
- if (IS_WORKER && xhr.status === 0)
857
- this._chunkError();
858
- };
859
-
860
- this._chunkLoaded = function()
861
- {
862
- if (xhr.readyState !== 4)
863
- return;
864
-
865
- if (xhr.status < 200 || xhr.status >= 400)
866
- {
867
- this._chunkError();
868
- return;
869
- }
870
-
871
- // Use chunckSize as it may be a diference on reponse lentgh due to characters with more than 1 byte
872
- this._start += this._config.chunkSize ? this._config.chunkSize : xhr.responseText.length;
873
- this._finished = !this._config.chunkSize || this._start >= getFileSize(xhr);
874
- this.parseChunk(xhr.responseText);
875
- };
876
-
877
- this._chunkError = function(errorMessage)
878
- {
879
- var errorText = xhr.statusText || errorMessage;
880
- this._sendError(new Error(errorText));
881
- };
882
-
883
- function getFileSize(xhr)
884
- {
885
- var contentRange = xhr.getResponseHeader('Content-Range');
886
- if (contentRange === null) { // no content range, then finish!
887
- return -1;
888
- }
889
- return parseInt(contentRange.substring(contentRange.lastIndexOf('/') + 1));
890
- }
891
- }
892
- NetworkStreamer.prototype = Object.create(ChunkStreamer.prototype);
893
- NetworkStreamer.prototype.constructor = NetworkStreamer;
894
-
895
-
896
- function FileStreamer(config)
897
- {
898
- config = config || {};
899
- if (!config.chunkSize)
900
- config.chunkSize = Papa.LocalChunkSize;
901
- ChunkStreamer.call(this, config);
902
-
903
- var reader, slice;
904
-
905
- // FileReader is better than FileReaderSync (even in worker) - see http://stackoverflow.com/q/24708649/1048862
906
- // But Firefox is a pill, too - see issue #76: https://github.com/mholt/PapaParse/issues/76
907
- var usingAsyncReader = typeof FileReader !== 'undefined'; // Safari doesn't consider it a function - see issue #105
908
-
909
- this.stream = function(file)
910
- {
911
- this._input = file;
912
- slice = file.slice || file.webkitSlice || file.mozSlice;
913
-
914
- if (usingAsyncReader)
915
- {
916
- reader = new FileReader(); // Preferred method of reading files, even in workers
917
- reader.onload = bindFunction(this._chunkLoaded, this);
918
- reader.onerror = bindFunction(this._chunkError, this);
919
- }
920
- else
921
- reader = new FileReaderSync(); // Hack for running in a web worker in Firefox
922
-
923
- this._nextChunk(); // Starts streaming
924
- };
925
-
926
- this._nextChunk = function()
927
- {
928
- if (!this._finished && (!this._config.preview || this._rowCount < this._config.preview))
929
- this._readChunk();
930
- };
931
-
932
- this._readChunk = function()
933
- {
934
- var input = this._input;
935
- if (this._config.chunkSize)
936
- {
937
- var end = Math.min(this._start + this._config.chunkSize, this._input.size);
938
- input = slice.call(input, this._start, end);
939
- }
940
- var txt = reader.readAsText(input, this._config.encoding);
941
- if (!usingAsyncReader)
942
- this._chunkLoaded({ target: { result: txt } }); // mimic the async signature
943
- };
944
-
945
- this._chunkLoaded = function(event)
946
- {
947
- // Very important to increment start each time before handling results
948
- this._start += this._config.chunkSize;
949
- this._finished = !this._config.chunkSize || this._start >= this._input.size;
950
- this.parseChunk(event.target.result);
951
- };
952
-
953
- this._chunkError = function()
954
- {
955
- this._sendError(reader.error);
956
- };
957
-
958
- }
959
- FileStreamer.prototype = Object.create(ChunkStreamer.prototype);
960
- FileStreamer.prototype.constructor = FileStreamer;
961
-
962
-
963
- function StringStreamer(config)
964
- {
965
- config = config || {};
966
- ChunkStreamer.call(this, config);
967
-
968
- var remaining;
969
- this.stream = function(s)
970
- {
971
- remaining = s;
972
- return this._nextChunk();
973
- };
974
- this._nextChunk = function()
975
- {
976
- if (this._finished) return;
977
- var size = this._config.chunkSize;
978
- var chunk;
979
- if(size) {
980
- chunk = remaining.substring(0, size);
981
- remaining = remaining.substring(size);
982
- } else {
983
- chunk = remaining;
984
- remaining = '';
985
- }
986
- this._finished = !remaining;
987
- return this.parseChunk(chunk);
988
- };
989
- }
990
- StringStreamer.prototype = Object.create(StringStreamer.prototype);
991
- StringStreamer.prototype.constructor = StringStreamer;
992
-
993
-
994
- function ReadableStreamStreamer(config)
995
- {
996
- config = config || {};
997
-
998
- ChunkStreamer.call(this, config);
999
-
1000
- var queue = [];
1001
- var parseOnData = true;
1002
- var streamHasEnded = false;
1003
-
1004
- this.pause = function()
1005
- {
1006
- ChunkStreamer.prototype.pause.apply(this, arguments);
1007
- this._input.pause();
1008
- };
1009
-
1010
- this.resume = function()
1011
- {
1012
- ChunkStreamer.prototype.resume.apply(this, arguments);
1013
- this._input.resume();
1014
- };
1015
-
1016
- this.stream = function(stream)
1017
- {
1018
- this._input = stream;
1019
-
1020
- this._input.on('data', this._streamData);
1021
- this._input.on('end', this._streamEnd);
1022
- this._input.on('error', this._streamError);
1023
- };
1024
-
1025
- this._checkIsFinished = function()
1026
- {
1027
- if (streamHasEnded && queue.length === 1) {
1028
- this._finished = true;
1029
- }
1030
- };
1031
-
1032
- this._nextChunk = function()
1033
- {
1034
- this._checkIsFinished();
1035
- if (queue.length)
1036
- {
1037
- this.parseChunk(queue.shift());
1038
- }
1039
- else
1040
- {
1041
- parseOnData = true;
1042
- }
1043
- };
1044
-
1045
- this._streamData = bindFunction(function(chunk)
1046
- {
1047
- try
1048
- {
1049
- queue.push(typeof chunk === 'string' ? chunk : chunk.toString(this._config.encoding));
1050
-
1051
- if (parseOnData)
1052
- {
1053
- parseOnData = false;
1054
- this._checkIsFinished();
1055
- this.parseChunk(queue.shift());
1056
- }
1057
- }
1058
- catch (error)
1059
- {
1060
- this._streamError(error);
1061
- }
1062
- }, this);
1063
-
1064
- this._streamError = bindFunction(function(error)
1065
- {
1066
- this._streamCleanUp();
1067
- this._sendError(error);
1068
- }, this);
1069
-
1070
- this._streamEnd = bindFunction(function()
1071
- {
1072
- this._streamCleanUp();
1073
- streamHasEnded = true;
1074
- this._streamData('');
1075
- }, this);
1076
-
1077
- this._streamCleanUp = bindFunction(function()
1078
- {
1079
- this._input.removeListener('data', this._streamData);
1080
- this._input.removeListener('end', this._streamEnd);
1081
- this._input.removeListener('error', this._streamError);
1082
- }, this);
1083
- }
1084
- ReadableStreamStreamer.prototype = Object.create(ChunkStreamer.prototype);
1085
- ReadableStreamStreamer.prototype.constructor = ReadableStreamStreamer;
1086
-
1087
-
1088
- function DuplexStreamStreamer(_config) {
1089
- var Duplex = require$$0.Duplex;
1090
- var config = copy(_config);
1091
- var parseOnWrite = true;
1092
- var writeStreamHasFinished = false;
1093
- var parseCallbackQueue = [];
1094
- var stream = null;
1095
-
1096
- this._onCsvData = function(results)
1097
- {
1098
- var data = results.data;
1099
- if (!stream.push(data) && !this._handle.paused()) {
1100
- // the writeable consumer buffer has filled up
1101
- // so we need to pause until more items
1102
- // can be processed
1103
- this._handle.pause();
1104
- }
1105
- };
1106
-
1107
- this._onCsvComplete = function()
1108
- {
1109
- // node will finish the read stream when
1110
- // null is pushed
1111
- stream.push(null);
1112
- };
1113
-
1114
- config.step = bindFunction(this._onCsvData, this);
1115
- config.complete = bindFunction(this._onCsvComplete, this);
1116
- ChunkStreamer.call(this, config);
1117
-
1118
- this._nextChunk = function()
1119
- {
1120
- if (writeStreamHasFinished && parseCallbackQueue.length === 1) {
1121
- this._finished = true;
1122
- }
1123
- if (parseCallbackQueue.length) {
1124
- parseCallbackQueue.shift()();
1125
- } else {
1126
- parseOnWrite = true;
1127
- }
1128
- };
1129
-
1130
- this._addToParseQueue = function(chunk, callback)
1131
- {
1132
- // add to queue so that we can indicate
1133
- // completion via callback
1134
- // node will automatically pause the incoming stream
1135
- // when too many items have been added without their
1136
- // callback being invoked
1137
- parseCallbackQueue.push(bindFunction(function() {
1138
- this.parseChunk(typeof chunk === 'string' ? chunk : chunk.toString(config.encoding));
1139
- if (isFunction(callback)) {
1140
- return callback();
1141
- }
1142
- }, this));
1143
- if (parseOnWrite) {
1144
- parseOnWrite = false;
1145
- this._nextChunk();
1146
- }
1147
- };
1148
-
1149
- this._onRead = function()
1150
- {
1151
- if (this._handle.paused()) {
1152
- // the writeable consumer can handle more data
1153
- // so resume the chunk parsing
1154
- this._handle.resume();
1155
- }
1156
- };
1157
-
1158
- this._onWrite = function(chunk, encoding, callback)
1159
- {
1160
- this._addToParseQueue(chunk, callback);
1161
- };
1162
-
1163
- this._onWriteComplete = function()
1164
- {
1165
- writeStreamHasFinished = true;
1166
- // have to write empty string
1167
- // so parser knows its done
1168
- this._addToParseQueue('');
1169
- };
1170
-
1171
- this.getStream = function()
1172
- {
1173
- return stream;
1174
- };
1175
- stream = new Duplex({
1176
- readableObjectMode: true,
1177
- decodeStrings: false,
1178
- read: bindFunction(this._onRead, this),
1179
- write: bindFunction(this._onWrite, this)
1180
- });
1181
- stream.once('finish', bindFunction(this._onWriteComplete, this));
1182
- }
1183
- if (typeof PAPA_BROWSER_CONTEXT === 'undefined') {
1184
- DuplexStreamStreamer.prototype = Object.create(ChunkStreamer.prototype);
1185
- DuplexStreamStreamer.prototype.constructor = DuplexStreamStreamer;
1186
- }
1187
-
1188
-
1189
- // Use one ParserHandle per entire CSV file or string
1190
- function ParserHandle(_config)
1191
- {
1192
- // One goal is to minimize the use of regular expressions...
1193
- var MAX_FLOAT = Math.pow(2, 53);
1194
- var MIN_FLOAT = -MAX_FLOAT;
1195
- var FLOAT = /^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/;
1196
- 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)))$/;
1197
- var self = this;
1198
- var _stepCounter = 0; // Number of times step was called (number of rows parsed)
1199
- var _rowCounter = 0; // Number of rows that have been parsed so far
1200
- var _input; // The input being parsed
1201
- var _parser; // The core parser being used
1202
- var _paused = false; // Whether we are paused or not
1203
- var _aborted = false; // Whether the parser has aborted or not
1204
- var _delimiterError; // Temporary state between delimiter detection and processing results
1205
- var _fields = []; // Fields are from the header row of the input, if there is one
1206
- var _results = { // The last results returned from the parser
1207
- data: [],
1208
- errors: [],
1209
- meta: {}
1210
- };
1211
-
1212
- if (isFunction(_config.step))
1213
- {
1214
- var userStep = _config.step;
1215
- _config.step = function(results)
1216
- {
1217
- _results = results;
1218
-
1219
- if (needsHeaderRow())
1220
- processResults();
1221
- else // only call user's step function after header row
1222
- {
1223
- processResults();
1224
-
1225
- // It's possbile that this line was empty and there's no row here after all
1226
- if (_results.data.length === 0)
1227
- return;
1228
-
1229
- _stepCounter += results.data.length;
1230
- if (_config.preview && _stepCounter > _config.preview)
1231
- _parser.abort();
1232
- else {
1233
- _results.data = _results.data[0];
1234
- userStep(_results, self);
1235
- }
1236
- }
1237
- };
1238
- }
1239
-
1240
- /**
1241
- * Parses input. Most users won't need, and shouldn't mess with, the baseIndex
1242
- * and ignoreLastRow parameters. They are used by streamers (wrapper functions)
1243
- * when an input comes in multiple chunks, like from a file.
1244
- */
1245
- this.parse = function(input, baseIndex, ignoreLastRow)
1246
- {
1247
- var quoteChar = _config.quoteChar || '"';
1248
- if (!_config.newline)
1249
- _config.newline = guessLineEndings(input, quoteChar);
1250
-
1251
- _delimiterError = false;
1252
- if (!_config.delimiter)
1253
- {
1254
- var delimGuess = guessDelimiter(input, _config.newline, _config.skipEmptyLines, _config.comments, _config.delimitersToGuess);
1255
- if (delimGuess.successful)
1256
- _config.delimiter = delimGuess.bestDelimiter;
1257
- else
1258
- {
1259
- _delimiterError = true; // add error after parsing (otherwise it would be overwritten)
1260
- _config.delimiter = Papa.DefaultDelimiter;
1261
- }
1262
- _results.meta.delimiter = _config.delimiter;
1263
- }
1264
- else if(isFunction(_config.delimiter))
1265
- {
1266
- _config.delimiter = _config.delimiter(input);
1267
- _results.meta.delimiter = _config.delimiter;
1268
- }
1269
-
1270
- var parserConfig = copy(_config);
1271
- if (_config.preview && _config.header)
1272
- parserConfig.preview++; // to compensate for header row
1273
-
1274
- _input = input;
1275
- _parser = new Parser(parserConfig);
1276
- _results = _parser.parse(_input, baseIndex, ignoreLastRow);
1277
- processResults();
1278
- return _paused ? { meta: { paused: true } } : (_results || { meta: { paused: false } });
1279
- };
1280
-
1281
- this.paused = function()
1282
- {
1283
- return _paused;
1284
- };
1285
-
1286
- this.pause = function()
1287
- {
1288
- _paused = true;
1289
- _parser.abort();
1290
-
1291
- // If it is streaming via "chunking", the reader will start appending correctly already so no need to substring,
1292
- // otherwise we can get duplicate content within a row
1293
- _input = isFunction(_config.chunk) ? "" : _input.substring(_parser.getCharIndex());
1294
- };
1295
-
1296
- this.resume = function()
1297
- {
1298
- if(self.streamer._halted) {
1299
- _paused = false;
1300
- self.streamer.parseChunk(_input, true);
1301
- } else {
1302
- // Bugfix: #636 In case the processing hasn't halted yet
1303
- // wait for it to halt in order to resume
1304
- setTimeout(self.resume, 3);
1305
- }
1306
- };
1307
-
1308
- this.aborted = function()
1309
- {
1310
- return _aborted;
1311
- };
1312
-
1313
- this.abort = function()
1314
- {
1315
- _aborted = true;
1316
- _parser.abort();
1317
- _results.meta.aborted = true;
1318
- if (isFunction(_config.complete))
1319
- _config.complete(_results);
1320
- _input = '';
1321
- };
1322
-
1323
- function testEmptyLine(s) {
1324
- return _config.skipEmptyLines === 'greedy' ? s.join('').trim() === '' : s.length === 1 && s[0].length === 0;
1325
- }
1326
-
1327
- function testFloat(s) {
1328
- if (FLOAT.test(s)) {
1329
- var floatValue = parseFloat(s);
1330
- if (floatValue > MIN_FLOAT && floatValue < MAX_FLOAT) {
1331
- return true;
1332
- }
1333
- }
1334
- return false;
1335
- }
1336
-
1337
- function processResults()
1338
- {
1339
- if (_results && _delimiterError)
1340
- {
1341
- addError('Delimiter', 'UndetectableDelimiter', 'Unable to auto-detect delimiting character; defaulted to \'' + Papa.DefaultDelimiter + '\'');
1342
- _delimiterError = false;
1343
- }
1344
-
1345
- if (_config.skipEmptyLines)
1346
- {
1347
- _results.data = _results.data.filter(function(d) {
1348
- return !testEmptyLine(d);
1349
- });
1350
- }
1351
-
1352
- if (needsHeaderRow())
1353
- fillHeaderFields();
1354
-
1355
- return applyHeaderAndDynamicTypingAndTransformation();
1356
- }
1357
-
1358
- function needsHeaderRow()
1359
- {
1360
- return _config.header && _fields.length === 0;
1361
- }
1362
-
1363
- function fillHeaderFields()
1364
- {
1365
- if (!_results)
1366
- return;
1367
-
1368
- function addHeader(header, i)
1369
- {
1370
- if (isFunction(_config.transformHeader))
1371
- header = _config.transformHeader(header, i);
1372
-
1373
- _fields.push(header);
1374
- }
1375
-
1376
- if (Array.isArray(_results.data[0]))
1377
- {
1378
- for (var i = 0; needsHeaderRow() && i < _results.data.length; i++)
1379
- _results.data[i].forEach(addHeader);
1380
-
1381
- _results.data.splice(0, 1);
1382
- }
1383
- // if _results.data[0] is not an array, we are in a step where _results.data is the row.
1384
- else
1385
- _results.data.forEach(addHeader);
1386
- }
1387
-
1388
- function shouldApplyDynamicTyping(field) {
1389
- // Cache function values to avoid calling it for each row
1390
- if (_config.dynamicTypingFunction && _config.dynamicTyping[field] === undefined) {
1391
- _config.dynamicTyping[field] = _config.dynamicTypingFunction(field);
1392
- }
1393
- return (_config.dynamicTyping[field] || _config.dynamicTyping) === true;
1394
- }
1395
-
1396
- function parseDynamic(field, value)
1397
- {
1398
- if (shouldApplyDynamicTyping(field))
1399
- {
1400
- if (value === 'true' || value === 'TRUE')
1401
- return true;
1402
- else if (value === 'false' || value === 'FALSE')
1403
- return false;
1404
- else if (testFloat(value))
1405
- return parseFloat(value);
1406
- else if (ISO_DATE.test(value))
1407
- return new Date(value);
1408
- else
1409
- return (value === '' ? null : value);
1410
- }
1411
- return value;
1412
- }
1413
-
1414
- function applyHeaderAndDynamicTypingAndTransformation()
1415
- {
1416
- if (!_results || (!_config.header && !_config.dynamicTyping && !_config.transform))
1417
- return _results;
1418
-
1419
- function processRow(rowSource, i)
1420
- {
1421
- var row = _config.header ? {} : [];
1422
-
1423
- var j;
1424
- for (j = 0; j < rowSource.length; j++)
1425
- {
1426
- var field = j;
1427
- var value = rowSource[j];
1428
-
1429
- if (_config.header)
1430
- field = j >= _fields.length ? '__parsed_extra' : _fields[j];
1431
-
1432
- if (_config.transform)
1433
- value = _config.transform(value,field);
1434
-
1435
- value = parseDynamic(field, value);
1436
-
1437
- if (field === '__parsed_extra')
1438
- {
1439
- row[field] = row[field] || [];
1440
- row[field].push(value);
1441
- }
1442
- else
1443
- row[field] = value;
1444
- }
1445
-
1446
-
1447
- if (_config.header)
1448
- {
1449
- if (j > _fields.length)
1450
- addError('FieldMismatch', 'TooManyFields', 'Too many fields: expected ' + _fields.length + ' fields but parsed ' + j, _rowCounter + i);
1451
- else if (j < _fields.length)
1452
- addError('FieldMismatch', 'TooFewFields', 'Too few fields: expected ' + _fields.length + ' fields but parsed ' + j, _rowCounter + i);
1453
- }
1454
-
1455
- return row;
1456
- }
1457
-
1458
- var incrementBy = 1;
1459
- if (!_results.data.length || Array.isArray(_results.data[0]))
1460
- {
1461
- _results.data = _results.data.map(processRow);
1462
- incrementBy = _results.data.length;
1463
- }
1464
- else
1465
- _results.data = processRow(_results.data, 0);
1466
-
1467
-
1468
- if (_config.header && _results.meta)
1469
- _results.meta.fields = _fields;
1470
-
1471
- _rowCounter += incrementBy;
1472
- return _results;
1473
- }
1474
-
1475
- function guessDelimiter(input, newline, skipEmptyLines, comments, delimitersToGuess) {
1476
- var bestDelim, bestDelta, fieldCountPrevRow, maxFieldCount;
1477
-
1478
- delimitersToGuess = delimitersToGuess || [',', '\t', '|', ';', Papa.RECORD_SEP, Papa.UNIT_SEP];
1479
-
1480
- for (var i = 0; i < delimitersToGuess.length; i++) {
1481
- var delim = delimitersToGuess[i];
1482
- var delta = 0, avgFieldCount = 0, emptyLinesCount = 0;
1483
- fieldCountPrevRow = undefined;
1484
-
1485
- var preview = new Parser({
1486
- comments: comments,
1487
- delimiter: delim,
1488
- newline: newline,
1489
- preview: 10
1490
- }).parse(input);
1491
-
1492
- for (var j = 0; j < preview.data.length; j++) {
1493
- if (skipEmptyLines && testEmptyLine(preview.data[j])) {
1494
- emptyLinesCount++;
1495
- continue;
1496
- }
1497
- var fieldCount = preview.data[j].length;
1498
- avgFieldCount += fieldCount;
1499
-
1500
- if (typeof fieldCountPrevRow === 'undefined') {
1501
- fieldCountPrevRow = fieldCount;
1502
- continue;
1503
- }
1504
- else if (fieldCount > 0) {
1505
- delta += Math.abs(fieldCount - fieldCountPrevRow);
1506
- fieldCountPrevRow = fieldCount;
1507
- }
1508
- }
1509
-
1510
- if (preview.data.length > 0)
1511
- avgFieldCount /= (preview.data.length - emptyLinesCount);
1512
-
1513
- if ((typeof bestDelta === 'undefined' || delta <= bestDelta)
1514
- && (typeof maxFieldCount === 'undefined' || avgFieldCount > maxFieldCount) && avgFieldCount > 1.99) {
1515
- bestDelta = delta;
1516
- bestDelim = delim;
1517
- maxFieldCount = avgFieldCount;
1518
- }
1519
- }
1520
-
1521
- _config.delimiter = bestDelim;
1522
-
1523
- return {
1524
- successful: !!bestDelim,
1525
- bestDelimiter: bestDelim
1526
- };
1527
- }
1528
-
1529
- function guessLineEndings(input, quoteChar)
1530
- {
1531
- input = input.substring(0, 1024 * 1024); // max length 1 MB
1532
- // Replace all the text inside quotes
1533
- var re = new RegExp(escapeRegExp(quoteChar) + '([^]*?)' + escapeRegExp(quoteChar), 'gm');
1534
- input = input.replace(re, '');
1535
-
1536
- var r = input.split('\r');
1537
-
1538
- var n = input.split('\n');
1539
-
1540
- var nAppearsFirst = (n.length > 1 && n[0].length < r[0].length);
1541
-
1542
- if (r.length === 1 || nAppearsFirst)
1543
- return '\n';
1544
-
1545
- var numWithN = 0;
1546
- for (var i = 0; i < r.length; i++)
1547
- {
1548
- if (r[i][0] === '\n')
1549
- numWithN++;
1550
- }
1551
-
1552
- return numWithN >= r.length / 2 ? '\r\n' : '\r';
1553
- }
1554
-
1555
- function addError(type, code, msg, row)
1556
- {
1557
- var error = {
1558
- type: type,
1559
- code: code,
1560
- message: msg
1561
- };
1562
- if(row !== undefined) {
1563
- error.row = row;
1564
- }
1565
- _results.errors.push(error);
1566
- }
1567
- }
1568
-
1569
- /** https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions */
1570
- function escapeRegExp(string)
1571
- {
1572
- return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
1573
- }
1574
-
1575
- /** The core parser implements speedy and correct CSV parsing */
1576
- function Parser(config)
1577
- {
1578
- // Unpack the config object
1579
- config = config || {};
1580
- var delim = config.delimiter;
1581
- var newline = config.newline;
1582
- var comments = config.comments;
1583
- var step = config.step;
1584
- var preview = config.preview;
1585
- var fastMode = config.fastMode;
1586
- var quoteChar;
1587
- if (config.quoteChar === undefined || config.quoteChar === null) {
1588
- quoteChar = '"';
1589
- } else {
1590
- quoteChar = config.quoteChar;
1591
- }
1592
- var escapeChar = quoteChar;
1593
- if (config.escapeChar !== undefined) {
1594
- escapeChar = config.escapeChar;
1595
- }
1596
-
1597
- // Delimiter must be valid
1598
- if (typeof delim !== 'string'
1599
- || Papa.BAD_DELIMITERS.indexOf(delim) > -1)
1600
- delim = ',';
1601
-
1602
- // Comment character must be valid
1603
- if (comments === delim)
1604
- throw new Error('Comment character same as delimiter');
1605
- else if (comments === true)
1606
- comments = '#';
1607
- else if (typeof comments !== 'string'
1608
- || Papa.BAD_DELIMITERS.indexOf(comments) > -1)
1609
- comments = false;
1610
-
1611
- // Newline must be valid: \r, \n, or \r\n
1612
- if (newline !== '\n' && newline !== '\r' && newline !== '\r\n')
1613
- newline = '\n';
1614
-
1615
- // We're gonna need these at the Parser scope
1616
- var cursor = 0;
1617
- var aborted = false;
1618
-
1619
- this.parse = function(input, baseIndex, ignoreLastRow)
1620
- {
1621
- // For some reason, in Chrome, this speeds things up (!?)
1622
- if (typeof input !== 'string')
1623
- throw new Error('Input must be a string');
1624
-
1625
- // We don't need to compute some of these every time parse() is called,
1626
- // but having them in a more local scope seems to perform better
1627
- var inputLen = input.length,
1628
- delimLen = delim.length,
1629
- newlineLen = newline.length,
1630
- commentsLen = comments.length;
1631
- var stepIsFunction = isFunction(step);
1632
-
1633
- // Establish starting state
1634
- cursor = 0;
1635
- var data = [], errors = [], row = [], lastCursor = 0;
1636
-
1637
- if (!input)
1638
- return returnable();
1639
-
1640
- // Rename headers if there are duplicates
1641
- if (config.header && !baseIndex)
1642
- {
1643
- var firstLine = input.split(newline)[0];
1644
- var headers = firstLine.split(delim);
1645
- var separator = '_';
1646
- var headerMap = [];
1647
- var headerCount = {};
1648
- var duplicateHeaders = false;
1649
-
1650
- for (var j in headers) {
1651
- var header = headers[j];
1652
- if (isFunction(config.transformHeader))
1653
- header = config.transformHeader(header, j);
1654
- var headerName = header;
1655
-
1656
- var count = headerCount[header] || 0;
1657
- if (count > 0) {
1658
- duplicateHeaders = true;
1659
- headerName = header + separator + count;
1660
- }
1661
- headerCount[header] = count + 1;
1662
- // In case it already exists, we add more separtors
1663
- while (headerMap.includes(headerName)) {
1664
- headerName = headerName + separator + count;
1665
- }
1666
- headerMap.push(headerName);
1667
- }
1668
- if (duplicateHeaders) {
1669
- var editedInput = input.split(newline);
1670
- editedInput[0] = headerMap.join(delim);
1671
- input = editedInput.join(newline);
1672
- }
1673
- }
1674
- if (fastMode || (fastMode !== false && input.indexOf(quoteChar) === -1))
1675
- {
1676
- var rows = input.split(newline);
1677
- for (var i = 0; i < rows.length; i++)
1678
- {
1679
- row = rows[i];
1680
- cursor += row.length;
1681
- if (i !== rows.length - 1)
1682
- cursor += newline.length;
1683
- else if (ignoreLastRow)
1684
- return returnable();
1685
- if (comments && row.substring(0, commentsLen) === comments)
1686
- continue;
1687
- if (stepIsFunction)
1688
- {
1689
- data = [];
1690
- pushRow(row.split(delim));
1691
- doStep();
1692
- if (aborted)
1693
- return returnable();
1694
- }
1695
- else
1696
- pushRow(row.split(delim));
1697
- if (preview && i >= preview)
1698
- {
1699
- data = data.slice(0, preview);
1700
- return returnable(true);
1701
- }
1702
- }
1703
- return returnable();
1704
- }
1705
-
1706
- var nextDelim = input.indexOf(delim, cursor);
1707
- var nextNewline = input.indexOf(newline, cursor);
1708
- var quoteCharRegex = new RegExp(escapeRegExp(escapeChar) + escapeRegExp(quoteChar), 'g');
1709
- var quoteSearch = input.indexOf(quoteChar, cursor);
1710
-
1711
- // Parser loop
1712
- for (;;)
1713
- {
1714
- // Field has opening quote
1715
- if (input[cursor] === quoteChar)
1716
- {
1717
- // Start our search for the closing quote where the cursor is
1718
- quoteSearch = cursor;
1719
-
1720
- // Skip the opening quote
1721
- cursor++;
1722
-
1723
- for (;;)
1724
- {
1725
- // Find closing quote
1726
- quoteSearch = input.indexOf(quoteChar, quoteSearch + 1);
1727
-
1728
- //No other quotes are found - no other delimiters
1729
- if (quoteSearch === -1)
1730
- {
1731
- if (!ignoreLastRow) {
1732
- // No closing quote... what a pity
1733
- errors.push({
1734
- type: 'Quotes',
1735
- code: 'MissingQuotes',
1736
- message: 'Quoted field unterminated',
1737
- row: data.length, // row has yet to be inserted
1738
- index: cursor
1739
- });
1740
- }
1741
- return finish();
1742
- }
1743
-
1744
- // Closing quote at EOF
1745
- if (quoteSearch === inputLen - 1)
1746
- {
1747
- var value = input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar);
1748
- return finish(value);
1749
- }
1750
-
1751
- // If this quote is escaped, it's part of the data; skip it
1752
- // If the quote character is the escape character, then check if the next character is the escape character
1753
- if (quoteChar === escapeChar && input[quoteSearch + 1] === escapeChar)
1754
- {
1755
- quoteSearch++;
1756
- continue;
1757
- }
1758
-
1759
- // If the quote character is not the escape character, then check if the previous character was the escape character
1760
- if (quoteChar !== escapeChar && quoteSearch !== 0 && input[quoteSearch - 1] === escapeChar)
1761
- {
1762
- continue;
1763
- }
1764
-
1765
- if(nextDelim !== -1 && nextDelim < (quoteSearch + 1)) {
1766
- nextDelim = input.indexOf(delim, (quoteSearch + 1));
1767
- }
1768
- if(nextNewline !== -1 && nextNewline < (quoteSearch + 1)) {
1769
- nextNewline = input.indexOf(newline, (quoteSearch + 1));
1770
- }
1771
- // Check up to nextDelim or nextNewline, whichever is closest
1772
- var checkUpTo = nextNewline === -1 ? nextDelim : Math.min(nextDelim, nextNewline);
1773
- var spacesBetweenQuoteAndDelimiter = extraSpaces(checkUpTo);
1774
-
1775
- // Closing quote followed by delimiter or 'unnecessary spaces + delimiter'
1776
- if (input.substr(quoteSearch + 1 + spacesBetweenQuoteAndDelimiter, delimLen) === delim)
1777
- {
1778
- row.push(input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar));
1779
- cursor = quoteSearch + 1 + spacesBetweenQuoteAndDelimiter + delimLen;
1780
-
1781
- // If char after following delimiter is not quoteChar, we find next quote char position
1782
- if (input[quoteSearch + 1 + spacesBetweenQuoteAndDelimiter + delimLen] !== quoteChar)
1783
- {
1784
- quoteSearch = input.indexOf(quoteChar, cursor);
1785
- }
1786
- nextDelim = input.indexOf(delim, cursor);
1787
- nextNewline = input.indexOf(newline, cursor);
1788
- break;
1789
- }
1790
-
1791
- var spacesBetweenQuoteAndNewLine = extraSpaces(nextNewline);
1792
-
1793
- // Closing quote followed by newline or 'unnecessary spaces + newLine'
1794
- if (input.substring(quoteSearch + 1 + spacesBetweenQuoteAndNewLine, quoteSearch + 1 + spacesBetweenQuoteAndNewLine + newlineLen) === newline)
1795
- {
1796
- row.push(input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar));
1797
- saveRow(quoteSearch + 1 + spacesBetweenQuoteAndNewLine + newlineLen);
1798
- nextDelim = input.indexOf(delim, cursor); // because we may have skipped the nextDelim in the quoted field
1799
- quoteSearch = input.indexOf(quoteChar, cursor); // we search for first quote in next line
1800
-
1801
- if (stepIsFunction)
1802
- {
1803
- doStep();
1804
- if (aborted)
1805
- return returnable();
1806
- }
1807
-
1808
- if (preview && data.length >= preview)
1809
- return returnable(true);
1810
-
1811
- break;
1812
- }
1813
-
1814
-
1815
- // 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
1816
- errors.push({
1817
- type: 'Quotes',
1818
- code: 'InvalidQuotes',
1819
- message: 'Trailing quote on quoted field is malformed',
1820
- row: data.length, // row has yet to be inserted
1821
- index: cursor
1822
- });
1823
-
1824
- quoteSearch++;
1825
- continue;
1826
-
1827
- }
1828
-
1829
- continue;
1830
- }
1831
-
1832
- // Comment found at start of new line
1833
- if (comments && row.length === 0 && input.substring(cursor, cursor + commentsLen) === comments)
1834
- {
1835
- if (nextNewline === -1) // Comment ends at EOF
1836
- return returnable();
1837
- cursor = nextNewline + newlineLen;
1838
- nextNewline = input.indexOf(newline, cursor);
1839
- nextDelim = input.indexOf(delim, cursor);
1840
- continue;
1841
- }
1842
-
1843
- // Next delimiter comes before next newline, so we've reached end of field
1844
- if (nextDelim !== -1 && (nextDelim < nextNewline || nextNewline === -1))
1845
- {
1846
- row.push(input.substring(cursor, nextDelim));
1847
- cursor = nextDelim + delimLen;
1848
- // we look for next delimiter char
1849
- nextDelim = input.indexOf(delim, cursor);
1850
- continue;
1851
- }
1852
-
1853
- // End of row
1854
- if (nextNewline !== -1)
1855
- {
1856
- row.push(input.substring(cursor, nextNewline));
1857
- saveRow(nextNewline + newlineLen);
1858
-
1859
- if (stepIsFunction)
1860
- {
1861
- doStep();
1862
- if (aborted)
1863
- return returnable();
1864
- }
1865
-
1866
- if (preview && data.length >= preview)
1867
- return returnable(true);
1868
-
1869
- continue;
1870
- }
1871
-
1872
- break;
1873
- }
1874
-
1875
-
1876
- return finish();
1877
-
1878
-
1879
- function pushRow(row)
1880
- {
1881
- data.push(row);
1882
- lastCursor = cursor;
1883
- }
1884
-
1885
- /**
1886
- * checks if there are extra spaces after closing quote and given index without any text
1887
- * if Yes, returns the number of spaces
1888
- */
1889
- function extraSpaces(index) {
1890
- var spaceLength = 0;
1891
- if (index !== -1) {
1892
- var textBetweenClosingQuoteAndIndex = input.substring(quoteSearch + 1, index);
1893
- if (textBetweenClosingQuoteAndIndex && textBetweenClosingQuoteAndIndex.trim() === '') {
1894
- spaceLength = textBetweenClosingQuoteAndIndex.length;
1895
- }
1896
- }
1897
- return spaceLength;
1898
- }
1899
-
1900
- /**
1901
- * Appends the remaining input from cursor to the end into
1902
- * row, saves the row, calls step, and returns the results.
1903
- */
1904
- function finish(value)
1905
- {
1906
- if (ignoreLastRow)
1907
- return returnable();
1908
- if (typeof value === 'undefined')
1909
- value = input.substring(cursor);
1910
- row.push(value);
1911
- cursor = inputLen; // important in case parsing is paused
1912
- pushRow(row);
1913
- if (stepIsFunction)
1914
- doStep();
1915
- return returnable();
1916
- }
1917
-
1918
- /**
1919
- * Appends the current row to the results. It sets the cursor
1920
- * to newCursor and finds the nextNewline. The caller should
1921
- * take care to execute user's step function and check for
1922
- * preview and end parsing if necessary.
1923
- */
1924
- function saveRow(newCursor)
1925
- {
1926
- cursor = newCursor;
1927
- pushRow(row);
1928
- row = [];
1929
- nextNewline = input.indexOf(newline, cursor);
1930
- }
1931
-
1932
- /** Returns an object with the results, errors, and meta. */
1933
- function returnable(stopped)
1934
- {
1935
- return {
1936
- data: data,
1937
- errors: errors,
1938
- meta: {
1939
- delimiter: delim,
1940
- linebreak: newline,
1941
- aborted: aborted,
1942
- truncated: !!stopped,
1943
- cursor: lastCursor + (baseIndex || 0)
1944
- }
1945
- };
1946
- }
1947
-
1948
- /** Executes the user's step function and resets data & errors. */
1949
- function doStep()
1950
- {
1951
- step(returnable());
1952
- data = [];
1953
- errors = [];
1954
- }
1955
- };
1956
-
1957
- /** Sets the abort flag */
1958
- this.abort = function()
1959
- {
1960
- aborted = true;
1961
- };
1962
-
1963
- /** Gets the cursor position */
1964
- this.getCharIndex = function()
1965
- {
1966
- return cursor;
1967
- };
1968
- }
1969
-
1970
-
1971
- function newWorker()
1972
- {
1973
- if (!Papa.WORKERS_SUPPORTED)
1974
- return false;
1975
-
1976
- var workerUrl = getWorkerBlob();
1977
- var w = new global.Worker(workerUrl);
1978
- w.onmessage = mainThreadReceivedMessage;
1979
- w.id = workerIdCounter++;
1980
- workers[w.id] = w;
1981
- return w;
1982
- }
1983
-
1984
- /** Callback when main thread receives a message */
1985
- function mainThreadReceivedMessage(e)
1986
- {
1987
- var msg = e.data;
1988
- var worker = workers[msg.workerId];
1989
- var aborted = false;
1990
-
1991
- if (msg.error)
1992
- worker.userError(msg.error, msg.file);
1993
- else if (msg.results && msg.results.data)
1994
- {
1995
- var abort = function() {
1996
- aborted = true;
1997
- completeWorker(msg.workerId, { data: [], errors: [], meta: { aborted: true } });
1998
- };
1999
-
2000
- var handle = {
2001
- abort: abort,
2002
- pause: notImplemented,
2003
- resume: notImplemented
2004
- };
2005
-
2006
- if (isFunction(worker.userStep))
2007
- {
2008
- for (var i = 0; i < msg.results.data.length; i++)
2009
- {
2010
- worker.userStep({
2011
- data: msg.results.data[i],
2012
- errors: msg.results.errors,
2013
- meta: msg.results.meta
2014
- }, handle);
2015
- if (aborted)
2016
- break;
2017
- }
2018
- delete msg.results; // free memory ASAP
2019
- }
2020
- else if (isFunction(worker.userChunk))
2021
- {
2022
- worker.userChunk(msg.results, handle, msg.file);
2023
- delete msg.results;
2024
- }
2025
- }
2026
-
2027
- if (msg.finished && !aborted)
2028
- completeWorker(msg.workerId, msg.results);
2029
- }
2030
-
2031
- function completeWorker(workerId, results) {
2032
- var worker = workers[workerId];
2033
- if (isFunction(worker.userComplete))
2034
- worker.userComplete(results);
2035
- worker.terminate();
2036
- delete workers[workerId];
2037
- }
2038
-
2039
- function notImplemented() {
2040
- throw new Error('Not implemented.');
2041
- }
2042
-
2043
- /** Callback when worker thread receives a message */
2044
- function workerThreadReceivedMessage(e)
2045
- {
2046
- var msg = e.data;
2047
-
2048
- if (typeof Papa.WORKER_ID === 'undefined' && msg)
2049
- Papa.WORKER_ID = msg.workerId;
2050
-
2051
- if (typeof msg.input === 'string')
2052
- {
2053
- global.postMessage({
2054
- workerId: Papa.WORKER_ID,
2055
- results: Papa.parse(msg.input, msg.config),
2056
- finished: true
2057
- });
2058
- }
2059
- else if ((global.File && msg.input instanceof File) || msg.input instanceof Object) // thank you, Safari (see issue #106)
2060
- {
2061
- var results = Papa.parse(msg.input, msg.config);
2062
- if (results)
2063
- global.postMessage({
2064
- workerId: Papa.WORKER_ID,
2065
- results: results,
2066
- finished: true
2067
- });
2068
- }
2069
- }
2070
-
2071
- /** Makes a deep copy of an array or object (mostly) */
2072
- function copy(obj)
2073
- {
2074
- if (typeof obj !== 'object' || obj === null)
2075
- return obj;
2076
- var cpy = Array.isArray(obj) ? [] : {};
2077
- for (var key in obj)
2078
- cpy[key] = copy(obj[key]);
2079
- return cpy;
2080
- }
2081
-
2082
- function bindFunction(f, self)
2083
- {
2084
- return function() { f.apply(self, arguments); };
2085
- }
2086
-
2087
- function isFunction(func)
2088
- {
2089
- return typeof func === 'function';
2090
- }
2091
-
2092
- return Papa;
2093
- }));
2094
- } (papaparse));
2095
-
2096
- var papaparseExports = papaparse.exports;
2097
- var Papa = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(papaparseExports);
2098
-
2099
- var isValidEmail = function isValidEmail(email) {
2100
- return yup.string().email().isValidSync(email);
2101
- };
2102
- var createEmailOptions = function createEmailOptions() {
2103
- var emails = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
2104
- return emails.map(function (email) {
2105
- return {
2106
- label: email,
2107
- value: email,
2108
- valid: isValidEmail(email)
2109
- };
2110
- });
2111
- };
2112
- var parseCsvEmails = function parseCsvEmails(file, onSuccess) {
2113
- Papa.parse(file, {
2114
- header: true,
2115
- skipEmptyLines: true,
2116
- transformHeader: function transformHeader(h) {
2117
- return h.toLowerCase().replace(/\W/g, "");
2118
- },
2119
- complete: function complete(results) {
2120
- var _results$meta$fields;
2121
- var isEmailFieldPresent = (_results$meta$fields = results.meta.fields) === null || _results$meta$fields === void 0 ? void 0 : _results$meta$fields.includes("email");
2122
- if (isEmailFieldPresent) {
2123
- var emails = results.data.filter(ramda.prop("email")).map(function (item) {
2124
- return item.email.trim();
2125
- });
2126
- onSuccess(createEmailOptions(emails));
2127
- } else {
2128
- Toastr.error(i18next.t("neetoMolecules.sendToFields.errors.invalidCsv"));
2129
- }
2130
- }
2131
- });
2132
- };
2133
-
2134
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2135
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2136
- var SendToFields = function SendToFields(_ref) {
2137
- var emailInputProps = _ref.emailInputProps,
2138
- ccInputProps = _ref.ccInputProps,
2139
- bccInputProps = _ref.bccInputProps,
2140
- _ref$showUploadCsvBut = _ref.showUploadCsvButton,
2141
- showUploadCsvButton = _ref$showUploadCsvBut === void 0 ? false : _ref$showUploadCsvBut,
2142
- _ref$showCcBccButton = _ref.showCcBccButton,
2143
- showCcBccButton = _ref$showCcBccButton === void 0 ? false : _ref$showCcBccButton,
2144
- _ref$showCcField = _ref.showCcField,
2145
- showCcField = _ref$showCcField === void 0 ? false : _ref$showCcField,
2146
- _ref$showBccField = _ref.showBccField,
2147
- showBccField = _ref$showBccField === void 0 ? false : _ref$showBccField,
2148
- _ref$showSendToField = _ref.showSendToField,
2149
- showSendToField = _ref$showSendToField === void 0 ? true : _ref$showSendToField;
2150
- var _useState = React.useState(false),
2151
- _useState2 = _slicedToArray(_useState, 2),
2152
- isBulkUploadPaneOpen = _useState2[0],
2153
- setIsBulkUploadPaneOpen = _useState2[1];
2154
- var sendToFieldRef = React.useRef();
2155
- var _useFormikContext = formik.useFormikContext(),
2156
- _useFormikContext$val = _useFormikContext.values,
2157
- showCopyEmails = _useFormikContext$val.showCopyEmails,
2158
- existingSendToEmails = _useFormikContext$val[emailInputProps.name || "sendTo"],
2159
- setFieldValue = _useFormikContext.setFieldValue;
2160
- var _useTranslation = reactI18next.useTranslation(),
2161
- t = _useTranslation.t;
2162
- var handleCSVFile = function handleCSVFile(file) {
2163
- try {
2164
- var _sendToFieldRef$curre;
2165
- var onSuccess = function onSuccess(values) {
2166
- return setFieldValue(emailInputProps.name || "sendTo", [].concat(_toConsumableArray(existingSendToEmails), _toConsumableArray(values)));
2167
- };
2168
- parseCsvEmails(file, onSuccess);
2169
- setIsBulkUploadPaneOpen(false);
2170
- (_sendToFieldRef$curre = sendToFieldRef.current) === null || _sendToFieldRef$curre === void 0 || _sendToFieldRef$curre.focus();
2171
- } catch (error) {
2172
- Toastr.error(error);
2173
- }
2174
- };
2175
- var handelCcBccButtonClick = function handelCcBccButtonClick(e) {
2176
- e.stopPropagation();
2177
- setFieldValue("showCopyEmails", !showCopyEmails);
2178
- };
2179
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
2180
- className: "relative w-full flex-col gap-2",
2181
- "data-testid": "send-to-text-field",
2182
- children: [showUploadCsvButton && /*#__PURE__*/jsxRuntime.jsx(Button, {
2183
- className: "absolute right-1 top-0",
2184
- "data-testid": "bulk-upload-button",
2185
- icon: Upload,
2186
- label: t("neetoMolecules.shareViaLink.bulkUpload"),
2187
- size: "small",
2188
- style: "link",
2189
- onClick: function onClick() {
2190
- return setIsBulkUploadPaneOpen(true);
2191
- }
2192
- }), showSendToField && /*#__PURE__*/jsxRuntime.jsx(MultiEmailInput, _objectSpread(_objectSpread({
2193
- name: "sendTo",
2194
- ref: sendToFieldRef
2195
- }, emailInputProps), {}, {
2196
- suffix: showCcBccButton && /*#__PURE__*/jsxRuntime.jsx(Button, {
2197
- "data-cy": "cc-bcc-button",
2198
- "data-testid": "cc-bcc-button",
2199
- label: t("neetoMolecules.emailForm.labels.ccBcc"),
2200
- size: "small",
2201
- style: "link",
2202
- onClick: handelCcBccButtonClick
2203
- })
2204
- })), (showCopyEmails || showCcField || showBccField) && /*#__PURE__*/jsxRuntime.jsxs("div", {
2205
- className: "mt-5 flex w-full flex-col gap-6",
2206
- children: [(showCopyEmails || showCcField) && /*#__PURE__*/jsxRuntime.jsx(MultiEmailInput, _objectSpread({
2207
- name: "sendToBcc"
2208
- }, ccInputProps)), (showCopyEmails || showBccField) && /*#__PURE__*/jsxRuntime.jsx(MultiEmailInput, _objectSpread({
2209
- name: "sendToCc"
2210
- }, bccInputProps))]
2211
- }), /*#__PURE__*/jsxRuntime.jsx(BulkUploadPane, {
2212
- fileSize: CSV_FILE_SIZE_IN_KB,
2213
- handleFileSubmit: handleCSVFile,
2214
- isOpen: isBulkUploadPaneOpen,
2215
- onClose: function onClose() {
2216
- return setIsBulkUploadPaneOpen(false);
2217
- }
2218
- })]
2219
- });
2220
- };
2221
-
2222
- module.exports = SendToFields;
2223
- //# sourceMappingURL=SendToFields.js.map