@darajs/core 0.4.8

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 (464) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +101 -0
  3. package/dist/actions/download-variable.d.ts +8 -0
  4. package/dist/actions/download-variable.d.ts.map +1 -0
  5. package/dist/actions/download-variable.js +140 -0
  6. package/dist/actions/download-variable.js.map +1 -0
  7. package/dist/actions/index.d.ts +7 -0
  8. package/dist/actions/index.d.ts.map +1 -0
  9. package/dist/actions/index.js +7 -0
  10. package/dist/actions/index.js.map +1 -0
  11. package/dist/actions/navigate-to.d.ts +8 -0
  12. package/dist/actions/navigate-to.d.ts.map +1 -0
  13. package/dist/actions/navigate-to.js +37 -0
  14. package/dist/actions/navigate-to.js.map +1 -0
  15. package/dist/actions/notify.d.ts +4 -0
  16. package/dist/actions/notify.d.ts.map +1 -0
  17. package/dist/actions/notify.js +11 -0
  18. package/dist/actions/notify.js.map +1 -0
  19. package/dist/actions/reset-variables.d.ts +8 -0
  20. package/dist/actions/reset-variables.d.ts.map +1 -0
  21. package/dist/actions/reset-variables.js +37 -0
  22. package/dist/actions/reset-variables.js.map +1 -0
  23. package/dist/actions/trigger-variable.d.ts +8 -0
  24. package/dist/actions/trigger-variable.d.ts.map +1 -0
  25. package/dist/actions/trigger-variable.js +14 -0
  26. package/dist/actions/trigger-variable.js.map +1 -0
  27. package/dist/actions/update-variable.d.ts +15 -0
  28. package/dist/actions/update-variable.d.ts.map +1 -0
  29. package/dist/actions/update-variable.js +56 -0
  30. package/dist/actions/update-variable.js.map +1 -0
  31. package/dist/api/core.d.ts +35 -0
  32. package/dist/api/core.d.ts.map +1 -0
  33. package/dist/api/core.js +112 -0
  34. package/dist/api/core.js.map +1 -0
  35. package/dist/api/http.d.ts +29 -0
  36. package/dist/api/http.d.ts.map +1 -0
  37. package/dist/api/http.js +126 -0
  38. package/dist/api/http.js.map +1 -0
  39. package/dist/api/index.d.ts +5 -0
  40. package/dist/api/index.d.ts.map +1 -0
  41. package/dist/api/index.js +5 -0
  42. package/dist/api/index.js.map +1 -0
  43. package/dist/api/websocket.d.ts +222 -0
  44. package/dist/api/websocket.d.ts.map +1 -0
  45. package/dist/api/websocket.js +353 -0
  46. package/dist/api/websocket.js.map +1 -0
  47. package/dist/assets/causalens-dark.svg +29 -0
  48. package/dist/assets/causalens-light.svg +29 -0
  49. package/dist/assets/dara-dark.svg +20 -0
  50. package/dist/assets/dara-light.svg +15 -0
  51. package/dist/assets/fonts/Manrope-VariableFont_wght.ttf +0 -0
  52. package/dist/auth/auth-wrapper.d.ts +15 -0
  53. package/dist/auth/auth-wrapper.d.ts.map +1 -0
  54. package/dist/auth/auth-wrapper.js +72 -0
  55. package/dist/auth/auth-wrapper.js.map +1 -0
  56. package/dist/auth/auth.d.ts +61 -0
  57. package/dist/auth/auth.d.ts.map +1 -0
  58. package/dist/auth/auth.js +163 -0
  59. package/dist/auth/auth.js.map +1 -0
  60. package/dist/auth/basic/basic-auth-login.d.ts +6 -0
  61. package/dist/auth/basic/basic-auth-login.d.ts.map +1 -0
  62. package/dist/auth/basic/basic-auth-login.js +171 -0
  63. package/dist/auth/basic/basic-auth-login.js.map +1 -0
  64. package/dist/auth/basic/basic-auth-logout.d.ts +6 -0
  65. package/dist/auth/basic/basic-auth-logout.d.ts.map +1 -0
  66. package/dist/auth/basic/basic-auth-logout.js +18 -0
  67. package/dist/auth/basic/basic-auth-logout.js.map +1 -0
  68. package/dist/auth/default/default-auth-login.d.ts +6 -0
  69. package/dist/auth/default/default-auth-login.d.ts.map +1 -0
  70. package/dist/auth/default/default-auth-login.js +59 -0
  71. package/dist/auth/default/default-auth-login.js.map +1 -0
  72. package/dist/auth/index.d.ts +7 -0
  73. package/dist/auth/index.d.ts.map +1 -0
  74. package/dist/auth/index.js +7 -0
  75. package/dist/auth/index.js.map +1 -0
  76. package/dist/auth/use-session-token.d.ts +19 -0
  77. package/dist/auth/use-session-token.d.ts.map +1 -0
  78. package/dist/auth/use-session-token.js +30 -0
  79. package/dist/auth/use-session-token.js.map +1 -0
  80. package/dist/components/fallback/default.d.ts +5 -0
  81. package/dist/components/fallback/default.d.ts.map +1 -0
  82. package/dist/components/fallback/default.js +10 -0
  83. package/dist/components/fallback/default.js.map +1 -0
  84. package/dist/components/fallback/dots.d.ts +7 -0
  85. package/dist/components/fallback/dots.d.ts.map +1 -0
  86. package/dist/components/fallback/dots.js +78 -0
  87. package/dist/components/fallback/dots.js.map +1 -0
  88. package/dist/components/fallback/row.d.ts +5 -0
  89. package/dist/components/fallback/row.d.ts.map +1 -0
  90. package/dist/components/fallback/row.js +14 -0
  91. package/dist/components/fallback/row.js.map +1 -0
  92. package/dist/components/for/for.d.ts +35 -0
  93. package/dist/components/for/for.d.ts.map +1 -0
  94. package/dist/components/for/for.js +44 -0
  95. package/dist/components/for/for.js.map +1 -0
  96. package/dist/components/index.d.ts +9 -0
  97. package/dist/components/index.d.ts.map +1 -0
  98. package/dist/components/index.js +9 -0
  99. package/dist/components/index.js.map +1 -0
  100. package/dist/components/menu/menu.d.ts +14 -0
  101. package/dist/components/menu/menu.d.ts.map +1 -0
  102. package/dist/components/menu/menu.js +58 -0
  103. package/dist/components/menu/menu.js.map +1 -0
  104. package/dist/components/progress-tracker/progress-tracker.d.ts +18 -0
  105. package/dist/components/progress-tracker/progress-tracker.d.ts.map +1 -0
  106. package/dist/components/progress-tracker/progress-tracker.js +204 -0
  107. package/dist/components/progress-tracker/progress-tracker.js.map +1 -0
  108. package/dist/components/router-content/router-content.d.ts +14 -0
  109. package/dist/components/router-content/router-content.d.ts.map +1 -0
  110. package/dist/components/router-content/router-content.js +17 -0
  111. package/dist/components/router-content/router-content.js.map +1 -0
  112. package/dist/components/side-bar-frame/side-bar-frame.d.ts +21 -0
  113. package/dist/components/side-bar-frame/side-bar-frame.d.ts.map +1 -0
  114. package/dist/components/side-bar-frame/side-bar-frame.js +87 -0
  115. package/dist/components/side-bar-frame/side-bar-frame.js.map +1 -0
  116. package/dist/components/top-bar-frame/top-bar-frame.d.ts +16 -0
  117. package/dist/components/top-bar-frame/top-bar-frame.d.ts.map +1 -0
  118. package/dist/components/top-bar-frame/top-bar-frame.js +89 -0
  119. package/dist/components/top-bar-frame/top-bar-frame.js.map +1 -0
  120. package/dist/dara_core-0.4.8-py3-none-any.whl +0 -0
  121. package/dist/devtools/backend-errors/backend-errors-ctx.d.ts +17 -0
  122. package/dist/devtools/backend-errors/backend-errors-ctx.d.ts.map +1 -0
  123. package/dist/devtools/backend-errors/backend-errors-ctx.js +37 -0
  124. package/dist/devtools/backend-errors/backend-errors-ctx.js.map +1 -0
  125. package/dist/devtools/backend-errors/backend-errors.d.ts +6 -0
  126. package/dist/devtools/backend-errors/backend-errors.d.ts.map +1 -0
  127. package/dist/devtools/backend-errors/backend-errors.js +57 -0
  128. package/dist/devtools/backend-errors/backend-errors.js.map +1 -0
  129. package/dist/devtools/backend-errors/error-display.d.ts +22 -0
  130. package/dist/devtools/backend-errors/error-display.d.ts.map +1 -0
  131. package/dist/devtools/backend-errors/error-display.js +101 -0
  132. package/dist/devtools/backend-errors/error-display.js.map +1 -0
  133. package/dist/devtools/backend-errors/index.d.ts +3 -0
  134. package/dist/devtools/backend-errors/index.d.ts.map +1 -0
  135. package/dist/devtools/backend-errors/index.js +3 -0
  136. package/dist/devtools/backend-errors/index.js.map +1 -0
  137. package/dist/devtools/devtools-content.d.ts +12 -0
  138. package/dist/devtools/devtools-content.d.ts.map +1 -0
  139. package/dist/devtools/devtools-content.js +73 -0
  140. package/dist/devtools/devtools-content.js.map +1 -0
  141. package/dist/devtools/devtools-context.d.ts +7 -0
  142. package/dist/devtools/devtools-context.d.ts.map +1 -0
  143. package/dist/devtools/devtools-context.js +9 -0
  144. package/dist/devtools/devtools-context.js.map +1 -0
  145. package/dist/devtools/devtools-wrapper.d.ts +8 -0
  146. package/dist/devtools/devtools-wrapper.d.ts.map +1 -0
  147. package/dist/devtools/devtools-wrapper.js +64 -0
  148. package/dist/devtools/devtools-wrapper.js.map +1 -0
  149. package/dist/devtools/devtools.d.ts +5 -0
  150. package/dist/devtools/devtools.d.ts.map +1 -0
  151. package/dist/devtools/devtools.js +10 -0
  152. package/dist/devtools/devtools.js.map +1 -0
  153. package/dist/devtools/floating-button.d.ts +23 -0
  154. package/dist/devtools/floating-button.d.ts.map +1 -0
  155. package/dist/devtools/floating-button.js +94 -0
  156. package/dist/devtools/floating-button.js.map +1 -0
  157. package/dist/devtools/index.d.ts +2 -0
  158. package/dist/devtools/index.d.ts.map +1 -0
  159. package/dist/devtools/index.js +2 -0
  160. package/dist/devtools/index.js.map +1 -0
  161. package/dist/devtools/resizer.d.ts +18 -0
  162. package/dist/devtools/resizer.d.ts.map +1 -0
  163. package/dist/devtools/resizer.js +49 -0
  164. package/dist/devtools/resizer.js.map +1 -0
  165. package/dist/devtools/use-move.d.ts +21 -0
  166. package/dist/devtools/use-move.d.ts.map +1 -0
  167. package/dist/devtools/use-move.js +56 -0
  168. package/dist/devtools/use-move.js.map +1 -0
  169. package/dist/index.css +95 -0
  170. package/dist/index.d.ts +17 -0
  171. package/dist/index.d.ts.map +1 -0
  172. package/dist/index.js +14 -0
  173. package/dist/index.js.map +1 -0
  174. package/dist/jest-setup.d.ts +2 -0
  175. package/dist/jest-setup.d.ts.map +1 -0
  176. package/dist/jest-setup.js +18 -0
  177. package/dist/jest-setup.js.map +1 -0
  178. package/dist/pages/error-page.d.ts +3 -0
  179. package/dist/pages/error-page.d.ts.map +1 -0
  180. package/dist/pages/error-page.js +32 -0
  181. package/dist/pages/error-page.js.map +1 -0
  182. package/dist/pages/sso-callback-page.d.ts +6 -0
  183. package/dist/pages/sso-callback-page.d.ts.map +1 -0
  184. package/dist/pages/sso-callback-page.js +8 -0
  185. package/dist/pages/sso-callback-page.js.map +1 -0
  186. package/dist/run.d.ts +22 -0
  187. package/dist/run.d.ts.map +1 -0
  188. package/dist/run.js +40 -0
  189. package/dist/run.js.map +1 -0
  190. package/dist/shared/center/center.d.ts +5 -0
  191. package/dist/shared/center/center.d.ts.map +1 -0
  192. package/dist/shared/center/center.js +15 -0
  193. package/dist/shared/center/center.js.map +1 -0
  194. package/dist/shared/context/direction-context.d.ts +6 -0
  195. package/dist/shared/context/direction-context.d.ts.map +1 -0
  196. package/dist/shared/context/direction-context.js +4 -0
  197. package/dist/shared/context/direction-context.js.map +1 -0
  198. package/dist/shared/context/display-context.d.ts +13 -0
  199. package/dist/shared/context/display-context.d.ts.map +1 -0
  200. package/dist/shared/context/display-context.js +4 -0
  201. package/dist/shared/context/display-context.js.map +1 -0
  202. package/dist/shared/context/fallback-context.d.ts +11 -0
  203. package/dist/shared/context/fallback-context.d.ts.map +1 -0
  204. package/dist/shared/context/fallback-context.js +4 -0
  205. package/dist/shared/context/fallback-context.js.map +1 -0
  206. package/dist/shared/context/global-task-context.d.ts +40 -0
  207. package/dist/shared/context/global-task-context.d.ts.map +1 -0
  208. package/dist/shared/context/global-task-context.js +81 -0
  209. package/dist/shared/context/global-task-context.js.map +1 -0
  210. package/dist/shared/context/importers-context.d.ts +6 -0
  211. package/dist/shared/context/importers-context.d.ts.map +1 -0
  212. package/dist/shared/context/importers-context.js +4 -0
  213. package/dist/shared/context/importers-context.js.map +1 -0
  214. package/dist/shared/context/index.d.ts +10 -0
  215. package/dist/shared/context/index.d.ts.map +1 -0
  216. package/dist/shared/context/index.js +10 -0
  217. package/dist/shared/context/index.js.map +1 -0
  218. package/dist/shared/context/registries-context.d.ts +20 -0
  219. package/dist/shared/context/registries-context.d.ts.map +1 -0
  220. package/dist/shared/context/registries-context.js +8 -0
  221. package/dist/shared/context/registries-context.js.map +1 -0
  222. package/dist/shared/context/request-extras-context.d.ts +33 -0
  223. package/dist/shared/context/request-extras-context.d.ts.map +1 -0
  224. package/dist/shared/context/request-extras-context.js +55 -0
  225. package/dist/shared/context/request-extras-context.js.map +1 -0
  226. package/dist/shared/context/variable-context.d.ts +10 -0
  227. package/dist/shared/context/variable-context.d.ts.map +1 -0
  228. package/dist/shared/context/variable-context.js +4 -0
  229. package/dist/shared/context/variable-context.js.map +1 -0
  230. package/dist/shared/context/websocket-context.d.ts +7 -0
  231. package/dist/shared/context/websocket-context.d.ts.map +1 -0
  232. package/dist/shared/context/websocket-context.js +4 -0
  233. package/dist/shared/context/websocket-context.js.map +1 -0
  234. package/dist/shared/dynamic-component/clean-props.d.ts +6 -0
  235. package/dist/shared/dynamic-component/clean-props.d.ts.map +1 -0
  236. package/dist/shared/dynamic-component/clean-props.js +13 -0
  237. package/dist/shared/dynamic-component/clean-props.js.map +1 -0
  238. package/dist/shared/dynamic-component/dynamic-component.d.ts +16 -0
  239. package/dist/shared/dynamic-component/dynamic-component.d.ts.map +1 -0
  240. package/dist/shared/dynamic-component/dynamic-component.js +252 -0
  241. package/dist/shared/dynamic-component/dynamic-component.js.map +1 -0
  242. package/dist/shared/error-handling/error-display.d.ts +8 -0
  243. package/dist/shared/error-handling/error-display.d.ts.map +1 -0
  244. package/dist/shared/error-handling/error-display.js +94 -0
  245. package/dist/shared/error-handling/error-display.js.map +1 -0
  246. package/dist/shared/error-handling/index.d.ts +3 -0
  247. package/dist/shared/error-handling/index.d.ts.map +1 -0
  248. package/dist/shared/error-handling/index.js +3 -0
  249. package/dist/shared/error-handling/index.js.map +1 -0
  250. package/dist/shared/error-handling/types.d.ts +11 -0
  251. package/dist/shared/error-handling/types.d.ts.map +1 -0
  252. package/dist/shared/error-handling/types.js +9 -0
  253. package/dist/shared/error-handling/types.js.map +1 -0
  254. package/dist/shared/event-bus/event-bus.d.ts +27 -0
  255. package/dist/shared/event-bus/event-bus.d.ts.map +1 -0
  256. package/dist/shared/event-bus/event-bus.js +58 -0
  257. package/dist/shared/event-bus/event-bus.js.map +1 -0
  258. package/dist/shared/global-state-store.d.ts +54 -0
  259. package/dist/shared/global-state-store.d.ts.map +1 -0
  260. package/dist/shared/global-state-store.js +168 -0
  261. package/dist/shared/global-state-store.js.map +1 -0
  262. package/dist/shared/index.d.ts +12 -0
  263. package/dist/shared/index.d.ts.map +1 -0
  264. package/dist/shared/index.js +10 -0
  265. package/dist/shared/index.js.map +1 -0
  266. package/dist/shared/interactivity/data-variable.d.ts +78 -0
  267. package/dist/shared/interactivity/data-variable.d.ts.map +1 -0
  268. package/dist/shared/interactivity/data-variable.js +218 -0
  269. package/dist/shared/interactivity/data-variable.js.map +1 -0
  270. package/dist/shared/interactivity/derived-variable.d.ts +160 -0
  271. package/dist/shared/interactivity/derived-variable.d.ts.map +1 -0
  272. package/dist/shared/interactivity/derived-variable.js +446 -0
  273. package/dist/shared/interactivity/derived-variable.js.map +1 -0
  274. package/dist/shared/interactivity/filtering.d.ts +9 -0
  275. package/dist/shared/interactivity/filtering.d.ts.map +1 -0
  276. package/dist/shared/interactivity/filtering.js +20 -0
  277. package/dist/shared/interactivity/filtering.js.map +1 -0
  278. package/dist/shared/interactivity/index.d.ts +10 -0
  279. package/dist/shared/interactivity/index.d.ts.map +1 -0
  280. package/dist/shared/interactivity/index.js +9 -0
  281. package/dist/shared/interactivity/index.js.map +1 -0
  282. package/dist/shared/interactivity/internal.d.ts +9 -0
  283. package/dist/shared/interactivity/internal.d.ts.map +1 -0
  284. package/dist/shared/interactivity/internal.js +11 -0
  285. package/dist/shared/interactivity/internal.js.map +1 -0
  286. package/dist/shared/interactivity/nested.d.ts +16 -0
  287. package/dist/shared/interactivity/nested.d.ts.map +1 -0
  288. package/dist/shared/interactivity/nested.js +54 -0
  289. package/dist/shared/interactivity/nested.js.map +1 -0
  290. package/dist/shared/interactivity/persistence.d.ts +43 -0
  291. package/dist/shared/interactivity/persistence.d.ts.map +1 -0
  292. package/dist/shared/interactivity/persistence.js +215 -0
  293. package/dist/shared/interactivity/persistence.js.map +1 -0
  294. package/dist/shared/interactivity/plain-variable.d.ts +17 -0
  295. package/dist/shared/interactivity/plain-variable.d.ts.map +1 -0
  296. package/dist/shared/interactivity/plain-variable.js +222 -0
  297. package/dist/shared/interactivity/plain-variable.js.map +1 -0
  298. package/dist/shared/interactivity/resolve-value.d.ts +13 -0
  299. package/dist/shared/interactivity/resolve-value.d.ts.map +1 -0
  300. package/dist/shared/interactivity/resolve-value.js +36 -0
  301. package/dist/shared/interactivity/resolve-value.js.map +1 -0
  302. package/dist/shared/interactivity/resolve-variable.d.ts +18 -0
  303. package/dist/shared/interactivity/resolve-variable.d.ts.map +1 -0
  304. package/dist/shared/interactivity/resolve-variable.js +46 -0
  305. package/dist/shared/interactivity/resolve-variable.js.map +1 -0
  306. package/dist/shared/interactivity/store.d.ts +76 -0
  307. package/dist/shared/interactivity/store.d.ts.map +1 -0
  308. package/dist/shared/interactivity/store.js +99 -0
  309. package/dist/shared/interactivity/store.js.map +1 -0
  310. package/dist/shared/interactivity/triggers.d.ts +31 -0
  311. package/dist/shared/interactivity/triggers.d.ts.map +1 -0
  312. package/dist/shared/interactivity/triggers.js +105 -0
  313. package/dist/shared/interactivity/triggers.js.map +1 -0
  314. package/dist/shared/interactivity/url-variable.d.ts +12 -0
  315. package/dist/shared/interactivity/url-variable.d.ts.map +1 -0
  316. package/dist/shared/interactivity/url-variable.js +27 -0
  317. package/dist/shared/interactivity/url-variable.js.map +1 -0
  318. package/dist/shared/interactivity/use-any-variable.d.ts +8 -0
  319. package/dist/shared/interactivity/use-any-variable.d.ts.map +1 -0
  320. package/dist/shared/interactivity/use-any-variable.js +39 -0
  321. package/dist/shared/interactivity/use-any-variable.js.map +1 -0
  322. package/dist/shared/interactivity/use-data-variable.d.ts +18 -0
  323. package/dist/shared/interactivity/use-data-variable.d.ts.map +1 -0
  324. package/dist/shared/interactivity/use-data-variable.js +58 -0
  325. package/dist/shared/interactivity/use-data-variable.js.map +1 -0
  326. package/dist/shared/interactivity/use-refresh-selector.d.ts +5 -0
  327. package/dist/shared/interactivity/use-refresh-selector.d.ts.map +1 -0
  328. package/dist/shared/interactivity/use-refresh-selector.js +20 -0
  329. package/dist/shared/interactivity/use-refresh-selector.js.map +1 -0
  330. package/dist/shared/interactivity/use-server-component.d.ts +24 -0
  331. package/dist/shared/interactivity/use-server-component.d.ts.map +1 -0
  332. package/dist/shared/interactivity/use-server-component.js +256 -0
  333. package/dist/shared/interactivity/use-server-component.js.map +1 -0
  334. package/dist/shared/interactivity/use-variable-state.d.ts +9 -0
  335. package/dist/shared/interactivity/use-variable-state.d.ts.map +1 -0
  336. package/dist/shared/interactivity/use-variable-state.js +26 -0
  337. package/dist/shared/interactivity/use-variable-state.js.map +1 -0
  338. package/dist/shared/interactivity/use-variable-value.d.ts +33 -0
  339. package/dist/shared/interactivity/use-variable-value.d.ts.map +1 -0
  340. package/dist/shared/interactivity/use-variable-value.js +94 -0
  341. package/dist/shared/interactivity/use-variable-value.js.map +1 -0
  342. package/dist/shared/interactivity/use-variable.d.ts +12 -0
  343. package/dist/shared/interactivity/use-variable.d.ts.map +1 -0
  344. package/dist/shared/interactivity/use-variable.js +84 -0
  345. package/dist/shared/interactivity/use-variable.js.map +1 -0
  346. package/dist/shared/private-route/private-route.d.ts +19 -0
  347. package/dist/shared/private-route/private-route.d.ts.map +1 -0
  348. package/dist/shared/private-route/private-route.js +35 -0
  349. package/dist/shared/private-route/private-route.js.map +1 -0
  350. package/dist/shared/template-root/dynamic-context.d.ts +9 -0
  351. package/dist/shared/template-root/dynamic-context.d.ts.map +1 -0
  352. package/dist/shared/template-root/dynamic-context.js +29 -0
  353. package/dist/shared/template-root/dynamic-context.js.map +1 -0
  354. package/dist/shared/template-root/template-root.d.ts +12 -0
  355. package/dist/shared/template-root/template-root.d.ts.map +1 -0
  356. package/dist/shared/template-root/template-root.js +94 -0
  357. package/dist/shared/template-root/template-root.js.map +1 -0
  358. package/dist/shared/utils/clean-session-cache.d.ts +9 -0
  359. package/dist/shared/utils/clean-session-cache.d.ts.map +1 -0
  360. package/dist/shared/utils/clean-session-cache.js +19 -0
  361. package/dist/shared/utils/clean-session-cache.js.map +1 -0
  362. package/dist/shared/utils/embed.d.ts +22 -0
  363. package/dist/shared/utils/embed.d.ts.map +1 -0
  364. package/dist/shared/utils/embed.js +43 -0
  365. package/dist/shared/utils/embed.js.map +1 -0
  366. package/dist/shared/utils/get-icon.d.ts +9 -0
  367. package/dist/shared/utils/get-icon.d.ts.map +1 -0
  368. package/dist/shared/utils/get-icon.js +30 -0
  369. package/dist/shared/utils/get-icon.js.map +1 -0
  370. package/dist/shared/utils/hashing.d.ts +14 -0
  371. package/dist/shared/utils/hashing.d.ts.map +1 -0
  372. package/dist/shared/utils/hashing.js +26 -0
  373. package/dist/shared/utils/hashing.js.map +1 -0
  374. package/dist/shared/utils/index.d.ts +19 -0
  375. package/dist/shared/utils/index.d.ts.map +1 -0
  376. package/dist/shared/utils/index.js +17 -0
  377. package/dist/shared/utils/index.js.map +1 -0
  378. package/dist/shared/utils/inject-css.d.ts +12 -0
  379. package/dist/shared/utils/inject-css.d.ts.map +1 -0
  380. package/dist/shared/utils/inject-css.js +25 -0
  381. package/dist/shared/utils/inject-css.js.map +1 -0
  382. package/dist/shared/utils/is-js-component.d.ts +9 -0
  383. package/dist/shared/utils/is-js-component.d.ts.map +1 -0
  384. package/dist/shared/utils/is-js-component.js +11 -0
  385. package/dist/shared/utils/is-js-component.js.map +1 -0
  386. package/dist/shared/utils/normalization.d.ts +19 -0
  387. package/dist/shared/utils/normalization.d.ts.map +1 -0
  388. package/dist/shared/utils/normalization.js +121 -0
  389. package/dist/shared/utils/normalization.js.map +1 -0
  390. package/dist/shared/utils/resolve-theme.d.ts +9 -0
  391. package/dist/shared/utils/resolve-theme.d.ts.map +1 -0
  392. package/dist/shared/utils/resolve-theme.js +28 -0
  393. package/dist/shared/utils/resolve-theme.js.map +1 -0
  394. package/dist/shared/utils/templating.d.ts +24 -0
  395. package/dist/shared/utils/templating.d.ts.map +1 -0
  396. package/dist/shared/utils/templating.js +67 -0
  397. package/dist/shared/utils/templating.js.map +1 -0
  398. package/dist/shared/utils/use-action-registry.d.ts +11 -0
  399. package/dist/shared/utils/use-action-registry.d.ts.map +1 -0
  400. package/dist/shared/utils/use-action-registry.js +18 -0
  401. package/dist/shared/utils/use-action-registry.js.map +1 -0
  402. package/dist/shared/utils/use-action.d.ts +34 -0
  403. package/dist/shared/utils/use-action.d.ts.map +1 -0
  404. package/dist/shared/utils/use-action.js +314 -0
  405. package/dist/shared/utils/use-action.js.map +1 -0
  406. package/dist/shared/utils/use-component-registry.d.ts +11 -0
  407. package/dist/shared/utils/use-component-registry.d.ts.map +1 -0
  408. package/dist/shared/utils/use-component-registry.js +57 -0
  409. package/dist/shared/utils/use-component-registry.js.map +1 -0
  410. package/dist/shared/utils/use-component-styles.d.ts +24 -0
  411. package/dist/shared/utils/use-component-styles.d.ts.map +1 -0
  412. package/dist/shared/utils/use-component-styles.js +69 -0
  413. package/dist/shared/utils/use-component-styles.js.map +1 -0
  414. package/dist/shared/utils/use-defer-loadable.d.ts +8 -0
  415. package/dist/shared/utils/use-defer-loadable.d.ts.map +1 -0
  416. package/dist/shared/utils/use-defer-loadable.js +44 -0
  417. package/dist/shared/utils/use-defer-loadable.js.map +1 -0
  418. package/dist/shared/utils/use-interval.d.ts +9 -0
  419. package/dist/shared/utils/use-interval.d.ts.map +1 -0
  420. package/dist/shared/utils/use-interval.js +19 -0
  421. package/dist/shared/utils/use-interval.js.map +1 -0
  422. package/dist/shared/utils/use-previous.d.ts +10 -0
  423. package/dist/shared/utils/use-previous.d.ts.map +1 -0
  424. package/dist/shared/utils/use-previous.js +17 -0
  425. package/dist/shared/utils/use-previous.js.map +1 -0
  426. package/dist/shared/utils/use-url-sync.d.ts +20 -0
  427. package/dist/shared/utils/use-url-sync.d.ts.map +1 -0
  428. package/dist/shared/utils/use-url-sync.js +68 -0
  429. package/dist/shared/utils/use-url-sync.js.map +1 -0
  430. package/dist/shared/utils/use-window-title.d.ts +3 -0
  431. package/dist/shared/utils/use-window-title.d.ts.map +1 -0
  432. package/dist/shared/utils/use-window-title.js +14 -0
  433. package/dist/shared/utils/use-window-title.js.map +1 -0
  434. package/dist/shared/variable-state-provider/variable-state-provider.d.ts +10 -0
  435. package/dist/shared/variable-state-provider/variable-state-provider.d.ts.map +1 -0
  436. package/dist/shared/variable-state-provider/variable-state-provider.js +29 -0
  437. package/dist/shared/variable-state-provider/variable-state-provider.js.map +1 -0
  438. package/dist/shared/wrapper/wrapper.d.ts +7 -0
  439. package/dist/shared/wrapper/wrapper.d.ts.map +1 -0
  440. package/dist/shared/wrapper/wrapper.js +14 -0
  441. package/dist/shared/wrapper/wrapper.js.map +1 -0
  442. package/dist/types/auth.d.ts +15 -0
  443. package/dist/types/auth.d.ts.map +1 -0
  444. package/dist/types/auth.js +6 -0
  445. package/dist/types/auth.js.map +1 -0
  446. package/dist/types/core.d.ts +440 -0
  447. package/dist/types/core.d.ts.map +1 -0
  448. package/dist/types/core.js +22 -0
  449. package/dist/types/core.js.map +1 -0
  450. package/dist/types/index.d.ts +7 -0
  451. package/dist/types/index.d.ts.map +1 -0
  452. package/dist/types/index.js +4 -0
  453. package/dist/types/index.js.map +1 -0
  454. package/dist/types/utils.d.ts +56 -0
  455. package/dist/types/utils.d.ts.map +1 -0
  456. package/dist/types/utils.js +93 -0
  457. package/dist/types/utils.js.map +1 -0
  458. package/dist/umd/dara.core.umd.js +86508 -0
  459. package/dist/umd/style.css +848 -0
  460. package/dist/utils.d.ts +11 -0
  461. package/dist/utils.d.ts.map +1 -0
  462. package/dist/utils.js +20 -0
  463. package/dist/utils.js.map +1 -0
  464. package/package.json +121 -0
@@ -0,0 +1,314 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { nanoid } from 'nanoid';
11
+ import { useContext, useLayoutEffect, useRef } from 'react';
12
+ import { useHistory, useLocation } from 'react-router-dom';
13
+ import { useRecoilCallback } from 'recoil';
14
+ import { concatMap, takeWhile } from 'rxjs/operators';
15
+ import { useNotifications } from '@darajs/ui-notifications';
16
+ import { HTTP_METHOD, Status, validateResponse } from '@darajs/ui-utils';
17
+ import { fetchTaskResult, handleAuthErrors } from '../../api';
18
+ import { request } from '../../api/http';
19
+ import { ImportersCtx, WebSocketCtx, useRequestExtras, useTaskContext } from '../../shared/context';
20
+ import { isActionImpl } from '../../types/utils';
21
+ import { useEventBus } from '../event-bus/event-bus';
22
+ import { useVariable } from '../interactivity';
23
+ import { getOrRegisterPlainVariable } from '../interactivity/plain-variable';
24
+ import { resolveVariable } from '../interactivity/resolve-variable';
25
+ import { normalizeRequest } from './normalization';
26
+ import useActionRegistry from './use-action-registry';
27
+ /**
28
+ * Invoke a server-side action.
29
+ * This is used for annotated actions, sends a POST request to the server to start an action execution.
30
+ *
31
+ * @param input input value for the action
32
+ * @param executionId unique id for the action execution; this should be used to subscribe to action messages **before** calling fetchAction
33
+ * @param annotatedAction annotated action instance
34
+ * @param actionCtx action context
35
+ */
36
+ function invokeAction(input, executionId, annotatedAction, actionCtx) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ // resolve kwargs to primitives, this registers variables if not already registered
39
+ const resolvedKwargs = Object.keys(annotatedAction.dynamic_kwargs).reduce((acc, k) => {
40
+ const value = annotatedAction.dynamic_kwargs[k];
41
+ acc[k] = resolveVariable(value, actionCtx.wsClient, actionCtx.taskCtx, actionCtx.extras, (v) =>
42
+ // This is only called for primitive variables so it should always resolve successfully
43
+ // hence not using a promise
44
+ actionCtx.snapshot.getLoadable(v).getValue());
45
+ return acc;
46
+ }, {});
47
+ const ws_channel = yield actionCtx.wsClient.getChannel();
48
+ const res = yield request(`/api/core/action/${annotatedAction.definition_uid}`, {
49
+ body: JSON.stringify({
50
+ execution_id: executionId,
51
+ input,
52
+ uid: annotatedAction.uid,
53
+ values: normalizeRequest(resolvedKwargs, annotatedAction.dynamic_kwargs),
54
+ ws_channel,
55
+ }),
56
+ method: HTTP_METHOD.POST,
57
+ }, actionCtx.extras);
58
+ yield handleAuthErrors(res, true);
59
+ yield validateResponse(res, `Failed to fetch the action value with uid: ${annotatedAction.uid}`);
60
+ const resContent = yield res.json();
61
+ // for tasks, wait for it to finish and fetch the result
62
+ // this is only used to pick up errors in the task execution
63
+ if ('task_id' in resContent) {
64
+ const taskId = resContent.task_id;
65
+ actionCtx.taskCtx.startTask(taskId);
66
+ yield actionCtx.wsClient.waitForTask(taskId);
67
+ actionCtx.taskCtx.endTask(taskId);
68
+ // We don't need the result as the MetaTask will send WS messages with actions as per usual
69
+ // fetchTaskResult will pick up on errors and raise them
70
+ yield fetchTaskResult(taskId, actionCtx.extras);
71
+ }
72
+ });
73
+ }
74
+ /**
75
+ * Global cache of action handlers by name. Used for perf so each action will only have to be
76
+ * resolved once.
77
+ */
78
+ const ACTION_HANDLER_BY_NAME = {};
79
+ /**
80
+ * Clear the global action handler cache.
81
+ * This is only used for testing.
82
+ */
83
+ export function clearActionHandlerCache_TEST() {
84
+ Object.keys(ACTION_HANDLER_BY_NAME).forEach((k) => delete ACTION_HANDLER_BY_NAME[k]);
85
+ }
86
+ /**
87
+ * Error thrown when an action is not handled by the app.
88
+ */
89
+ class UnhandledActionError extends Error {
90
+ constructor(message, actionImpl) {
91
+ super(message);
92
+ this.actionImpl = actionImpl;
93
+ }
94
+ }
95
+ /**
96
+ * Resolve an action implementation into an action handler function.
97
+ *
98
+ * @param actionImpl action implementation
99
+ * @param getAction callback to get the action definition from the action implementation
100
+ * @param importers importers available in the app
101
+ */
102
+ function resolveActionImpl(actionImpl, getAction, importers, actionCtx) {
103
+ return __awaiter(this, void 0, void 0, function* () {
104
+ let actionHandler;
105
+ // resolve action handler function by name
106
+ // cache action handler globally for performance, they are pure functions so it's safe to do so
107
+ if (!ACTION_HANDLER_BY_NAME[actionImpl.name]) {
108
+ try {
109
+ const actionDef = getAction(actionImpl);
110
+ const moduleContent = yield importers[actionDef.py_module]();
111
+ actionHandler = moduleContent[actionImpl.name];
112
+ // only cache if we successfully resolved a built-in action handler
113
+ ACTION_HANDLER_BY_NAME[actionImpl.name] = actionHandler;
114
+ }
115
+ catch (_a) {
116
+ // if we failed to resolve the action handler, use the catch-all handler if defined
117
+ if (actionCtx.onUnhandledAction) {
118
+ // this one is explicitly not cached since it's an arbitrary user-defined handler
119
+ actionHandler = actionCtx.onUnhandledAction;
120
+ }
121
+ else {
122
+ throw new UnhandledActionError(`Action definition for impl "${actionImpl.name}" not found`, actionImpl);
123
+ }
124
+ }
125
+ }
126
+ else {
127
+ actionHandler = ACTION_HANDLER_BY_NAME[actionImpl.name];
128
+ }
129
+ return actionHandler;
130
+ });
131
+ }
132
+ /**
133
+ * Execute a given action.
134
+ *
135
+ * @param input component input value
136
+ * @param action action implementation or annotated action
137
+ * @param actionCtx action execution context
138
+ * @param getAction callback to get the action definition from the action implementation
139
+ * @param importers available importers in the app
140
+ */
141
+ function executeAction(input, action, actionCtx, getAction, importers) {
142
+ return __awaiter(this, void 0, void 0, function* () {
143
+ // if it's a simple action implementation, run the handler directly
144
+ if (isActionImpl(action)) {
145
+ const handler = yield resolveActionImpl(action, getAction, importers, actionCtx);
146
+ const result = handler(actionCtx, action);
147
+ // handle async handlers
148
+ if (result instanceof Promise) {
149
+ yield result;
150
+ }
151
+ return;
152
+ }
153
+ // otherwise call back to the server to execute the annotated action
154
+ // subscribe to action messages before even calling the action to avoid races
155
+ const executionId = nanoid();
156
+ const observable = actionCtx.wsClient.actionMessages$(executionId);
157
+ return new Promise((resolve, reject) => {
158
+ let activeTasks = 0; // Counter to keep track of active tasks
159
+ let streamCompleted = false; // Flag to check if the stream is completed
160
+ let isSettled = false;
161
+ let sub;
162
+ const checkForCompletion = () => {
163
+ if (!isSettled && streamCompleted && activeTasks === 0) {
164
+ isSettled = true;
165
+ sub.unsubscribe();
166
+ resolve();
167
+ }
168
+ };
169
+ const onError = (error) => {
170
+ if (!isSettled) {
171
+ isSettled = true;
172
+ sub.unsubscribe();
173
+ reject(error);
174
+ }
175
+ };
176
+ sub = observable
177
+ .pipe(concatMap((actionImpl) => __awaiter(this, void 0, void 0, function* () {
178
+ if (actionImpl) {
179
+ const handler = yield resolveActionImpl(actionImpl, getAction, importers, actionCtx);
180
+ return [handler, actionImpl];
181
+ }
182
+ return null;
183
+ })), takeWhile((res) => !!res) // stop when falsy is returned from concatMap
184
+ )
185
+ .subscribe({
186
+ complete: () => {
187
+ streamCompleted = true; // Set the flag when the stream is complete
188
+ checkForCompletion();
189
+ },
190
+ error: onError, // Reject the promise if there's an error in the stream
191
+ next: (_a) => __awaiter(this, [_a], void 0, function* ([handler, actionImpl]) {
192
+ try {
193
+ activeTasks += 1;
194
+ const result = handler(actionCtx, actionImpl);
195
+ // If it's a promise, await it to ensure sequential execution
196
+ if (result instanceof Promise) {
197
+ yield result;
198
+ }
199
+ }
200
+ catch (error) {
201
+ onError(error);
202
+ }
203
+ finally {
204
+ if (activeTasks > 0) {
205
+ activeTasks -= 1;
206
+ }
207
+ checkForCompletion();
208
+ }
209
+ }),
210
+ });
211
+ // now request the action to be executed
212
+ invokeAction(input, executionId, action, actionCtx).catch(onError);
213
+ });
214
+ });
215
+ }
216
+ const noop = () => Promise.resolve();
217
+ /**
218
+ * The useActionIsLoading hook returns a boolean indicating whether the action is currently in progress. This is
219
+ * currently only supported for single AnnotatedAction instances of actions and will return false in all other cases
220
+ * due to the lack of loading variable to use as a source of truth.
221
+ *
222
+ * @param action - the action to check the loading state of
223
+ * @returns the loading state of the action
224
+ */
225
+ export function useActionIsLoading(action) {
226
+ // We allow conditional logic with hooks here under the assumption that the action will never change during the
227
+ // component lifetime. As ActionImpls have no loading variable we return false. As we expect to deprecate array's
228
+ // of actions in the near future as all the functionality then we return false as well due to the complexity of
229
+ // extracting potentially multiple annotated actions out of the array and resolving all their loading states
230
+ if (!action || isActionImpl(action) || Array.isArray(action)) {
231
+ return false;
232
+ }
233
+ // eslint-disable-next-line react-hooks/rules-of-hooks
234
+ return useVariable(action.loading)[0];
235
+ }
236
+ /**
237
+ * Consume an action def from the framework and return a callback function that can be used to trigger it
238
+ * and a loading state boolean indicating whether an action is currently in progress
239
+ *
240
+ * @param action the action passed in
241
+ * @param options optional extra options for the hook
242
+ */
243
+ export default function useAction(action, options) {
244
+ const { client: wsClient } = useContext(WebSocketCtx);
245
+ const importers = useContext(ImportersCtx);
246
+ const { get: getAction } = useActionRegistry();
247
+ const notificationCtx = useNotifications();
248
+ const extras = useRequestExtras();
249
+ const history = useHistory();
250
+ const taskCtx = useTaskContext();
251
+ const location = useLocation();
252
+ const eventBus = useEventBus();
253
+ // keep actionCtx in a ref to avoid re-creating the callbacks
254
+ const actionCtx = useRef();
255
+ const optionsRef = useRef(options);
256
+ useLayoutEffect(() => {
257
+ actionCtx.current = {
258
+ extras,
259
+ history,
260
+ location,
261
+ notificationCtx,
262
+ taskCtx,
263
+ wsClient,
264
+ eventBus,
265
+ };
266
+ optionsRef.current = options;
267
+ });
268
+ const callback = useRecoilCallback((cbInterface) => (input) => __awaiter(this, void 0, void 0, function* () {
269
+ var _a;
270
+ const actionsToExecute = Array.isArray(action) ? action : [action];
271
+ // execute actions sequentially
272
+ for (const actionToExecute of actionsToExecute) {
273
+ const loadingVariable = !isActionImpl(actionToExecute) ?
274
+ getOrRegisterPlainVariable(actionToExecute.loading, wsClient, taskCtx, extras)
275
+ : null;
276
+ if (loadingVariable) {
277
+ cbInterface.set(loadingVariable, true);
278
+ }
279
+ // this is redefined for each action to have up-to-date snapshot
280
+ const fullActionContext = Object.assign(Object.assign({}, actionCtx.current), { input, onUnhandledAction: (_a = optionsRef.current) === null || _a === void 0 ? void 0 : _a.onUnhandledAction,
281
+ // Recoil callback interface cannot be spread as it is a Proxy
282
+ gotoSnapshot: cbInterface.gotoSnapshot, refresh: cbInterface.refresh, reset: cbInterface.reset, set: cbInterface.set, snapshot: cbInterface.snapshot, transact_UNSTABLE: cbInterface.transact_UNSTABLE });
283
+ try {
284
+ // eslint-disable-next-line no-await-in-loop
285
+ yield executeAction(input, actionToExecute, fullActionContext, getAction, importers);
286
+ }
287
+ catch (error) {
288
+ // Display for easier debugging
289
+ // eslint-disable-next-line no-console
290
+ console.error(error);
291
+ let message = 'Try again or contact the application owner';
292
+ // Display the unhandled action directly as it might be helpful for developers
293
+ if (error instanceof UnhandledActionError) {
294
+ message = error.message;
295
+ }
296
+ actionCtx.current.notificationCtx.pushNotification({
297
+ key: '_actionError', // same key so action errors don't stack
298
+ message,
299
+ status: Status.ERROR,
300
+ title: 'Error executing action',
301
+ });
302
+ }
303
+ if (loadingVariable) {
304
+ cbInterface.set(loadingVariable, false);
305
+ }
306
+ }
307
+ }), [action, getAction, importers]);
308
+ // return a noop if no action is passed
309
+ if (!action) {
310
+ return noop;
311
+ }
312
+ return callback;
313
+ }
314
+ //# sourceMappingURL=use-action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-action.js","sourceRoot":"","sources":["../../../js/shared/utils/use-action.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAqB,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAC1D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C/B,sCAAsC;gBACtC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBAErB,IAAI,OAAO,GAAG,4CAA4C,CAAC;gBAE3D,8EAA8E;gBAC9E,IAAI,KAAK,YAAY,oBAAoB,EAAE,CAAC;oBACxC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;gBAC5B,CAAC;gBAED,SAAS,CAAC,OAAO,CAAC,eAAe,CAAC,gBAAgB,CAAC;oBAC/C,GAAG,EAAE,cAAc,EAAE,wCAAwC;oBAC7D,OAAO;oBACP,MAAM,EAAE,MAAM,CAAC,KAAK;oBACpB,KAAK,EAAE,wBAAwB;iBAClC,CAAC,CAAC;YACP,CAAC;YAED,IAAI,eAAe,EAAE,CAAC;gBAClB,WAAW,CAAC,GAAG,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;YAC5C,CAAC;QACL,CAAC;IACL,CAAC,CAAA,EACD,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC,CACjC,CAAC;IAEF,uCAAuC;IACvC,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { Component, ComponentInstance } from '../../types/core';
2
+ interface ComponentRegistryInterface {
3
+ get: (instance: ComponentInstance) => Promise<Component>;
4
+ }
5
+ /**
6
+ * The component registry pulls the full list of components from the backend and then returns a function that allows a
7
+ * specific component to be requested using it's instance.
8
+ */
9
+ declare function useComponentRegistry(maxRetries?: number): ComponentRegistryInterface;
10
+ export default useComponentRegistry;
11
+ //# sourceMappingURL=use-component-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-component-registry.d.ts","sourceRoot":"","sources":["../../../js/shared/utils/use-component-registry.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE5D,UAAU,0BAA0B;IAChC,GAAG,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;CAC5D;AAED;;;GAGG;AACH,iBAAS,oBAAoB,CAAC,UAAU,SAAI,GAAG,0BAA0B,CA2CxE;AAED,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,57 @@
1
+ /* eslint-disable no-await-in-loop */
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ /* eslint-disable react-hooks/exhaustive-deps */
12
+ import { useCallback, useContext } from 'react';
13
+ import { HTTP_METHOD, validateResponse } from '@darajs/ui-utils';
14
+ import { request } from '../../api';
15
+ import { handleAuthErrors } from '../../auth/auth';
16
+ import { RegistriesCtx, useRequestExtras } from '../../shared/context';
17
+ /**
18
+ * The component registry pulls the full list of components from the backend and then returns a function that allows a
19
+ * specific component to be requested using it's instance.
20
+ */
21
+ function useComponentRegistry(maxRetries = 5) {
22
+ const { componentRegistry: components, refetchComponents } = useContext(RegistriesCtx);
23
+ const extras = useRequestExtras();
24
+ const get = useCallback((instance) => __awaiter(this, void 0, void 0, function* () {
25
+ let component = null;
26
+ let registry = Object.assign({}, components);
27
+ let i = 0;
28
+ while (i < maxRetries) {
29
+ if (registry && registry[instance.name]) {
30
+ component = registry[instance.name];
31
+ break;
32
+ }
33
+ if (i === 0) {
34
+ const res = yield request(`/api/core/components?name=${instance.name}`, { method: HTTP_METHOD.GET }, extras);
35
+ yield handleAuthErrors(res, true);
36
+ yield validateResponse(res, 'Failed to fetch the config for this app');
37
+ registry = yield res.json();
38
+ }
39
+ else {
40
+ // If component has not been found, it could be a nested py_component, so we refetch the registry
41
+ // to see if the component might have been added to the registry in the meantime
42
+ // But first wait for 0,5s before retrying, to give time for backend to update the registry
43
+ yield new Promise((resolve) => setTimeout(resolve, 500));
44
+ const { data } = yield refetchComponents();
45
+ registry = data;
46
+ }
47
+ i++;
48
+ }
49
+ if (!component) {
50
+ throw new Error(`Attempted to load a component (${instance.name}) that is not in the registry`);
51
+ }
52
+ return component;
53
+ }), [components]);
54
+ return { get };
55
+ }
56
+ export default useComponentRegistry;
57
+ //# sourceMappingURL=use-component-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-component-registry.js","sourceRoot":"","sources":["../../../js/shared/utils/use-component-registry.tsx"],"names":[],"mappings":"AAAA,qCAAqC;;;;;;;;;;AAErC,gDAAgD;AAChD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEjE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAOnE;;;GAGG;AACH,SAAS,oBAAoB,CAAC,UAAU,GAAG,CAAC;IACxC,MAAM,EAAE,iBAAiB,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IACvF,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAC;IAClC,MAAM,GAAG,GAAG,WAAW,CACnB,CAAO,QAA2B,EAAsB,EAAE;QACtD,IAAI,SAAS,GAAc,IAAI,CAAC;QAChC,IAAI,QAAQ,qBAAQ,UAAU,CAAE,CAAC;QACjC,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,OAAO,CAAC,GAAG,U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ties which extends to those that are missing React's defined list
5
+ */
6
+ interface CustomCSSProperties extends React.CSSProperties {
7
+ gap?: string;
8
+ }
9
+ /**
10
+ * Parse a raw_css property into styles and css
11
+ *
12
+ * @param rawCss raw css property to parse
13
+ */
14
+ export declare function parseRawCss(rawCss: string | CustomCSSProperties | React.CSSProperties): [rawStyles: CustomCSSProperties, rawCss: string];
15
+ /**
16
+ * Styling utility hook which takes in base styling props and raw_css
17
+ * Outputs `style` and `css` properties to inject into the top-level component
18
+ *
19
+ * @param props props to get styles from
20
+ * @param useDisplayContext whether or not to use the display context, for some components such as Modal, these do not care for the context of their parent
21
+ */
22
+ export default function useComponentStyles(props: StyledComponentProps, useDisplayContext?: boolean): [CustomCSSProperties, string];
23
+ export {};
24
+ //# sourceMappingURL=use-component-styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-component-styles.d.ts","sourceRoot":"","sources":["../../../js/shared/utils/use-component-styles.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAQ/C;;GAEG;AACH,UAAU,mBAAoB,SAAQ,KAAK,CAAC,aAAa;IACrD,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AAsCD;;;;GAIG;AACH,wBAAgB,WAAW,CACvB,MAAM,EAAE,MAAM,GAAG,mBAAmB,GAAG,KAAK,CAAC,aAAa,GAC3D,CAAC,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,CAAC,CAOlD;AAED;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACtC,KAAK,EAAE,oBAAoB,EAC3B,iBAAiB,UAAO,GACzB,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAoC/B"}
@@ -0,0 +1,69 @@
1
+ /* eslint-disable react-hooks/exhaustive-deps */
2
+ import { useContext, useMemo } from 'react';
3
+ import { useDeepCompare } from '@darajs/ui-utils';
4
+ import { default as DisplayCtx } from '../../shared/context/display-context';
5
+ /**
6
+ * Sets the flex property of a component based on props passed to it
7
+ *
8
+ * @param props the props passed to the component
9
+ * @param displayCtx the display context of the component, contains the parent layout context
10
+ * @param useDisplayContext whether or not to consider width/height in conjunction with displayCtx for some components such as Modal, these do not care for the context of their parent
11
+ */
12
+ function flexStyles(props, displayCtx, useDisplayContext) {
13
+ let flexBasis = props.basis;
14
+ let flexShrink = props.shrink;
15
+ let flexGrow = props.grow;
16
+ if (useDisplayContext) {
17
+ // In a horizontal Stack setting the width should also set the flex-basis
18
+ if (props.width && displayCtx.direction === 'horizontal') {
19
+ flexBasis !== null && flexBasis !== void 0 ? flexBasis : (flexBasis = props.width);
20
+ flexShrink !== null && flexShrink !== void 0 ? flexShrink : (flexShrink = '0');
21
+ flexGrow !== null && flexGrow !== void 0 ? flexGrow : (flexGrow = '0');
22
+ }
23
+ // In a vertical Stack setting the height should also set the flex-basis
24
+ if (props.height && displayCtx.direction === 'vertical') {
25
+ flexBasis !== null && flexBasis !== void 0 ? flexBasis : (flexBasis = props.height);
26
+ flexShrink !== null && flexShrink !== void 0 ? flexShrink : (flexShrink = '0');
27
+ flexGrow !== null && flexGrow !== void 0 ? flexGrow : (flexGrow = '0');
28
+ }
29
+ }
30
+ // If hug is set, then the flex-basis should be set to content
31
+ // Otherwise we check if the parent is a component that has hug set to true, and its children should inherit
32
+ if (props.hug || (props.hug !== false && displayCtx.hug)) {
33
+ flexBasis !== null && flexBasis !== void 0 ? flexBasis : (flexBasis = 'content');
34
+ flexShrink !== null && flexShrink !== void 0 ? flexShrink : (flexShrink = '1');
35
+ flexGrow !== null && flexGrow !== void 0 ? flexGrow : (flexGrow = '0');
36
+ }
37
+ return { flexBasis, flexGrow, flexShrink };
38
+ }
39
+ /**
40
+ * Parse a raw_css property into styles and css
41
+ *
42
+ * @param rawCss raw css property to parse
43
+ */
44
+ export function parseRawCss(rawCss) {
45
+ const isRawObject = typeof rawCss === 'object' && rawCss !== null && rawCss !== undefined;
46
+ const componentCss = !isRawObject && typeof rawCss === 'string' ? rawCss : '';
47
+ const styles = isRawObject ? rawCss : {};
48
+ return [styles, componentCss];
49
+ }
50
+ /**
51
+ * Styling utility hook which takes in base styling props and raw_css
52
+ * Outputs `style` and `css` properties to inject into the top-level component
53
+ *
54
+ * @param props props to get styles from
55
+ * @param useDisplayContext whether or not to use the display context, for some components such as Modal, these do not care for the context of their parent
56
+ */
57
+ export default function useComponentStyles(props, useDisplayContext = true) {
58
+ const [rawStyles, rawCss] = parseRawCss(props.raw_css);
59
+ const displayCtx = useContext(DisplayCtx);
60
+ const flexProps = flexStyles(props, displayCtx, useDisplayContext);
61
+ const styles = useMemo(() => {
62
+ var _a;
63
+ const stylesObj = Object.assign(Object.assign(Object.assign({ backgroundColor: props.background, border: props.border, borderRadius: props.border_radius, color: props.color, fontFamily: props.font, fontSize: props.font_size, fontStyle: props.italic ? 'italic' : 'normal', fontWeight: props.bold ? 'bold' : 'normal', gap: props.gap, height: props.height, margin: props.margin, maxHeight: props.max_height, maxWidth: props.max_width, minHeight: props.min_height, minWidth: props.min_width, overflow: props.overflow, padding: props.padding, position: props.position, textDecoration: props.underline ? 'underline' : 'none', width: props.width }, flexProps), rawStyles), ((_a = props.style) !== null && _a !== void 0 ? _a : {}));
64
+ // Filter out null/undefined values so they don't end up accidentally overriding other style properties
65
+ return Object.fromEntries(Object.entries(stylesObj).filter(([, v]) => v !== null && v !== undefined));
66
+ }, [useDeepCompare(props)]);
67
+ return [styles, rawCss];
68
+ }
69
+ //# sourceMappingURL=use-component-styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-component-styles.js","sourceRoot":"","sources":["../../../js/shared/utils/use-component-styles.tsx"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAG5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,OAAO,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,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAC7C,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,EAC1C,GAAG,EAAE,KAAK,CAAC,GAAG,EACd,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,SAAS,EAAE,KAAK,CAAC,UAAU,EAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,SAAS,EAAE,KAAK,CAAC,UAAU,EAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,cAAc,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,EACtD,KAAK,EAAE,KAAK,CAAC,KAAK,IACf,SAAS,GACT,SAAS,GACT,CAAC,MAAA,KAAK,CAAC,KAAK,mCAAI,EAAE,CAAC,CACzB,CAAC;QAEF,uGAAuG;QACvG,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC;IAC1G,CAAC,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE5B,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { Loadable } from 'recoil';
2
+ /**
3
+ * A hook that allows you to defer the loading of a loadable depending on the suspend setting in FallbackCtx.
4
+ *
5
+ * @param loadable The loadable to defer
6
+ */
7
+ export default function useDeferLoadable<T>(loadable: Loadable<T>): T;
8
+ //# sourceMappingURL=use-defer-loadable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-defer-loadable.d.ts","sourceRoot":"","sources":["../../../js/shared/utils/use-defer-loadable.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAIlC;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CA0CpE"}
@@ -0,0 +1,44 @@
1
+ import { useContext, useEffect, useRef, useState } from 'react';
2
+ import { FallbackCtx } from '../../shared/context';
3
+ /**
4
+ * A hook that allows you to defer the loading of a loadable depending on the suspend setting in FallbackCtx.
5
+ *
6
+ * @param loadable The loadable to defer
7
+ */
8
+ export default function useDeferLoadable(loadable) {
9
+ const { suspend } = useContext(FallbackCtx);
10
+ // Suspend on first render with getValue()
11
+ const [availableState, setAvailableState] = useState(() => loadable.getValue());
12
+ const timerId = useRef(null);
13
+ const isFirstRender = useRef(true);
14
+ const [showFallback, setShowFallback] = useState(false);
15
+ useEffect(() => {
16
+ // Skip the first render, as we're suspending anyway
17
+ if (isFirstRender.current) {
18
+ isFirstRender.current = false;
19
+ return;
20
+ }
21
+ // when the selector becomes loading, set a timeout if suspend is a number to switch to suspend mode
22
+ if (loadable.state === 'loading' && typeof suspend === 'number') {
23
+ timerId.current = setTimeout(() => {
24
+ setShowFallback(true);
25
+ }, suspend);
26
+ }
27
+ return () => {
28
+ clearTimeout(timerId.current);
29
+ };
30
+ }, [loadable.state, suspend]);
31
+ useEffect(() => {
32
+ if (loadable.state === 'hasValue') {
33
+ clearTimeout(timerId.current);
34
+ setShowFallback(false);
35
+ setAvailableState(loadable.valueOrThrow());
36
+ }
37
+ }, [loadable]);
38
+ // Suspend
39
+ if (suspend === true || showFallback) {
40
+ return loadable.getValue();
41
+ }
42
+ return availableState;
43
+ }
44
+ //# sourceMappingURL=use-defer-loadable.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AK,EAAE,OAAO,CAAC,CAAC,CAAC;IAE9B,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,QAAQ,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;YAChC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC9B,eAAe,CAAC,KAAK,CAAC,CAAC;YACvB,iBAAiB,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC;QAC/C,CAAC;IACL,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,UAAU;IACV,IAAI,OAAO,KAAK,IAAI,IAAI,YAAY,EAAE,CAAC;QACnC,OAAO,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAC/B,CAAC;IAED,OAAO,cAAc,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Helper hook that runs a function after given intervals
3
+ *
4
+ * @param callback the function to run after each interval
5
+ * @param delay the delay in seconds between each interval
6
+ */
7
+ declare function useInterval(callback: () => void, delay: number): void;
8
+ export default useInterval;
9
+ //# sourceMappingURL=use-interval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-interval.d.ts","sourceRoot":"","sources":["../../../js/shared/utils/use-interval.tsx"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,iBAAS,WAAW,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAU9D;AAED,eAAe,WAAW,CAAC"}
@@ -0,0 +1,19 @@
1
+ /* eslint-disable react-hooks/exhaustive-deps */
2
+ import { useEffect } from 'react';
3
+ import { useDeepCompare } from '@darajs/ui-utils';
4
+ /**
5
+ * Helper hook that runs a function after given intervals
6
+ *
7
+ * @param callback the function to run after each interval
8
+ * @param delay the delay in seconds between each interval
9
+ */
10
+ function useInterval(callback, delay) {
11
+ useEffect(() => {
12
+ if (delay) {
13
+ const id = setInterval(callback, delay * 1000);
14
+ return () => clearInterval(id);
15
+ }
16
+ }, useDeepCompare([delay, callback]));
17
+ }
18
+ export default useInterval;
19
+ //# sourceMappingURL=use-interval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-interval.js","sourceRoot":"","sources":["../../../js/shared/utils/use-interval.tsx"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;;GAKG;AACH,SAAS,WAAW,CAAC,QAAoB,EAAE,KAAa;IACpD,SAAS,CACL,GAAG,EAAE;QACD,IAAI,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,GAAG,WAAW,CAAC,QAAQ,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC;YAC/C,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QACnC,CAAC;IACL,CAAC,EACD,cAAc,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CACpC,CAAC;AACN,CAAC;AAED,eAAe,WAAW,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * A helper hook to keep track of the previous value of a variable.
3
+ * Uses a `ref` underneath so does not cause additional re-renders.
4
+ *
5
+ * @param value value to keep track of
6
+ * @param initialValue initial value
7
+ */
8
+ declare function usePrevious<T>(value: T, initialValue: T): T;
9
+ export default usePrevious;
10
+ //# sourceMappingURL=use-previous.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-previous.d.ts","sourceRoot":"","sources":["../../../js/shared/utils/use-previous.tsx"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,iBAAS,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,CAMpD;AAED,eAAe,WAAW,CAAC"}