@darajs/components 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 (302) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +37 -0
  3. package/dist/common/accordion/accordion.d.ts +17 -0
  4. package/dist/common/accordion/accordion.d.ts.map +1 -0
  5. package/dist/common/accordion/accordion.js +36 -0
  6. package/dist/common/accordion/accordion.js.map +1 -0
  7. package/dist/common/anchor/anchor.d.ts +17 -0
  8. package/dist/common/anchor/anchor.d.ts.map +1 -0
  9. package/dist/common/anchor/anchor.js +40 -0
  10. package/dist/common/anchor/anchor.js.map +1 -0
  11. package/dist/common/bullet-list/bullet_list.d.ts +16 -0
  12. package/dist/common/bullet-list/bullet_list.d.ts.map +1 -0
  13. package/dist/common/bullet-list/bullet_list.js +17 -0
  14. package/dist/common/bullet-list/bullet_list.js.map +1 -0
  15. package/dist/common/button/button.d.ts +27 -0
  16. package/dist/common/button/button.d.ts.map +1 -0
  17. package/dist/common/button/button.js +47 -0
  18. package/dist/common/button/button.js.map +1 -0
  19. package/dist/common/button-bar/button-bar.d.ts +22 -0
  20. package/dist/common/button-bar/button-bar.d.ts.map +1 -0
  21. package/dist/common/button-bar/button-bar.js +27 -0
  22. package/dist/common/button-bar/button-bar.js.map +1 -0
  23. package/dist/common/card/card.d.ts +24 -0
  24. package/dist/common/card/card.d.ts.map +1 -0
  25. package/dist/common/card/card.js +58 -0
  26. package/dist/common/card/card.js.map +1 -0
  27. package/dist/common/carousel/carousel.d.ts +27 -0
  28. package/dist/common/carousel/carousel.d.ts.map +1 -0
  29. package/dist/common/carousel/carousel.js +42 -0
  30. package/dist/common/carousel/carousel.js.map +1 -0
  31. package/dist/common/checkbox-group/checkbox-group.d.ts +24 -0
  32. package/dist/common/checkbox-group/checkbox-group.d.ts.map +1 -0
  33. package/dist/common/checkbox-group/checkbox-group.js +37 -0
  34. package/dist/common/checkbox-group/checkbox-group.js.map +1 -0
  35. package/dist/common/code/code.d.ts +12 -0
  36. package/dist/common/code/code.d.ts.map +1 -0
  37. package/dist/common/code/code.js +11 -0
  38. package/dist/common/code/code.js.map +1 -0
  39. package/dist/common/component-select-list/component-select-list.d.ts +23 -0
  40. package/dist/common/component-select-list/component-select-list.d.ts.map +1 -0
  41. package/dist/common/component-select-list/component-select-list.js +29 -0
  42. package/dist/common/component-select-list/component-select-list.js.map +1 -0
  43. package/dist/common/constants.d.ts +19 -0
  44. package/dist/common/constants.d.ts.map +1 -0
  45. package/dist/common/constants.js +21 -0
  46. package/dist/common/constants.js.map +1 -0
  47. package/dist/common/context/form-context.d.ts +20 -0
  48. package/dist/common/context/form-context.d.ts.map +1 -0
  49. package/dist/common/context/form-context.js +28 -0
  50. package/dist/common/context/form-context.js.map +1 -0
  51. package/dist/common/context/index.d.ts +2 -0
  52. package/dist/common/context/index.d.ts.map +1 -0
  53. package/dist/common/context/index.js +2 -0
  54. package/dist/common/context/index.js.map +1 -0
  55. package/dist/common/datepicker/datepicker.d.ts +31 -0
  56. package/dist/common/datepicker/datepicker.d.ts.map +1 -0
  57. package/dist/common/datepicker/datepicker.js +70 -0
  58. package/dist/common/datepicker/datepicker.js.map +1 -0
  59. package/dist/common/dropzone/dropzone.d.ts +21 -0
  60. package/dist/common/dropzone/dropzone.d.ts.map +1 -0
  61. package/dist/common/dropzone/dropzone.js +101 -0
  62. package/dist/common/dropzone/dropzone.js.map +1 -0
  63. package/dist/common/form/form.d.ts +11 -0
  64. package/dist/common/form/form.d.ts.map +1 -0
  65. package/dist/common/form/form.js +46 -0
  66. package/dist/common/form/form.js.map +1 -0
  67. package/dist/common/form-page/form-page.d.ts +12 -0
  68. package/dist/common/form-page/form-page.d.ts.map +1 -0
  69. package/dist/common/form-page/form-page.js +18 -0
  70. package/dist/common/form-page/form-page.js.map +1 -0
  71. package/dist/common/grid/column.d.ts +20 -0
  72. package/dist/common/grid/column.d.ts.map +1 -0
  73. package/dist/common/grid/column.js +22 -0
  74. package/dist/common/grid/column.js.map +1 -0
  75. package/dist/common/grid/grid.d.ts +18 -0
  76. package/dist/common/grid/grid.d.ts.map +1 -0
  77. package/dist/common/grid/grid.js +31 -0
  78. package/dist/common/grid/grid.js.map +1 -0
  79. package/dist/common/grid/row.d.ts +22 -0
  80. package/dist/common/grid/row.d.ts.map +1 -0
  81. package/dist/common/grid/row.js +236 -0
  82. package/dist/common/grid/row.js.map +1 -0
  83. package/dist/common/heading/heading.d.ts +9 -0
  84. package/dist/common/heading/heading.d.ts.map +1 -0
  85. package/dist/common/heading/heading.js +14 -0
  86. package/dist/common/heading/heading.js.map +1 -0
  87. package/dist/common/html-raw/html-raw.d.ts +15 -0
  88. package/dist/common/html-raw/html-raw.d.ts.map +1 -0
  89. package/dist/common/html-raw/html-raw.js +22 -0
  90. package/dist/common/html-raw/html-raw.js.map +1 -0
  91. package/dist/common/icon/icon.d.ts +8 -0
  92. package/dist/common/icon/icon.d.ts.map +1 -0
  93. package/dist/common/icon/icon.js +11 -0
  94. package/dist/common/icon/icon.js.map +1 -0
  95. package/dist/common/if/if.d.ts +27 -0
  96. package/dist/common/if/if.d.ts.map +1 -0
  97. package/dist/common/if/if.js +53 -0
  98. package/dist/common/if/if.js.map +1 -0
  99. package/dist/common/image/image.d.ts +15 -0
  100. package/dist/common/image/image.d.ts.map +1 -0
  101. package/dist/common/image/image.js +19 -0
  102. package/dist/common/image/image.js.map +1 -0
  103. package/dist/common/index.d.ts +43 -0
  104. package/dist/common/index.d.ts.map +1 -0
  105. package/dist/common/index.js +41 -0
  106. package/dist/common/index.js.map +1 -0
  107. package/dist/common/input/input.d.ts +20 -0
  108. package/dist/common/input/input.d.ts.map +1 -0
  109. package/dist/common/input/input.js +57 -0
  110. package/dist/common/input/input.js.map +1 -0
  111. package/dist/common/label/label.d.ts +21 -0
  112. package/dist/common/label/label.d.ts.map +1 -0
  113. package/dist/common/label/label.js +30 -0
  114. package/dist/common/label/label.js.map +1 -0
  115. package/dist/common/markdown/markdown.d.ts +17 -0
  116. package/dist/common/markdown/markdown.d.ts.map +1 -0
  117. package/dist/common/markdown/markdown.js +19 -0
  118. package/dist/common/markdown/markdown.js.map +1 -0
  119. package/dist/common/modal/modal.d.ts +15 -0
  120. package/dist/common/modal/modal.d.ts.map +1 -0
  121. package/dist/common/modal/modal.js +19 -0
  122. package/dist/common/modal/modal.js.map +1 -0
  123. package/dist/common/overlay/overlay.d.ts +16 -0
  124. package/dist/common/overlay/overlay.d.ts.map +1 -0
  125. package/dist/common/overlay/overlay.js +31 -0
  126. package/dist/common/overlay/overlay.js.map +1 -0
  127. package/dist/common/paragraph/paragraph.d.ts +9 -0
  128. package/dist/common/paragraph/paragraph.d.ts.map +1 -0
  129. package/dist/common/paragraph/paragraph.js +10 -0
  130. package/dist/common/paragraph/paragraph.js.map +1 -0
  131. package/dist/common/progress-bar/progress-bar.d.ts +17 -0
  132. package/dist/common/progress-bar/progress-bar.d.ts.map +1 -0
  133. package/dist/common/progress-bar/progress-bar.js +23 -0
  134. package/dist/common/progress-bar/progress-bar.js.map +1 -0
  135. package/dist/common/radio-group/radio-group.d.ts +21 -0
  136. package/dist/common/radio-group/radio-group.d.ts.map +1 -0
  137. package/dist/common/radio-group/radio-group.js +30 -0
  138. package/dist/common/radio-group/radio-group.js.map +1 -0
  139. package/dist/common/select/select.d.ts +31 -0
  140. package/dist/common/select/select.d.ts.map +1 -0
  141. package/dist/common/select/select.js +129 -0
  142. package/dist/common/select/select.js.map +1 -0
  143. package/dist/common/slider/slider.d.ts +29 -0
  144. package/dist/common/slider/slider.d.ts.map +1 -0
  145. package/dist/common/slider/slider.js +38 -0
  146. package/dist/common/slider/slider.js.map +1 -0
  147. package/dist/common/spacer/spacer.d.ts +10 -0
  148. package/dist/common/spacer/spacer.d.ts.map +1 -0
  149. package/dist/common/spacer/spacer.js +30 -0
  150. package/dist/common/spacer/spacer.js.map +1 -0
  151. package/dist/common/stack/stack.d.ts +12 -0
  152. package/dist/common/stack/stack.d.ts.map +1 -0
  153. package/dist/common/stack/stack.js +42 -0
  154. package/dist/common/stack/stack.js.map +1 -0
  155. package/dist/common/switch/switch.d.ts +14 -0
  156. package/dist/common/switch/switch.d.ts.map +1 -0
  157. package/dist/common/switch/switch.js +31 -0
  158. package/dist/common/switch/switch.js.map +1 -0
  159. package/dist/common/tabbed-card/tabbed-card.d.ts +24 -0
  160. package/dist/common/tabbed-card/tabbed-card.d.ts.map +1 -0
  161. package/dist/common/tabbed-card/tabbed-card.js +62 -0
  162. package/dist/common/tabbed-card/tabbed-card.js.map +1 -0
  163. package/dist/common/table/cells/adaptive-precision-cell.d.ts +9 -0
  164. package/dist/common/table/cells/adaptive-precision-cell.d.ts.map +1 -0
  165. package/dist/common/table/cells/adaptive-precision-cell.js +30 -0
  166. package/dist/common/table/cells/adaptive-precision-cell.js.map +1 -0
  167. package/dist/common/table/cells/badge-formatter-cell.d.ts +19 -0
  168. package/dist/common/table/cells/badge-formatter-cell.d.ts.map +1 -0
  169. package/dist/common/table/cells/badge-formatter-cell.js +18 -0
  170. package/dist/common/table/cells/badge-formatter-cell.js.map +1 -0
  171. package/dist/common/table/cells/code-cell.d.ts +12 -0
  172. package/dist/common/table/cells/code-cell.d.ts.map +1 -0
  173. package/dist/common/table/cells/code-cell.js +19 -0
  174. package/dist/common/table/cells/code-cell.js.map +1 -0
  175. package/dist/common/table/cells/compare-cell.d.ts +13 -0
  176. package/dist/common/table/cells/compare-cell.d.ts.map +1 -0
  177. package/dist/common/table/cells/compare-cell.js +34 -0
  178. package/dist/common/table/cells/compare-cell.js.map +1 -0
  179. package/dist/common/table/cells/formatted-text-cell.d.ts +9 -0
  180. package/dist/common/table/cells/formatted-text-cell.d.ts.map +1 -0
  181. package/dist/common/table/cells/formatted-text-cell.js +15 -0
  182. package/dist/common/table/cells/formatted-text-cell.js.map +1 -0
  183. package/dist/common/table/cells/index.d.ts +11 -0
  184. package/dist/common/table/cells/index.d.ts.map +1 -0
  185. package/dist/common/table/cells/index.js +11 -0
  186. package/dist/common/table/cells/index.js.map +1 -0
  187. package/dist/common/table/cells/link-cell.d.ts +10 -0
  188. package/dist/common/table/cells/link-cell.d.ts.map +1 -0
  189. package/dist/common/table/cells/link-cell.js +15 -0
  190. package/dist/common/table/cells/link-cell.js.map +1 -0
  191. package/dist/common/table/cells/number-cell.d.ts +11 -0
  192. package/dist/common/table/cells/number-cell.d.ts.map +1 -0
  193. package/dist/common/table/cells/number-cell.js +16 -0
  194. package/dist/common/table/cells/number-cell.js.map +1 -0
  195. package/dist/common/table/cells/number-intl-cell.d.ts +11 -0
  196. package/dist/common/table/cells/number-intl-cell.d.ts.map +1 -0
  197. package/dist/common/table/cells/number-intl-cell.js +16 -0
  198. package/dist/common/table/cells/number-intl-cell.js.map +1 -0
  199. package/dist/common/table/cells/percentage-cell.d.ts +11 -0
  200. package/dist/common/table/cells/percentage-cell.d.ts.map +1 -0
  201. package/dist/common/table/cells/percentage-cell.js +16 -0
  202. package/dist/common/table/cells/percentage-cell.js.map +1 -0
  203. package/dist/common/table/cells/threshold-formatted-cell.d.ts +15 -0
  204. package/dist/common/table/cells/threshold-formatted-cell.d.ts.map +1 -0
  205. package/dist/common/table/cells/threshold-formatted-cell.js +20 -0
  206. package/dist/common/table/cells/threshold-formatted-cell.js.map +1 -0
  207. package/dist/common/table/table.d.ts +60 -0
  208. package/dist/common/table/table.d.ts.map +1 -0
  209. package/dist/common/table/table.js +456 -0
  210. package/dist/common/table/table.js.map +1 -0
  211. package/dist/common/text/text.d.ts +12 -0
  212. package/dist/common/text/text.d.ts.map +1 -0
  213. package/dist/common/text/text.js +23 -0
  214. package/dist/common/text/text.js.map +1 -0
  215. package/dist/common/textarea/textarea.d.ts +19 -0
  216. package/dist/common/textarea/textarea.d.ts.map +1 -0
  217. package/dist/common/textarea/textarea.js +42 -0
  218. package/dist/common/textarea/textarea.js.map +1 -0
  219. package/dist/common/tooltip/tooltip.d.ts +18 -0
  220. package/dist/common/tooltip/tooltip.d.ts.map +1 -0
  221. package/dist/common/tooltip/tooltip.js +18 -0
  222. package/dist/common/tooltip/tooltip.js.map +1 -0
  223. package/dist/common/types.d.ts +26 -0
  224. package/dist/common/types.d.ts.map +1 -0
  225. package/dist/common/types.js +9 -0
  226. package/dist/common/types.js.map +1 -0
  227. package/dist/dara_components-0.4.8-py3-none-any.whl +0 -0
  228. package/dist/graphs/causal-graph-viewer.d.ts +55 -0
  229. package/dist/graphs/causal-graph-viewer.d.ts.map +1 -0
  230. package/dist/graphs/causal-graph-viewer.js +44 -0
  231. package/dist/graphs/causal-graph-viewer.js.map +1 -0
  232. package/dist/graphs/graph-layout.d.ts +65 -0
  233. package/dist/graphs/graph-layout.d.ts.map +1 -0
  234. package/dist/graphs/graph-layout.js +152 -0
  235. package/dist/graphs/graph-layout.js.map +1 -0
  236. package/dist/graphs/index.d.ts +8 -0
  237. package/dist/graphs/index.d.ts.map +1 -0
  238. package/dist/graphs/index.js +6 -0
  239. package/dist/graphs/index.js.map +1 -0
  240. package/dist/graphs/node-hierarchy-builder.d.ts +24 -0
  241. package/dist/graphs/node-hierarchy-builder.d.ts.map +1 -0
  242. package/dist/graphs/node-hierarchy-builder.js +40 -0
  243. package/dist/graphs/node-hierarchy-builder.js.map +1 -0
  244. package/dist/graphs/utils.d.ts +10 -0
  245. package/dist/graphs/utils.d.ts.map +1 -0
  246. package/dist/graphs/utils.js +31 -0
  247. package/dist/graphs/utils.js.map +1 -0
  248. package/dist/graphs/visual-edge-encoder.d.ts +38 -0
  249. package/dist/graphs/visual-edge-encoder.d.ts.map +1 -0
  250. package/dist/graphs/visual-edge-encoder.js +94 -0
  251. package/dist/graphs/visual-edge-encoder.js.map +1 -0
  252. package/dist/index.d.ts +5 -0
  253. package/dist/index.d.ts.map +1 -0
  254. package/dist/index.js +5 -0
  255. package/dist/index.js.map +1 -0
  256. package/dist/plotting/bokeh/bokeh.d.ts +28 -0
  257. package/dist/plotting/bokeh/bokeh.d.ts.map +1 -0
  258. package/dist/plotting/bokeh/bokeh.js +125 -0
  259. package/dist/plotting/bokeh/bokeh.js.map +1 -0
  260. package/dist/plotting/index.d.ts +4 -0
  261. package/dist/plotting/index.d.ts.map +1 -0
  262. package/dist/plotting/index.js +5 -0
  263. package/dist/plotting/index.js.map +1 -0
  264. package/dist/plotting/matplotlib/matplotlib.d.ts +12 -0
  265. package/dist/plotting/matplotlib/matplotlib.d.ts.map +1 -0
  266. package/dist/plotting/matplotlib/matplotlib.js +14 -0
  267. package/dist/plotting/matplotlib/matplotlib.js.map +1 -0
  268. package/dist/plotting/plotly/plotly.d.ts +60 -0
  269. package/dist/plotting/plotly/plotly.d.ts.map +1 -0
  270. package/dist/plotting/plotly/plotly.js +235 -0
  271. package/dist/plotting/plotly/plotly.js.map +1 -0
  272. package/dist/smart/chat/chat.d.ts +16 -0
  273. package/dist/smart/chat/chat.d.ts.map +1 -0
  274. package/dist/smart/chat/chat.js +174 -0
  275. package/dist/smart/chat/chat.js.map +1 -0
  276. package/dist/smart/code-editor.d.ts +12 -0
  277. package/dist/smart/code-editor.d.ts.map +1 -0
  278. package/dist/smart/code-editor.js +15 -0
  279. package/dist/smart/code-editor.js.map +1 -0
  280. package/dist/smart/data-slicer-filter/data-slicer-filter.d.ts +47 -0
  281. package/dist/smart/data-slicer-filter/data-slicer-filter.d.ts.map +1 -0
  282. package/dist/smart/data-slicer-filter/data-slicer-filter.js +124 -0
  283. package/dist/smart/data-slicer-filter/data-slicer-filter.js.map +1 -0
  284. package/dist/smart/filter-status-button/filter-status-button.d.ts +14 -0
  285. package/dist/smart/filter-status-button/filter-status-button.d.ts.map +1 -0
  286. package/dist/smart/filter-status-button/filter-status-button.js +49 -0
  287. package/dist/smart/filter-status-button/filter-status-button.js.map +1 -0
  288. package/dist/smart/hierarchy-selector/hierarchy-selector.d.ts +23 -0
  289. package/dist/smart/hierarchy-selector/hierarchy-selector.d.ts.map +1 -0
  290. package/dist/smart/hierarchy-selector/hierarchy-selector.js +17 -0
  291. package/dist/smart/hierarchy-selector/hierarchy-selector.js.map +1 -0
  292. package/dist/smart/hierarchy-viewer/hierarchy-viewer.d.ts +16 -0
  293. package/dist/smart/hierarchy-viewer/hierarchy-viewer.d.ts.map +1 -0
  294. package/dist/smart/hierarchy-viewer/hierarchy-viewer.js +17 -0
  295. package/dist/smart/hierarchy-viewer/hierarchy-viewer.js.map +1 -0
  296. package/dist/smart/index.d.ts +7 -0
  297. package/dist/smart/index.d.ts.map +1 -0
  298. package/dist/smart/index.js +8 -0
  299. package/dist/smart/index.js.map +1 -0
  300. package/dist/umd/dara.components.umd.js +387222 -0
  301. package/dist/umd/style.css +745 -0
  302. package/package.json +87 -0
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Based on a color string, return the color from the theme if it starts with 'theme.'
3
+ *
4
+ * @param theme the currently active theme
5
+ * @param colorString the string passed to the color property
6
+ */
7
+ function getThemeColor(theme, colorString) {
8
+ if (colorString.startsWith('theme')) {
9
+ return theme.colors[colorString.replace('theme.', '')];
10
+ }
11
+ return colorString;
12
+ }
13
+ /**
14
+ * Tranform the color properties of a legend object to use the theme colors if necessary
15
+ *
16
+ * @param theme the currently active theme
17
+ * @param legend a legend object
18
+ */
19
+ export function transformLegendColor(theme, legend) {
20
+ if (legend.type === 'edge') {
21
+ const transformedLegend = Object.assign(Object.assign({}, legend), { color: getThemeColor(theme, legend === null || legend === void 0 ? void 0 : legend.color) });
22
+ return transformedLegend;
23
+ }
24
+ if (legend.type === 'node') {
25
+ const transformedLegend = Object.assign(Object.assign({}, legend), { color: getThemeColor(theme, legend === null || legend === void 0 ? void 0 : legend.color), highlight_color: getThemeColor(theme, legend === null || legend === void 0 ? void 0 : legend.highlight_color) });
26
+ return transformedLegend;
27
+ }
28
+ // For 'spacer' we don't need to transform anything
29
+ return legend;
30
+ }
31
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../js/graphs/utils.tsx"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,SAAS,aAAa,CAAC,KAAmB,EAAE,WAAmB;IAC3D,IAAI,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAClC,OAAO,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAiC,CAAC,CAAC;IAC3F,CAAC;IACD,OAAO,WAAW,CAAC;AACvB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAmB,EAAE,MAA6B;IACnF,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACzB,MAAM,iBAAiB,mCAChB,MAAM,KACT,KAAK,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,GAC7C,CAAC;QACF,OAAO,iBAAiB,CAAC;IAC7B,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACzB,MAAM,iBAAiB,mCAChB,MAAM,KACT,KAAK,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,EAC1C,eAAe,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,eAAe,CAAC,GACjE,CAAC;QACF,OAAO,iBAAiB,CAAC;IAC7B,CAAC;IACD,mDAAmD;IACnD,OAAO,MAAM,CAAC;AAClB,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { Action, StyledComponentProps, Variable } from '@darajs/core';
2
+ import { CausalGraphNode, EdgeConstraint, EditorMode, GraphLegendDefinition, ZoomThresholds } from '@darajs/ui-causal-graph-editor';
3
+ import { GraphLayoutDefinition } from './graph-layout';
4
+ interface VisualEdgeEncoderProps extends StyledComponentProps {
5
+ /** Optional additional legends to show */
6
+ additional_legends?: GraphLegendDefinition[];
7
+ /** Whether to allow node/edge selection even when editable = false */
8
+ allow_selection_when_not_editable?: boolean;
9
+ /** Default legends dict for each editor mode available */
10
+ default_legends?: Record<EditorMode, GraphLegendDefinition[]>;
11
+ /** Allow editing */
12
+ editable?: boolean;
13
+ /** Graph layout definition object */
14
+ graph_layout: GraphLayoutDefinition;
15
+ /** Edge constraints to show */
16
+ initial_constraints?: Variable<EdgeConstraint[]> | EdgeConstraint[];
17
+ /** Available nodes */
18
+ nodes: Variable<string[] | Record<string, CausalGraphNode>> | string[] | Record<string, CausalGraphNode>;
19
+ /** Action def for clicking on an edge in the graph */
20
+ on_click_edge?: Action;
21
+ /** Action def for clicking on a node in the graph */
22
+ on_click_node?: Action;
23
+ /** Handler called whenever constraints are updated */
24
+ on_update?: Action;
25
+ /** Whether focusing the graph is required before mousewheel zooming is enabled */
26
+ require_focus_to_zoom?: boolean;
27
+ /** Optional parameter to force a tooltip to use a particular font size */
28
+ tooltip_size?: number;
29
+ /** Optional user-defined zoom thresholds to use instead of defaults */
30
+ zoom_thresholds?: ZoomThresholds;
31
+ }
32
+ /**
33
+ * A wrapper using essentially a preset of the high level causal graph editor under the hood,
34
+ * exposing a similar API to SimpleEdgeEncoder + extra graph editor props which can be modified in this preset
35
+ */
36
+ declare function VisualEdgeEncoder(props: VisualEdgeEncoderProps): JSX.Element;
37
+ export default VisualEdgeEncoder;
38
+ //# sourceMappingURL=visual-edge-encoder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visual-edge-encoder.d.ts","sourceRoot":"","sources":["../../js/graphs/visual-edge-encoder.tsx"],"names":[],"mappings":"AAGA,OAAO,EACH,MAAM,EAEN,oBAAoB,EACpB,QAAQ,EAKX,MAAM,cAAc,CAAC;AAEtB,OAAO,EAGH,eAAe,EAEf,cAAc,EAEd,UAAU,EACV,qBAAqB,EACrB,cAAc,EACjB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,qBAAqB,EAAyB,MAAM,gBAAgB,CAAC;AAG9E,UAAU,sBAAuB,SAAQ,oBAAoB;IACzD,0CAA0C;IAC1C,kBAAkB,CAAC,EAAE,qBAAqB,EAAE,CAAC;IAC7C,sEAAsE;IACtE,iCAAiC,CAAC,EAAE,OAAO,CAAC;IAC5C,0DAA0D;IAC1D,eAAe,CAAC,EAAE,MAAM,CAAC,UAAU,EAAE,qBAAqB,EAAE,CAAC,CAAC;IAC9D,oBAAoB;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qCAAqC;IACrC,YAAY,EAAE,qBAAqB,CAAC;IACpC,+BAA+B;IAC/B,mBAAmB,CAAC,EAAE,QAAQ,CAAC,cAAc,EAAE,CAAC,GAAG,cAAc,EAAE,CAAC;IACpE,sBAAsB;IACtB,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACzG,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qDAAqD;IACrD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kFAAkF;IAClF,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,0EAA0E;IAC1E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,eAAe,CAAC,EAAE,cAAc,CAAC;CACpC;AA+CD;;;GAGG;AACH,iBAAS,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,GAAG,GAAG,CAAC,OAAO,CA8ErE;AAED,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,94 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /* eslint-disable react-hooks/exhaustive-deps */
3
+ import { useMemo } from 'react';
4
+ import { Notifications, injectCss, useAction, useComponentStyles, useVariable, } from '@darajs/core';
5
+ import { useTheme } from '@darajs/styled-components';
6
+ import { CausalGraphViewer, EdgeType, EditorMode, } from '@darajs/ui-causal-graph-editor';
7
+ import { parseLayoutDefinition } from './graph-layout';
8
+ import { transformLegendColor } from './utils';
9
+ const StyledGraphEditor = injectCss(CausalGraphViewer);
10
+ /**
11
+ * Parse initially defined constraints.
12
+ * Reverses backward directed edges.
13
+ *
14
+ * @param constraints constraints to parse
15
+ */
16
+ function parseConstraints(constraints) {
17
+ if (!constraints) {
18
+ return [];
19
+ }
20
+ return constraints.map((c) => {
21
+ const constraintType = c.type;
22
+ const { source, target } = c;
23
+ return Object.assign(Object.assign({}, c), { source,
24
+ target, type: constraintType });
25
+ });
26
+ }
27
+ function isNodeList(nodes) {
28
+ return Array.isArray(nodes);
29
+ }
30
+ /**
31
+ * Parse nodes provided by user to the uniform format
32
+ *
33
+ * @param nodes nodes to parse
34
+ */
35
+ function parseNodes(nodes) {
36
+ if (isNodeList(nodes)) {
37
+ return nodes.reduce((acc, n) => {
38
+ return Object.assign(Object.assign({}, acc), { [n]: {} });
39
+ }, {});
40
+ }
41
+ return nodes;
42
+ }
43
+ /**
44
+ * A wrapper using essentially a preset of the high level causal graph editor under the hood,
45
+ * exposing a similar API to SimpleEdgeEncoder + extra graph editor props which can be modified in this preset
46
+ */
47
+ function VisualEdgeEncoder(props) {
48
+ const { pushNotification } = Notifications.useNotifications();
49
+ const [style, css] = useComponentStyles(props);
50
+ const [nodes] = useVariable(props.nodes);
51
+ const parsedNodes = useMemo(() => parseNodes(nodes), [nodes]);
52
+ const theme = useTheme();
53
+ const [initialConstraints] = useVariable(props.initial_constraints);
54
+ const parsedConstraints = useMemo(() => parseConstraints(initialConstraints), [initialConstraints]);
55
+ const graphLayout = useMemo(() => parseLayoutDefinition(props.graph_layout), []);
56
+ const onClickEdge = useAction(props.on_click_edge);
57
+ const onClickNode = useAction(props.on_click_node);
58
+ const onUpdate = useAction(props.on_update);
59
+ const formattedDefaultLegends = useMemo(() => {
60
+ return Object.fromEntries(Object.entries(props.default_legends).map(([editorMode, defaultLegends]) => {
61
+ return [editorMode, defaultLegends.map((legend) => transformLegendColor(theme, legend))];
62
+ }));
63
+ }, [props.default_legends, theme]);
64
+ const formattedAdditionalLegends = useMemo(() => {
65
+ var _a;
66
+ return (_a = props.additional_legends) === null || _a === void 0 ? void 0 : _a.map((legend) => transformLegendColor(theme, legend));
67
+ }, [props.additional_legends, theme]);
68
+ // Parse provided list of nodes into a graph data object that's understood by the graph editor
69
+ const graphData = useMemo(() => {
70
+ return {
71
+ // If initial constraints are passed, we need to also add edges for each constraint
72
+ edges: parsedConstraints.reduce((acc, c) => {
73
+ // Make sure the constraint is fully built - could be i.e. half-built by simple edge encoder
74
+ if (c.source && c.target) {
75
+ if (!(c.source in acc)) {
76
+ acc[c.source] = {};
77
+ }
78
+ acc[c.source][c.target] = {
79
+ destination: parsedNodes[c.target],
80
+ edge_type: EdgeType.UNDIRECTED_EDGE,
81
+ meta: {},
82
+ source: parsedNodes[c.source],
83
+ };
84
+ }
85
+ return acc;
86
+ }, {}),
87
+ nodes: parsedNodes,
88
+ version: 'none', // doesn't matter as we don't output a whole graph
89
+ };
90
+ }, [parsedNodes, parsedConstraints]);
91
+ return (_jsx(StyledGraphEditor, { "$rawCss": css, additionalLegends: formattedAdditionalLegends, allowSelectionWhenNotEditable: props.allow_selection_when_not_editable, defaultLegends: formattedDefaultLegends, editable: props.editable, editorMode: EditorMode.EDGE_ENCODER, graphData: graphData, graphLayout: graphLayout, initialConstraints: parsedConstraints, onClickEdge: onClickEdge, onClickNode: onClickNode, onEdgeConstraintsUpdate: onUpdate, onNotify: pushNotification, requireFocusToZoom: props.require_focus_to_zoom, style: style, tooltipSize: props.tooltip_size, zoomThresholds: props.zoom_thresholds }));
92
+ }
93
+ export default VisualEdgeEncoder;
94
+ //# sourceMappingURL=visual-edge-encoder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visual-edge-encoder.js","sourceRoot":"","sources":["../../js/graphs/visual-edge-encoder.tsx"],"names":[],"mappings":";AAAA,gDAAgD;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OA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W,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAErC,OAAO,CACH,KAAC,iBAAiB,eACL,GAAG,EACZ,iBAAiB,EAAE,0BAA0B,EAC7C,6BAA6B,EAAE,KAAK,CAAC,iCAAiC,EACtE,cAAc,EAAE,uBAAuB,EACvC,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,UAAU,EAAE,UAAU,CAAC,YAAY,EACnC,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,kBAAkB,EAAE,iBAAiB,EACrC,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EACxB,uBAAuB,EAAE,QAAQ,EACjC,QAAQ,EAAE,gBAAgB,EAC1B,kBAAkB,EAAE,KAAK,CAAC,qBAAqB,EAC/C,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,KAAK,CAAC,YAAY,EAC/B,cAAc,EAAE,KAAK,CAAC,eAAe,GACvC,CACL,CAAC;AACN,CAAC;AAED,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './common';
2
+ export * from './plotting';
3
+ export * from './smart';
4
+ export * from './graphs';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../js/index.tsx"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from './common';
2
+ export * from './plotting';
3
+ export * from './smart';
4
+ export * from './graphs';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../js/index.tsx"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type * as BokehLib from '@bokeh/bokehjs/build/js/lib';
2
+ import { Action, StyledComponentProps } from '@darajs/core';
3
+ interface BokehProps extends StyledComponentProps {
4
+ document: string;
5
+ events?: [string, Action][];
6
+ }
7
+ declare global {
8
+ interface Window {
9
+ /**
10
+ * Bokeh library
11
+ */
12
+ Bokeh: typeof BokehLib;
13
+ /**
14
+ * Whether Bokeh is currently loading; this is set on window so that multiple Bokeh components
15
+ * won't try to load Bokeh at the same time
16
+ */
17
+ bokehLoading?: boolean;
18
+ }
19
+ }
20
+ /**
21
+ * A component for displaying a serialized Bokeh Document. Takes a Bokeh Document that has been serialized
22
+ * to a JSON string.
23
+ *
24
+ * @param {BokehProps} props - the component props
25
+ */
26
+ declare function Bokeh(props: BokehProps): JSX.Element;
27
+ export default Bokeh;
28
+ //# sourceMappingURL=bokeh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bokeh.d.ts","sourceRoot":"","sources":["../../../js/plotting/bokeh/bokeh.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,QAAQ,MAAM,6BAA6B,CAAC;AAI7D,OAAO,EAAE,MAAM,EAAmB,oBAAoB,EAA4C,MAAM,cAAc,CAAC;AAiBvH,UAAU,UAAW,SAAQ,oBAAoB;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;CAC/B;AAID,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ;;WAEG;QACH,KAAK,EAAE,OAAO,QAAQ,CAAC;QACvB;;;WAGG;QACH,YAAY,CAAC,EAAE,OAAO,CAAC;KAC1B;CACJ;AAGD;;;;;GAKG;AACH,iBAAS,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,GAAG,CAAC,OAAO,CAoH7C;AAED,eAAe,KAAK,CAAC"}
@@ -0,0 +1,125 @@
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 { jsx as _jsx } from "react/jsx-runtime";
11
+ import { useEffect, useId, useMemo, useState } from 'react';
12
+ import { DefaultFallback, injectCss, useAction, useComponentStyles } from '@darajs/core';
13
+ import styled from '@darajs/styled-components';
14
+ const BOKEH_LIBRARIES = [
15
+ 'https://cdn.bokeh.org/bokeh/release/bokeh-{version}.min.js',
16
+ 'https://cdn.bokeh.org/bokeh/release/bokeh-widgets-{version}.min.js',
17
+ 'https://cdn.bokeh.org/bokeh/release/bokeh-tables-{version}.min.js',
18
+ 'https://cdn.bokeh.org/bokeh/release/bokeh-api-{version}.min.js',
19
+ 'https://cdn.bokeh.org/bokeh/release/bokeh-gl-{version}.min.js',
20
+ 'https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-{version}.min.js',
21
+ ];
22
+ const BokehRoot = injectCss(styled.div `
23
+ display: flex;
24
+ flex: 1 1 auto;
25
+ `);
26
+ const createEventName = (baseEventName, figId) => `BOKEH_FIGURE_${baseEventName}_${figId}`;
27
+ /* eslint-disable no-underscore-dangle */
28
+ /**
29
+ * A component for displaying a serialized Bokeh Document. Takes a Bokeh Document that has been serialized
30
+ * to a JSON string.
31
+ *
32
+ * @param {BokehProps} props - the component props
33
+ */
34
+ function Bokeh(props) {
35
+ const [style, css] = useComponentStyles(props);
36
+ const [isLoading, setIsLoading] = useState(true);
37
+ const docJson = useMemo(() => JSON.parse(props.document), [props.document]);
38
+ const rootId = useMemo(() => docJson.roots[0].id, [docJson]);
39
+ const id = useId();
40
+ const events = [];
41
+ const eventActions = [];
42
+ if (props.events) {
43
+ for (let i = 0; i < props.events.length; i++) {
44
+ const [name, action] = props.events[i];
45
+ // eslint-disable-next-line react-hooks/rules-of-hooks
46
+ eventActions.push([name, useAction(action)]);
47
+ }
48
+ }
49
+ /**
50
+ * Wait for Bokeh to be available on window
51
+ */
52
+ function waitForBokeh() {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ return new Promise((resolve) => {
55
+ const interval = setInterval(() => {
56
+ if (window.Bokeh) {
57
+ clearInterval(interval);
58
+ resolve();
59
+ }
60
+ }, 100);
61
+ });
62
+ });
63
+ }
64
+ function loadBokehLibrary(url, version) {
65
+ const script = document.createElement('script');
66
+ script.src = url.replace('{version}', version);
67
+ script.async = true;
68
+ document.head.appendChild(script);
69
+ }
70
+ function initializeBokeh() {
71
+ return __awaiter(this, void 0, void 0, function* () {
72
+ const bokehVersion = docJson.version;
73
+ // if it's already loading, wait for it to be available
74
+ if (window.bokehLoading) {
75
+ yield waitForBokeh();
76
+ }
77
+ else if (!window.Bokeh) {
78
+ // otherwise, load it
79
+ const [core, ...libraries] = BOKEH_LIBRARIES;
80
+ // Core needs to be loaded before all the other libraries
81
+ loadBokehLibrary(core, bokehVersion);
82
+ yield waitForBokeh();
83
+ libraries.forEach((url) => {
84
+ loadBokehLibrary(url, bokehVersion);
85
+ });
86
+ }
87
+ events.forEach(([ev, handler]) => {
88
+ document.removeEventListener(ev, handler);
89
+ });
90
+ eventActions.forEach(([name, action]) => {
91
+ const handler = (e) => {
92
+ action(e.detail);
93
+ };
94
+ const evtName = createEventName(name, docJson.roots[0].id);
95
+ document.addEventListener(evtName, handler);
96
+ events.push([evtName, handler]);
97
+ });
98
+ if (docJson) {
99
+ window.Bokeh.embed.embed_item({
100
+ doc: docJson,
101
+ root_id: rootId,
102
+ target_id: id,
103
+ });
104
+ }
105
+ setIsLoading(false);
106
+ });
107
+ }
108
+ useEffect(() => {
109
+ initializeBokeh();
110
+ return () => {
111
+ const index = window.Bokeh.documents.findIndex((doc) => doc.roots()[0].id === docJson.roots[0].id);
112
+ if (index > -1) {
113
+ const doc = window.Bokeh.documents[index];
114
+ doc.clear();
115
+ window.Bokeh.documents.splice(index, 1);
116
+ }
117
+ };
118
+ }, [docJson]);
119
+ return (_jsx(BokehRoot, { "$rawCss": css, "data-root-id": rootId, id: id, style: Object.assign({ minHeight: '350px', minWidth: '350px' }, style), children: isLoading && (_jsx(DefaultFallback, { style: {
120
+ display: 'flex',
121
+ flex: '1 1 auto',
122
+ } })) }));
123
+ }
124
+ export default Bokeh;
125
+ //# sourceMappingURL=bokeh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bokeh.js","sourceRoot":"","sources":["../../../js/plotting/bokeh/bokeh.tsx"],"names":[],"mappings":";;;;;;;;;;AAGA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAU,eAAe,EAAwB,SAAS,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvH,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAE/C,MAAM,eAAe,GAAG;IACpB,4DAA4D;IAC5D,oEAAoE;IACpE,mEAAmE;IACnE,gEAAgE;IAChE,+DAA+D;IAC/D,oEAAoE;CACvE,CAAC;AAEF,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAA;;;CAGrC,CAAC,CAAC;AAOH,MAAM,eAAe,GAAG,CAAC,aAAqB,EAAE,KAAa,EAAU,EAAE,CAAC,gBAAgB,aAAa,IAAI,KAAK,EAAE,CAAC;AAgBnH,yCAAyC;AACzC;;;;;GAKG;AACH,SAAS,KAAK,CAAC,KAAiB;IAC5B,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAC/C,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAA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AO,EAAE,MAAM;gBACf,IAAI,EAAE,UAAU;aACnB,GACH,CACL,GACO,CACf,CAAC;AACN,CAAC;AAED,eAAe,KAAK,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { default as Bokeh } from './bokeh/bokeh';
2
+ export { default as Plotly } from './plotly/plotly';
3
+ export { default as Matplotlib } from './matplotlib/matplotlib';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../js/plotting/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,5 @@
1
+ // eslint-disable-next-line import/prefer-default-export
2
+ export { default as Bokeh } from './bokeh/bokeh';
3
+ export { default as Plotly } from './plotly/plotly';
4
+ export { default as Matplotlib } from './matplotlib/matplotlib';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../js/plotting/index.tsx"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { StyledComponentProps } from '@darajs/core';
2
+ interface MatplotlibProps extends StyledComponentProps {
3
+ figure: string;
4
+ }
5
+ /**
6
+ * A component for displaying an image of Matplotlib or Seaborn plot.
7
+ *
8
+ * @param {MatplotlibProps} props - the component props
9
+ */
10
+ declare function Matplotlib(props: MatplotlibProps): JSX.Element;
11
+ export default Matplotlib;
12
+ //# sourceMappingURL=matplotlib.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matplotlib.d.ts","sourceRoot":"","sources":["../../../js/plotting/matplotlib/matplotlib.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAiC,MAAM,cAAc,CAAC;AAEnF,UAAU,eAAgB,SAAQ,oBAAoB;IAClD,MAAM,EAAE,MAAM,CAAC;CAClB;AAID;;;;GAIG;AACH,iBAAS,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,GAAG,CAAC,OAAO,CAUvD;AAED,eAAe,UAAU,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { injectCss, useComponentStyles } from '@darajs/core';
3
+ const StyledImg = injectCss('img');
4
+ /**
5
+ * A component for displaying an image of Matplotlib or Seaborn plot.
6
+ *
7
+ * @param {MatplotlibProps} props - the component props
8
+ */
9
+ function Matplotlib(props) {
10
+ const [style, css] = useComponentStyles(props);
11
+ return (_jsx(StyledImg, { "$rawCss": css, alt: "Matplotlib graph", src: `data:image/svg+xml;base64,${props.figure}`, style: style }));
12
+ }
13
+ export default Matplotlib;
14
+ //# sourceMappingURL=matplotlib.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matplotlib.js","sourceRoot":"","sources":["../../../js/plotting/matplotlib/matplotlib.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAwB,SAAS,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAMnF,MAAM,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;AAEnC;;;;GAIG;AACH,SAAS,UAAU,CAAC,KAAsB;IACtC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAC/C,OAAO,CACH,KAAC,SAAS,eACG,GAAG,EACZ,GAAG,EAAC,kBAAkB,EACtB,GAAG,EAAE,6BAA6B,KAAK,CAAC,MAAM,EAAE,EAChD,KAAK,EAAE,KAAK,GACd,CACL,CAAC;AACN,CAAC;AAED,eAAe,UAAU,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { Action, StyledComponentProps } from '@darajs/core';
2
+ /**
3
+ * Names defined by plotly.js, this is what Python will send us
4
+ */
5
+ declare enum PlotlyEventName {
6
+ AfterExport = "plotly_afterexport",
7
+ AfterPlot = "plotly_afterplot",
8
+ Animated = "plotly_animated",
9
+ AnimatingFrame = "plotly_animatingframe",
10
+ AnimationInterrupted = "plotly_animationinterrupted",
11
+ AutoSize = "plotly_autosize",
12
+ BeforeExport = "plotly_beforeexport",
13
+ BeforeHover = "plotly_beforehover",
14
+ ButtonClicked = "plotly_buttonclicked",
15
+ Click = "plotly_click",
16
+ ClickAnnotation = "plotly_clickannotation",
17
+ Deselect = "plotly_deselect",
18
+ DoubleClick = "plotly_doubleclick",
19
+ Framework = "plotly_framework",
20
+ Hover = "plotly_hover",
21
+ LegendClick = "plotly_legendclick",
22
+ LegendDoubleClick = "plotly_legenddoubleclick",
23
+ Redraw = "plotly_redraw",
24
+ Relayout = "plotly_relayout",
25
+ Restyle = "plotly_restyle",
26
+ Selected = "plotly_selected",
27
+ Selecting = "plotly_selecting",
28
+ SliderChange = "plotly_sliderchange",
29
+ SliderEnd = "plotly_sliderend",
30
+ SliderStart = "plotly_sliderstart",
31
+ TransitionInterrupted = "plotly_transitioninterrupted",
32
+ Transitioning = "plotly_transitioning",
33
+ Unhover = "plotly_unhover",
34
+ WebglContextLost = "plotly_webglcontextlost"
35
+ }
36
+ /**
37
+ * Event object as passed from Python
38
+ */
39
+ interface Event {
40
+ actions: Array<Action>;
41
+ custom_js: string;
42
+ event_name: PlotlyEventName;
43
+ }
44
+ /**
45
+ * Props for the Plotly component
46
+ */
47
+ interface PlotlyProps extends StyledComponentProps {
48
+ /** An array of event objects */
49
+ events?: Array<Event>;
50
+ /** A string containing the JSON object of figure properties */
51
+ figure: string;
52
+ }
53
+ /**
54
+ * A component for displaying Plotly graphs
55
+ *
56
+ * @param {PlotlyProps} props - the component props
57
+ */
58
+ declare function Plotly(props: PlotlyProps): JSX.Element;
59
+ export default Plotly;
60
+ //# sourceMappingURL=plotly.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plotly.d.ts","sourceRoot":"","sources":["../../../js/plotting/plotly/plotly.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAA4C,MAAM,cAAc,CAAC;AAEtG;;GAEG;AACH,aAAK,eAAe;IAChB,WAAW,uBAAuB;IAClC,SAAS,qBAAqB;IAC9B,QAAQ,oBAAoB;IAC5B,cAAc,0BAA0B;IACxC,oBAAoB,gCAAgC;IACpD,QAAQ,oBAAoB;IAC5B,YAAY,wBAAwB;IACpC,WAAW,uBAAuB;IAClC,aAAa,yBAAyB;IACtC,KAAK,iBAAiB;IACtB,eAAe,2BAA2B;IAC1C,QAAQ,oBAAoB;IAC5B,WAAW,uBAAuB;IAClC,SAAS,qBAAqB;IAC9B,KAAK,iBAAiB;IACtB,WAAW,uBAAuB;IAClC,iBAAiB,6BAA6B;IAC9C,MAAM,kBAAkB;IACxB,QAAQ,oBAAoB;IAC5B,OAAO,mBAAmB;IAC1B,QAAQ,oBAAoB;IAC5B,SAAS,qBAAqB;IAC9B,YAAY,wBAAwB;IACpC,SAAS,qBAAqB;IAC9B,WAAW,uBAAuB;IAClC,qBAAqB,iCAAiC;IACtD,aAAa,yBAAyB;IACtC,OAAO,mBAAmB;IAC1B,gBAAgB,4BAA4B;CAC/C;AA8DD;;GAEG;AACH,UAAU,KAAK;IACX,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,eAAe,CAAC;CAC/B;AAED;;GAEG;AACH,UAAU,WAAY,SAAQ,oBAAoB;IAC9C,gCAAgC;IAChC,MAAM,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACtB,+DAA+D;IAC/D,MA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