@perspective-dev/viewer 5.3.1 → 5.4.0
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/dist/cdn/perspective-viewer.js +6 -6
- package/dist/cdn/perspective-viewer.js.map +2 -2
- package/dist/css/blueprint.css +1 -1
- package/dist/css/botanical.css +1 -1
- package/dist/css/dracula.css +1 -1
- package/dist/css/eggplant.css +1 -1
- package/dist/css/gruvbox-dark.css +1 -1
- package/dist/css/gruvbox.css +1 -1
- package/dist/css/icons.css +1 -1
- package/dist/css/intl/ar.css +1 -0
- package/dist/css/intl/de.css +1 -1
- package/dist/css/intl/es.css +1 -1
- package/dist/css/intl/fr.css +1 -1
- package/dist/css/intl/ja.css +1 -1
- package/dist/css/intl/pt.css +1 -1
- package/dist/css/intl/zh.css +1 -1
- package/dist/css/intl.css +1 -1
- package/dist/css/ledger.css +1 -1
- package/dist/css/monokai.css +1 -1
- package/dist/css/nord.css +1 -1
- package/dist/css/phosphor.css +1 -1
- package/dist/css/pro-dark.css +1 -1
- package/dist/css/pro.css +1 -1
- package/dist/css/solarized-dark.css +1 -1
- package/dist/css/solarized.css +1 -1
- package/dist/css/themes.css +1 -1
- package/dist/css/vaporwave.css +1 -1
- package/dist/css/velvet.css +1 -1
- package/dist/docs/perspective-docs.json +1 -1
- package/dist/esm/extensions.d.ts +0 -5
- package/dist/esm/perspective-viewer.inline.js +9 -9
- package/dist/esm/perspective-viewer.inline.js.map +3 -3
- package/dist/esm/perspective-viewer.js +5 -5
- package/dist/esm/perspective-viewer.js.map +2 -2
- package/dist/esm/ts-rs/ViewOnUpdateResp.d.ts +1 -1
- package/dist/wasm/perspective-viewer.d.ts +62 -73
- package/dist/wasm/perspective-viewer.js +226 -238
- package/dist/wasm/perspective-viewer.wasm +0 -0
- package/dist/wasm/perspective-viewer.wasm.d.ts +18 -28
- package/package.json +7 -7
- package/src/css/_context_menu.css +1 -1
- package/src/css/_dropdown_menu.css +1 -1
- package/src/css/_viewer_bundle.css +7 -8
- package/src/css/column-dropdown.css +0 -3
- package/src/css/column-selector.css +8 -5
- package/src/css/column-settings-panel.css +0 -225
- package/src/css/column-style.css +13 -0
- package/src/css/config-selector.css +18 -10
- package/src/css/filter-dropdown.css +5 -5
- package/src/css/form/debug.css +28 -4
- package/src/css/function-dropdown.css +5 -5
- package/src/css/panel-tab.css +23 -0
- package/src/css/plugin-selector.css +5 -5
- package/src/css/render-warning.css +1 -1
- package/src/css/status-bar.css +52 -21
- package/src/css/type-icon.css +1 -3
- package/src/css/{containers → ui/containers}/context-menu.css +22 -16
- package/src/css/ui/containers/dropdown-menu-items.css +66 -0
- package/src/css/{containers → ui/containers}/dropdown-menu.css +8 -53
- package/src/css/viewer.css +32 -26
- package/src/rust/components/chat_panel.rs +1 -1
- package/src/rust/components/{form/code_editor.rs → code_editor.rs} +4 -2
- package/src/rust/components/column_dropdown.rs +2 -2
- package/src/rust/components/column_selector/active_column.rs +15 -9
- package/src/rust/components/column_selector/aggregate_selector.rs +1 -1
- package/src/rust/components/column_selector/config_selector.rs +2 -2
- package/src/rust/components/column_selector/filter_column.rs +8 -5
- package/src/rust/components/column_selector/inactive_column.rs +4 -2
- package/src/rust/components/column_selector/pivot_column.rs +4 -3
- package/src/rust/components/column_selector/sort_column.rs +7 -4
- package/src/rust/components/column_selector.rs +3 -3
- package/src/rust/components/column_settings_sidebar/style_tab/agg_depth_selector.rs +1 -1
- package/src/rust/components/column_settings_sidebar/style_tab/primitive_field.rs +15 -17
- package/src/rust/components/column_settings_sidebar/style_tab/symbol/symbol_selector.rs +1 -1
- package/src/rust/components/column_settings_sidebar/style_tab.rs +4 -5
- package/src/rust/components/column_settings_sidebar.rs +3 -4
- package/src/rust/components/copy_dropdown.rs +1 -1
- package/src/rust/components/datetime_column_style/custom.rs +1 -3
- package/src/rust/components/datetime_column_style/simple.rs +1 -2
- package/src/rust/components/datetime_column_style.rs +1 -2
- package/src/rust/components/{form/debug.rs → debug_panel.rs} +5 -5
- package/src/rust/components/{containers/dragdrop_list.rs → dragdrop_list.rs} +2 -10
- package/src/rust/components/export_dropdown.rs +1 -1
- package/src/rust/components/expression_editor.rs +1 -1
- package/src/rust/components/filter_dropdown.rs +2 -2
- package/src/rust/components/function_dropdown.rs +2 -2
- package/src/rust/components/main_panel/frame_theme.rs +3 -59
- package/src/rust/components/main_panel/reconcile.rs +9 -4
- package/src/rust/components/main_panel/render.rs +62 -11
- package/src/rust/components/main_panel/update.rs +39 -10
- package/src/rust/components/main_panel.rs +26 -2
- package/src/rust/components/mod.rs +5 -7
- package/src/rust/components/new_panel_menu.rs +97 -0
- package/src/rust/components/number_series_style.rs +2 -3
- package/src/rust/components/panel_menu.rs +61 -87
- package/src/rust/components/panel_tab.rs +100 -43
- package/src/rust/components/plugin_tab.rs +1 -1
- package/src/rust/components/render_warning.rs +2 -2
- package/src/rust/components/{status_bar_counter.rs → rows_counter.rs} +10 -10
- package/src/rust/components/settings_panel.rs +2 -2
- package/src/rust/components/status_bar.rs +113 -19
- package/src/rust/components/status_indicator.rs +5 -14
- package/src/rust/components/string_column_style.rs +1 -2
- package/src/rust/components/{style/mod.rs → style.rs} +32 -15
- package/src/rust/components/style_controls/number_string_format/digits_section.rs +3 -5
- package/src/rust/components/style_controls/number_string_format/misc_section.rs +1 -1
- package/src/rust/components/style_controls/number_string_format/style_section.rs +1 -1
- package/src/rust/components/viewer/msg.rs +43 -30
- package/src/rust/components/viewer/panels.rs +50 -19
- package/src/rust/components/viewer/render.rs +15 -13
- package/src/rust/components/viewer/settings.rs +137 -68
- package/src/rust/components/viewer/snapshots.rs +5 -10
- package/src/rust/components/viewer/wiring.rs +1 -21
- package/src/rust/components/viewer.rs +15 -10
- package/src/rust/components/window_editor.rs +8 -9
- package/src/rust/config/column_config_schema.rs +2 -27
- package/src/rust/config/mod.rs +0 -2
- package/src/rust/config/workspace_config.rs +2 -1
- package/src/rust/custom_elements/debug_plugin.rs +1 -10
- package/src/rust/custom_elements/mod.rs +0 -3
- package/src/rust/custom_elements/viewer.rs +0 -18
- package/src/rust/js/plugin.rs +0 -86
- package/src/rust/lib.rs +12 -15
- package/src/rust/presentation/column_locator.rs +3 -7
- package/src/rust/presentation.rs +68 -38
- package/src/rust/queries/hosted_tables.rs +38 -0
- package/src/rust/queries/mod.rs +2 -0
- package/src/rust/queries/palette_set.rs +1 -1
- package/src/rust/renderer/activate.rs +1 -3
- package/src/rust/renderer/dispatch.rs +83 -22
- package/src/rust/renderer/limits.rs +24 -5
- package/src/rust/renderer/plugin_config.rs +1 -0
- package/src/rust/renderer/props.rs +2 -1
- package/src/rust/renderer.rs +14 -27
- package/src/rust/session/props.rs +4 -3
- package/src/rust/session/view_subscription.rs +19 -6
- package/src/rust/session.rs +38 -70
- package/src/rust/tasks/create_panel.rs +1 -1
- package/src/rust/tasks/dismiss_render_warning.rs +1 -1
- package/src/rust/tasks/eject.rs +1 -0
- package/src/rust/tasks/pipeline.rs +0 -60
- package/src/rust/tasks/presize_panels.rs +24 -1
- package/src/rust/tasks/restore_and_render.rs +0 -17
- package/src/rust/tasks/send_column_config.rs +1 -1
- package/src/rust/tasks/send_plugin_config.rs +1 -1
- package/src/rust/tasks/set_edit_mode.rs +1 -1
- package/src/rust/{components → ui}/containers/control_group.rs +25 -3
- package/src/rust/{components → ui}/containers/dropdown_menu.rs +5 -2
- package/src/rust/{components → ui}/containers/mod.rs +0 -4
- package/src/rust/{components → ui}/containers/scroll_panel.rs +0 -22
- package/src/rust/{components → ui}/containers/scroll_panel_item.rs +0 -13
- package/src/rust/{components → ui}/containers/select.rs +0 -6
- package/src/rust/{components → ui}/containers/sidebar.rs +5 -32
- package/src/rust/{components → ui}/containers/split_panel.rs +8 -80
- package/src/rust/{components → ui}/containers/tab_list.rs +15 -9
- package/src/rust/{components → ui}/context_menu.rs +8 -13
- package/src/rust/{presentation/drag_helpers.rs → ui/dragdrop.rs} +26 -31
- package/src/rust/{components → ui}/font_loader.rs +0 -26
- package/src/rust/{components → ui}/form/color_selector.rs +4 -2
- package/src/rust/ui/form/intl_label.rs +81 -0
- package/src/rust/{components → ui}/form/mirrored_textarea.rs +0 -53
- package/src/rust/{components → ui}/form/mod.rs +1 -10
- package/src/rust/{components → ui}/form/multi_stop_gradient_selector.rs +4 -5
- package/src/rust/{components → ui}/form/named_value_picker.rs +1 -6
- package/src/rust/{components → ui}/form/number_field.rs +1 -1
- package/src/rust/{components → ui}/form/number_range_field.rs +1 -1
- package/src/rust/{components → ui}/form/optional_field.rs +3 -1
- package/src/rust/{components → ui}/form/palette_selector.rs +4 -5
- package/src/rust/{components → ui}/form/select_enum_field.rs +2 -2
- package/src/rust/{components → ui}/form/select_value_field.rs +2 -2
- package/src/rust/ui/mod.rs +56 -0
- package/src/rust/ui/modal.rs +61 -0
- package/src/rust/{components → ui}/portal.rs +174 -79
- package/src/rust/{components/style/style_provider.rs → ui/style.rs} +4 -34
- package/src/rust/utils/completion.rs +0 -6
- package/src/rust/{config/css_scale.rs → utils/css.rs} +38 -35
- package/src/rust/utils/mod.rs +2 -0
- package/src/rust/workspace.rs +35 -0
- package/src/svg/boolean-type.svg +3 -2
- package/src/svg/checkbox-checked-icon.svg +4 -7
- package/src/svg/checkbox-hover.svg +3 -3
- package/src/svg/checkbox-off.svg +2 -3
- package/src/svg/checkbox-on.svg +3 -3
- package/src/svg/checkbox-unchecked-icon.svg +3 -3
- package/src/svg/datagrid-select-column.svg +8 -15
- package/src/svg/datagrid-select-region.svg +8 -15
- package/src/svg/datagrid-select-row-tree.svg +7 -12
- package/src/svg/datagrid-select-row.svg +8 -13
- package/src/svg/date-type.svg +4 -23
- package/src/svg/drawer-tab-hover.svg +4 -6
- package/src/svg/drawer-tab-invert-hover.svg +5 -5
- package/src/svg/drawer-tab-invert.svg +3 -5
- package/src/svg/drawer-tab.svg +5 -5
- package/src/svg/mega-menu-icons-candlestick.svg +5 -37
- package/src/svg/mega-menu-icons-ohlc.svg +4 -39
- package/src/svg/mega-menu-icons-sunburst.svg +4 -38
- package/src/svg/mega-menu-icons-treemap.svg +3 -43
- package/src/svg/mega-menu-icons-y-scatter.svg +12 -72
- package/src/svg/new-panel-icon.svg +4 -0
- package/src/svg/number-type.svg +3 -3
- package/src/svg/radio-hover.svg +3 -3
- package/src/svg/radio-off.svg +3 -3
- package/src/svg/radio-on.svg +3 -3
- package/src/svg/status_ok.svg +3 -26
- package/src/svg/string-type.svg +4 -8
- package/src/svg/theme-icon.svg +5 -5
- package/src/themes/blueprint.css +0 -57
- package/src/themes/botanical.css +0 -36
- package/src/themes/defaults.css +1 -24
- package/src/themes/dracula.css +0 -58
- package/src/themes/eggplant.css +0 -58
- package/src/themes/gruvbox-dark.css +0 -65
- package/src/themes/gruvbox.css +1 -39
- package/src/themes/icons.css +1 -8
- package/src/themes/intl/ar.css +185 -0
- package/src/themes/intl/de.css +45 -35
- package/src/themes/intl/es.css +40 -30
- package/src/themes/intl/fr.css +39 -29
- package/src/themes/intl/ja.css +41 -31
- package/src/themes/intl/pt.css +37 -27
- package/src/themes/intl/zh.css +47 -37
- package/src/themes/intl.css +16 -3
- package/src/themes/ledger.css +1 -59
- package/src/themes/monokai.css +0 -51
- package/src/themes/nord.css +0 -55
- package/src/themes/phosphor.css +0 -48
- package/src/themes/pro-dark.css +0 -37
- package/src/themes/pro.css +3 -23
- package/src/themes/solarized-dark.css +0 -31
- package/src/themes/solarized.css +1 -24
- package/src/themes/vaporwave.css +0 -44
- package/src/themes/velvet.css +0 -60
- package/src/ts/extensions.ts +0 -13
- package/src/ts/ts-rs/ViewOnUpdateResp.ts +1 -1
- package/src/css/plugin-settings-panel.css +0 -171
- package/src/rust/components/modal.rs +0 -177
- package/src/rust/custom_elements/copy_dropdown.rs +0 -219
- package/src/rust/custom_elements/export_dropdown.rs +0 -216
- package/src/rust/custom_elements/modal.rs +0 -299
- /package/dist/wasm/snippets/{perspective-viewer-87bd21b215d0631a → perspective-viewer-adc6f3f79141112b}/inline0.js +0 -0
- /package/dist/wasm/snippets/{perspective-viewer-87bd21b215d0631a → perspective-viewer-adc6f3f79141112b}/inline1.js +0 -0
- /package/dist/wasm/snippets/{perspective-viewer-87bd21b215d0631a → perspective-viewer-adc6f3f79141112b}/inline2.js +0 -0
- /package/dist/wasm/snippets/{perspective-viewer-87bd21b215d0631a → perspective-viewer-adc6f3f79141112b}/inline3.js +0 -0
- /package/dist/wasm/snippets/{perspective-viewer-87bd21b215d0631a → perspective-viewer-adc6f3f79141112b}/inline4.js +0 -0
- /package/dist/wasm/snippets/{perspective-viewer-87bd21b215d0631a → perspective-viewer-adc6f3f79141112b}/inline5.js +0 -0
- /package/src/css/{containers → ui/containers}/scroll-panel.css +0 -0
- /package/src/css/{containers → ui/containers}/split-panel.css +0 -0
- /package/src/css/{containers → ui/containers}/tabs.css +0 -0
- /package/src/css/{dom → ui/dom}/checkbox.css +0 -0
- /package/src/css/{dom → ui/dom}/scrollbar.css +0 -0
- /package/src/css/{dom → ui/dom}/select.css +0 -0
- /package/src/css/{form → ui/form}/mirrored-textarea.css +0 -0
- /package/src/rust/components/{form → code_editor}/highlight.rs +0 -0
- /package/src/rust/{components → ui}/containers/sidebar_close_button.rs +0 -0
- /package/src/rust/{components → ui}/form/number_input.rs +0 -0
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
|
2
|
-
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
|
|
3
|
-
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
|
|
4
|
-
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
|
|
5
|
-
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
|
|
6
|
-
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
|
|
7
|
-
// ┃ Copyright (c) 2017, the Perspective Authors. ┃
|
|
8
|
-
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
|
|
9
|
-
// ┃ This file is part of the Perspective library, distributed under the terms ┃
|
|
10
|
-
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
|
|
11
|
-
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
|
12
|
-
|
|
13
|
-
use std::cell::RefCell;
|
|
14
|
-
use std::rc::Rc;
|
|
15
|
-
|
|
16
|
-
use perspective_js::utils::global;
|
|
17
|
-
use wasm_bindgen::prelude::*;
|
|
18
|
-
use wasm_bindgen_futures::spawn_local;
|
|
19
|
-
use web_sys::*;
|
|
20
|
-
use yew::prelude::*;
|
|
21
|
-
|
|
22
|
-
use super::viewer::PerspectiveViewerElement;
|
|
23
|
-
use crate::components::export_dropdown::ExportDropDownMenu;
|
|
24
|
-
use crate::components::portal::PortalModal;
|
|
25
|
-
use crate::components::style::{StyleProvider, StyleSurface};
|
|
26
|
-
use crate::config::*;
|
|
27
|
-
use crate::presentation::Presentation;
|
|
28
|
-
use crate::renderer::*;
|
|
29
|
-
use crate::session::*;
|
|
30
|
-
use crate::tasks::*;
|
|
31
|
-
use crate::utils::*;
|
|
32
|
-
use crate::*;
|
|
33
|
-
|
|
34
|
-
type TargetState = Rc<RefCell<Option<HtmlElement>>>;
|
|
35
|
-
|
|
36
|
-
#[derive(Properties, PartialEq)]
|
|
37
|
-
struct ExportDropDownWrapperProps {
|
|
38
|
-
renderer: Renderer,
|
|
39
|
-
session: Session,
|
|
40
|
-
callback: Callback<ExportFile>,
|
|
41
|
-
target: TargetState,
|
|
42
|
-
custom_element: HtmlElement,
|
|
43
|
-
#[prop_or_default]
|
|
44
|
-
theme: String,
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
enum ExportDropDownWrapperMsg {
|
|
48
|
-
Open,
|
|
49
|
-
Close,
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
struct ExportDropDownWrapper {
|
|
53
|
-
target: Option<HtmlElement>,
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
impl Component for ExportDropDownWrapper {
|
|
57
|
-
type Message = ExportDropDownWrapperMsg;
|
|
58
|
-
type Properties = ExportDropDownWrapperProps;
|
|
59
|
-
|
|
60
|
-
fn create(_ctx: &Context<Self>) -> Self {
|
|
61
|
-
Self { target: None }
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool {
|
|
65
|
-
match msg {
|
|
66
|
-
ExportDropDownWrapperMsg::Open => {
|
|
67
|
-
self.target = ctx.props().target.borrow().clone();
|
|
68
|
-
true
|
|
69
|
-
},
|
|
70
|
-
ExportDropDownWrapperMsg::Close => {
|
|
71
|
-
self.target = None;
|
|
72
|
-
true
|
|
73
|
-
},
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
fn view(&self, ctx: &Context<Self>) -> Html {
|
|
78
|
-
let on_close = ctx.link().callback(|_| ExportDropDownWrapperMsg::Close);
|
|
79
|
-
html! {
|
|
80
|
-
<StyleProvider
|
|
81
|
-
root={ctx.props().custom_element.clone()}
|
|
82
|
-
surface={StyleSurface::DropdownMenu}
|
|
83
|
-
>
|
|
84
|
-
<PortalModal
|
|
85
|
-
tag_name="perspective-export-menu"
|
|
86
|
-
surface={StyleSurface::DropdownMenu}
|
|
87
|
-
target={self.target.clone()}
|
|
88
|
-
own_focus=true
|
|
89
|
-
{on_close}
|
|
90
|
-
theme={ctx.props().theme.clone()}
|
|
91
|
-
>
|
|
92
|
-
<ExportDropDownMenu
|
|
93
|
-
renderer={ctx.props().renderer.clone()}
|
|
94
|
-
session={ctx.props().session.clone()}
|
|
95
|
-
callback={ctx.props().callback.clone()}
|
|
96
|
-
/>
|
|
97
|
-
</PortalModal>
|
|
98
|
-
</StyleProvider>
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
#[wasm_bindgen]
|
|
104
|
-
#[derive(Clone)]
|
|
105
|
-
pub struct ExportDropDownMenuElement {
|
|
106
|
-
elem: HtmlElement,
|
|
107
|
-
target: TargetState,
|
|
108
|
-
root: Rc<RefCell<Option<AppHandle<ExportDropDownWrapper>>>>,
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
impl CustomElementMetadata for ExportDropDownMenuElement {
|
|
112
|
-
const CUSTOM_ELEMENT_NAME: &'static str = "perspective-export-menu";
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
#[wasm_bindgen]
|
|
116
|
-
impl ExportDropDownMenuElement {
|
|
117
|
-
#[wasm_bindgen(constructor)]
|
|
118
|
-
pub fn new(elem: HtmlElement) -> Self {
|
|
119
|
-
Self {
|
|
120
|
-
elem,
|
|
121
|
-
target: Default::default(),
|
|
122
|
-
root: Default::default(),
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
pub fn open(&self, target: HtmlElement) {
|
|
127
|
-
*self.target.borrow_mut() = Some(target);
|
|
128
|
-
if let Some(root) = self.root.borrow().as_ref() {
|
|
129
|
-
root.send_message(ExportDropDownWrapperMsg::Open);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
pub fn hide(&self) -> ApiResult<()> {
|
|
134
|
-
if let Some(root) = self.root.borrow().as_ref() {
|
|
135
|
-
root.send_message(ExportDropDownWrapperMsg::Close);
|
|
136
|
-
}
|
|
137
|
-
Ok(())
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
pub fn __set_model(&self, parent: &PerspectiveViewerElement) {
|
|
141
|
-
if let Some(panel) = parent.workspace.active_panel() {
|
|
142
|
-
self.set_config_model(&panel.session, &panel.renderer, &parent.presentation);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
pub fn connected_callback(&self) {}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
impl ExportDropDownMenuElement {
|
|
150
|
-
pub fn new_from_model(
|
|
151
|
-
session: &Session,
|
|
152
|
-
renderer: &Renderer,
|
|
153
|
-
presentation: &Presentation,
|
|
154
|
-
) -> Self {
|
|
155
|
-
let dropdown = global::document()
|
|
156
|
-
.create_element("perspective-export-menu")
|
|
157
|
-
.unwrap()
|
|
158
|
-
.unchecked_into::<HtmlElement>();
|
|
159
|
-
|
|
160
|
-
let elem = Self::new(dropdown);
|
|
161
|
-
elem.set_config_model(session, renderer, presentation);
|
|
162
|
-
elem
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
fn set_config_model(
|
|
166
|
-
&self,
|
|
167
|
-
session: &Session,
|
|
168
|
-
renderer: &Renderer,
|
|
169
|
-
presentation: &Presentation,
|
|
170
|
-
) {
|
|
171
|
-
let callback = Callback::from({
|
|
172
|
-
let session = session.clone();
|
|
173
|
-
let renderer = renderer.clone();
|
|
174
|
-
let presentation = presentation.clone();
|
|
175
|
-
let target = self.target.clone();
|
|
176
|
-
let root = self.root.clone();
|
|
177
|
-
move |x: ExportFile| {
|
|
178
|
-
if !x.name.is_empty() {
|
|
179
|
-
clone!(target, root, session, renderer, presentation);
|
|
180
|
-
spawn_local(async move {
|
|
181
|
-
let val =
|
|
182
|
-
export_method_to_blob(&session, &renderer, &presentation, x.method)
|
|
183
|
-
.await
|
|
184
|
-
.unwrap();
|
|
185
|
-
let is_chart = renderer.is_chart();
|
|
186
|
-
download(&x.as_filename(is_chart), &val).unwrap();
|
|
187
|
-
*target.borrow_mut() = None;
|
|
188
|
-
if let Some(root) = root.borrow().as_ref() {
|
|
189
|
-
root.send_message(ExportDropDownWrapperMsg::Close);
|
|
190
|
-
}
|
|
191
|
-
})
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
let renderer = renderer.clone();
|
|
197
|
-
let session = session.clone();
|
|
198
|
-
let init = ShadowRootInit::new(ShadowRootMode::Open);
|
|
199
|
-
let shadow_root = self
|
|
200
|
-
.elem
|
|
201
|
-
.attach_shadow(&init)
|
|
202
|
-
.unwrap()
|
|
203
|
-
.unchecked_into::<Element>();
|
|
204
|
-
|
|
205
|
-
let props = yew::props!(ExportDropDownWrapperProps {
|
|
206
|
-
renderer,
|
|
207
|
-
session,
|
|
208
|
-
callback,
|
|
209
|
-
target: self.target.clone(),
|
|
210
|
-
custom_element: self.elem.clone(),
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
let handle = yew::Renderer::with_root_and_props(shadow_root, props).render();
|
|
214
|
-
*self.root.borrow_mut() = Some(handle);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
|
2
|
-
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
|
|
3
|
-
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
|
|
4
|
-
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
|
|
5
|
-
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
|
|
6
|
-
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
|
|
7
|
-
// ┃ Copyright (c) 2017, the Perspective Authors. ┃
|
|
8
|
-
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
|
|
9
|
-
// ┃ This file is part of the Perspective library, distributed under the terms ┃
|
|
10
|
-
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
|
|
11
|
-
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
|
12
|
-
|
|
13
|
-
use std::cell::{Cell, RefCell};
|
|
14
|
-
use std::rc::Rc;
|
|
15
|
-
|
|
16
|
-
use derivative::Derivative;
|
|
17
|
-
use futures::Future;
|
|
18
|
-
use perspective_js::utils::{global, *};
|
|
19
|
-
use wasm_bindgen::JsCast;
|
|
20
|
-
use wasm_bindgen::prelude::*;
|
|
21
|
-
use web_sys::*;
|
|
22
|
-
use yew::html::SendAsMessage;
|
|
23
|
-
use yew::prelude::*;
|
|
24
|
-
|
|
25
|
-
use crate::components::modal::*;
|
|
26
|
-
use crate::utils::*;
|
|
27
|
-
|
|
28
|
-
type BlurHandlerType = Rc<RefCell<Option<Closure<dyn FnMut(FocusEvent)>>>>;
|
|
29
|
-
|
|
30
|
-
/// A `ModalElement` wraps the parameterized yew `Component` in a Custom
|
|
31
|
-
/// Element.
|
|
32
|
-
///
|
|
33
|
-
/// Via the `open()` and `close()` methods, a `ModalElement` can be positioned
|
|
34
|
-
/// next to any existing on-page elements, accounting for viewport,
|
|
35
|
-
/// scroll position, etc.
|
|
36
|
-
///
|
|
37
|
-
/// `#[derive(Clone)]` generates the trait bound `T: Clone`, which is not
|
|
38
|
-
/// required because `Scope<T>` implements Clone without this bound; thus
|
|
39
|
-
/// `Clone` must be implemented by the `derivative` crate's
|
|
40
|
-
/// [custom bounds](https://mcarton.github.io/rust-derivative/latest/Debug.html#custom-bound)
|
|
41
|
-
/// support.
|
|
42
|
-
#[derive(Derivative)]
|
|
43
|
-
#[derivative(Clone(bound = ""))]
|
|
44
|
-
pub struct ModalElement<T>
|
|
45
|
-
where
|
|
46
|
-
T: Component,
|
|
47
|
-
T::Properties: ModalLink<T>,
|
|
48
|
-
{
|
|
49
|
-
root: Rc<RefCell<Option<AppHandle<Modal<T>>>>>,
|
|
50
|
-
pub custom_element: HtmlElement,
|
|
51
|
-
target: Rc<RefCell<Option<HtmlElement>>>,
|
|
52
|
-
blurhandler: BlurHandlerType,
|
|
53
|
-
own_focus: bool,
|
|
54
|
-
resize_sub: Rc<RefCell<Option<Subscription>>>,
|
|
55
|
-
anchor: Rc<Cell<ModalAnchor>>,
|
|
56
|
-
on_blur: Option<Callback<()>>,
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
impl<T> ModalElement<T>
|
|
60
|
-
where
|
|
61
|
-
T: Component,
|
|
62
|
-
T::Properties: ModalLink<T>,
|
|
63
|
-
{
|
|
64
|
-
pub fn new(
|
|
65
|
-
custom_element: web_sys::HtmlElement,
|
|
66
|
-
props: T::Properties,
|
|
67
|
-
own_focus: bool,
|
|
68
|
-
on_blur: Option<Callback<()>>,
|
|
69
|
-
) -> Self {
|
|
70
|
-
custom_element.set_attribute("tabindex", "0").unwrap();
|
|
71
|
-
let init = web_sys::ShadowRootInit::new(web_sys::ShadowRootMode::Open);
|
|
72
|
-
let shadow_root = custom_element
|
|
73
|
-
.attach_shadow(&init)
|
|
74
|
-
.unwrap()
|
|
75
|
-
.unchecked_into::<web_sys::Element>();
|
|
76
|
-
|
|
77
|
-
let cprops = yew::props!(ModalProps<T> {
|
|
78
|
-
child: Some(html_nested! {
|
|
79
|
-
<T ..props />
|
|
80
|
-
}),
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
let root = Rc::new(RefCell::new(Some(
|
|
84
|
-
yew::Renderer::with_root_and_props(shadow_root, cprops).render(),
|
|
85
|
-
)));
|
|
86
|
-
|
|
87
|
-
let blurhandler = Rc::new(RefCell::new(None));
|
|
88
|
-
Self {
|
|
89
|
-
root,
|
|
90
|
-
custom_element,
|
|
91
|
-
target: Rc::new(RefCell::new(None)),
|
|
92
|
-
own_focus,
|
|
93
|
-
blurhandler,
|
|
94
|
-
resize_sub: Rc::new(RefCell::new(None)),
|
|
95
|
-
anchor: Default::default(),
|
|
96
|
-
on_blur,
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
fn calc_anchor_pos(&self, target: &HtmlElement) -> (f64, f64) {
|
|
101
|
-
let target_rect = target.get_bounding_client_rect();
|
|
102
|
-
let modal_rect = self.custom_element.get_bounding_client_rect();
|
|
103
|
-
calc_anchor_position(self.anchor.get(), &target_rect, &modal_rect)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
async fn open_within_viewport(&self, target: HtmlElement) -> ApiResult<()> {
|
|
107
|
-
let elem = target.unchecked_ref::<HtmlElement>();
|
|
108
|
-
let rect = elem.get_bounding_client_rect();
|
|
109
|
-
let width = rect.width();
|
|
110
|
-
let height = rect.height();
|
|
111
|
-
let top = rect.top();
|
|
112
|
-
let left = rect.left();
|
|
113
|
-
*self.target.borrow_mut() = Some(target.clone());
|
|
114
|
-
|
|
115
|
-
// Default, top left/bottom left
|
|
116
|
-
let msg = ModalMsg::SetPos {
|
|
117
|
-
top: top + height - 1.0,
|
|
118
|
-
left,
|
|
119
|
-
visible: false,
|
|
120
|
-
rev_vert: false,
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
self.root.borrow().as_ref().unwrap().send_message(msg);
|
|
124
|
-
global::body().append_child(&self.custom_element)?;
|
|
125
|
-
request_animation_frame().await;
|
|
126
|
-
|
|
127
|
-
// Check if the modal has been positioned off-screen and re-locate if necessary
|
|
128
|
-
self.anchor.set(calc_relative_position(
|
|
129
|
-
&self.custom_element,
|
|
130
|
-
top,
|
|
131
|
-
left,
|
|
132
|
-
height,
|
|
133
|
-
width,
|
|
134
|
-
));
|
|
135
|
-
|
|
136
|
-
let (top, left) = self.calc_anchor_pos(&target);
|
|
137
|
-
let msg = ModalMsg::SetPos {
|
|
138
|
-
top,
|
|
139
|
-
left,
|
|
140
|
-
visible: true,
|
|
141
|
-
rev_vert: self.anchor.get().is_rev_vert(),
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
self.root.borrow().as_ref().unwrap().send_message(msg);
|
|
145
|
-
|
|
146
|
-
if self.own_focus {
|
|
147
|
-
let mut this = Some(self.clone());
|
|
148
|
-
*self.blurhandler.borrow_mut() = Some(Closure::new(move |_| {
|
|
149
|
-
this.take().and_then(|x| x.hide().ok()).unwrap_or(())
|
|
150
|
-
}));
|
|
151
|
-
|
|
152
|
-
self.custom_element
|
|
153
|
-
.dataset()
|
|
154
|
-
.set("poscorrected", "true")
|
|
155
|
-
.unwrap();
|
|
156
|
-
|
|
157
|
-
self.custom_element.add_event_listener_with_callback(
|
|
158
|
-
"blur",
|
|
159
|
-
self.blurhandler
|
|
160
|
-
.borrow()
|
|
161
|
-
.as_ref()
|
|
162
|
-
.unwrap()
|
|
163
|
-
.as_ref()
|
|
164
|
-
.unchecked_ref(),
|
|
165
|
-
)?;
|
|
166
|
-
|
|
167
|
-
Ok(self.custom_element.focus()?)
|
|
168
|
-
} else {
|
|
169
|
-
Ok(())
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
pub fn send_message(&self, msg: T::Message) {
|
|
174
|
-
self.root
|
|
175
|
-
.borrow()
|
|
176
|
-
.as_ref()
|
|
177
|
-
.unwrap()
|
|
178
|
-
.send_message(ModalMsg::SubMsg(msg))
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
pub fn send_message_batch(&self, msgs: Vec<T::Message>) {
|
|
182
|
-
self.root
|
|
183
|
-
.borrow()
|
|
184
|
-
.as_ref()
|
|
185
|
-
.unwrap()
|
|
186
|
-
.send_message_batch(msgs.into_iter().map(ModalMsg::SubMsg).collect())
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
pub fn send_future_batch<Fut>(&self, future: Fut)
|
|
190
|
-
where
|
|
191
|
-
Fut: Future + 'static,
|
|
192
|
-
Fut::Output: SendAsMessage<Modal<T>>,
|
|
193
|
-
{
|
|
194
|
-
self.root
|
|
195
|
-
.borrow()
|
|
196
|
-
.as_ref()
|
|
197
|
-
.unwrap()
|
|
198
|
-
.send_future_batch(future)
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/// Open this modal by attaching directly to `document.body` with position
|
|
202
|
-
/// absolutely positioned relative to an alread-connected `target`
|
|
203
|
-
/// element.
|
|
204
|
-
///
|
|
205
|
-
/// Because the Custom Element has a `blur` handler, we must invoke this
|
|
206
|
-
/// before attempting to re-parent the element.
|
|
207
|
-
pub async fn open(
|
|
208
|
-
self,
|
|
209
|
-
target: web_sys::HtmlElement,
|
|
210
|
-
resize_pubsub: Option<&PubSub<()>>,
|
|
211
|
-
) -> ApiResult<()> {
|
|
212
|
-
if let Some(resize) = resize_pubsub {
|
|
213
|
-
let this = self.clone();
|
|
214
|
-
let target = target.clone();
|
|
215
|
-
let anchor = self.anchor.clone();
|
|
216
|
-
*self.resize_sub.borrow_mut() = Some(resize.add_listener(move |()| {
|
|
217
|
-
let (top, left) = this.calc_anchor_pos(&target);
|
|
218
|
-
let msg = ModalMsg::SetPos {
|
|
219
|
-
top,
|
|
220
|
-
left,
|
|
221
|
-
visible: true,
|
|
222
|
-
rev_vert: anchor.get().is_rev_vert(),
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
this.root.borrow().as_ref().unwrap().send_message(msg);
|
|
226
|
-
}));
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
target.class_list().add_1("modal-target").unwrap();
|
|
230
|
-
let theme = get_theme(&target);
|
|
231
|
-
self.open_within_viewport(target).await.unwrap();
|
|
232
|
-
if let Some(theme) = theme {
|
|
233
|
-
self.custom_element.set_attribute("theme", &theme).unwrap();
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
Ok(())
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
pub fn is_open(&self) -> bool {
|
|
240
|
-
self.custom_element.is_connected()
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/// Remove from document.
|
|
244
|
-
pub fn hide(&self) -> ApiResult<()> {
|
|
245
|
-
if self.is_open() {
|
|
246
|
-
if self.own_focus {
|
|
247
|
-
self.custom_element.remove_event_listener_with_callback(
|
|
248
|
-
"blur",
|
|
249
|
-
self.blurhandler
|
|
250
|
-
.borrow()
|
|
251
|
-
.as_ref()
|
|
252
|
-
.unwrap()
|
|
253
|
-
.as_ref()
|
|
254
|
-
.unchecked_ref(),
|
|
255
|
-
)?;
|
|
256
|
-
|
|
257
|
-
*self.blurhandler.borrow_mut() = None;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
global::body().remove_child(&self.custom_element)?;
|
|
261
|
-
if let Some(blur) = &self.on_blur {
|
|
262
|
-
blur.emit(());
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
let target = self.target.borrow_mut().take().unwrap();
|
|
266
|
-
let event = web_sys::CustomEvent::new("-perspective-close-expression")?;
|
|
267
|
-
target.class_list().remove_1("modal-target").unwrap();
|
|
268
|
-
if get_theme(&target).is_some() {
|
|
269
|
-
self.custom_element.remove_attribute("theme")?;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
target.dispatch_event(&event)?;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
Ok(())
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
/// Remove from document and cleanup.
|
|
279
|
-
pub fn destroy(self) -> ApiResult<()> {
|
|
280
|
-
self.hide()?;
|
|
281
|
-
self.root.borrow_mut().take().unwrap().destroy();
|
|
282
|
-
Ok(())
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
fn get_theme(elem: &HtmlElement) -> Option<String> {
|
|
287
|
-
let styles = global::window().get_computed_style(elem).unwrap().unwrap();
|
|
288
|
-
styles
|
|
289
|
-
.get_property_value("--psp-theme-name")
|
|
290
|
-
.ok()
|
|
291
|
-
.and_then(|x| {
|
|
292
|
-
let trimmed = x.trim();
|
|
293
|
-
if !trimmed.is_empty() {
|
|
294
|
-
Some(trimmed[1..trimmed.len() - 1].to_owned())
|
|
295
|
-
} else {
|
|
296
|
-
None
|
|
297
|
-
}
|
|
298
|
-
})
|
|
299
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|