@legalplace/wizardx-core 2.6.4 → 2.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (348) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/App.js +13 -4
  3. package/dist/PluginLoader.d.ts +3 -1
  4. package/dist/PluginLoader.js +12 -0
  5. package/dist/ThemeLoader.d.ts +2 -2
  6. package/dist/components/SmartScript.d.ts +2 -2
  7. package/dist/components/SmartScript.js +2 -0
  8. package/dist/componentsConnectors/connectBox.d.ts +3 -1
  9. package/dist/componentsConnectors/connectDocument.d.ts +3 -1
  10. package/dist/componentsConnectors/connectHeader.d.ts +3 -1
  11. package/dist/componentsConnectors/connectMetaTitle.d.ts +3 -1
  12. package/dist/componentsConnectors/connectOption.d.ts +6 -2
  13. package/dist/componentsConnectors/connectOption.js +1 -1
  14. package/dist/componentsConnectors/connectPagination.d.ts +3 -1
  15. package/dist/componentsConnectors/connectPreview.d.ts +3 -1
  16. package/dist/componentsConnectors/connectProgress.d.ts +3 -1
  17. package/dist/componentsConnectors/connectRootOption.d.ts +3 -1
  18. package/dist/componentsConnectors/connectSection.d.ts +3 -1
  19. package/dist/componentsConnectors/connectSection.js +7 -10
  20. package/dist/componentsConnectors/connectSummary.d.ts +3 -1
  21. package/dist/componentsConnectors/connectSummaryItem.d.ts +3 -1
  22. package/dist/componentsConnectors/connectVariable.d.ts +6 -2
  23. package/dist/componentsConnectors/connectVariable.js +1 -1
  24. package/dist/componentsConnectors/connectWizardWrapper.d.ts +3 -1
  25. package/dist/componentsConnectors/connector/componentConnector.d.ts +5 -1
  26. package/dist/componentsConnectors/connector/componentConnector.js +43 -4
  27. package/dist/componentsConnectors/connector/index.d.ts +1 -0
  28. package/dist/componentsConnectors/connector/index.js +1 -0
  29. package/dist/componentsConnectors/index.d.ts +17 -0
  30. package/dist/componentsConnectors/index.js +17 -0
  31. package/dist/componentsConnectors/library.d.ts +43 -15
  32. package/dist/helpers/apiEndpoint.d.ts +1 -0
  33. package/dist/helpers/apiEndpoint.js +4 -0
  34. package/dist/helpers/index.d.ts +4 -0
  35. package/dist/helpers/index.js +4 -0
  36. package/dist/helpers/propsEqualityCheck.d.ts +1 -0
  37. package/dist/helpers/propsEqualityCheck.js +10 -0
  38. package/dist/hooks/index.d.ts +4 -0
  39. package/dist/hooks/index.js +4 -0
  40. package/dist/hooks/useActions.d.ts +2 -0
  41. package/dist/hooks/useActions.js +4 -0
  42. package/dist/hooks/useDispatch.d.ts +1 -0
  43. package/dist/hooks/useDispatch.js +4 -0
  44. package/dist/hooks/useSelectors.d.ts +2 -0
  45. package/dist/hooks/useSelectors.js +4 -0
  46. package/dist/index.d.ts +13 -0
  47. package/dist/index.js +13 -0
  48. package/dist/libs/PathReader.d.ts +10 -6
  49. package/dist/libs/PathReader.js +47 -28
  50. package/dist/libs/index.d.ts +5 -0
  51. package/dist/libs/index.js +5 -0
  52. package/dist/redux/actions/index.d.ts +9 -0
  53. package/dist/redux/actions/index.js +9 -0
  54. package/dist/redux/actions/library.d.ts +59 -63
  55. package/dist/redux/actions/sagas/index.d.ts +3 -0
  56. package/dist/redux/actions/sagas/index.js +3 -0
  57. package/dist/redux/actions/sagas/model.d.ts +1 -5
  58. package/dist/redux/constants/app.d.ts +2 -0
  59. package/dist/redux/constants/app.js +2 -0
  60. package/dist/redux/constants/index.d.ts +8 -0
  61. package/dist/redux/constants/index.js +8 -0
  62. package/dist/redux/constants/sagas/index.d.ts +3 -0
  63. package/dist/redux/constants/sagas/index.js +3 -0
  64. package/dist/redux/index.d.ts +5 -0
  65. package/dist/redux/index.js +5 -0
  66. package/dist/redux/middlewares/conditionsWatcherMiddleware.js +11 -5
  67. package/dist/redux/middlewares/conditionsWatcherMiddleware.test.js +120 -113
  68. package/dist/redux/middlewares/paginationWatcherMiddleware.js +2 -2
  69. package/dist/redux/middlewares/smartscriptMiddleware.js +8 -0
  70. package/dist/redux/reducers/pluginsStore.d.ts +3 -0
  71. package/dist/redux/reducers/pluginsStore.js +12 -0
  72. package/dist/redux/routerHistory.js +2 -2
  73. package/dist/redux/sagas/fetchModel.js +22 -6
  74. package/dist/redux/sagas/initInputs.js +6 -7
  75. package/dist/redux/sagas/saveData.js +2 -0
  76. package/dist/redux/selectors/app.js +13 -18
  77. package/dist/redux/selectors/cache.d.ts +17 -0
  78. package/dist/redux/selectors/cache.js +35 -0
  79. package/dist/redux/selectors/conditions.js +7 -7
  80. package/dist/redux/selectors/index.d.ts +8 -0
  81. package/dist/redux/selectors/index.js +8 -0
  82. package/dist/redux/selectors/inputs.js +3 -3
  83. package/dist/redux/selectors/library.d.ts +2 -2
  84. package/dist/redux/selectors/references.js +26 -26
  85. package/dist/redux/selectors/selectors.d.ts +2 -2
  86. package/dist/redux/selectors/selectors.js +19 -8
  87. package/dist/redux/selectors/selectors.test.js +6 -6
  88. package/dist/redux/selectors/user.js +5 -5
  89. package/dist/redux/store.d.ts +1 -1
  90. package/dist/redux/store.js +12 -4
  91. package/dist/service/api.manager.d.ts +1 -6
  92. package/dist/service/index.d.ts +3 -0
  93. package/dist/service/index.js +3 -0
  94. package/dist/types/PluginConfig.type.d.ts +57 -0
  95. package/dist/types/PluginConfig.type.js +1 -0
  96. package/dist/types/State.type.d.ts +6 -0
  97. package/dist/types/config.type.d.ts +3 -1
  98. package/dist/types/index.d.ts +11 -0
  99. package/dist/types/index.js +11 -0
  100. package/package.json +13 -13
  101. package/.depcheckrc +0 -1
  102. package/.eslintignore +0 -2
  103. package/.eslintrc +0 -5
  104. package/__mocks__/fileMock.js +0 -1
  105. package/babel.config.json +0 -3
  106. package/jest.config.ts +0 -193
  107. package/setupJest.ts +0 -8
  108. package/src/App.test.tsx +0 -41
  109. package/src/App.tsx +0 -152
  110. package/src/Globals.ts +0 -69
  111. package/src/Loader.tsx +0 -8
  112. package/src/PluginLoader.test.tsx +0 -70
  113. package/src/PluginLoader.tsx +0 -407
  114. package/src/Shimmer.tsx +0 -108
  115. package/src/ThemeLoader.test.tsx +0 -82
  116. package/src/ThemeLoader.tsx +0 -95
  117. package/src/components/PluginRoute.tsx +0 -48
  118. package/src/components/SmartScript.tsx +0 -166
  119. package/src/components/UserLocked/UserLockedComponent.tsx +0 -33
  120. package/src/components/View.test.tsx +0 -110
  121. package/src/components/View.tsx +0 -114
  122. package/src/componentsConnectors/connectBox.test.tsx +0 -226
  123. package/src/componentsConnectors/connectBox.tsx +0 -70
  124. package/src/componentsConnectors/connectDocument.test.tsx +0 -108
  125. package/src/componentsConnectors/connectDocument.tsx +0 -64
  126. package/src/componentsConnectors/connectHeader.tsx +0 -21
  127. package/src/componentsConnectors/connectMetaTitle.test.tsx +0 -40
  128. package/src/componentsConnectors/connectMetaTitle.tsx +0 -8
  129. package/src/componentsConnectors/connectOption.tsx +0 -222
  130. package/src/componentsConnectors/connectPagination.tsx +0 -102
  131. package/src/componentsConnectors/connectPreview.tsx +0 -5
  132. package/src/componentsConnectors/connectProgress.tsx +0 -59
  133. package/src/componentsConnectors/connectRootOption.tsx +0 -95
  134. package/src/componentsConnectors/connectSection.tsx +0 -79
  135. package/src/componentsConnectors/connectSummary.tsx +0 -21
  136. package/src/componentsConnectors/connectSummaryItem.tsx +0 -102
  137. package/src/componentsConnectors/connectTermsheet.tsx +0 -359
  138. package/src/componentsConnectors/connectVariable.tsx +0 -191
  139. package/src/componentsConnectors/connectWizardWrapper.tsx +0 -30
  140. package/src/componentsConnectors/connector/componentConnector.tsx +0 -219
  141. package/src/componentsConnectors/library.ts +0 -35
  142. package/src/config.test.ts +0 -63
  143. package/src/config.ts +0 -11
  144. package/src/constants/emailValidation.ts +0 -2
  145. package/src/constants/phoneValidation.ts +0 -4
  146. package/src/definitions/path.join.d.ts +0 -4
  147. package/src/helpers/outputsParsing.ts +0 -412
  148. package/src/helpers/preloadTheme.ts +0 -17
  149. package/src/helpers/scriptsLoader.ts +0 -20
  150. package/src/hooks/usePrevious.ts +0 -9
  151. package/src/libs/ConditionsInitiator.ts +0 -164
  152. package/src/libs/ConditionsRunner/DataPopulator.ts +0 -266
  153. package/src/libs/ConditionsRunner.ts +0 -454
  154. package/src/libs/DocumentsOutputs.ts +0 -171
  155. package/src/libs/Eval/EvalBase.ts +0 -116
  156. package/src/libs/Eval/EvalFunctions.ts +0 -724
  157. package/src/libs/Eval/NumbersToLetters.ts +0 -185
  158. package/src/libs/EvalVariable.ts +0 -265
  159. package/src/libs/EventsTracking.ts +0 -250
  160. package/src/libs/InputsInitiator.ts +0 -136
  161. package/src/libs/NumAuto.test.ts +0 -55
  162. package/src/libs/NumAuto.ts +0 -56
  163. package/src/libs/OvcConverter.ts +0 -285
  164. package/src/libs/PathReader.ts +0 -272
  165. package/src/libs/SectionValidity.test.ts +0 -146
  166. package/src/libs/SectionValidity.ts +0 -110
  167. package/src/libs/SmartScriptStore.ts +0 -492
  168. package/src/misc/test_model.ts +0 -14603
  169. package/src/misc/test_models/connectDocumen.testmodel.json +0 -178
  170. package/src/misc/test_models/setDefaults.testmodel.json +0 -279
  171. package/src/misc/test_models/testmodel.json +0 -1
  172. package/src/polyfills/index.ts +0 -5
  173. package/src/polyfills/objectValues.ts +0 -4
  174. package/src/polyfills/prepend.ts +0 -31
  175. package/src/polyfills/stringRepeat.ts +0 -44
  176. package/src/redux/actions/app.test.ts +0 -123
  177. package/src/redux/actions/app.ts +0 -249
  178. package/src/redux/actions/conditions.test.ts +0 -84
  179. package/src/redux/actions/conditions.ts +0 -135
  180. package/src/redux/actions/inputs.test.ts +0 -85
  181. package/src/redux/actions/inputs.ts +0 -111
  182. package/src/redux/actions/library.ts +0 -23
  183. package/src/redux/actions/mandatories.ts +0 -98
  184. package/src/redux/actions/references.test.ts +0 -48
  185. package/src/redux/actions/references.ts +0 -37
  186. package/src/redux/actions/sagas/data.test.ts +0 -11
  187. package/src/redux/actions/sagas/data.ts +0 -18
  188. package/src/redux/actions/sagas/model.test.ts +0 -14
  189. package/src/redux/actions/sagas/model.ts +0 -48
  190. package/src/redux/actions/sagas/user.ts +0 -25
  191. package/src/redux/actions/smartscript.ts +0 -55
  192. package/src/redux/actions/user.test.ts +0 -18
  193. package/src/redux/actions/user.ts +0 -41
  194. package/src/redux/constants/app.ts +0 -36
  195. package/src/redux/constants/conditions.ts +0 -25
  196. package/src/redux/constants/inputs.ts +0 -15
  197. package/src/redux/constants/mandatories.ts +0 -11
  198. package/src/redux/constants/references.ts +0 -7
  199. package/src/redux/constants/sagas/data.ts +0 -1
  200. package/src/redux/constants/sagas/model.ts +0 -2
  201. package/src/redux/constants/sagas/user.ts +0 -2
  202. package/src/redux/constants/smartscript.ts +0 -9
  203. package/src/redux/constants/user.ts +0 -6
  204. package/src/redux/listeners/subscriber.test.ts +0 -45
  205. package/src/redux/listeners/subscriber.ts +0 -29
  206. package/src/redux/middlewares/conditionsWatcherMiddleware.test.ts +0 -370
  207. package/src/redux/middlewares/conditionsWatcherMiddleware.ts +0 -321
  208. package/src/redux/middlewares/evaluationsWatcherMiddleware.test.ts +0 -323
  209. package/src/redux/middlewares/evaluationsWatcherMiddleware.ts +0 -250
  210. package/src/redux/middlewares/mandatoriesWatcherMiddleware.ts +0 -473
  211. package/src/redux/middlewares/multiplesActionsMiddleware.test.ts +0 -230
  212. package/src/redux/middlewares/multiplesActionsMiddleware.ts +0 -121
  213. package/src/redux/middlewares/paginationWatcherMiddleware.ts +0 -251
  214. package/src/redux/middlewares/pluginsHookMiddleware.ts +0 -24
  215. package/src/redux/middlewares/prefillerWatcherMiddleware.test.ts +0 -118
  216. package/src/redux/middlewares/prefillerWatcherMiddleware.ts +0 -462
  217. package/src/redux/middlewares/smartscriptMiddleware.ts +0 -228
  218. package/src/redux/middlewares/thirdpartyScriptsMiddleware.ts +0 -41
  219. package/src/redux/reducers/app/customizations/initCustomizationAutoDefault.ts +0 -16
  220. package/src/redux/reducers/app/customizations/initCustomizationMeta.ts +0 -16
  221. package/src/redux/reducers/app/instance/initInstance.ts +0 -29
  222. package/src/redux/reducers/app/instance/setDataStatus.ts +0 -16
  223. package/src/redux/reducers/app/instance/updateInstance.ts +0 -30
  224. package/src/redux/reducers/app/instance/updateInstancePaid.ts +0 -20
  225. package/src/redux/reducers/app/instance.test.ts +0 -106
  226. package/src/redux/reducers/app/meta/fetchModelFailed.ts +0 -11
  227. package/src/redux/reducers/app/meta/fetchModelNonBlocking.ts +0 -11
  228. package/src/redux/reducers/app/meta/fetchModelSucceeded.ts +0 -11
  229. package/src/redux/reducers/app/meta/fetchModelUnhealthy.ts +0 -18
  230. package/src/redux/reducers/app/meta/fetchModelUserLocked.ts +0 -11
  231. package/src/redux/reducers/app/meta/initMeta.ts +0 -22
  232. package/src/redux/reducers/app/meta/setModelUuid.ts +0 -17
  233. package/src/redux/reducers/app/meta.test.ts +0 -90
  234. package/src/redux/reducers/app/pagination/goNextPage.ts +0 -69
  235. package/src/redux/reducers/app/pagination/goPage.ts +0 -81
  236. package/src/redux/reducers/app/pagination/goPreviousPage.ts +0 -60
  237. package/src/redux/reducers/app/pagination/initPagination.ts +0 -46
  238. package/src/redux/reducers/app/pagination/updateAvailableAppStates.ts +0 -77
  239. package/src/redux/reducers/app/pagination.test.ts +0 -363
  240. package/src/redux/reducers/app/wizard/updateAvailableSections.ts +0 -40
  241. package/src/redux/reducers/app/wizard.test.ts +0 -84
  242. package/src/redux/reducers/app.test.ts +0 -336
  243. package/src/redux/reducers/app.ts +0 -150
  244. package/src/redux/reducers/conditions/addMultipleOccurency.test.ts +0 -131
  245. package/src/redux/reducers/conditions/addMultipleOccurency.ts +0 -155
  246. package/src/redux/reducers/conditions/deleteMultipleOccurency.test.ts +0 -95
  247. package/src/redux/reducers/conditions/deleteMultipleOccurency.ts +0 -141
  248. package/src/redux/reducers/conditions/initConditions.ts +0 -18
  249. package/src/redux/reducers/conditions/updateDocumentConditions.test.ts +0 -47
  250. package/src/redux/reducers/conditions/updateDocumentConditions.ts +0 -21
  251. package/src/redux/reducers/conditions/updateOptionConditions.ts +0 -24
  252. package/src/redux/reducers/conditions/updateOptionValidatorCondition.test.ts +0 -50
  253. package/src/redux/reducers/conditions/updateOptionValidatorCondition.ts +0 -28
  254. package/src/redux/reducers/conditions/updatePrefillerConditions.ts +0 -29
  255. package/src/redux/reducers/conditions/updateSectionConditions.ts +0 -28
  256. package/src/redux/reducers/conditions/updateVariableConditions.ts +0 -25
  257. package/src/redux/reducers/conditions/updateVariableValidatorCondition.test.ts +0 -50
  258. package/src/redux/reducers/conditions/updateVariableValidatorCondition.ts +0 -28
  259. package/src/redux/reducers/conditions.test.ts +0 -241
  260. package/src/redux/reducers/conditions.ts +0 -68
  261. package/src/redux/reducers/inputs/addMultipleOccurency.test.ts +0 -117
  262. package/src/redux/reducers/inputs/addMultipleOccurency.ts +0 -50
  263. package/src/redux/reducers/inputs/deleteMultipleOccurency.test.ts +0 -70
  264. package/src/redux/reducers/inputs/deleteMultipleOccurency.ts +0 -50
  265. package/src/redux/reducers/inputs/initOption.ts +0 -16
  266. package/src/redux/reducers/inputs/initVariable.ts +0 -16
  267. package/src/redux/reducers/inputs/updateOptionInput.ts +0 -24
  268. package/src/redux/reducers/inputs/updateVariableInput.ts +0 -24
  269. package/src/redux/reducers/inputs.test.ts +0 -221
  270. package/src/redux/reducers/inputs.ts +0 -51
  271. package/src/redux/reducers/mandatories/addMultipleOccurency.ts +0 -52
  272. package/src/redux/reducers/mandatories/deleteMultipleOccurency.ts +0 -55
  273. package/src/redux/reducers/mandatories/initMandatoryOption.ts +0 -17
  274. package/src/redux/reducers/mandatories/initMandatoryVariable.ts +0 -17
  275. package/src/redux/reducers/mandatories/setMandatoryIgnore.ts +0 -17
  276. package/src/redux/reducers/mandatories/setMandatoryOption.ts +0 -25
  277. package/src/redux/reducers/mandatories/setMandatorySection.ts +0 -20
  278. package/src/redux/reducers/mandatories/setMandatoryVariable.ts +0 -24
  279. package/src/redux/reducers/mandatories.ts +0 -56
  280. package/src/redux/reducers/references/initReferences.ts +0 -37
  281. package/src/redux/reducers/references/updateOptionMeta.ts +0 -73
  282. package/src/redux/reducers/references/updateVariableMeta.ts +0 -72
  283. package/src/redux/reducers/references.ts +0 -59
  284. package/src/redux/reducers/smartscript/enableSmartScript.ts +0 -13
  285. package/src/redux/reducers/smartscript/initSmartScriptTriggers.ts +0 -14
  286. package/src/redux/reducers/smartscript/updateSmartscriptOptionHidden.ts +0 -30
  287. package/src/redux/reducers/smartscript/updateSmartscriptVariableHidden.ts +0 -30
  288. package/src/redux/reducers/smartscript.ts +0 -47
  289. package/src/redux/reducers/user/initUser.ts +0 -15
  290. package/src/redux/reducers/user/setUserStatus.ts +0 -13
  291. package/src/redux/reducers/user/setUserValidToken.ts +0 -13
  292. package/src/redux/reducers/user.test.ts +0 -51
  293. package/src/redux/reducers/user.ts +0 -40
  294. package/src/redux/routerHistore.test.ts +0 -19
  295. package/src/redux/routerHistory.ts +0 -26
  296. package/src/redux/sagas/fetchModel.test.ts +0 -76
  297. package/src/redux/sagas/fetchModel.ts +0 -683
  298. package/src/redux/sagas/homogeneousRadioInputsSaga.ts +0 -42
  299. package/src/redux/sagas/initInputs.ts +0 -110
  300. package/src/redux/sagas/runner.test.ts +0 -12
  301. package/src/redux/sagas/runner.ts +0 -26
  302. package/src/redux/sagas/saveData.test.ts +0 -125
  303. package/src/redux/sagas/saveData.ts +0 -55
  304. package/src/redux/sagas/setDefaults.test.ts +0 -100
  305. package/src/redux/sagas/setDefaults.ts +0 -167
  306. package/src/redux/sagas/setUserEmail.ts +0 -175
  307. package/src/redux/selectors/app.test.ts +0 -162
  308. package/src/redux/selectors/app.ts +0 -331
  309. package/src/redux/selectors/conditions.test.ts +0 -92
  310. package/src/redux/selectors/conditions.ts +0 -293
  311. package/src/redux/selectors/inputs.test.ts +0 -72
  312. package/src/redux/selectors/inputs.ts +0 -76
  313. package/src/redux/selectors/library.ts +0 -17
  314. package/src/redux/selectors/mandatories.ts +0 -83
  315. package/src/redux/selectors/references.test.ts +0 -660
  316. package/src/redux/selectors/references.ts +0 -413
  317. package/src/redux/selectors/selectors.test.ts +0 -21
  318. package/src/redux/selectors/selectors.ts +0 -87
  319. package/src/redux/selectors/smartscript.ts +0 -30
  320. package/src/redux/selectors/user.test.ts +0 -39
  321. package/src/redux/selectors/user.ts +0 -45
  322. package/src/redux/store.test.ts +0 -22
  323. package/src/redux/store.ts +0 -100
  324. package/src/service/api.manager.ts +0 -261
  325. package/src/service/auth.service.ts +0 -5
  326. package/src/service/pardot.service.ts +0 -10
  327. package/src/tests-misc/plugins/jestTestPlugin/after.tsx +0 -5
  328. package/src/tests-misc/plugins/jestTestPlugin/before.tsx +0 -11
  329. package/src/tests-misc/plugins/jestTestPlugin/index.ts +0 -11
  330. package/src/tests-misc/plugins/jestTestPlugin/title.tsx +0 -8
  331. package/src/tests-misc/themes/jestTestTheme/components/EmailComponent.tsx +0 -5
  332. package/src/tests-misc/themes/jestTestTheme/components/TermsheetComponent.tsx +0 -5
  333. package/src/tests-misc/themes/jestTestTheme/components/WizardComponent.tsx +0 -5
  334. package/src/tests-misc/themes/jestTestTheme/faltyIndex.ts +0 -3
  335. package/src/tests-misc/themes/jestTestTheme/faltyIndexLoader.ts +0 -1
  336. package/src/tests-misc/themes/jestTestTheme/index.ts +0 -13
  337. package/src/types/Actions.type.ts +0 -612
  338. package/src/types/Components.type.ts +0 -181
  339. package/src/types/State.type.ts +0 -323
  340. package/src/types/Termsheet.type.ts +0 -28
  341. package/src/types/api.type.ts +0 -37
  342. package/src/types/config.type.ts +0 -55
  343. package/src/types/env.type.ts +0 -5
  344. package/src/types/getActions.type.ts +0 -3
  345. package/src/types/getConnectors.type.ts +0 -5
  346. package/src/types/getSelectors.type.ts +0 -3
  347. package/src/wizard-params.ts +0 -56
  348. package/tsconfig.json +0 -43
@@ -1,185 +0,0 @@
1
- /**
2
- * NumberToLetter
3
- * --------------
4
- * Converts numbers to letters, original code was written by GALA OUSSE Brice
5
- * https://github.com/hbendalibraham/number-to-letters/blob/master/nombre_en_lettre.js
6
- * --------------
7
- * Library was rewritten in order to add typescript support and to handle errors with
8
- * throws instead of simple string returns
9
- */
10
- export class NumberToLetter {
11
- static French(
12
- number: string | number,
13
- units: string | false = false,
14
- decimals: string | false = false
15
- ): string {
16
- const letter: Record<number, string> = {
17
- 0: "zéro",
18
- 1: "un",
19
- 2: "deux",
20
- 3: "trois",
21
- 4: "quatre",
22
- 5: "cinq",
23
- 6: "six",
24
- 7: "sept",
25
- 8: "huit",
26
- 9: "neuf",
27
- 10: "dix",
28
- 11: "onze",
29
- 12: "douze",
30
- 13: "treize",
31
- 14: "quatorze",
32
- 15: "quinze",
33
- 16: "seize",
34
- 17: "dix-sept",
35
- 18: "dix-huit",
36
- 19: "dix-neuf",
37
- 20: "vingt",
38
- 30: "trente",
39
- 40: "quarante",
40
- 50: "cinquante",
41
- 60: "soixante",
42
- 70: "soixante-dix",
43
- 80: "quatre-vingt",
44
- 90: "quatre-vingt-dix",
45
- };
46
-
47
- let quotient;
48
- let left;
49
- let numberToLetter = "";
50
-
51
- // Validating number before proceeding
52
- if (number.toString().replace(/ /gi, "").length > 15)
53
- throw new Error("Capacity overrun");
54
- if (Number.isNaN(number.toString().replace(/ /gi, "")))
55
- throw new Error("Unvalid number");
56
-
57
- // Parsing number
58
- const nb = parseFloat(number.toString().replace(/ /gi, ""));
59
-
60
- // Handling commas
61
- if (Math.ceil(nb) !== nb) {
62
- const [wholeNumberPart, decimalPart] = number.toString().split(".");
63
- const decimalNumber = decimalPart?.startsWith("0")
64
- ? Array.from(decimalPart)
65
- .map((decimal) => this.French(decimal))
66
- .join(" ")
67
- : this.French(decimalPart);
68
- return (
69
- this.French(wholeNumberPart) +
70
- (units ? ` ${units} et ` : " virgule ") +
71
- decimalNumber +
72
- (decimals ? ` ${decimals}` : "")
73
- );
74
- }
75
-
76
- /**
77
- * Converting number to letters
78
- */
79
- const numberLength = nb.toString().length;
80
- switch (numberLength) {
81
- case 1:
82
- numberToLetter = letter[nb];
83
- break;
84
- case 2:
85
- if (nb > 19) {
86
- quotient = Math.floor(nb / 10);
87
- left = nb % 10;
88
- if (nb < 71 || (nb > 79 && nb < 91)) {
89
- if (left === 0) numberToLetter = letter[quotient * 10];
90
- if (left === 1)
91
- numberToLetter = `${letter[quotient * 10]}-et-${letter[left]}`;
92
- if (left > 1)
93
- numberToLetter = `${letter[quotient * 10]}-${letter[left]}`;
94
- } else
95
- numberToLetter = `${letter[(quotient - 1) * 10]}-${
96
- letter[10 + left]
97
- }`;
98
- } else numberToLetter = letter[nb];
99
- break;
100
- case 3:
101
- quotient = Math.floor(nb / 100);
102
- left = nb % 100;
103
- if (quotient === 1 && left === 0) numberToLetter = "cent";
104
- if (quotient === 1 && left !== 0)
105
- numberToLetter = `cent ${this.French(left)}`;
106
- if (quotient > 1 && left === 0)
107
- numberToLetter = `${letter[quotient]} cents`;
108
- if (quotient > 1 && left !== 0)
109
- numberToLetter = `${letter[quotient]} cent ${this.French(left)}`;
110
- break;
111
- case 4:
112
- case 5:
113
- case 6:
114
- quotient = Math.floor(nb / 1000);
115
- left = nb - quotient * 1000;
116
- if (quotient === 1 && left === 0) numberToLetter = "mille";
117
- if (quotient === 1 && left !== 0)
118
- numberToLetter = `mille ${this.French(left)}`;
119
- if (quotient > 1 && left === 0)
120
- numberToLetter = `${this.French(quotient)} mille`;
121
- if (quotient > 1 && left !== 0)
122
- numberToLetter = `${this.French(quotient)} mille ${this.French(
123
- left
124
- )}`;
125
- break;
126
- case 7:
127
- case 8:
128
- case 9:
129
- quotient = Math.floor(nb / 1000000);
130
- left = nb % 1000000;
131
- if (quotient === 1 && left === 0) numberToLetter = "un million";
132
- if (quotient === 1 && left !== 0)
133
- numberToLetter = `un million ${this.French(left)}`;
134
- if (quotient > 1 && left === 0)
135
- numberToLetter = `${this.French(quotient)} millions`;
136
- if (quotient > 1 && left !== 0)
137
- numberToLetter = `${this.French(quotient)} millions ${this.French(
138
- left
139
- )}`;
140
- break;
141
- case 10:
142
- case 11:
143
- case 12:
144
- quotient = Math.floor(nb / 1000000000);
145
- left = nb - quotient * 1000000000;
146
- if (quotient === 1 && left === 0) numberToLetter = "un milliard";
147
- if (quotient === 1 && left !== 0)
148
- numberToLetter = `un milliard ${this.French(left)}`;
149
- if (quotient > 1 && left === 0)
150
- numberToLetter = `${this.French(quotient)} milliards`;
151
- if (quotient > 1 && left !== 0)
152
- numberToLetter = `${this.French(quotient)} milliards ${this.French(
153
- left
154
- )}`;
155
- break;
156
- case 13:
157
- case 14:
158
- case 15:
159
- quotient = Math.floor(nb / 1000000000000);
160
- left = nb - quotient * 1000000000000;
161
- if (quotient === 1 && left === 0) numberToLetter = "un billion";
162
- if (quotient === 1 && left !== 0)
163
- numberToLetter = `un billion ${this.French(left)}`;
164
- if (quotient > 1 && left === 0)
165
- numberToLetter = `${this.French(quotient)} billions`;
166
- if (quotient > 1 && left !== 0)
167
- numberToLetter = `${this.French(quotient)} billions ${this.French(
168
- left
169
- )}`;
170
- break;
171
- default:
172
- throw new Error(`Capacity overrun`);
173
- }
174
-
175
- if (
176
- numberToLetter.substr(
177
- numberToLetter.length - "quatre-vingt".length,
178
- "quatre-vingt".length
179
- ) === "quatre-vingt"
180
- )
181
- numberToLetter += "s";
182
-
183
- return numberToLetter;
184
- }
185
- }
@@ -1,265 +0,0 @@
1
- /* eslint-disable no-await-in-loop */
2
- import type { VariableV3 } from "@legalplace/models-v3-types";
3
- import { selectVariableReference } from "../redux/selectors/references";
4
- import { EvalFunctions } from "./Eval/EvalFunctions";
5
-
6
- /**
7
- * EvalVariable class
8
- * ------------------
9
- * Parses an eval variable's
10
- * evaluation
11
- */
12
- export class EvalVariable extends EvalFunctions {
13
- variablesValues: Record<string, string | number> = {};
14
-
15
- evaluation: string;
16
-
17
- rawEvaluation: string;
18
-
19
- result: string | number | null = null;
20
-
21
- index: number;
22
-
23
- hasFunctions = false;
24
-
25
- abortEvaluation = false;
26
-
27
- constructor(variable: VariableV3, index: number) {
28
- super(variable.id, index);
29
-
30
- this.evaluation =
31
- typeof variable.eval?.formula === "string" ? variable.eval?.formula : "0";
32
- this.rawEvaluation = this.evaluation;
33
- this.index = index;
34
-
35
- // Setting isDisplay
36
- if (/^D=(.*)/i.test(this.evaluation)) {
37
- this.isDisplay = true;
38
- }
39
-
40
- // Compiling & executing functions
41
- this.executeFunctions();
42
-
43
- // Populating value
44
- this.populateValues();
45
-
46
- // Evaluating
47
- this.evaluate();
48
- }
49
-
50
- /**
51
- * Populates evaluation with the required variables
52
- */
53
- populateValues(): void {
54
- let evalVariables = {};
55
-
56
- // Extracting eval variables tags
57
- const match = this.evaluation.match(/\[var:([0-9]+)\]/gi);
58
- if (match !== null) {
59
- // Tranforming tags into integer ids
60
- const evalVariablesTags: string[] = [...match];
61
- const evalVariablesIds = evalVariablesTags.map((current) => {
62
- const matchId = current.match(/([0-9]+)/);
63
- if (matchId === null) return 0;
64
- return parseInt(matchId[0], 10);
65
- });
66
-
67
- // Getting values
68
- evalVariablesIds.forEach((variableId) => {
69
- let value = this.getVariableValue(variableId, false);
70
- if (typeof value === "string" && value.trim().length === 0) {
71
- value = "___EMPTY___";
72
-
73
- if (this.isVariableEditable(variableId)) this.abortEvaluation = true;
74
- }
75
- evalVariables = {
76
- ...evalVariables,
77
- [variableId]: value,
78
- };
79
- });
80
- }
81
-
82
- this.variablesValues = evalVariables;
83
-
84
- let operation = `${this.evaluation}`;
85
- Object.keys(this.variablesValues).forEach((variableId) => {
86
- let value = this.variablesValues[variableId];
87
- value = typeof value === "number" ? value.toString() : value;
88
- operation = operation.replace(
89
- new RegExp(`\\[var:${variableId}\\]`, "g"),
90
- value
91
- );
92
- });
93
-
94
- this.evaluation = operation;
95
- }
96
-
97
- /**
98
- * Executes evaluation functions
99
- */
100
- executeFunctions(): void {
101
- /**
102
- * Functions list
103
- */
104
- const functionsList: Record<string, (...args: any[]) => string | number> = {
105
- AFFICHER_DATE: this.afficherDate,
106
- AFFICHER_ANNEE: this.afficherAnnee,
107
- JOUR_OUVRE: this.jourOuvre,
108
- JOUR_OUVRABLE: this.jourOuvrable,
109
- DATE: this.date,
110
- AJOUTER_JOURS_OUVRABLES: this.ajouterJoursOuvrables,
111
- AJOUTER_JOURS_OUVRES: this.ajouterJoursOuvres,
112
- AJOUTER_JOURS: this.ajouterJours,
113
- AJOUTER_MOIS: this.ajouterMois,
114
- AJOUTER_ANNEES: this.ajouterAnnees,
115
- ENLEVER_JOURS_OUVRABLES: this.enleverJoursOuvrables,
116
- ENLEVER_JOURS_OUVRES: this.enleverJoursOuvres,
117
- ENLEVER_JOURS: this.enleverJours,
118
- ENLEVER_MOIS: this.enleverMois,
119
- ENLEVER_ANNEES: this.enleverAnnees,
120
- DUREE_JOURS: this.dureeJours,
121
- DUREE_MOIS: this.dureeMois,
122
- DUREE_ANNEES: this.dureeAnnees,
123
- TODAY: this.today,
124
- SOMME: this.somme,
125
- LETTRES: this.lettres,
126
- };
127
-
128
- /**
129
- * Extracting and executing functions
130
- */
131
- const regex = /([a-z_]+)\(([^()]*)\)/gi;
132
- let formulas = this.evaluation.match(regex);
133
-
134
- // Keep the loop running until we detect no more functions
135
- while (formulas && this.doNotEvaluate === false) {
136
- for (let i = 0; i < formulas.length; i += 1) {
137
- const formula = formulas[i];
138
-
139
- const reg = new RegExp(regex, "gi");
140
- const extract = reg.exec(formula);
141
- if (extract === null) return;
142
-
143
- // Stopping evaluation right after a function detects an error
144
- if (this.doNotEvaluate === true) return;
145
-
146
- const functionName = extract[1];
147
- const args = extract[2]
148
- .split(extract[2].indexOf(";") > -1 ? ";" : ",")
149
- .map((v) => v.trim());
150
-
151
- let result = "";
152
- if (Object.keys(functionsList).includes(functionName)) {
153
- result = functionsList[functionName].apply(this, args).toString();
154
- this.hasFunctions = true;
155
- } else {
156
- // eslint-disable-next-line no-console
157
- console.error(
158
- `Erreur de modélisation: la fonction %c"${functionName}" %cest inconnue dans la formule: ${this.rawEvaluation}`,
159
- "font-weight: bold;",
160
- "font-weight: initial"
161
- );
162
- this.doNotEvaluate = true;
163
- }
164
-
165
- this.evaluation = this.evaluation.replace(formula, result);
166
- }
167
-
168
- formulas = this.evaluation.match(regex);
169
- }
170
- }
171
-
172
- /**
173
- * Evaluates current evaluation
174
- */
175
- evaluate(): string | number {
176
- // Stoping evaluation in case the functions processing decided so
177
- if (this.doNotEvaluate === true) {
178
- this.result = "";
179
- return "";
180
- }
181
- if (
182
- typeof this.evaluation !== "string" ||
183
- this.evaluation.trim().length === 0
184
- ) {
185
- this.result = "";
186
- return "";
187
- }
188
-
189
- let result;
190
- try {
191
- // If result is a date returning it
192
- if (/^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/.test(this.evaluation)) {
193
- result = this.evaluation;
194
- } else if (/^D=(.*)/i.test(this.evaluation)) {
195
- result = this.setEmpty(this.evaluation.replace(/^D=/i, ""), "");
196
- } else if (this.abortEvaluation === true) {
197
- result = "";
198
- } else {
199
- const cleanEvaluation = this.setEmpty(this.evaluation, 0);
200
- // eslint-disable-next-line no-eval
201
- result = eval(
202
- typeof cleanEvaluation === "string"
203
- ? cleanEvaluation
204
- : cleanEvaluation.toString()
205
- );
206
- if (result === Infinity || Number.isNaN(result)) {
207
- result = this.hasFunctions === true ? "" : 0;
208
- }
209
- }
210
- } catch (e) {
211
- result =
212
- this.hasFunctions === true || this.abortEvaluation === true ? "" : 0;
213
- }
214
-
215
- // Rounding
216
- if (typeof result === "number") {
217
- const variableReference = selectVariableReference(this.id);
218
- if (variableReference?.eval === undefined)
219
- throw new Error(`Variable ${this.id} does not exist`);
220
- const { decimals, round } = variableReference.eval;
221
- const evalDecimal =
222
- (typeof decimals === "number" && !Number.isNaN(decimals)) ||
223
- typeof decimals === "string"
224
- ? decimals
225
- : undefined;
226
-
227
- // Decimals
228
- let numberOfDecimals = 0;
229
- if (evalDecimal !== undefined) {
230
- numberOfDecimals =
231
- typeof evalDecimal === "string"
232
- ? parseInt(evalDecimal, 10)
233
- : evalDecimal;
234
- }
235
-
236
- // Decimals
237
- let decma = 1;
238
- for (let i = 0; i < numberOfDecimals; i += 1) decma *= 10;
239
-
240
- // Rounding strategy
241
- const rounders = {
242
- round: Math.round,
243
- ceil: Math.ceil,
244
- floor: Math.floor,
245
- };
246
- if (round !== undefined && rounders[round]) {
247
- if (evalDecimal !== undefined) {
248
- result = rounders[round](result * decma) / decma;
249
- } else {
250
- result = rounders[round](result);
251
- }
252
- } else if (evalDecimal !== undefined) {
253
- result = Math.round(result * decma) / decma;
254
- }
255
- }
256
-
257
- if (result === undefined) {
258
- this.result = "";
259
- return "";
260
- }
261
-
262
- this.result = result.toString();
263
- return result;
264
- }
265
- }
@@ -1,250 +0,0 @@
1
- import Cookies from "universal-cookie";
2
- import Globals from "../Globals";
3
-
4
- export type EventsPropsType = Record<
5
- string,
6
- string | number | boolean | Record<string, string | number | boolean>
7
- >;
8
-
9
- const cookie = new Cookies();
10
-
11
- class _EventsTracking {
12
- private initiated = false;
13
-
14
- private queue: [string, any[]][] = [];
15
-
16
- private queueTimer: ReturnType<typeof setTimeout> | null = null;
17
-
18
- public track(eventName: string, eventProps?: EventsPropsType) {
19
- if (!this.initiated) this.init();
20
-
21
- // Mixpanel
22
- this.trackMix(eventName, { ...eventProps });
23
-
24
- // Facebook Pixel
25
- this.trackFB(eventName, { ...eventProps });
26
-
27
- // Google Analytics
28
- this.trackGA(eventName, { ...eventProps });
29
- }
30
-
31
- public register(props: EventsPropsType) {
32
- if (!this.initiated) this.init();
33
-
34
- // Mixpanel
35
- this.registerMix(props);
36
-
37
- // Facebook Pixel
38
- this.registerFB(props);
39
- }
40
-
41
- public trigger(name: string) {
42
- if (!this.initiated) this.init();
43
-
44
- // Hotjar
45
- this.triggerHj(name);
46
- }
47
-
48
- private init() {
49
- this.initiated = true;
50
- this.register({
51
- "WizardX Build Commit":
52
- process.env.REACT_APP_COMMIT || "Unkown build commit",
53
- Environement: Globals.appEnv,
54
- "Powered By": "WizardX",
55
- ...this.getXSource(),
56
- ...this.getXAbTests(),
57
- });
58
- this.trigger("wizardx");
59
- }
60
-
61
- private getXSource(): Record<string, string> {
62
- const xSource = cookie.get("X-Source");
63
-
64
- return typeof xSource === "string" && xSource.trim().length > 0
65
- ? {
66
- "X-Source": xSource,
67
- }
68
- : {};
69
- }
70
-
71
- private getXAbTests(): Record<string, string> {
72
- const xAbTests = cookie.get("X-AbTests");
73
-
74
- if (typeof xAbTests === "object") {
75
- const xAbTestsFlattened: Record<string, string> = {};
76
-
77
- Object.keys(xAbTests).forEach((abTestName) => {
78
- xAbTestsFlattened[`X-AbTests[${abTestName}]`] = xAbTests[abTestName];
79
- });
80
-
81
- return xAbTestsFlattened;
82
- }
83
-
84
- return typeof xAbTests === "string" && xAbTests.trim().length > 0
85
- ? {
86
- "X-AbTests": xAbTests,
87
- }
88
- : {};
89
- }
90
-
91
- /**
92
- * Executes events tracking queue
93
- */
94
- private executeQueue() {
95
- for (let i = 0; i < this.queue.length; i += 1) {
96
- const currentEvent = this.queue[i];
97
- const args = [];
98
- const [fnName] = currentEvent;
99
- if (currentEvent.length > 1) {
100
- for (let x = 0; x < currentEvent[1].length; x += 1)
101
- args.push(currentEvent[1][x]);
102
-
103
- args.push(true);
104
-
105
- let fn: (...a: any) => any;
106
-
107
- switch (fnName) {
108
- case "trackMix":
109
- fn = this.trackMix.bind(this);
110
- break;
111
- case "trackFB":
112
- fn = this.trackFB.bind(this);
113
- break;
114
- case "trackGA":
115
- fn = this.trackGA.bind(this);
116
- break;
117
- case "registerMix":
118
- fn = this.registerMix.bind(this);
119
- break;
120
- case "registerFB":
121
- fn = this.registerFB.bind(this);
122
- break;
123
- case "triggerHj":
124
- fn = this.triggerHj.bind(this);
125
- break;
126
- default:
127
- throw new Error(
128
- `Unkown function "${fnName}" found on events tracking queue`
129
- );
130
- }
131
-
132
- // Getting function
133
- const result = fn(...args);
134
- if (result === true) {
135
- this.queue.splice(i, 1);
136
- }
137
- }
138
- }
139
- }
140
-
141
- private queueTimeout() {
142
- if (this.queueTimer !== null) clearTimeout(this.queueTimer);
143
-
144
- this.queueTimer = setTimeout(() => {
145
- this.executeQueue();
146
- }, 50);
147
- }
148
-
149
- public trackMix(
150
- eventName: string,
151
- eventProps?: EventsPropsType,
152
- doNotPushToQueue = false
153
- ) {
154
- if (!this.initiated) this.init();
155
-
156
- if (typeof window.mixpanel !== "undefined") {
157
- if (this.queue.length > 0 && !doNotPushToQueue) this.executeQueue();
158
- window.mixpanel.track(eventName, eventProps);
159
- return true;
160
- }
161
-
162
- if (doNotPushToQueue === false)
163
- this.queue.push(["trackMix", [eventName, eventProps]]);
164
-
165
- this.queueTimeout();
166
- return false;
167
- }
168
-
169
- private trackFB(
170
- eventName: string,
171
- eventProps?: EventsPropsType,
172
- doNotPushToQueue = false
173
- ) {
174
- if (typeof window.fbq !== "undefined") {
175
- if (this.queue.length > 0 && !doNotPushToQueue) this.executeQueue();
176
- window.fbq("trackCustom", eventName, eventProps);
177
- return true;
178
- }
179
-
180
- if (doNotPushToQueue === false)
181
- this.queue.push(["trackFB", [eventName, eventProps]]);
182
-
183
- this.queueTimeout();
184
- return false;
185
- }
186
-
187
- private trackGA(
188
- eventName: string,
189
- eventProps?: EventsPropsType,
190
- doNotPushToQueue = false
191
- ) {
192
- if (typeof window.ga !== "undefined") {
193
- if (this.queue.length > 0 && !doNotPushToQueue) this.executeQueue();
194
- window.ga(
195
- "send",
196
- "event",
197
- "lpTracking",
198
- "track",
199
- eventName,
200
- 1,
201
- eventProps
202
- );
203
- return true;
204
- }
205
-
206
- if (doNotPushToQueue === false)
207
- this.queue.push(["trackGA", [eventName, eventProps]]);
208
-
209
- this.queueTimeout();
210
- return false;
211
- }
212
-
213
- private registerMix(props: EventsPropsType, doNotPushToQueue = false) {
214
- if (typeof window.mixpanel !== "undefined") {
215
- if (this.queue.length > 0 && !doNotPushToQueue) this.executeQueue();
216
- window.mixpanel.register(props);
217
- return true;
218
- }
219
- if (doNotPushToQueue === false) this.queue.push(["registerMix", [props]]);
220
-
221
- this.queueTimeout();
222
- return false;
223
- }
224
-
225
- private registerFB(props: EventsPropsType, doNotPushToQueue = false) {
226
- if (typeof window.fbq !== "undefined") {
227
- if (this.queue.length > 0 && !doNotPushToQueue) this.executeQueue();
228
- window.fbq("trackCustom", "GeneralProps", props);
229
- return true;
230
- }
231
- if (doNotPushToQueue === false) this.queue.push(["registerFB", [props]]);
232
-
233
- this.queueTimeout();
234
- return false;
235
- }
236
-
237
- private triggerHj(name: string, doNotPushToQueue = false) {
238
- if (typeof window.hj !== "undefined") {
239
- if (this.queue.length > 0 && !doNotPushToQueue) this.executeQueue();
240
- window.hj("trigger", name);
241
- return true;
242
- }
243
- if (doNotPushToQueue === false) this.queue.push(["triggerHj", [name]]);
244
-
245
- this.queueTimeout();
246
- return false;
247
- }
248
- }
249
-
250
- export const EventsTracking = new _EventsTracking();