@perspective-dev/viewer 5.5.1 → 5.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +82 -3
- package/dist/cdn/perspective-viewer.js +9 -9
- package/dist/cdn/perspective-viewer.js.map +4 -4
- 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 -1
- 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/column-format.js +2 -0
- package/dist/esm/column-format.js.map +7 -0
- package/dist/esm/extensions.d.ts +3 -13
- package/dist/esm/perspective-viewer.d.ts +1 -1
- package/dist/esm/perspective-viewer.js +9 -9
- package/dist/esm/perspective-viewer.js.map +4 -4
- package/dist/esm/plugin.d.ts +4 -1
- package/dist/esm/select-detail.d.ts +15 -0
- package/dist/esm/select-detail.js +2 -0
- package/dist/esm/select-detail.js.map +7 -0
- package/dist/esm/ts-rs/DerivedTableConfig.d.ts +35 -0
- package/dist/esm/ts-rs/Layout.d.ts +2 -2
- package/dist/esm/ts-rs/Orientation.d.ts +2 -1
- package/dist/esm/ts-rs/PanelViewerConfig.d.ts +7 -6
- package/dist/esm/ts-rs/RestoreOptions.d.ts +3 -7
- package/dist/esm/ts-rs/SplitLayout.d.ts +13 -0
- package/dist/esm/ts-rs/TabLayout.d.ts +3 -0
- package/dist/esm/ts-rs/TableRef.d.ts +9 -0
- package/dist/esm/ts-rs/ViewerConfig.d.ts +7 -6
- package/dist/esm/ts-rs/ViewerConfigUpdate.d.ts +7 -5
- package/dist/esm/ts-rs/WorkspaceConfig.d.ts +9 -1
- package/dist/esm/ts-rs/WorkspaceConfigUpdate.d.ts +11 -1
- package/dist/wasm/perspective-viewer.d.ts +115 -35
- package/dist/wasm/perspective-viewer.js +312 -188
- package/dist/wasm/perspective-viewer.wasm +0 -0
- package/dist/wasm/perspective-viewer.wasm.d.ts +21 -17
- package/package.json +32 -19
- package/src/css/column-selector.css +205 -50
- package/src/css/ui/containers/context-menu.css +12 -1
- package/src/css/ui/containers/dropdown-menu-items.css +29 -0
- package/src/css/ui/containers/scroll-panel.css +4 -1
- package/src/rust/agent/client/protocol.rs +0 -89
- package/src/rust/agent/markdown/mod.rs +0 -238
- package/src/rust/agent/preamble.md +3 -0
- package/src/rust/agent/tools.rs +282 -17
- package/src/rust/components/column_selector/active_column.rs +15 -5
- package/src/rust/components/column_selector/add_expression_button.rs +9 -26
- package/src/rust/components/column_selector/config_selector.rs +35 -7
- package/src/rust/components/column_selector/derived_control.rs +229 -0
- package/src/rust/components/column_selector/expr_edit_button.rs +3 -2
- package/src/rust/components/column_selector/filter_column.rs +2 -4
- package/src/rust/components/column_selector/inactive_column.rs +4 -5
- package/src/rust/components/column_selector/pivot_column.rs +21 -1
- package/src/rust/components/column_selector/sort_column.rs +4 -3
- package/src/rust/components/column_selector.rs +21 -1
- package/src/rust/components/column_settings_sidebar/save_settings.rs +5 -3
- package/src/rust/components/column_settings_sidebar/style_tab/symbol/row_selector.rs +1 -1
- package/src/rust/components/column_settings_sidebar/style_tab.rs +1 -0
- package/src/rust/components/column_settings_sidebar.rs +25 -19
- package/src/rust/components/debug_panel.rs +38 -29
- package/src/rust/components/dragdrop_list.rs +8 -9
- package/src/rust/components/empty_row.rs +3 -3
- package/src/rust/components/filter_dropdown.rs +100 -101
- package/src/rust/components/main_panel/msg.rs +6 -4
- package/src/rust/components/main_panel/reconcile.rs +67 -25
- package/src/rust/components/main_panel/render.rs +70 -51
- package/src/rust/components/main_panel/update.rs +20 -21
- package/src/rust/components/main_panel.rs +87 -60
- package/src/rust/components/new_panel_menu.rs +69 -1
- package/src/rust/components/panel_menu.rs +63 -12
- package/src/rust/components/plugin_tab.rs +3 -2
- package/src/rust/components/render_warning.rs +2 -1
- package/src/rust/components/settings_panel.rs +4 -4
- package/src/rust/components/status_bar.rs +74 -24
- package/src/rust/components/status_indicator.rs +8 -1
- package/src/rust/components/viewer/filters.rs +13 -1
- package/src/rust/components/viewer/msg.rs +4 -0
- package/src/rust/components/viewer/panels.rs +41 -1
- package/src/rust/components/viewer/render.rs +1 -0
- package/src/rust/components/viewer/settings.rs +0 -22
- package/src/rust/components/viewer/snapshots.rs +2 -2
- package/src/rust/components/viewer/wiring.rs +14 -0
- package/src/rust/components/viewer.rs +45 -25
- package/src/rust/components/window_editor.rs +5 -4
- package/src/rust/config/column_config_schema.rs +38 -377
- package/src/rust/config/number_string_format.rs +0 -94
- package/src/rust/config/options.rs +3 -7
- package/src/rust/config/plugin_static_config.rs +0 -42
- package/src/rust/config/viewer_config.rs +47 -17
- package/src/rust/config/workspace_config.rs +160 -129
- package/src/rust/custom_elements/viewer.rs +187 -131
- package/src/rust/custom_events.rs +33 -18
- package/src/rust/derived.rs +266 -0
- package/src/rust/exprtk/tokenize.rs +0 -54
- package/src/rust/js/plugin.rs +1 -1
- package/src/rust/js/regular_layout.rs +225 -3
- package/src/rust/lib.rs +3 -0
- package/src/rust/presentation.rs +23 -4
- package/src/rust/queries/column_locator.rs +55 -48
- package/src/rust/queries/get_viewer_config.rs +1 -1
- package/src/rust/queries/plugin_column_styles.rs +22 -23
- package/src/rust/renderer/dispatch.rs +2 -0
- package/src/rust/renderer/plugin_config.rs +652 -487
- package/src/rust/renderer/props.rs +4 -0
- package/src/rust/renderer/registry.rs +2 -6
- package/src/rust/renderer/state.rs +205 -0
- package/src/rust/renderer.rs +201 -59
- package/src/rust/session/metadata.rs +30 -9
- package/src/rust/session/op_queue.rs +430 -0
- package/src/rust/session/panel_state.rs +327 -0
- package/src/rust/session/view_subscription.rs +42 -3
- package/src/rust/session.rs +900 -395
- package/src/rust/tasks/apply_global_filters.rs +49 -35
- package/src/rust/tasks/auto_pause.rs +22 -12
- package/src/rust/tasks/copy_export.rs +5 -0
- package/src/rust/tasks/create_panel.rs +34 -9
- package/src/rust/tasks/derive.rs +312 -0
- package/src/rust/tasks/mod.rs +6 -2
- package/src/rust/tasks/pipeline.rs +145 -89
- package/src/rust/tasks/reset_all.rs +31 -20
- package/src/rust/tasks/restore_derived.rs +200 -0
- package/src/rust/tasks/restore_panel.rs +153 -141
- package/src/rust/tasks/send_column_config.rs +56 -29
- package/src/rust/tasks/send_plugin_config.rs +52 -23
- package/src/rust/tasks/set_edit_mode.rs +33 -25
- package/src/rust/tasks/sync_update_panels.rs +30 -12
- package/src/rust/tasks/table_lifecycle.rs +70 -34
- package/src/rust/tasks/transactional_restore.rs +387 -0
- package/src/rust/tasks/update_theme.rs +45 -6
- package/src/rust/ui/containers/scroll_panel.rs +17 -10
- package/src/rust/ui/containers/split_panel.rs +0 -41
- package/src/rust/ui/context_menu.rs +157 -18
- package/src/rust/ui/font_loader.rs +23 -35
- package/src/rust/ui/form/mirrored_textarea.rs +0 -12
- package/src/rust/ui/form/multi_stop_gradient_selector.rs +0 -89
- package/src/rust/ui/form/palette_selector.rs +0 -51
- package/src/rust/ui/portal.rs +4 -10
- package/src/rust/utils/browser/mod.rs +2 -3
- package/src/{ts/perspective-viewer.inline.ts → rust/utils/browser/mouse.rs} +11 -10
- package/src/rust/utils/browser/request_animation_frame.rs +27 -8
- package/src/rust/utils/css.rs +0 -360
- package/src/rust/utils/local_fonts.rs +0 -36
- package/src/rust/utils/mod.rs +2 -3
- package/src/rust/utils/modal_position.rs +15 -21
- package/src/rust/utils/{browser/tests/mod.rs → plugin_host_state.rs} +31 -1
- package/src/rust/utils/pubsub.rs +0 -1
- package/src/rust/workspace.rs +187 -140
- package/src/svg/derived.svg +6 -0
- package/src/themes/icons.css +1 -0
- package/src/themes/intl/ar.css +11 -0
- package/src/themes/intl/de.css +11 -0
- package/src/themes/intl/es.css +11 -0
- package/src/themes/intl/fr.css +11 -0
- package/src/themes/intl/ja.css +11 -0
- package/src/themes/intl/pt.css +11 -0
- package/src/themes/intl/zh.css +11 -0
- package/src/themes/intl.css +11 -0
- package/src/ts/extensions.ts +3 -36
- package/src/ts/perspective-viewer.ts +1 -1
- package/src/ts/plugin.ts +4 -1
- package/src/{rust/utils/tests/request_animation_frame.rs → ts/select-detail.ts} +32 -26
- package/src/ts/ts-rs/DerivedTableConfig.ts +22 -0
- package/src/ts/ts-rs/Layout.ts +2 -2
- package/src/ts/ts-rs/Orientation.ts +2 -1
- package/src/ts/ts-rs/PanelViewerConfig.ts +7 -6
- package/src/ts/ts-rs/RestoreOptions.ts +3 -7
- package/src/ts/ts-rs/SplitLayout.ts +17 -1
- package/src/ts/ts-rs/TabLayout.ts +3 -0
- package/src/ts/ts-rs/TableRef.ts +9 -0
- package/src/ts/ts-rs/ViewerConfig.ts +7 -6
- package/src/ts/ts-rs/ViewerConfigUpdate.ts +7 -5
- package/src/ts/ts-rs/WorkspaceConfig.ts +7 -1
- package/src/ts/ts-rs/WorkspaceConfigUpdate.ts +9 -1
- package/dist/esm/perspective-viewer.inline.d.ts +0 -3
- package/dist/esm/perspective-viewer.inline.js +0 -21
- package/dist/esm/perspective-viewer.inline.js.map +0 -7
- package/src/rust/tasks/restore_and_render.rs +0 -107
- package/src/rust/utils/browser/tests/debounce.rs +0 -163
- package/src/rust/utils/tests/mod.rs +0 -14
- package/src/rust/utils/tests/pubsub.rs +0 -95
- /package/dist/wasm/snippets/{perspective-viewer-6813b568219c6763 → perspective-viewer-7fc45549159e01e4}/inline0.js +0 -0
- /package/dist/wasm/snippets/{perspective-viewer-6813b568219c6763 → perspective-viewer-7fc45549159e01e4}/inline1.js +0 -0
- /package/dist/wasm/snippets/{perspective-viewer-6813b568219c6763 → perspective-viewer-7fc45549159e01e4}/inline2.js +0 -0
- /package/dist/wasm/snippets/{perspective-viewer-6813b568219c6763 → perspective-viewer-7fc45549159e01e4}/inline3.js +0 -0
- /package/dist/wasm/snippets/{perspective-viewer-6813b568219c6763 → perspective-viewer-7fc45549159e01e4}/inline4.js +0 -0
- /package/dist/wasm/snippets/{perspective-viewer-6813b568219c6763 → perspective-viewer-7fc45549159e01e4}/inline5.js +0 -0
|
@@ -38,7 +38,7 @@ pub fn row_selector(props: &RowSelectorProps) -> Html {
|
|
|
38
38
|
let on_select = {
|
|
39
39
|
clone!(props.dropdown, props.index, props.set_focused_index);
|
|
40
40
|
props.on_select.reform(move |key| {
|
|
41
|
-
dropdown.
|
|
41
|
+
dropdown.dismiss();
|
|
42
42
|
set_focused_index.emit(Some(index + 1));
|
|
43
43
|
key
|
|
44
44
|
})
|
|
@@ -34,6 +34,7 @@ use crate::components::expression_editor::ExpressionEditorProps;
|
|
|
34
34
|
use crate::components::type_icon::TypeIconType;
|
|
35
35
|
use crate::components::window_editor::WindowEditorProps;
|
|
36
36
|
use crate::presentation::{ColumnLocator, ColumnSettingsTab, Presentation};
|
|
37
|
+
use crate::queries::{has_column_config, is_pivot_only_column};
|
|
37
38
|
use crate::renderer::Renderer;
|
|
38
39
|
use crate::session::{Session, SessionMetadataRc};
|
|
39
40
|
use crate::tasks::{
|
|
@@ -218,7 +219,9 @@ impl Component for ColumnSettingsPanel {
|
|
|
218
219
|
|
|
219
220
|
fn changed(&mut self, ctx: &yew::prelude::Context<Self>, old_props: &Self::Properties) -> bool {
|
|
220
221
|
let next = Initials::of(ctx.props());
|
|
221
|
-
if ctx.props().selected_column != old_props.selected_column
|
|
222
|
+
if ctx.props().selected_column != old_props.selected_column
|
|
223
|
+
|| next != Initials::of(old_props)
|
|
224
|
+
{
|
|
222
225
|
self.reset_to(ctx, next);
|
|
223
226
|
} else {
|
|
224
227
|
self.refresh_derived(ctx);
|
|
@@ -541,33 +544,36 @@ impl ColumnSettingsPanel {
|
|
|
541
544
|
self.save_enabled = changed && valid;
|
|
542
545
|
}
|
|
543
546
|
|
|
544
|
-
fn initials(&self) -> Initials {
|
|
545
|
-
Initials {
|
|
546
|
-
column_name: self.column_name.clone(),
|
|
547
|
-
expr: self.initial_expr_value.clone(),
|
|
548
|
-
header: self.initial_header_value.clone(),
|
|
549
|
-
window: self.initial_window_value.clone(),
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
|
|
553
547
|
fn refresh_derived(&mut self, ctx: &yew::prelude::Context<Self>) {
|
|
554
|
-
|
|
548
|
+
let view_ty = ctx
|
|
555
549
|
.props()
|
|
556
550
|
.metadata
|
|
557
551
|
.locator_view_type(&ctx.props().selected_column);
|
|
558
552
|
|
|
553
|
+
self.maybe_ty = match ctx.props().selected_column.name() {
|
|
554
|
+
Some(name) if is_pivot_only_column(name, &ctx.props().view_config) => {
|
|
555
|
+
ctx.props().metadata.get_column_table_type(name).or(view_ty)
|
|
556
|
+
},
|
|
557
|
+
_ => view_ty,
|
|
558
|
+
};
|
|
559
|
+
|
|
559
560
|
self.tabs = {
|
|
560
561
|
let mut tabs = vec![];
|
|
561
562
|
let is_new_expr = ctx.props().selected_column.is_new_expr();
|
|
563
|
+
let selected_name = ctx
|
|
564
|
+
.props()
|
|
565
|
+
.selected_column
|
|
566
|
+
.name()
|
|
567
|
+
.map(|x| x.to_string())
|
|
568
|
+
.unwrap_or_default();
|
|
569
|
+
|
|
562
570
|
let show_styles = !is_new_expr
|
|
563
|
-
&&
|
|
564
|
-
|
|
565
|
-
ctx.props()
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
.unwrap_or_default(),
|
|
570
|
-
));
|
|
571
|
+
&& has_column_config(
|
|
572
|
+
&selected_name,
|
|
573
|
+
&ctx.props().view_config,
|
|
574
|
+
&ctx.props().metadata,
|
|
575
|
+
&ctx.props().renderer,
|
|
576
|
+
);
|
|
571
577
|
|
|
572
578
|
if !is_new_expr && show_styles {
|
|
573
579
|
tabs.push(ColumnSettingsTab::Style);
|
|
@@ -22,13 +22,12 @@ use crate::components::code_editor::CodeEditor;
|
|
|
22
22
|
use crate::config::*;
|
|
23
23
|
use crate::js::{MimeType, copy_to_clipboard, paste_from_clipboard};
|
|
24
24
|
use crate::presentation::*;
|
|
25
|
-
use crate::queries::fetch_hosted_tables;
|
|
26
25
|
use crate::renderer::*;
|
|
27
26
|
use crate::session::*;
|
|
28
27
|
use crate::utils::*;
|
|
29
28
|
use crate::workspace::Workspace;
|
|
30
29
|
|
|
31
|
-
#[derive(Clone,
|
|
30
|
+
#[derive(Clone, Properties)]
|
|
32
31
|
pub struct DebugPanelProps {
|
|
33
32
|
pub presentation: Presentation,
|
|
34
33
|
pub renderer: Renderer,
|
|
@@ -47,9 +46,16 @@ pub struct DebugPanelProps {
|
|
|
47
46
|
pub on_auto_width: Callback<f64>,
|
|
48
47
|
}
|
|
49
48
|
|
|
49
|
+
impl PartialEq for DebugPanelProps {
|
|
50
|
+
fn eq(&self, rhs: &Self) -> bool {
|
|
51
|
+
self.initial_width == rhs.initial_width
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
50
55
|
/// Whether the editor holds text the panel has not successfully applied, read
|
|
51
|
-
/// synchronously by the config-change listeners
|
|
52
|
-
/// `
|
|
56
|
+
/// synchronously by the config-change listeners and again when a
|
|
57
|
+
/// [`DebugPanelProps::set_text`] read lands, so neither a failed apply's own
|
|
58
|
+
/// `view_config_changed` nor an in-flight config read discards it.
|
|
53
59
|
type Dirty = Rc<Cell<bool>>;
|
|
54
60
|
|
|
55
61
|
#[function_component(DebugPanel)]
|
|
@@ -72,10 +78,12 @@ pub fn debug_panel(props: &DebugPanelProps) -> Html {
|
|
|
72
78
|
}
|
|
73
79
|
});
|
|
74
80
|
|
|
75
|
-
use_effect_with((
|
|
81
|
+
use_effect_with((), {
|
|
76
82
|
clone!(error, modified, dirty);
|
|
77
|
-
|
|
78
|
-
|
|
83
|
+
let state = props.clone();
|
|
84
|
+
let text = expr.setter();
|
|
85
|
+
move |()| {
|
|
86
|
+
state.set_text(text.clone(), dirty.clone());
|
|
79
87
|
error.set(None);
|
|
80
88
|
let sub1 = state
|
|
81
89
|
.renderer
|
|
@@ -154,7 +162,7 @@ pub fn debug_panel(props: &DebugPanelProps) -> Html {
|
|
|
154
162
|
clone!(modified, dirty);
|
|
155
163
|
move |_, (text, error, props)| {
|
|
156
164
|
dirty.set(false);
|
|
157
|
-
props.set_text(text.clone());
|
|
165
|
+
props.set_text(text.clone(), dirty.clone());
|
|
158
166
|
error.set(None);
|
|
159
167
|
modified.set(false);
|
|
160
168
|
}
|
|
@@ -214,7 +222,9 @@ pub fn debug_panel(props: &DebugPanelProps) -> Html {
|
|
|
214
222
|
}
|
|
215
223
|
|
|
216
224
|
impl DebugPanelProps {
|
|
217
|
-
|
|
225
|
+
/// Asynchronously read this panel's config into the editor, unless the
|
|
226
|
+
/// editor has unapplied text by the time the read lands.
|
|
227
|
+
fn set_text(&self, setter: UseStateSetter<Rc<String>>, dirty: Dirty) {
|
|
218
228
|
let props = self.clone();
|
|
219
229
|
ApiFuture::spawn(async move {
|
|
220
230
|
let config = crate::queries::get_viewer_config(
|
|
@@ -222,12 +232,16 @@ impl DebugPanelProps {
|
|
|
222
232
|
&props.renderer,
|
|
223
233
|
&props.presentation,
|
|
224
234
|
)
|
|
225
|
-
.await
|
|
235
|
+
.await?
|
|
236
|
+
.map_table(|name| props.workspace.inline_table_ref(&name));
|
|
226
237
|
let json = JsValue::from_serde_ext(&config)?;
|
|
227
238
|
let js_string =
|
|
228
239
|
js_sys::JSON::stringify_with_replacer_and_space(&json, &JsValue::NULL, &2.into())?;
|
|
229
240
|
|
|
230
|
-
|
|
241
|
+
if !dirty.get() {
|
|
242
|
+
setter.set(Rc::new(js_string.as_string().unwrap()));
|
|
243
|
+
}
|
|
244
|
+
|
|
231
245
|
Ok(())
|
|
232
246
|
});
|
|
233
247
|
}
|
|
@@ -246,7 +260,7 @@ impl DebugPanelProps {
|
|
|
246
260
|
}
|
|
247
261
|
|
|
248
262
|
error.set(None);
|
|
249
|
-
props.set_text(text.clone());
|
|
263
|
+
props.set_text(text.clone(), dirty.clone());
|
|
250
264
|
modified.set(false);
|
|
251
265
|
}
|
|
252
266
|
}
|
|
@@ -283,21 +297,6 @@ impl DebugPanelProps {
|
|
|
283
297
|
},
|
|
284
298
|
};
|
|
285
299
|
|
|
286
|
-
if let OptionalUpdate::Update(name) = &config.table {
|
|
287
|
-
let hosted = fetch_hosted_tables(&props.workspace).await;
|
|
288
|
-
if !hosted
|
|
289
|
-
.iter()
|
|
290
|
-
.any(|(_, names)| names.iter().any(|n| n == name))
|
|
291
|
-
{
|
|
292
|
-
fail(
|
|
293
|
-
format!("Unknown table \"{name}\""),
|
|
294
|
-
locate_key(&source, "table"),
|
|
295
|
-
);
|
|
296
|
-
|
|
297
|
-
return Ok(());
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
300
|
let active = props.workspace.active_renderer().as_ref() == Some(&props.renderer);
|
|
302
301
|
let result = crate::tasks::restore_panel(
|
|
303
302
|
&props.session,
|
|
@@ -308,6 +307,7 @@ impl DebugPanelProps {
|
|
|
308
307
|
config,
|
|
309
308
|
crate::tasks::RestoreErrors::Suppress,
|
|
310
309
|
MissingTable::Error,
|
|
310
|
+
None,
|
|
311
311
|
)
|
|
312
312
|
.await;
|
|
313
313
|
|
|
@@ -316,9 +316,18 @@ impl DebugPanelProps {
|
|
|
316
316
|
dirty.set(false);
|
|
317
317
|
error.set(None);
|
|
318
318
|
modified.set(false);
|
|
319
|
-
props.set_text(text);
|
|
319
|
+
props.set_text(text, dirty.clone());
|
|
320
|
+
},
|
|
321
|
+
Err(e) => {
|
|
322
|
+
let message = format!("{e}");
|
|
323
|
+
let position = if message.starts_with("Unknown table") {
|
|
324
|
+
locate_key(&source, "table")
|
|
325
|
+
} else {
|
|
326
|
+
(0, 0)
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
fail(message, position)
|
|
320
330
|
},
|
|
321
|
-
Err(e) => fail(format!("{e}"), (0, 0)),
|
|
322
331
|
}
|
|
323
332
|
|
|
324
333
|
Ok(())
|
|
@@ -24,7 +24,7 @@ use crate::components::column_selector::{EmptyColumn, InPlaceColumn, InvalidColu
|
|
|
24
24
|
use crate::components::type_icon::TypeIcon;
|
|
25
25
|
use crate::presentation::{DragDropContainer, Presentation};
|
|
26
26
|
use crate::ui::intl_slug;
|
|
27
|
-
use crate::utils::DragTarget;
|
|
27
|
+
use crate::utils::{DragTarget, left_click};
|
|
28
28
|
|
|
29
29
|
#[derive(Properties, Derivative)]
|
|
30
30
|
#[derivative(Clone(bound = ""))]
|
|
@@ -161,8 +161,6 @@ where
|
|
|
161
161
|
if freeze && self.frozen_size.is_none() {
|
|
162
162
|
let elem = self.elem.cast::<HtmlElement>().unwrap();
|
|
163
163
|
self.frozen_size = Some({
|
|
164
|
-
// `offset_width` and family are `i32`, but Chrome _really_
|
|
165
|
-
// uses fractional pixel widths for these which can only be
|
|
166
164
|
// recovered by parsing the generated stylesheet ...
|
|
167
165
|
let txt = window()
|
|
168
166
|
.unwrap()
|
|
@@ -178,7 +176,8 @@ where
|
|
|
178
176
|
});
|
|
179
177
|
true
|
|
180
178
|
} else if !freeze {
|
|
181
|
-
// Don't render because the invoker will do so through
|
|
179
|
+
// Don't render because the invoker will do so through
|
|
180
|
+
// `dragdrop`.
|
|
182
181
|
self.frozen_size = None;
|
|
183
182
|
false
|
|
184
183
|
} else {
|
|
@@ -191,8 +190,8 @@ where
|
|
|
191
190
|
fn view(&self, ctx: &Context<Self>) -> Html {
|
|
192
191
|
let dragover = Callback::from(|_event: DragEvent| _event.prevent_default());
|
|
193
192
|
|
|
194
|
-
// On dragleave, signal the parent but no need to redraw as parent will
|
|
195
|
-
// `change()` when resetting props.
|
|
193
|
+
// On dragleave, signal the parent but no need to redraw as parent will
|
|
194
|
+
// call `change()` when resetting props.
|
|
196
195
|
let drag_container = DragDropContainer::new(
|
|
197
196
|
{
|
|
198
197
|
let total = ctx.props().children.len();
|
|
@@ -244,7 +243,7 @@ where
|
|
|
244
243
|
.map(|x| V::is_self_move(x))
|
|
245
244
|
.unwrap_or_default();
|
|
246
245
|
|
|
247
|
-
let close = ctx.props().parent.callback(|_| V::close(0));
|
|
246
|
+
let close = left_click(ctx.props().parent.callback(|_| V::close(0)));
|
|
248
247
|
let dragenter = ctx.props().parent.callback({
|
|
249
248
|
let container_noderef = container_noderef.clone();
|
|
250
249
|
move |event: DragEvent| {
|
|
@@ -332,7 +331,7 @@ where
|
|
|
332
331
|
.into_iter()
|
|
333
332
|
.enumerate()
|
|
334
333
|
.map(|(idx, column)| {
|
|
335
|
-
let close = ctx.props().parent.callback(move |_| V::close(idx));
|
|
334
|
+
let close = left_click(ctx.props().parent.callback(move |_| V::close(idx)));
|
|
336
335
|
let dragenter = ctx.props().parent.callback({
|
|
337
336
|
let link = ctx.link().clone();
|
|
338
337
|
let container_noderef = container_noderef.clone();
|
|
@@ -441,7 +440,7 @@ where
|
|
|
441
440
|
</div>
|
|
442
441
|
<span
|
|
443
442
|
class="toggle-mode is_column_active"
|
|
444
|
-
onmousedown={ctx.props().parent.callback(move |_| V::close(0))}
|
|
443
|
+
onmousedown={left_click(ctx.props().parent.callback(move |_| V::close(0)))}
|
|
445
444
|
/>
|
|
446
445
|
</div>
|
|
447
446
|
} else if show_empty {
|
|
@@ -106,7 +106,7 @@ impl Component for EmptyRow {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
fn destroy(&mut self, ctx: &Context<Self>) {
|
|
109
|
-
ctx.props().dropdown.
|
|
109
|
+
ctx.props().dropdown.reset();
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool {
|
|
@@ -121,7 +121,7 @@ impl Component for EmptyRow {
|
|
|
121
121
|
false
|
|
122
122
|
},
|
|
123
123
|
Blur => {
|
|
124
|
-
p.dropdown.
|
|
124
|
+
p.dropdown.reset();
|
|
125
125
|
if let Some(elem) = self.input_ref.cast::<HtmlInputElement>() {
|
|
126
126
|
elem.set_value("");
|
|
127
127
|
}
|
|
@@ -139,7 +139,7 @@ impl Component for EmptyRow {
|
|
|
139
139
|
},
|
|
140
140
|
KeyDown(13) => {
|
|
141
141
|
p.dropdown.item_select();
|
|
142
|
-
p.dropdown.
|
|
142
|
+
p.dropdown.dismiss();
|
|
143
143
|
p.set_focused_index.emit(Some(p.index + 1));
|
|
144
144
|
true
|
|
145
145
|
},
|
|
@@ -14,7 +14,6 @@ use std::cell::RefCell;
|
|
|
14
14
|
use std::collections::HashSet;
|
|
15
15
|
use std::rc::Rc;
|
|
16
16
|
|
|
17
|
-
use perspective_client::clone;
|
|
18
17
|
use web_sys::*;
|
|
19
18
|
use yew::html::ImplicitClone;
|
|
20
19
|
use yew::prelude::*;
|
|
@@ -25,12 +24,19 @@ use crate::ui::PortalModal;
|
|
|
25
24
|
use crate::utils::*;
|
|
26
25
|
use crate::*;
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
struct
|
|
27
|
+
/// The suggestion list while it is on screen, the only state a key may act on.
|
|
28
|
+
struct OpenState {
|
|
30
29
|
values: Vec<String>,
|
|
31
30
|
selected: usize,
|
|
32
|
-
on_select:
|
|
33
|
-
target:
|
|
31
|
+
on_select: Callback<String>,
|
|
32
|
+
target: HtmlElement,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
#[derive(Default)]
|
|
36
|
+
enum FilterDropDownState {
|
|
37
|
+
#[default]
|
|
38
|
+
Hidden,
|
|
39
|
+
Open(OpenState),
|
|
34
40
|
}
|
|
35
41
|
|
|
36
42
|
#[derive(Clone)]
|
|
@@ -62,7 +68,6 @@ impl FilterDropDownElement {
|
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
pub fn reautocomplete(&self) {
|
|
65
|
-
// Re-open portal with current target
|
|
66
71
|
self.notify.emit(());
|
|
67
72
|
}
|
|
68
73
|
|
|
@@ -78,97 +83,94 @@ impl FilterDropDownElement {
|
|
|
78
83
|
match current_column {
|
|
79
84
|
Some(filter_col) if filter_col == column => {
|
|
80
85
|
let values = filter_values(&input, &self.all_values, &exclude);
|
|
81
|
-
|
|
82
|
-
let _ = self.hide();
|
|
83
|
-
} else {
|
|
84
|
-
let mut s = self.state.borrow_mut();
|
|
85
|
-
s.values = values;
|
|
86
|
-
s.selected = 0;
|
|
87
|
-
s.on_select = Some(callback);
|
|
88
|
-
if s.target.is_none() {
|
|
89
|
-
s.target = Some(target);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
drop(s);
|
|
93
|
-
self.notify.emit(());
|
|
94
|
-
}
|
|
86
|
+
self.show(values, &input, target, callback);
|
|
95
87
|
},
|
|
96
88
|
_ => {
|
|
97
|
-
clone
|
|
98
|
-
self.state,
|
|
99
|
-
self.session,
|
|
100
|
-
self.all_values,
|
|
101
|
-
self.notify,
|
|
102
|
-
old_column = self.column
|
|
103
|
-
);
|
|
89
|
+
let this = self.clone();
|
|
104
90
|
ApiFuture::spawn(async move {
|
|
105
91
|
let fetched =
|
|
106
|
-
crate::queries::get_column_values(&session, column.1.clone()).await?;
|
|
107
|
-
*all_values.borrow_mut() = Some(fetched);
|
|
108
|
-
|
|
109
|
-
let
|
|
110
|
-
|
|
111
|
-
*old_column.borrow_mut() = Some(column);
|
|
112
|
-
{
|
|
113
|
-
let mut s = state.borrow_mut();
|
|
114
|
-
s.on_select = Some(callback);
|
|
115
|
-
if should_hide {
|
|
116
|
-
let fv = self::filter_values("", &all_values, &exclude);
|
|
117
|
-
s.values = fv;
|
|
118
|
-
s.target = Some(target);
|
|
119
|
-
} else {
|
|
120
|
-
s.values = values;
|
|
121
|
-
s.target = Some(target);
|
|
122
|
-
}
|
|
123
|
-
s.selected = 0;
|
|
124
|
-
}
|
|
125
|
-
if should_hide {
|
|
126
|
-
state.borrow_mut().target = None;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
notify.emit(());
|
|
92
|
+
crate::queries::get_column_values(&this.session, column.1.clone()).await?;
|
|
93
|
+
*this.all_values.borrow_mut() = Some(fetched);
|
|
94
|
+
*this.column.borrow_mut() = Some(column);
|
|
95
|
+
let values = filter_values(&input, &this.all_values, &exclude);
|
|
96
|
+
this.show(values, &input, target, callback);
|
|
130
97
|
Ok(())
|
|
131
98
|
});
|
|
132
99
|
},
|
|
133
100
|
}
|
|
134
101
|
}
|
|
135
102
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
103
|
+
/// Open the list, or dismiss it when `input` is its one exact match.
|
|
104
|
+
fn show(
|
|
105
|
+
&self,
|
|
106
|
+
values: Vec<String>,
|
|
107
|
+
input: &str,
|
|
108
|
+
target: HtmlElement,
|
|
109
|
+
on_select: Callback<String>,
|
|
110
|
+
) {
|
|
111
|
+
if values.len() == 1 && values[0] == input {
|
|
112
|
+
self.dismiss();
|
|
113
|
+
} else {
|
|
114
|
+
*self.state.borrow_mut() = FilterDropDownState::Open(OpenState {
|
|
115
|
+
values,
|
|
116
|
+
selected: 0,
|
|
117
|
+
on_select,
|
|
118
|
+
target,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
self.notify.emit(());
|
|
142
122
|
}
|
|
143
123
|
}
|
|
144
124
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
state.
|
|
148
|
-
|
|
149
|
-
|
|
125
|
+
/// Accept a visible list's highlighted suggestion; a hidden list has none.
|
|
126
|
+
pub fn item_select(&self) {
|
|
127
|
+
let selected = match &*self.state.borrow() {
|
|
128
|
+
FilterDropDownState::Open(open) => open
|
|
129
|
+
.values
|
|
130
|
+
.get(open.selected)
|
|
131
|
+
.map(|value| (value.clone(), open.on_select.clone())),
|
|
132
|
+
FilterDropDownState::Hidden => None,
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
if let Some((value, on_select)) = selected {
|
|
136
|
+
on_select.emit(value);
|
|
150
137
|
}
|
|
138
|
+
}
|
|
151
139
|
|
|
152
|
-
|
|
153
|
-
self.
|
|
140
|
+
pub fn item_down(&self) {
|
|
141
|
+
self.step(1);
|
|
154
142
|
}
|
|
155
143
|
|
|
156
144
|
pub fn item_up(&self) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
145
|
+
self.step(-1);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
fn step(&self, delta: isize) {
|
|
149
|
+
let moved = match &mut *self.state.borrow_mut() {
|
|
150
|
+
FilterDropDownState::Open(open) if !open.values.is_empty() => {
|
|
151
|
+
let len = open.values.len() as isize;
|
|
152
|
+
open.selected = (open.selected as isize + delta).rem_euclid(len) as usize;
|
|
153
|
+
true
|
|
154
|
+
},
|
|
155
|
+
_ => false,
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
if moved {
|
|
159
|
+
self.notify.emit(());
|
|
160
160
|
}
|
|
161
|
+
}
|
|
161
162
|
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
/// Close the list, keeping the column's values for the next keystroke.
|
|
164
|
+
pub fn dismiss(&self) {
|
|
165
|
+
*self.state.borrow_mut() = FilterDropDownState::Hidden;
|
|
164
166
|
self.notify.emit(());
|
|
165
167
|
}
|
|
166
168
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
+
/// Close the list and forget the column so the next focus refetches it.
|
|
170
|
+
pub fn reset(&self) {
|
|
169
171
|
self.column.borrow_mut().take();
|
|
170
|
-
self.
|
|
171
|
-
|
|
172
|
+
self.all_values.borrow_mut().take();
|
|
173
|
+
self.dismiss();
|
|
172
174
|
}
|
|
173
175
|
}
|
|
174
176
|
|
|
@@ -201,35 +203,32 @@ impl Component for FilterDropDownPortal {
|
|
|
201
203
|
}
|
|
202
204
|
|
|
203
205
|
fn view(&self, ctx: &Context<Self>) -> Html {
|
|
204
|
-
let
|
|
205
|
-
let
|
|
206
|
+
let element = &ctx.props().element;
|
|
207
|
+
let state = element.state.borrow();
|
|
208
|
+
let FilterDropDownState::Open(open) = &*state else {
|
|
209
|
+
return html! {};
|
|
210
|
+
};
|
|
211
|
+
|
|
206
212
|
let on_close = {
|
|
207
|
-
let element =
|
|
208
|
-
Callback::from(move |()|
|
|
209
|
-
let _ = element.hide();
|
|
210
|
-
})
|
|
213
|
+
let element = element.clone();
|
|
214
|
+
Callback::from(move |()| element.dismiss())
|
|
211
215
|
};
|
|
212
216
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
{
|
|
224
|
-
|
|
225
|
-
{
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
<FilterDropDownView {values} {selected} {on_select} />
|
|
229
|
-
</PortalModal>
|
|
230
|
-
}
|
|
231
|
-
} else {
|
|
232
|
-
html! {}
|
|
217
|
+
html! {
|
|
218
|
+
<PortalModal
|
|
219
|
+
tag_name="perspective-dropdown"
|
|
220
|
+
sheet={StyleSurface::FilterDropdown.sheet()}
|
|
221
|
+
target={Some(open.target.clone())}
|
|
222
|
+
own_focus=false
|
|
223
|
+
{on_close}
|
|
224
|
+
theme={ctx.props().theme.clone()}
|
|
225
|
+
>
|
|
226
|
+
<FilterDropDownView
|
|
227
|
+
values={open.values.clone()}
|
|
228
|
+
selected={open.selected}
|
|
229
|
+
on_select={open.on_select.clone()}
|
|
230
|
+
/>
|
|
231
|
+
</PortalModal>
|
|
233
232
|
}
|
|
234
233
|
}
|
|
235
234
|
}
|
|
@@ -238,7 +237,7 @@ impl Component for FilterDropDownPortal {
|
|
|
238
237
|
struct FilterDropDownViewProps {
|
|
239
238
|
values: Vec<String>,
|
|
240
239
|
selected: usize,
|
|
241
|
-
on_select:
|
|
240
|
+
on_select: Callback<String>,
|
|
242
241
|
}
|
|
243
242
|
|
|
244
243
|
#[function_component]
|
|
@@ -249,7 +248,7 @@ fn FilterDropDownView(props: &FilterDropDownViewProps) -> Html {
|
|
|
249
248
|
.iter()
|
|
250
249
|
.enumerate()
|
|
251
250
|
.map(|(idx, value)| {
|
|
252
|
-
let click = props.on_select.
|
|
251
|
+
let click = props.on_select.reform({
|
|
253
252
|
let value = value.clone();
|
|
254
253
|
move |_: MouseEvent| value.clone()
|
|
255
254
|
});
|
|
@@ -49,12 +49,14 @@ pub enum MainPanelMsg {
|
|
|
49
49
|
BeforeResize(web_sys::Event),
|
|
50
50
|
|
|
51
51
|
/// A right-click opened the panel context menu (target panel id, client
|
|
52
|
-
/// x, y). Fired by the imperative `contextmenu` listener on the
|
|
53
|
-
///
|
|
52
|
+
/// x, y). Fired by the imperative `contextmenu` listener on the viewer
|
|
53
|
+
/// host — see `_contextmenu_listener` — and by each `PanelTab`.
|
|
54
54
|
/// `Some(id)` activates that panel and opens its
|
|
55
55
|
/// [`PanelMenu`](crate::components::panel_menu::PanelMenu) at the
|
|
56
|
-
/// cursor; `None`
|
|
57
|
-
///
|
|
56
|
+
/// cursor; `None` (no frame on the composed path — status bar,
|
|
57
|
+
/// sidebars, the empty stage) resolves to the ACTIVE panel, else to a
|
|
58
|
+
/// target-less menu offering only "New", whose items create the first
|
|
59
|
+
/// panel.
|
|
58
60
|
ContextMenu(Option<String>, f64, f64),
|
|
59
61
|
|
|
60
62
|
/// Dismiss the panel context menu (the menu session ended).
|