@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.
- package/LICENSE +201 -0
- package/README.md +37 -0
- package/dist/common/accordion/accordion.d.ts +17 -0
- package/dist/common/accordion/accordion.d.ts.map +1 -0
- package/dist/common/accordion/accordion.js +36 -0
- package/dist/common/accordion/accordion.js.map +1 -0
- package/dist/common/anchor/anchor.d.ts +17 -0
- package/dist/common/anchor/anchor.d.ts.map +1 -0
- package/dist/common/anchor/anchor.js +40 -0
- package/dist/common/anchor/anchor.js.map +1 -0
- package/dist/common/bullet-list/bullet_list.d.ts +16 -0
- package/dist/common/bullet-list/bullet_list.d.ts.map +1 -0
- package/dist/common/bullet-list/bullet_list.js +17 -0
- package/dist/common/bullet-list/bullet_list.js.map +1 -0
- package/dist/common/button/button.d.ts +27 -0
- package/dist/common/button/button.d.ts.map +1 -0
- package/dist/common/button/button.js +47 -0
- package/dist/common/button/button.js.map +1 -0
- package/dist/common/button-bar/button-bar.d.ts +22 -0
- package/dist/common/button-bar/button-bar.d.ts.map +1 -0
- package/dist/common/button-bar/button-bar.js +27 -0
- package/dist/common/button-bar/button-bar.js.map +1 -0
- package/dist/common/card/card.d.ts +24 -0
- package/dist/common/card/card.d.ts.map +1 -0
- package/dist/common/card/card.js +58 -0
- package/dist/common/card/card.js.map +1 -0
- package/dist/common/carousel/carousel.d.ts +27 -0
- package/dist/common/carousel/carousel.d.ts.map +1 -0
- package/dist/common/carousel/carousel.js +42 -0
- package/dist/common/carousel/carousel.js.map +1 -0
- package/dist/common/checkbox-group/checkbox-group.d.ts +24 -0
- package/dist/common/checkbox-group/checkbox-group.d.ts.map +1 -0
- package/dist/common/checkbox-group/checkbox-group.js +37 -0
- package/dist/common/checkbox-group/checkbox-group.js.map +1 -0
- package/dist/common/code/code.d.ts +12 -0
- package/dist/common/code/code.d.ts.map +1 -0
- package/dist/common/code/code.js +11 -0
- package/dist/common/code/code.js.map +1 -0
- package/dist/common/component-select-list/component-select-list.d.ts +23 -0
- package/dist/common/component-select-list/component-select-list.d.ts.map +1 -0
- package/dist/common/component-select-list/component-select-list.js +29 -0
- package/dist/common/component-select-list/component-select-list.js.map +1 -0
- package/dist/common/constants.d.ts +19 -0
- package/dist/common/constants.d.ts.map +1 -0
- package/dist/common/constants.js +21 -0
- package/dist/common/constants.js.map +1 -0
- package/dist/common/context/form-context.d.ts +20 -0
- package/dist/common/context/form-context.d.ts.map +1 -0
- package/dist/common/context/form-context.js +28 -0
- package/dist/common/context/form-context.js.map +1 -0
- package/dist/common/context/index.d.ts +2 -0
- package/dist/common/context/index.d.ts.map +1 -0
- package/dist/common/context/index.js +2 -0
- package/dist/common/context/index.js.map +1 -0
- package/dist/common/datepicker/datepicker.d.ts +31 -0
- package/dist/common/datepicker/datepicker.d.ts.map +1 -0
- package/dist/common/datepicker/datepicker.js +70 -0
- package/dist/common/datepicker/datepicker.js.map +1 -0
- package/dist/common/dropzone/dropzone.d.ts +21 -0
- package/dist/common/dropzone/dropzone.d.ts.map +1 -0
- package/dist/common/dropzone/dropzone.js +101 -0
- package/dist/common/dropzone/dropzone.js.map +1 -0
- package/dist/common/form/form.d.ts +11 -0
- package/dist/common/form/form.d.ts.map +1 -0
- package/dist/common/form/form.js +46 -0
- package/dist/common/form/form.js.map +1 -0
- package/dist/common/form-page/form-page.d.ts +12 -0
- package/dist/common/form-page/form-page.d.ts.map +1 -0
- package/dist/common/form-page/form-page.js +18 -0
- package/dist/common/form-page/form-page.js.map +1 -0
- package/dist/common/grid/column.d.ts +20 -0
- package/dist/common/grid/column.d.ts.map +1 -0
- package/dist/common/grid/column.js +22 -0
- package/dist/common/grid/column.js.map +1 -0
- package/dist/common/grid/grid.d.ts +18 -0
- package/dist/common/grid/grid.d.ts.map +1 -0
- package/dist/common/grid/grid.js +31 -0
- package/dist/common/grid/grid.js.map +1 -0
- package/dist/common/grid/row.d.ts +22 -0
- package/dist/common/grid/row.d.ts.map +1 -0
- package/dist/common/grid/row.js +236 -0
- package/dist/common/grid/row.js.map +1 -0
- package/dist/common/heading/heading.d.ts +9 -0
- package/dist/common/heading/heading.d.ts.map +1 -0
- package/dist/common/heading/heading.js +14 -0
- package/dist/common/heading/heading.js.map +1 -0
- package/dist/common/html-raw/html-raw.d.ts +15 -0
- package/dist/common/html-raw/html-raw.d.ts.map +1 -0
- package/dist/common/html-raw/html-raw.js +22 -0
- package/dist/common/html-raw/html-raw.js.map +1 -0
- package/dist/common/icon/icon.d.ts +8 -0
- package/dist/common/icon/icon.d.ts.map +1 -0
- package/dist/common/icon/icon.js +11 -0
- package/dist/common/icon/icon.js.map +1 -0
- package/dist/common/if/if.d.ts +27 -0
- package/dist/common/if/if.d.ts.map +1 -0
- package/dist/common/if/if.js +53 -0
- package/dist/common/if/if.js.map +1 -0
- package/dist/common/image/image.d.ts +15 -0
- package/dist/common/image/image.d.ts.map +1 -0
- package/dist/common/image/image.js +19 -0
- package/dist/common/image/image.js.map +1 -0
- package/dist/common/index.d.ts +43 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/index.js +41 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/input/input.d.ts +20 -0
- package/dist/common/input/input.d.ts.map +1 -0
- package/dist/common/input/input.js +57 -0
- package/dist/common/input/input.js.map +1 -0
- package/dist/common/label/label.d.ts +21 -0
- package/dist/common/label/label.d.ts.map +1 -0
- package/dist/common/label/label.js +30 -0
- package/dist/common/label/label.js.map +1 -0
- package/dist/common/markdown/markdown.d.ts +17 -0
- package/dist/common/markdown/markdown.d.ts.map +1 -0
- package/dist/common/markdown/markdown.js +19 -0
- package/dist/common/markdown/markdown.js.map +1 -0
- package/dist/common/modal/modal.d.ts +15 -0
- package/dist/common/modal/modal.d.ts.map +1 -0
- package/dist/common/modal/modal.js +19 -0
- package/dist/common/modal/modal.js.map +1 -0
- package/dist/common/overlay/overlay.d.ts +16 -0
- package/dist/common/overlay/overlay.d.ts.map +1 -0
- package/dist/common/overlay/overlay.js +31 -0
- package/dist/common/overlay/overlay.js.map +1 -0
- package/dist/common/paragraph/paragraph.d.ts +9 -0
- package/dist/common/paragraph/paragraph.d.ts.map +1 -0
- package/dist/common/paragraph/paragraph.js +10 -0
- package/dist/common/paragraph/paragraph.js.map +1 -0
- package/dist/common/progress-bar/progress-bar.d.ts +17 -0
- package/dist/common/progress-bar/progress-bar.d.ts.map +1 -0
- package/dist/common/progress-bar/progress-bar.js +23 -0
- package/dist/common/progress-bar/progress-bar.js.map +1 -0
- package/dist/common/radio-group/radio-group.d.ts +21 -0
- package/dist/common/radio-group/radio-group.d.ts.map +1 -0
- package/dist/common/radio-group/radio-group.js +30 -0
- package/dist/common/radio-group/radio-group.js.map +1 -0
- package/dist/common/select/select.d.ts +31 -0
- package/dist/common/select/select.d.ts.map +1 -0
- package/dist/common/select/select.js +129 -0
- package/dist/common/select/select.js.map +1 -0
- package/dist/common/slider/slider.d.ts +29 -0
- package/dist/common/slider/slider.d.ts.map +1 -0
- package/dist/common/slider/slider.js +38 -0
- package/dist/common/slider/slider.js.map +1 -0
- package/dist/common/spacer/spacer.d.ts +10 -0
- package/dist/common/spacer/spacer.d.ts.map +1 -0
- package/dist/common/spacer/spacer.js +30 -0
- package/dist/common/spacer/spacer.js.map +1 -0
- package/dist/common/stack/stack.d.ts +12 -0
- package/dist/common/stack/stack.d.ts.map +1 -0
- package/dist/common/stack/stack.js +42 -0
- package/dist/common/stack/stack.js.map +1 -0
- package/dist/common/switch/switch.d.ts +14 -0
- package/dist/common/switch/switch.d.ts.map +1 -0
- package/dist/common/switch/switch.js +31 -0
- package/dist/common/switch/switch.js.map +1 -0
- package/dist/common/tabbed-card/tabbed-card.d.ts +24 -0
- package/dist/common/tabbed-card/tabbed-card.d.ts.map +1 -0
- package/dist/common/tabbed-card/tabbed-card.js +62 -0
- package/dist/common/tabbed-card/tabbed-card.js.map +1 -0
- package/dist/common/table/cells/adaptive-precision-cell.d.ts +9 -0
- package/dist/common/table/cells/adaptive-precision-cell.d.ts.map +1 -0
- package/dist/common/table/cells/adaptive-precision-cell.js +30 -0
- package/dist/common/table/cells/adaptive-precision-cell.js.map +1 -0
- package/dist/common/table/cells/badge-formatter-cell.d.ts +19 -0
- package/dist/common/table/cells/badge-formatter-cell.d.ts.map +1 -0
- package/dist/common/table/cells/badge-formatter-cell.js +18 -0
- package/dist/common/table/cells/badge-formatter-cell.js.map +1 -0
- package/dist/common/table/cells/code-cell.d.ts +12 -0
- package/dist/common/table/cells/code-cell.d.ts.map +1 -0
- package/dist/common/table/cells/code-cell.js +19 -0
- package/dist/common/table/cells/code-cell.js.map +1 -0
- package/dist/common/table/cells/compare-cell.d.ts +13 -0
- package/dist/common/table/cells/compare-cell.d.ts.map +1 -0
- package/dist/common/table/cells/compare-cell.js +34 -0
- package/dist/common/table/cells/compare-cell.js.map +1 -0
- package/dist/common/table/cells/formatted-text-cell.d.ts +9 -0
- package/dist/common/table/cells/formatted-text-cell.d.ts.map +1 -0
- package/dist/common/table/cells/formatted-text-cell.js +15 -0
- package/dist/common/table/cells/formatted-text-cell.js.map +1 -0
- package/dist/common/table/cells/index.d.ts +11 -0
- package/dist/common/table/cells/index.d.ts.map +1 -0
- package/dist/common/table/cells/index.js +11 -0
- package/dist/common/table/cells/index.js.map +1 -0
- package/dist/common/table/cells/link-cell.d.ts +10 -0
- package/dist/common/table/cells/link-cell.d.ts.map +1 -0
- package/dist/common/table/cells/link-cell.js +15 -0
- package/dist/common/table/cells/link-cell.js.map +1 -0
- package/dist/common/table/cells/number-cell.d.ts +11 -0
- package/dist/common/table/cells/number-cell.d.ts.map +1 -0
- package/dist/common/table/cells/number-cell.js +16 -0
- package/dist/common/table/cells/number-cell.js.map +1 -0
- package/dist/common/table/cells/number-intl-cell.d.ts +11 -0
- package/dist/common/table/cells/number-intl-cell.d.ts.map +1 -0
- package/dist/common/table/cells/number-intl-cell.js +16 -0
- package/dist/common/table/cells/number-intl-cell.js.map +1 -0
- package/dist/common/table/cells/percentage-cell.d.ts +11 -0
- package/dist/common/table/cells/percentage-cell.d.ts.map +1 -0
- package/dist/common/table/cells/percentage-cell.js +16 -0
- package/dist/common/table/cells/percentage-cell.js.map +1 -0
- package/dist/common/table/cells/threshold-formatted-cell.d.ts +15 -0
- package/dist/common/table/cells/threshold-formatted-cell.d.ts.map +1 -0
- package/dist/common/table/cells/threshold-formatted-cell.js +20 -0
- package/dist/common/table/cells/threshold-formatted-cell.js.map +1 -0
- package/dist/common/table/table.d.ts +60 -0
- package/dist/common/table/table.d.ts.map +1 -0
- package/dist/common/table/table.js +456 -0
- package/dist/common/table/table.js.map +1 -0
- package/dist/common/text/text.d.ts +12 -0
- package/dist/common/text/text.d.ts.map +1 -0
- package/dist/common/text/text.js +23 -0
- package/dist/common/text/text.js.map +1 -0
- package/dist/common/textarea/textarea.d.ts +19 -0
- package/dist/common/textarea/textarea.d.ts.map +1 -0
- package/dist/common/textarea/textarea.js +42 -0
- package/dist/common/textarea/textarea.js.map +1 -0
- package/dist/common/tooltip/tooltip.d.ts +18 -0
- package/dist/common/tooltip/tooltip.d.ts.map +1 -0
- package/dist/common/tooltip/tooltip.js +18 -0
- package/dist/common/tooltip/tooltip.js.map +1 -0
- package/dist/common/types.d.ts +26 -0
- package/dist/common/types.d.ts.map +1 -0
- package/dist/common/types.js +9 -0
- package/dist/common/types.js.map +1 -0
- package/dist/dara_components-0.4.8-py3-none-any.whl +0 -0
- package/dist/graphs/causal-graph-viewer.d.ts +55 -0
- package/dist/graphs/causal-graph-viewer.d.ts.map +1 -0
- package/dist/graphs/causal-graph-viewer.js +44 -0
- package/dist/graphs/causal-graph-viewer.js.map +1 -0
- package/dist/graphs/graph-layout.d.ts +65 -0
- package/dist/graphs/graph-layout.d.ts.map +1 -0
- package/dist/graphs/graph-layout.js +152 -0
- package/dist/graphs/graph-layout.js.map +1 -0
- package/dist/graphs/index.d.ts +8 -0
- package/dist/graphs/index.d.ts.map +1 -0
- package/dist/graphs/index.js +6 -0
- package/dist/graphs/index.js.map +1 -0
- package/dist/graphs/node-hierarchy-builder.d.ts +24 -0
- package/dist/graphs/node-hierarchy-builder.d.ts.map +1 -0
- package/dist/graphs/node-hierarchy-builder.js +40 -0
- package/dist/graphs/node-hierarchy-builder.js.map +1 -0
- package/dist/graphs/utils.d.ts +10 -0
- package/dist/graphs/utils.d.ts.map +1 -0
- package/dist/graphs/utils.js +31 -0
- package/dist/graphs/utils.js.map +1 -0
- package/dist/graphs/visual-edge-encoder.d.ts +38 -0
- package/dist/graphs/visual-edge-encoder.d.ts.map +1 -0
- package/dist/graphs/visual-edge-encoder.js +94 -0
- package/dist/graphs/visual-edge-encoder.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/plotting/bokeh/bokeh.d.ts +28 -0
- package/dist/plotting/bokeh/bokeh.d.ts.map +1 -0
- package/dist/plotting/bokeh/bokeh.js +125 -0
- package/dist/plotting/bokeh/bokeh.js.map +1 -0
- package/dist/plotting/index.d.ts +4 -0
- package/dist/plotting/index.d.ts.map +1 -0
- package/dist/plotting/index.js +5 -0
- package/dist/plotting/index.js.map +1 -0
- package/dist/plotting/matplotlib/matplotlib.d.ts +12 -0
- package/dist/plotting/matplotlib/matplotlib.d.ts.map +1 -0
- package/dist/plotting/matplotlib/matplotlib.js +14 -0
- package/dist/plotting/matplotlib/matplotlib.js.map +1 -0
- package/dist/plotting/plotly/plotly.d.ts +60 -0
- package/dist/plotting/plotly/plotly.d.ts.map +1 -0
- package/dist/plotting/plotly/plotly.js +235 -0
- package/dist/plotting/plotly/plotly.js.map +1 -0
- package/dist/smart/chat/chat.d.ts +16 -0
- package/dist/smart/chat/chat.d.ts.map +1 -0
- package/dist/smart/chat/chat.js +174 -0
- package/dist/smart/chat/chat.js.map +1 -0
- package/dist/smart/code-editor.d.ts +12 -0
- package/dist/smart/code-editor.d.ts.map +1 -0
- package/dist/smart/code-editor.js +15 -0
- package/dist/smart/code-editor.js.map +1 -0
- package/dist/smart/data-slicer-filter/data-slicer-filter.d.ts +47 -0
- package/dist/smart/data-slicer-filter/data-slicer-filter.d.ts.map +1 -0
- package/dist/smart/data-slicer-filter/data-slicer-filter.js +124 -0
- package/dist/smart/data-slicer-filter/data-slicer-filter.js.map +1 -0
- package/dist/smart/filter-status-button/filter-status-button.d.ts +14 -0
- package/dist/smart/filter-status-button/filter-status-button.d.ts.map +1 -0
- package/dist/smart/filter-status-button/filter-status-button.js +49 -0
- package/dist/smart/filter-status-button/filter-status-button.js.map +1 -0
- package/dist/smart/hierarchy-selector/hierarchy-selector.d.ts +23 -0
- package/dist/smart/hierarchy-selector/hierarchy-selector.d.ts.map +1 -0
- package/dist/smart/hierarchy-selector/hierarchy-selector.js +17 -0
- package/dist/smart/hierarchy-selector/hierarchy-selector.js.map +1 -0
- package/dist/smart/hierarchy-viewer/hierarchy-viewer.d.ts +16 -0
- package/dist/smart/hierarchy-viewer/hierarchy-viewer.d.ts.map +1 -0
- package/dist/smart/hierarchy-viewer/hierarchy-viewer.js +17 -0
- package/dist/smart/hierarchy-viewer/hierarchy-viewer.js.map +1 -0
- package/dist/smart/index.d.ts +7 -0
- package/dist/smart/index.d.ts.map +1 -0
- package/dist/smart/index.js +8 -0
- package/dist/smart/index.js.map +1 -0
- package/dist/umd/dara.components.umd.js +387222 -0
- package/dist/umd/style.css +745 -0
- package/package.json +87 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import Plot from 'react-plotly.js';
|
|
4
|
+
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
5
|
+
import { injectCss, useAction, useComponentStyles } from '@darajs/core';
|
|
6
|
+
/**
|
|
7
|
+
* Names defined by plotly.js, this is what Python will send us
|
|
8
|
+
*/
|
|
9
|
+
var PlotlyEventName;
|
|
10
|
+
(function (PlotlyEventName) {
|
|
11
|
+
PlotlyEventName["AfterExport"] = "plotly_afterexport";
|
|
12
|
+
PlotlyEventName["AfterPlot"] = "plotly_afterplot";
|
|
13
|
+
PlotlyEventName["Animated"] = "plotly_animated";
|
|
14
|
+
PlotlyEventName["AnimatingFrame"] = "plotly_animatingframe";
|
|
15
|
+
PlotlyEventName["AnimationInterrupted"] = "plotly_animationinterrupted";
|
|
16
|
+
PlotlyEventName["AutoSize"] = "plotly_autosize";
|
|
17
|
+
PlotlyEventName["BeforeExport"] = "plotly_beforeexport";
|
|
18
|
+
PlotlyEventName["BeforeHover"] = "plotly_beforehover";
|
|
19
|
+
PlotlyEventName["ButtonClicked"] = "plotly_buttonclicked";
|
|
20
|
+
PlotlyEventName["Click"] = "plotly_click";
|
|
21
|
+
PlotlyEventName["ClickAnnotation"] = "plotly_clickannotation";
|
|
22
|
+
PlotlyEventName["Deselect"] = "plotly_deselect";
|
|
23
|
+
PlotlyEventName["DoubleClick"] = "plotly_doubleclick";
|
|
24
|
+
PlotlyEventName["Framework"] = "plotly_framework";
|
|
25
|
+
PlotlyEventName["Hover"] = "plotly_hover";
|
|
26
|
+
PlotlyEventName["LegendClick"] = "plotly_legendclick";
|
|
27
|
+
PlotlyEventName["LegendDoubleClick"] = "plotly_legenddoubleclick";
|
|
28
|
+
PlotlyEventName["Redraw"] = "plotly_redraw";
|
|
29
|
+
PlotlyEventName["Relayout"] = "plotly_relayout";
|
|
30
|
+
PlotlyEventName["Restyle"] = "plotly_restyle";
|
|
31
|
+
PlotlyEventName["Selected"] = "plotly_selected";
|
|
32
|
+
PlotlyEventName["Selecting"] = "plotly_selecting";
|
|
33
|
+
PlotlyEventName["SliderChange"] = "plotly_sliderchange";
|
|
34
|
+
PlotlyEventName["SliderEnd"] = "plotly_sliderend";
|
|
35
|
+
PlotlyEventName["SliderStart"] = "plotly_sliderstart";
|
|
36
|
+
PlotlyEventName["TransitionInterrupted"] = "plotly_transitioninterrupted";
|
|
37
|
+
PlotlyEventName["Transitioning"] = "plotly_transitioning";
|
|
38
|
+
PlotlyEventName["Unhover"] = "plotly_unhover";
|
|
39
|
+
PlotlyEventName["WebglContextLost"] = "plotly_webglcontextlost";
|
|
40
|
+
})(PlotlyEventName || (PlotlyEventName = {}));
|
|
41
|
+
/**
|
|
42
|
+
* eventHandlersMap maps the plotly.js event names to the names we need for Plot component props
|
|
43
|
+
*/
|
|
44
|
+
const eventHandlersMap = {
|
|
45
|
+
[PlotlyEventName.Click]: 'onClick',
|
|
46
|
+
[PlotlyEventName.Hover]: 'onHover',
|
|
47
|
+
[PlotlyEventName.Selecting]: 'onSelecting',
|
|
48
|
+
[PlotlyEventName.Selected]: 'onSelected',
|
|
49
|
+
[PlotlyEventName.Unhover]: 'onUnhover',
|
|
50
|
+
[PlotlyEventName.SliderChange]: 'onSliderChange',
|
|
51
|
+
[PlotlyEventName.AnimationInterrupted]: 'onAnimationInterrupted',
|
|
52
|
+
[PlotlyEventName.AnimatingFrame]: 'onAnimatingFrame',
|
|
53
|
+
[PlotlyEventName.Animated]: 'onAnimated',
|
|
54
|
+
[PlotlyEventName.BeforeHover]: 'onBeforeHover',
|
|
55
|
+
[PlotlyEventName.ButtonClicked]: 'onButtonClicked',
|
|
56
|
+
[PlotlyEventName.ClickAnnotation]: 'onClickAnnotation',
|
|
57
|
+
[PlotlyEventName.Deselect]: 'onDeselect',
|
|
58
|
+
[PlotlyEventName.DoubleClick]: 'onDoubleClick',
|
|
59
|
+
[PlotlyEventName.Framework]: 'onFramework',
|
|
60
|
+
[PlotlyEventName.LegendClick]: 'onLegendClick',
|
|
61
|
+
[PlotlyEventName.LegendDoubleClick]: 'onLegendDoubleClick',
|
|
62
|
+
[PlotlyEventName.Redraw]: 'onRedraw',
|
|
63
|
+
[PlotlyEventName.Relayout]: 'onRelayout',
|
|
64
|
+
[PlotlyEventName.Restyle]: 'onRestyle',
|
|
65
|
+
[PlotlyEventName.TransitionInterrupted]: 'onTransitionInterrupted',
|
|
66
|
+
[PlotlyEventName.Transitioning]: 'onTransitioning',
|
|
67
|
+
[PlotlyEventName.WebglContextLost]: 'onWebGlContextLost',
|
|
68
|
+
[PlotlyEventName.SliderEnd]: 'onSliderEnd',
|
|
69
|
+
[PlotlyEventName.SliderStart]: 'onSliderStart',
|
|
70
|
+
[PlotlyEventName.BeforeExport]: 'onBeforeExport',
|
|
71
|
+
[PlotlyEventName.AfterExport]: 'onAfterExport',
|
|
72
|
+
[PlotlyEventName.AfterPlot]: 'onAfterPlot',
|
|
73
|
+
[PlotlyEventName.AutoSize]: 'onAutoSize',
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
*
|
|
77
|
+
* Filters the event data received from plotly to remove large objects that cause JSON stringify circular structure errors.
|
|
78
|
+
* Taken and adapted from https://github.com/plotly/dash/blob/dev/components/dash-core-components/src/fragments/Graph.react.js#L55
|
|
79
|
+
*
|
|
80
|
+
* @param figure - the plotly figure
|
|
81
|
+
* @param eventData - the data from the event
|
|
82
|
+
* @param event - the name of the event
|
|
83
|
+
* @returns - the filtered event data
|
|
84
|
+
*/
|
|
85
|
+
function filterEventData(figure, eventData, event) {
|
|
86
|
+
var _a;
|
|
87
|
+
let filteredEventData;
|
|
88
|
+
if ([PlotlyEventName.Click, PlotlyEventName.Hover, PlotlyEventName.Selected].includes(event)) {
|
|
89
|
+
const points = [];
|
|
90
|
+
const pointEventData = eventData;
|
|
91
|
+
if (!pointEventData) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
/*
|
|
95
|
+
* remove `data`, `layout`, `xaxis`, etc
|
|
96
|
+
* objects from the event data since they're so big
|
|
97
|
+
* and cause JSON stringify ciricular structure errors.
|
|
98
|
+
*
|
|
99
|
+
* also, pull down the `customdata` point from the data array
|
|
100
|
+
* into the event object
|
|
101
|
+
*/
|
|
102
|
+
const { data } = figure;
|
|
103
|
+
for (let i = 0; i < pointEventData.points.length; i++) {
|
|
104
|
+
const fullPoint = pointEventData.points[i];
|
|
105
|
+
const pointData = Object.fromEntries(Object.entries(fullPoint).filter(([, value]) => {
|
|
106
|
+
return typeof value !== 'object' && !Array.isArray(value);
|
|
107
|
+
}));
|
|
108
|
+
// permit a bounding box to pass through, if present
|
|
109
|
+
if ('bbox' in fullPoint) {
|
|
110
|
+
pointData.bbox = fullPoint.bbox;
|
|
111
|
+
}
|
|
112
|
+
if ((fullPoint === null || fullPoint === void 0 ? void 0 : fullPoint.curveNumber) && ((_a = data[pointData.curveNumber]) === null || _a === void 0 ? void 0 : _a.customdata)) {
|
|
113
|
+
if (fullPoint.pointNumber) {
|
|
114
|
+
if (typeof fullPoint.pointNumber === 'number') {
|
|
115
|
+
pointData.customdata = data[pointData.curveNumber].customdata[fullPoint.pointNumber];
|
|
116
|
+
}
|
|
117
|
+
else if (!fullPoint.pointNumber && fullPoint.data.mode.includes('lines')) {
|
|
118
|
+
pointData.customdata = data[pointData.curveNumber].customdata;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else if ('pointNumbers' in fullPoint) {
|
|
122
|
+
pointData.customdata = fullPoint.pointNumbers.map((point) => {
|
|
123
|
+
return data[pointData.curveNumber].customdata[point];
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// specific to histogram. see https://github.com/plotly/plotly.js/pull/2113/
|
|
128
|
+
if ('pointNumbers' in fullPoint) {
|
|
129
|
+
pointData.pointNumbers = fullPoint.pointNumbers;
|
|
130
|
+
}
|
|
131
|
+
points[i] = pointData;
|
|
132
|
+
}
|
|
133
|
+
filteredEventData = { points };
|
|
134
|
+
}
|
|
135
|
+
else if (event === PlotlyEventName.Relayout || event === PlotlyEventName.Restyle) {
|
|
136
|
+
/*
|
|
137
|
+
* relayout shouldn't include any big objects
|
|
138
|
+
* it will usually just contain the ranges of the axes like
|
|
139
|
+
* "xaxis.range[0]": 0.7715822247381828,
|
|
140
|
+
* "xaxis.range[1]": 3.0095292008680063`
|
|
141
|
+
*/
|
|
142
|
+
filteredEventData = eventData;
|
|
143
|
+
}
|
|
144
|
+
if ('range' in eventData) {
|
|
145
|
+
filteredEventData.range = eventData.range;
|
|
146
|
+
}
|
|
147
|
+
if ('lassoPoints' in eventData) {
|
|
148
|
+
filteredEventData.lassoPoints = eventData.lassoPoints;
|
|
149
|
+
}
|
|
150
|
+
return filteredEventData;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
*
|
|
154
|
+
* Executes the custom js for a given event
|
|
155
|
+
*
|
|
156
|
+
* @param customJs - the custom js string to execute
|
|
157
|
+
* @param eventData - the data from the event
|
|
158
|
+
* @param figure - the plotly figure
|
|
159
|
+
* @returns - the new figure obtained by the customJS function
|
|
160
|
+
*/
|
|
161
|
+
function executeCustomJs(customJs, eventData, figure) {
|
|
162
|
+
// function running under eval is not run underst strict mode, therefore we need to prepend it
|
|
163
|
+
const customJsFunction = `
|
|
164
|
+
return (function(data, figure) {
|
|
165
|
+
'use strict';
|
|
166
|
+
${customJs}
|
|
167
|
+
return figure;
|
|
168
|
+
})(data, figure);
|
|
169
|
+
`;
|
|
170
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func
|
|
171
|
+
const userFunction = new Function('data', 'figure', customJsFunction);
|
|
172
|
+
const newFigure = userFunction(eventData, figure);
|
|
173
|
+
return newFigure;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
*
|
|
177
|
+
* For a given event type executes if defined the Dara actions and custom js. It will also update the figure object based on the custom js function.
|
|
178
|
+
*
|
|
179
|
+
* @param eventType - the name of the event
|
|
180
|
+
* @param eventData - the data from the event
|
|
181
|
+
* @param eventActions - the actions to execute
|
|
182
|
+
* @param figure - the plotly figure
|
|
183
|
+
* @param setFigure - the function to update the figure
|
|
184
|
+
*/
|
|
185
|
+
function handleEvent(eventType, eventData, eventActions, figure, setFigure) {
|
|
186
|
+
eventActions === null || eventActions === void 0 ? void 0 : eventActions.forEach((eventAction) => {
|
|
187
|
+
if (eventAction === null || eventAction === void 0 ? void 0 : eventAction.handler) {
|
|
188
|
+
const filteredData = filterEventData(figure, eventData, eventType);
|
|
189
|
+
eventAction.handler(filteredData.points);
|
|
190
|
+
}
|
|
191
|
+
if (eventAction === null || eventAction === void 0 ? void 0 : eventAction.custom_js) {
|
|
192
|
+
const newFigure = executeCustomJs(eventAction.custom_js, eventData, figure);
|
|
193
|
+
setFigure(newFigure);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
const StyledPlotly = injectCss('div');
|
|
198
|
+
/* eslint-disable no-underscore-dangle */
|
|
199
|
+
/**
|
|
200
|
+
* A component for displaying Plotly graphs
|
|
201
|
+
*
|
|
202
|
+
* @param {PlotlyProps} props - the component props
|
|
203
|
+
*/
|
|
204
|
+
function Plotly(props) {
|
|
205
|
+
var _a, _b;
|
|
206
|
+
const [style, css] = useComponentStyles(props);
|
|
207
|
+
const [figure, setFigure] = useState(() => JSON.parse(props.figure));
|
|
208
|
+
const eventActions = new Map();
|
|
209
|
+
if (props.events) {
|
|
210
|
+
props.events.forEach((event) => {
|
|
211
|
+
var _a;
|
|
212
|
+
const actions = new Array();
|
|
213
|
+
event === null || event === void 0 ? void 0 : event.actions.forEach((action) => {
|
|
214
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
215
|
+
const actionHandler = useAction(action);
|
|
216
|
+
actions.push({ custom_js: event.custom_js, handler: actionHandler });
|
|
217
|
+
});
|
|
218
|
+
const currentActions = (_a = eventActions.get(event.event_name)) !== null && _a !== void 0 ? _a : [];
|
|
219
|
+
eventActions.set(event.event_name, [...currentActions, ...actions]);
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
// add an event handler for each Plot event, e.g. onClick, onHover, etc
|
|
223
|
+
const eventHandlers = Object.keys(eventHandlersMap).reduce((acc, key) => {
|
|
224
|
+
const eventHandlerName = eventHandlersMap[key];
|
|
225
|
+
const eventHandler = (e) => {
|
|
226
|
+
handleEvent(key, e, eventActions.get(key), figure, setFigure);
|
|
227
|
+
};
|
|
228
|
+
// we are casting to any here because there is an issue with union vs intersection of types
|
|
229
|
+
acc[eventHandlerName] = eventHandler;
|
|
230
|
+
return acc;
|
|
231
|
+
}, {});
|
|
232
|
+
return (_jsx(StyledPlotly, { "$rawCss": css, style: Object.assign({ flex: '1 1 auto', minHeight: '350px', height: (_a = figure.layout) === null || _a === void 0 ? void 0 : _a.height, width: (_b = figure.layout) === null || _b === void 0 ? void 0 : _b.width }, style), children: _jsx(AutoSizer, { children: ({ height, width }) => (_jsx(Plot, Object.assign({ config: { responsive: true }, data: figure.data, frames: figure.frames, layout: figure.layout }, eventHandlers, { style: { height, width }, useResizeHandler: true }))) }) }));
|
|
233
|
+
}
|
|
234
|
+
export default Plotly;
|
|
235
|
+
//# sourceMappingURL=plotly.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plotly.js","sourceRoot":"","sources":["../../../js/plotting/plotly/plotly.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,IAAoB,MAAM,iBAAiB,CAAC;AACnD,OAAO,SAAS,MAAM,8BAA8B,CAAC;AAErD,OAAO,EAAgC,SAAS,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEtG;;GAEG;AACH,IAAK,eA8BJ;AA9BD,WAAK,eAAe;IAChB,qDAAkC,CAAA;IAClC,iDAA8B,CAAA;IAC9B,+CAA4B,CAAA;IAC5B,2DAAwC,CAAA;IACxC,uEAAoD,CAAA;IACpD,+CAA4B,CAAA;IAC5B,uDAAoC,CAAA;IACpC,qDAAkC,CAAA;IAClC,yDAAsC,CAAA;IACtC,yCAAsB,CAAA;IACtB,6DAA0C,CAAA;IAC1C,+CAA4B,CAAA;IAC5B,qDAAkC,CAAA;IAClC,iDAA8B,CAAA;IAC9B,yCAAsB,CAAA;IACtB,qDAAkC,CAAA;IAClC,iEAA8C,CAAA;IAC9C,2CAAwB,CAAA;IACxB,+CAA4B,CAAA;IAC5B,6CAA0B,CAAA;IAC1B,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K,EAAE,EACxB,gBAAgB,UAClB,CACL,GACO,GACD,CAClB,CAAC;AACN,CAAC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { StyledComponentProps, Variable } from '@darajs/core';
|
|
2
|
+
import { Message } from '@darajs/ui-components';
|
|
3
|
+
interface ChatProps extends StyledComponentProps {
|
|
4
|
+
/** Passthrough the className property */
|
|
5
|
+
className: string;
|
|
6
|
+
/** The value Variable to display and update */
|
|
7
|
+
value?: Variable<Message[]>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The Chat component switches between a chat button and a chat sidebar, allowing the user to interact with a chat.
|
|
11
|
+
*
|
|
12
|
+
* @param props the component props
|
|
13
|
+
*/
|
|
14
|
+
declare function Chat(props: ChatProps): JSX.Element;
|
|
15
|
+
export default Chat;
|
|
16
|
+
//# sourceMappingURL=chat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../../js/smart/chat/chat.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEH,oBAAoB,EAEpB,QAAQ,EAQX,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,OAAO,EAA0C,MAAM,uBAAuB,CAAC;AAGxF,UAAU,SAAU,SAAQ,oBAAoB;IAC5C,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;CAC/B;AAkID;;;;GAIG;AACH,iBAAS,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,GAAG,CAAC,OAAO,CAyF3C;AAED,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,174 @@
|
|
|
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, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import { handleAuthErrors, injectCss, request, useComponentStyles, useRequestExtras, useUser, useVariable, } from '@darajs/core';
|
|
13
|
+
import styled, { useTheme } from '@darajs/styled-components';
|
|
14
|
+
import { Chat as UiChat } from '@darajs/ui-components';
|
|
15
|
+
import { HTTP_METHOD, validateResponse } from '@darajs/ui-utils';
|
|
16
|
+
const ThreadWrapper = styled.div `
|
|
17
|
+
pointer-events: auto;
|
|
18
|
+
|
|
19
|
+
position: fixed;
|
|
20
|
+
right: 1rem;
|
|
21
|
+
bottom: -0.1rem;
|
|
22
|
+
|
|
23
|
+
margin: 1rem;
|
|
24
|
+
|
|
25
|
+
border-radius: 0.4rem;
|
|
26
|
+
`;
|
|
27
|
+
const ChatButton = styled.button `
|
|
28
|
+
position: absolute;
|
|
29
|
+
right: 0.5rem;
|
|
30
|
+
bottom: 0.5rem;
|
|
31
|
+
|
|
32
|
+
width: 32px;
|
|
33
|
+
height: 32px;
|
|
34
|
+
padding: 7px 6px;
|
|
35
|
+
|
|
36
|
+
color: ${(props) => props.theme.colors.background};
|
|
37
|
+
|
|
38
|
+
background-color: ${(props) => props.theme.colors.primary};
|
|
39
|
+
border: none;
|
|
40
|
+
border-radius: 2rem;
|
|
41
|
+
|
|
42
|
+
:hover {
|
|
43
|
+
background-color: ${(props) => props.theme.colors.primaryHover};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
:active {
|
|
47
|
+
background-color: ${(props) => props.theme.colors.primaryDown};
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
const StyledChat = injectCss(UiChat);
|
|
51
|
+
/**
|
|
52
|
+
* Parse the user data into the UI user data format
|
|
53
|
+
*
|
|
54
|
+
* @param user the user data to parse
|
|
55
|
+
*/
|
|
56
|
+
function parseUserData(user) {
|
|
57
|
+
return {
|
|
58
|
+
id: user === null || user === void 0 ? void 0 : user.identity_id,
|
|
59
|
+
name: user.identity_name,
|
|
60
|
+
email: user === null || user === void 0 ? void 0 : user.identity_email,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get all the users which have been active in the chat
|
|
65
|
+
*
|
|
66
|
+
* @param chat the chat to get users from
|
|
67
|
+
*/
|
|
68
|
+
function getAllUsersInChat(chat) {
|
|
69
|
+
const userMap = new Map();
|
|
70
|
+
chat.forEach((message) => {
|
|
71
|
+
const { email } = message.user;
|
|
72
|
+
// we get the users by email, since this list will be used to send users notifications later on about activity in chat, and this is the most relevant way of identifying them
|
|
73
|
+
if (email && !userMap.has(email)) {
|
|
74
|
+
userMap.set(email, message.user);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
// Return only the unique users who have an email
|
|
78
|
+
return Array.from(userMap.values());
|
|
79
|
+
}
|
|
80
|
+
/** User data for an unknown user */
|
|
81
|
+
const anonymousUser = { identity_name: 'Anonymous' };
|
|
82
|
+
/**
|
|
83
|
+
* Api call to send the new message payload
|
|
84
|
+
*/
|
|
85
|
+
function sendNewMessage(payload, extras) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
try {
|
|
88
|
+
const res = yield request('/api/chat/messages', {
|
|
89
|
+
body: JSON.stringify(payload),
|
|
90
|
+
method: HTTP_METHOD.POST,
|
|
91
|
+
}, extras);
|
|
92
|
+
yield handleAuthErrors(res, true);
|
|
93
|
+
yield validateResponse(res, 'Failed to send message notification');
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
// eslint-disable-next-line no-console
|
|
97
|
+
console.error('Failed to send message notification:', error);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Check if the given selector has been rendered more than once in the document
|
|
103
|
+
*
|
|
104
|
+
* @param selector the selector to check
|
|
105
|
+
*/
|
|
106
|
+
function checkMoreThanOneRenderedElement(selector) {
|
|
107
|
+
const elements = document.querySelectorAll(selector);
|
|
108
|
+
return elements.length > 1;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get the highest z-index of the elements with the given selector
|
|
112
|
+
*
|
|
113
|
+
* @param selector the selector to get the z-index from
|
|
114
|
+
*/
|
|
115
|
+
function getHighestZIndex(selector) {
|
|
116
|
+
const elements = document.querySelectorAll(selector);
|
|
117
|
+
let highest = 998; // Start with 998
|
|
118
|
+
elements.forEach((element) => {
|
|
119
|
+
const zIndex = parseInt(window.getComputedStyle(element).zIndex);
|
|
120
|
+
if (zIndex > highest) {
|
|
121
|
+
highest = zIndex;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
return highest;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The Chat component switches between a chat button and a chat sidebar, allowing the user to interact with a chat.
|
|
128
|
+
*
|
|
129
|
+
* @param props the component props
|
|
130
|
+
*/
|
|
131
|
+
function Chat(props) {
|
|
132
|
+
var _a;
|
|
133
|
+
const [style, css] = useComponentStyles(props);
|
|
134
|
+
const [value, setValue] = useVariable(props.value);
|
|
135
|
+
const [showChat, setShowChat] = React.useState(false);
|
|
136
|
+
const [areThereOtherChats, setAreThereOtherChats] = React.useState(false);
|
|
137
|
+
const [zIndex, setZIndex] = React.useState(998);
|
|
138
|
+
const user = useUser();
|
|
139
|
+
const theme = useTheme();
|
|
140
|
+
const extras = useRequestExtras();
|
|
141
|
+
const userData = (_a = user.data) !== null && _a !== void 0 ? _a : anonymousUser;
|
|
142
|
+
const onUpdate = (newValue) => {
|
|
143
|
+
// If the new value is longer than the old value, we can assume that a new message was added
|
|
144
|
+
// or if newValue is defined and value is not.
|
|
145
|
+
if ((newValue && !value) || (newValue === null || newValue === void 0 ? void 0 : newValue.length) > (value === null || value === void 0 ? void 0 : value.length)) {
|
|
146
|
+
const newMessage = newValue[newValue.length - 1];
|
|
147
|
+
const users = getAllUsersInChat(newValue);
|
|
148
|
+
const notificationPayload = {
|
|
149
|
+
app_url: window.location.href,
|
|
150
|
+
users,
|
|
151
|
+
content: newMessage,
|
|
152
|
+
};
|
|
153
|
+
sendNewMessage(notificationPayload, extras);
|
|
154
|
+
}
|
|
155
|
+
setValue(newValue);
|
|
156
|
+
};
|
|
157
|
+
const onClickChatButton = () => {
|
|
158
|
+
setShowChat(true);
|
|
159
|
+
setZIndex(getHighestZIndex('.chat-thread') + 1);
|
|
160
|
+
// we need to update here so that if the chat button is clicked again when it is already open, the background color is updated
|
|
161
|
+
setAreThereOtherChats(checkMoreThanOneRenderedElement('.chat-thread'));
|
|
162
|
+
};
|
|
163
|
+
React.useLayoutEffect(() => {
|
|
164
|
+
setAreThereOtherChats(checkMoreThanOneRenderedElement('.chat-thread'));
|
|
165
|
+
}, [showChat]);
|
|
166
|
+
return (_jsxs(_Fragment, { children: [showChat && (
|
|
167
|
+
// we set the z-index so that the latest chat thread opened is always on top, and if there is a chat thread open, we set the background color so that the transparency does not show the thread behind
|
|
168
|
+
_jsx(ThreadWrapper, { className: "chat-thread", style: {
|
|
169
|
+
zIndex,
|
|
170
|
+
backgroundColor: areThereOtherChats ? theme.colors.background : 'transparent',
|
|
171
|
+
}, children: _jsx(StyledChat, { "$rawCss": css, className: props.className, onClose: () => setShowChat(false), onUpdate: onUpdate, isPopup: true, style: Object.assign({}, style), value: value, activeUser: parseUserData(userData) }) })), _jsx(ChatButton, { onClick: onClickChatButton, children: _jsxs("svg", { fill: "none", height: "20", viewBox: "0 0 32 32", width: "20", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("rect", { fill: "none", height: "24", rx: "3", width: "30", x: "1", y: "1.33594" }), _jsx("rect", { height: "24", rx: "3", stroke: theme.colors.background, strokeWidth: "2", width: "30", x: "1", y: "1.33594" }), _jsx("path", { d: "M8 8.33594H24", stroke: theme.colors.background, strokeLinecap: "round", strokeWidth: "2" }), _jsx("path", { d: "M8 13.3359H24", stroke: theme.colors.background, strokeLinecap: "round", strokeWidth: "2" }), _jsx("path", { d: "M8 18.3359H24", stroke: theme.colors.background, strokeLinecap: "round", strokeWidth: "2" }), _jsx("path", { d: "M18.5981 26.1641L16 30.6641L13.4019 26.1641L18.5981 26.1641Z", fill: theme.colors.background, stroke: theme.colors.background }), _jsx("path", { d: "M16 28.3359L13.4019 23.8359L18.5981 23.8359L16 28.3359Z", fill: "none" })] }) })] }));
|
|
172
|
+
}
|
|
173
|
+
export default Chat;
|
|
174
|
+
//# sourceMappingURL=chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../../js/smart/chat/chat.tsx"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAKH,gBAAgB,EAChB,SAAS,EACT,OAAO,EACP,kBAAkB,EAClB,gBAAgB,EAChB,OAAO,EACP,WAAW,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAW,IAAI,IAAI,MAAM,EAA0B,MAAM,uBAAuB,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAejE,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;CAU/B,CAAC;AAEF,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAA;;;;;;;;;aASnB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,M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X,EAAE,EAAC,GAAG,EACN,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,UAAU,EAC/B,WAAW,EAAC,GAAG,EACf,KAAK,EAAC,IAAI,EACV,CAAC,EAAC,GAAG,EACL,CAAC,EAAC,SAAS,GACb,EACF,eAAM,CAAC,EAAC,eAAe,EAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,aAAa,EAAC,OAAO,EAAC,WAAW,EAAC,GAAG,GAAG,EACjG,eAAM,CAAC,EAAC,eAAe,EAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,aAAa,EAAC,OAAO,EAAC,WAAW,EAAC,GAAG,GAAG,EACjG,eAAM,CAAC,EAAC,eAAe,EAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,aAAa,EAAC,OAAO,EAAC,WAAW,EAAC,GAAG,GAAG,EACjG,eACI,CAAC,EAAC,8DAA8D,EAChE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,UAAU,EAC7B,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,UAAU,GACjC,EACF,eAAM,CAAC,EAAC,yDAAyD,EAAC,IAAI,EAAC,MAAM,GAAG,IAC9E,GACG,IACd,CACN,CAAC;AACN,CAAC;AAED,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StyledComponentProps, Variable } from '@darajs/core';
|
|
2
|
+
interface CodeEditorProps extends StyledComponentProps {
|
|
3
|
+
script: Variable<string>;
|
|
4
|
+
language?: 'json' | 'python' | 'markdown' | 'sql';
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A component that creates a CodeEditor. The script is stored in a variable and is updated
|
|
8
|
+
* as user types in the code editor area.
|
|
9
|
+
*/
|
|
10
|
+
declare function CodeEditor(props: CodeEditorProps): JSX.Element;
|
|
11
|
+
export default CodeEditor;
|
|
12
|
+
//# sourceMappingURL=code-editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-editor.d.ts","sourceRoot":"","sources":["../../js/smart/code-editor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAA8C,MAAM,cAAc,CAAC;AAG1G,UAAU,eAAgB,SAAQ,oBAAoB;IAClD,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,KAAK,CAAC;CACrD;AAID;;;GAGG;AACH,iBAAS,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,GAAG,CAAC,OAAO,CAavD;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { injectCss, useComponentStyles, useVariable } from '@darajs/core';
|
|
3
|
+
import { CodeEditor as UICodeEditor } from '@darajs/ui-code-editor';
|
|
4
|
+
const StyledCodeEditor = injectCss(UICodeEditor);
|
|
5
|
+
/**
|
|
6
|
+
* A component that creates a CodeEditor. The script is stored in a variable and is updated
|
|
7
|
+
* as user types in the code editor area.
|
|
8
|
+
*/
|
|
9
|
+
function CodeEditor(props) {
|
|
10
|
+
const [style, css] = useComponentStyles(props);
|
|
11
|
+
const [script, setScript] = useVariable(props.script);
|
|
12
|
+
return (_jsx(StyledCodeEditor, { "$rawCss": css, initialScript: script, onChange: setScript, style: style, language: props.language }));
|
|
13
|
+
}
|
|
14
|
+
export default CodeEditor;
|
|
15
|
+
//# sourceMappingURL=code-editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-editor.js","sourceRoot":"","sources":["../../js/smart/code-editor.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkC,SAAS,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC1G,OAAO,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAOpE,MAAM,gBAAgB,GAAG,SAAS,CAAC,YAAY,CAAC,CAAC;AAEjD;;;GAGG;AACH,SAAS,UAAU,CAAC,KAAsB;IACtC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAC/C,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAEtD,OAAO,CACH,KAAC,gBAAgB,eACJ,GAAG,EACZ,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,SAAS,EACnB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,KAAK,CAAC,QAAQ,GAC1B,CACL,CAAC;AACN,CAAC;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Variable } from '@darajs/core';
|
|
2
|
+
declare enum ColumnType {
|
|
3
|
+
CATEGORICAL = "categorical",
|
|
4
|
+
DATETIME = "datetime",
|
|
5
|
+
NUMERICAL = "numerical"
|
|
6
|
+
}
|
|
7
|
+
interface Column {
|
|
8
|
+
name: string;
|
|
9
|
+
type: ColumnType;
|
|
10
|
+
}
|
|
11
|
+
interface FilterInstance {
|
|
12
|
+
/**
|
|
13
|
+
* Used internally to uniquely identify filters - prevents us from having to rely on indexes
|
|
14
|
+
*/
|
|
15
|
+
__id: string;
|
|
16
|
+
column: string;
|
|
17
|
+
from_date: string;
|
|
18
|
+
range: string;
|
|
19
|
+
to_date: string;
|
|
20
|
+
values: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Parse a date value into a date
|
|
24
|
+
*
|
|
25
|
+
* @param date date to parse
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseDateString(date: string | Date): Date;
|
|
28
|
+
interface DataSlicerFilterProps {
|
|
29
|
+
/**
|
|
30
|
+
* List of available columns
|
|
31
|
+
*/
|
|
32
|
+
columns: Variable<Column[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Variable holding a list of filters
|
|
35
|
+
*/
|
|
36
|
+
filters: Variable<FilterInstance[]>;
|
|
37
|
+
/**
|
|
38
|
+
* Height of the filter component
|
|
39
|
+
*/
|
|
40
|
+
height: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* DataSlicerFilter displays an editable list of filters to apply to a dataset
|
|
44
|
+
*/
|
|
45
|
+
declare function DataSlicerFilter(props: DataSlicerFilterProps): JSX.Element;
|
|
46
|
+
export default DataSlicerFilter;
|
|
47
|
+
//# sourceMappingURL=data-slicer-filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-slicer-filter.d.ts","sourceRoot":"","sources":["../../../js/smart/data-slicer-filter/data-slicer-filter.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,QAAQ,EAAe,MAAM,cAAc,CAAC;AAKrD,aAAK,UAAU;IACX,WAAW,gBAAgB;IAC3B,QAAQ,aAAa;IACrB,SAAS,cAAc;CAC1B;AAED,UAAU,MAAM;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;CACpB;AAED,UAAU,cAAc;IACpB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAClB;AAsDD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAYzD;AAED,UAAU,qBAAqB;IAC3B;;OAEG;IACH,OAAO,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5B;;OAEG;IACH,OAAO,EAAE,QAAQ,CAAC,cAAc,EAAE,CAAC,CAAC;IACpC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAClB;AAID;;GAEG;AACH,iBAAS,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,GAAG,CAAC,OAAO,CAgHnE;AAED,eAAe,gBAAgB,CAAC"}
|