@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
|
@@ -21,7 +21,8 @@ use wasm_bindgen::prelude::*;
|
|
|
21
21
|
use yew::prelude::*;
|
|
22
22
|
|
|
23
23
|
use super::MainPanel;
|
|
24
|
-
use crate::js::RegularLayout;
|
|
24
|
+
use crate::js::{Layout, Orientation, RegularLayout};
|
|
25
|
+
use crate::workspace::PanelId;
|
|
25
26
|
|
|
26
27
|
/// Layout interaction tuning constants, applied via
|
|
27
28
|
/// [`RegularLayout::restore_physics`] when the layout element mounts.
|
|
@@ -40,18 +41,10 @@ const LAYOUT_PHYSICS: LayoutPhysics = LayoutPhysics {
|
|
|
40
41
|
};
|
|
41
42
|
|
|
42
43
|
impl MainPanel {
|
|
43
|
-
/// Size each STAGED panel's hidden
|
|
44
|
-
///
|
|
45
|
-
///
|
|
46
|
-
|
|
47
|
-
/// redistribution) minus the frame-chrome fallback the presize sweep
|
|
48
|
-
/// uses. Prediction only — the staged first draw renders at these
|
|
49
|
-
/// dimensions, and any delta from the real committed cell is
|
|
50
|
-
/// reconciled by the post-commit reactive resize (free when exact,
|
|
51
|
-
/// via the charts transport's dims-unchanged guard). Imperative
|
|
52
|
-
/// because it MEASURES the committed layout box, which a `view()`
|
|
53
|
-
/// style prop cannot.
|
|
54
|
-
pub(super) fn size_staging_wrappers(&self) {
|
|
44
|
+
/// Size each STAGED panel's hidden `.psp-staging` wrapper to the exact
|
|
45
|
+
/// plugin box its promote insert will commit (see
|
|
46
|
+
/// `.plan/DUPLICATE_STAGING_PREDICTION_PLAN.md`).
|
|
47
|
+
pub(super) fn size_staging_wrappers(&self, ctx: &Context<Self>) {
|
|
55
48
|
let Some(root) = self.main_panel_ref.cast::<web_sys::Element>() else {
|
|
56
49
|
return;
|
|
57
50
|
};
|
|
@@ -64,23 +57,70 @@ impl MainPanel {
|
|
|
64
57
|
return;
|
|
65
58
|
}
|
|
66
59
|
|
|
67
|
-
let Some(
|
|
60
|
+
let Some(el) = self.layout_ref.cast::<web_sys::HtmlElement>() else {
|
|
68
61
|
return;
|
|
69
62
|
};
|
|
70
63
|
|
|
71
|
-
let
|
|
72
|
-
let
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
64
|
+
let layout: &RegularLayout = el.unchecked_ref();
|
|
65
|
+
let Ok(mut tree) = layout.save().into_serde_ext::<Layout>() else {
|
|
66
|
+
return;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
let (chrome_w, chrome_h) = self
|
|
70
|
+
.placed_chrome(ctx, layout)
|
|
71
|
+
.unwrap_or(crate::tasks::CHROME_FALLBACK);
|
|
72
|
+
|
|
73
|
+
let mut index = self.inserted.len();
|
|
76
74
|
for i in 0..wrappers.length() {
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
let Some(wrapper) = wrappers
|
|
76
|
+
.get(i)
|
|
77
|
+
.and_then(|node| node.dyn_into::<web_sys::HtmlElement>().ok())
|
|
78
|
+
else {
|
|
79
|
+
continue;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
let Some(name) = wrapper.get_attribute("data-panel") else {
|
|
83
|
+
continue;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
tree = tree.insert_split(index, &name, Orientation::Horizontal);
|
|
87
|
+
index += 1;
|
|
88
|
+
let Some(window) = tree
|
|
89
|
+
.view_window(&name)
|
|
90
|
+
.and_then(|window| JsValue::from_serde_ext(&window).ok())
|
|
91
|
+
else {
|
|
92
|
+
continue;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
let cell: web_sys::DomRect = layout.real_coordinates(&window).unchecked_into();
|
|
96
|
+
let width = (cell.width() - chrome_w).max(0.0);
|
|
97
|
+
let height = (cell.height() - chrome_h).max(0.0);
|
|
98
|
+
let _ = wrapper.style().set_property("width", &format!("{width}px"));
|
|
99
|
+
let _ = wrapper
|
|
100
|
+
.style()
|
|
101
|
+
.set_property("height", &format!("{height}px"));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/// The frame chrome around a placed, visible plugin, measured from the
|
|
106
|
+
/// first such panel.
|
|
107
|
+
fn placed_chrome(&self, ctx: &Context<Self>, layout: &RegularLayout) -> Option<(f64, f64)> {
|
|
108
|
+
let layout_el: &web_sys::Element = layout.unchecked_ref();
|
|
109
|
+
self.inserted.iter().find_map(|name| {
|
|
110
|
+
let panel = ctx.props().workspace.panel(&PanelId::from(name.as_str()))?;
|
|
111
|
+
if !panel.renderer.is_plugin_activated().unwrap_or(false)
|
|
112
|
+
|| panel.renderer.is_plugin_hidden()
|
|
79
113
|
{
|
|
80
|
-
|
|
81
|
-
let _ = el.style().set_property("height", &format!("{height}px"));
|
|
114
|
+
return None;
|
|
82
115
|
}
|
|
83
|
-
|
|
116
|
+
|
|
117
|
+
let plugin = panel.renderer.active_plugin()?;
|
|
118
|
+
let frame = layout_el
|
|
119
|
+
.query_selector(&format!("regular-layout-frame[name=\"{name}\"]"))
|
|
120
|
+
.ok()??;
|
|
121
|
+
|
|
122
|
+
crate::tasks::plugin_chrome(&frame, plugin.unchecked_ref())
|
|
123
|
+
})
|
|
84
124
|
}
|
|
85
125
|
|
|
86
126
|
/// Reconcile the `<regular-layout>` grid against `panel_ids`: `insertPanel`
|
|
@@ -111,6 +151,7 @@ impl MainPanel {
|
|
|
111
151
|
if self.listener_target.as_ref() != Some(&el) {
|
|
112
152
|
if self.listener_target.is_some() {
|
|
113
153
|
self.inserted.clear();
|
|
154
|
+
self.on_screen.clear();
|
|
114
155
|
}
|
|
115
156
|
|
|
116
157
|
let _ = el.add_event_listener_with_callback(
|
|
@@ -183,7 +224,8 @@ impl MainPanel {
|
|
|
183
224
|
// horizontal) rather than the default (path `[]`), which would
|
|
184
225
|
// *stack* into the root tab-layout — a stack only renders its
|
|
185
226
|
// selected tab, and without frame chrome there's no tab-bar to
|
|
186
|
-
// reach the others. Splitting keeps every panel visible
|
|
227
|
+
// reach the others. Splitting keeps every panel visible
|
|
228
|
+
// side-by-side.
|
|
187
229
|
let index = self.inserted.len();
|
|
188
230
|
let path = JsValue::from(js_sys::Array::of1(&JsValue::from_f64(index as f64)));
|
|
189
231
|
let _ = layout.insert_panel(name, path, JsValue::from_bool(true));
|
|
@@ -58,19 +58,21 @@ impl MainPanel {
|
|
|
58
58
|
let on_dismiss_warning = dismiss_render_warning_callback(session, renderer);
|
|
59
59
|
|
|
60
60
|
// Each panel's plugin is mounted in the viewer's light DOM under its
|
|
61
|
-
// panel-id slot (see `renderer::activate`). Render one
|
|
62
|
-
// cell per panel: a concrete `<div name=…>`
|
|
63
|
-
// `regular-layout` grid-places via its
|
|
64
|
-
// only matches *direct*,
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
//
|
|
61
|
+
// panel-id slot (see `renderer::activate`). Render one
|
|
62
|
+
// `<regular-layout>` cell per panel: a concrete `<div name=…>`
|
|
63
|
+
// wrapper (which `regular-layout` grid-places via its
|
|
64
|
+
// `::slotted([name])` rule — that only matches *direct*,
|
|
65
|
+
// non-`<slot>` children, hence the wrapper) whose
|
|
66
|
+
// inner forwarding `<slot>` projects the light-DOM plugin into the
|
|
67
|
+
// placed cell. The `<regular-layout>` element is ALWAYS
|
|
68
|
+
// rendered — at zero panels it is merely empty (its tree
|
|
69
|
+
// collapses to a childless split, and it paints nothing of its
|
|
70
|
+
// own), which keeps the stage CSS (viewer.css keys the stage
|
|
71
|
+
// background + inset bleed on the element) and the attached
|
|
72
|
+
// listeners alive across empty↔populated transitions.
|
|
71
73
|
let plugin_area = {
|
|
72
|
-
// The active panel (whose engines the status bar/settings target)
|
|
73
|
-
// the one the active renderer is bound to.
|
|
74
|
+
// The active panel (whose engines the status bar/settings target)
|
|
75
|
+
// is the one the active renderer is bound to.
|
|
74
76
|
let active_slot = renderer.slot_name();
|
|
75
77
|
// Panel-count chrome (`single`/`multi`, closable, draggable)
|
|
76
78
|
let placed_count = ctx.props().workspace.placed_count();
|
|
@@ -99,20 +101,25 @@ impl MainPanel {
|
|
|
99
101
|
class.push("active");
|
|
100
102
|
}
|
|
101
103
|
} else {
|
|
102
|
-
// Lone panel: can't be closed to zero — hide the close
|
|
103
|
-
// (see viewer.css) and
|
|
104
|
+
// Lone panel: can't be closed to zero — hide the close
|
|
105
|
+
// button (see viewer.css) and
|
|
106
|
+
// skip the active outline.
|
|
104
107
|
class.push("single");
|
|
105
108
|
}
|
|
106
109
|
|
|
107
|
-
// Activate this panel on pointerdown anywhere in it (body
|
|
108
|
-
// titlebar), so *working* in a panel
|
|
109
|
-
// —
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
//
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
//
|
|
110
|
+
// Activate this panel on pointerdown anywhere in it (body
|
|
111
|
+
// or titlebar), so *working* in a panel
|
|
112
|
+
// — not only clicking its tab — targets
|
|
113
|
+
// it with the shared settings/toolbar. regular-layout
|
|
114
|
+
// emits `regular-layout-select` on tab clicks only, which
|
|
115
|
+
// left body interaction unable to
|
|
116
|
+
// change the active panel. Tab clicks
|
|
117
|
+
// still also fire `-select`, but that dispatch is async
|
|
118
|
+
// (after `restore`) so it lands after
|
|
119
|
+
// this synchronous handler — within a
|
|
120
|
+
// stack, switching tabs still resolves to the clicked
|
|
121
|
+
// panel. Re-activating the
|
|
122
|
+
// already-active panel is a no-op upstream.
|
|
116
123
|
let on_activate = ctx.props().on_activate_panel.clone();
|
|
117
124
|
let activate_name = name.clone();
|
|
118
125
|
let onpointerdown = Callback::from(move |_: web_sys::PointerEvent| {
|
|
@@ -121,25 +128,33 @@ impl MainPanel {
|
|
|
121
128
|
}
|
|
122
129
|
});
|
|
123
130
|
|
|
124
|
-
// Right-click anywhere in the panel opens the context menu.
|
|
125
|
-
// is handled by the imperative
|
|
131
|
+
// Right-click anywhere in the panel opens the context menu.
|
|
132
|
+
// This is handled by the imperative
|
|
133
|
+
// `contextmenu` listener on the
|
|
126
134
|
// panel container (see `_contextmenu_listener`), NOT a Yew
|
|
127
|
-
// `oncontextmenu` here: the plugin body is light-DOM
|
|
128
|
-
// the renderer, so Yew's
|
|
129
|
-
//
|
|
135
|
+
// `oncontextmenu` here: the plugin body is light-DOM
|
|
136
|
+
// attached by the renderer, so Yew's
|
|
137
|
+
// delegated handler — which walks the vdom
|
|
138
|
+
// — never matches a right-click on it, leaving the native
|
|
139
|
+
// menu.
|
|
130
140
|
|
|
131
141
|
// `<regular-layout-frame>` gives each panel a titlebar (its
|
|
132
|
-
// `slot="tab"`) and a `::part(container)`. Two forwarding
|
|
133
|
-
// project our light-DOM nodes
|
|
134
|
-
//
|
|
135
|
-
//
|
|
136
|
-
//
|
|
137
|
-
//
|
|
142
|
+
// `slot="tab"`) and a `::part(container)`. Two forwarding
|
|
143
|
+
// `<slot>`s project our light-DOM nodes
|
|
144
|
+
// in: `name` → the plugin (into the
|
|
145
|
+
// container), and `tab-<name>` (with `slot="tab"`) → this
|
|
146
|
+
// panel's `<PanelTab>` (into the
|
|
147
|
+
// titlebar). Both targets live in the
|
|
148
|
+
// viewer's light DOM, so the slots — being in the viewer's
|
|
149
|
+
// shadow — collect them and forward
|
|
150
|
+
// them one level deeper into the frame.
|
|
138
151
|
//
|
|
139
|
-
// The frame no longer carries the theme: the per-panel
|
|
140
|
-
// applied directly to the
|
|
141
|
-
//
|
|
142
|
-
//
|
|
152
|
+
// The frame no longer carries the theme: the per-panel
|
|
153
|
+
// theme is applied directly to the
|
|
154
|
+
// light-DOM plugin + tab (each stamped with
|
|
155
|
+
// a `theme` attribute) via the `perspective-viewer
|
|
156
|
+
// [theme="X"]` document rules, so it
|
|
157
|
+
// themes through the native cascade instead
|
|
143
158
|
// of a scraped/inlined `--psp-*` block.
|
|
144
159
|
html! {
|
|
145
160
|
<regular-layout-frame
|
|
@@ -154,10 +169,11 @@ impl MainPanel {
|
|
|
154
169
|
}
|
|
155
170
|
});
|
|
156
171
|
|
|
157
|
-
// Per-panel tab titles: regular-layout's tabs render their label
|
|
158
|
-
// a `--regular-layout-<id>--title` custom property
|
|
159
|
-
// set one per titled panel on the
|
|
160
|
-
// inherit into each
|
|
172
|
+
// Per-panel tab titles: regular-layout's tabs render their label
|
|
173
|
+
// from a `--regular-layout-<id>--title` custom property
|
|
174
|
+
// (a CSS string). We set one per titled panel on the
|
|
175
|
+
// `<regular-layout>` host; they inherit into each
|
|
176
|
+
// frame/tab's shadow.
|
|
161
177
|
let title_style = ctx
|
|
162
178
|
.props()
|
|
163
179
|
.panel_titles
|
|
@@ -171,10 +187,11 @@ impl MainPanel {
|
|
|
171
187
|
|
|
172
188
|
// One `<PanelTab>` per panel, mounted in the viewer's light DOM and
|
|
173
189
|
// forwarded into its frame's titlebar by the `tab-<id>` slot above.
|
|
174
|
-
// Rendered as siblings of `<regular-layout>` (their DOM placement
|
|
175
|
-
// irrelevant — each portals itself onto the viewer
|
|
176
|
-
// drives regular-layout's own
|
|
177
|
-
// listener picks
|
|
190
|
+
// Rendered as siblings of `<regular-layout>` (their DOM placement
|
|
191
|
+
// is irrelevant — each portals itself onto the viewer
|
|
192
|
+
// host). `on_select` drives regular-layout's own
|
|
193
|
+
// `select` (the `regular-layout-select` listener picks
|
|
194
|
+
// up activation).
|
|
178
195
|
let viewer_elem = ctx.props().presentation.viewer_elem().clone();
|
|
179
196
|
// A lone panel can't be closed to zero, and has nowhere to be
|
|
180
197
|
// dragged — so it's neither closable nor draggable; its tab also
|
|
@@ -199,12 +216,13 @@ impl MainPanel {
|
|
|
199
216
|
// `regular-layout` on the re-render. Driving the layout first — and
|
|
200
217
|
// discovering the close via the `regular-layout-update` DOM event —
|
|
201
218
|
// ran the layout-update resize fan-out over a still-present-but-
|
|
202
|
-
// doomed panel, spawning an (uncancellable) draw that then raced
|
|
203
|
-
// disposal ("restore() called before load()").
|
|
219
|
+
// doomed panel, spawning an (uncancellable) draw that then raced
|
|
220
|
+
// its disposal ("restore() called before load()").
|
|
204
221
|
let on_close = ctx.props().on_close_panel.clone();
|
|
205
|
-
// Commit an in-tab title edit to that panel's own session — the
|
|
206
|
-
// `title_changed` → `TitlesChanged` refresh loop
|
|
207
|
-
// driven by the status bar re-renders
|
|
222
|
+
// Commit an in-tab title edit to that panel's own session — the
|
|
223
|
+
// same `title_changed` → `TitlesChanged` refresh loop
|
|
224
|
+
// that used to be driven by the status bar re-renders
|
|
225
|
+
// the tab with the new title.
|
|
208
226
|
let on_rename = {
|
|
209
227
|
let workspace = ctx.props().workspace.clone();
|
|
210
228
|
Callback::from(move |(id, title): (String, Option<String>)| {
|
|
@@ -406,6 +424,7 @@ impl MainPanel {
|
|
|
406
424
|
on_reset={ctx.props().on_reset.clone()}
|
|
407
425
|
{on_new_panel}
|
|
408
426
|
session_props={ctx.props().session_props.clone()}
|
|
427
|
+
render_error={ctx.props().renderer_props.render_error.clone()}
|
|
409
428
|
presentation_props={ctx.props().presentation_props.clone()}
|
|
410
429
|
is_settings_open={ctx.props().is_settings_open}
|
|
411
430
|
update_count={ctx.props().update_count}
|
|
@@ -58,12 +58,18 @@ impl MainPanel {
|
|
|
58
58
|
|
|
59
59
|
let layout: RegularLayout = el.unchecked_into();
|
|
60
60
|
let mut closed = Vec::new();
|
|
61
|
+
let on_screen = &mut self.on_screen;
|
|
61
62
|
self.inserted.retain(|id| {
|
|
62
63
|
if layout.contains_panel(id) {
|
|
64
|
+
on_screen.insert(id.clone());
|
|
63
65
|
true
|
|
64
|
-
} else
|
|
66
|
+
} else if on_screen.remove(id)
|
|
67
|
+
|| !ctx.props().panel_ids.iter().any(|p| p.as_str() == id)
|
|
68
|
+
{
|
|
65
69
|
closed.push(id.clone());
|
|
66
70
|
false
|
|
71
|
+
} else {
|
|
72
|
+
true
|
|
67
73
|
}
|
|
68
74
|
});
|
|
69
75
|
|
|
@@ -73,8 +79,6 @@ impl MainPanel {
|
|
|
73
79
|
ctx.props().on_panel_closed.emit(id);
|
|
74
80
|
}
|
|
75
81
|
|
|
76
|
-
let reissue = self.forget_dropped_removals(&layout);
|
|
77
|
-
|
|
78
82
|
// A layout change (divider drag, insert, restore) reflows the
|
|
79
83
|
// grid cells without resizing the host, so the host
|
|
80
84
|
// `ResizeObserver` never fires. Resize every activated panel's
|
|
@@ -127,25 +131,8 @@ impl MainPanel {
|
|
|
127
131
|
self.hidden_tabs = hidden;
|
|
128
132
|
true
|
|
129
133
|
} else {
|
|
130
|
-
closed_any
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/// Forget every issued removal whose panel survived the commit, so the
|
|
135
|
-
/// next `reconcile` re-issues it.
|
|
136
|
-
fn forget_dropped_removals(&mut self, layout: &RegularLayout) -> bool {
|
|
137
|
-
let dropped = self
|
|
138
|
-
.pending_removals
|
|
139
|
-
.iter()
|
|
140
|
-
.filter(|id| layout.contains_panel(id))
|
|
141
|
-
.cloned()
|
|
142
|
-
.collect::<Vec<_>>();
|
|
143
|
-
let reissue = !dropped.is_empty();
|
|
144
|
-
for id in dropped {
|
|
145
|
-
self.pending_removals.remove(&id);
|
|
134
|
+
closed_any
|
|
146
135
|
}
|
|
147
|
-
|
|
148
|
-
reissue
|
|
149
136
|
}
|
|
150
137
|
|
|
151
138
|
pub(super) fn on_tab_selected(&self, ctx: &Context<Self>, name: String) -> bool {
|
|
@@ -160,6 +147,18 @@ impl MainPanel {
|
|
|
160
147
|
x: f64,
|
|
161
148
|
y: f64,
|
|
162
149
|
) -> bool {
|
|
150
|
+
// A frame-less right-click (status bar, sidebars) targets the
|
|
151
|
+
// ACTIVE panel, validated against the workspace so a stale slot
|
|
152
|
+
// name after an eject falls back to the target-less stage menu.
|
|
153
|
+
let id = id.or_else(|| {
|
|
154
|
+
ctx.props().renderer.slot_name().filter(|name| {
|
|
155
|
+
ctx.props()
|
|
156
|
+
.workspace
|
|
157
|
+
.panel(&crate::workspace::PanelId::from(name.as_str()))
|
|
158
|
+
.is_some()
|
|
159
|
+
})
|
|
160
|
+
});
|
|
161
|
+
|
|
163
162
|
// Make the right-clicked panel active so active-targeting
|
|
164
163
|
// commands (e.g. Reset) act on it; then show the menu.
|
|
165
164
|
if let Some(id) = &id {
|
|
@@ -185,14 +185,15 @@ pub struct MainPanel {
|
|
|
185
185
|
/// and attached alongside the others.
|
|
186
186
|
_layout_before_resize_listener: Closure<dyn FnMut(web_sys::Event)>,
|
|
187
187
|
|
|
188
|
-
/// `contextmenu` listener on the
|
|
189
|
-
/// point covering
|
|
190
|
-
///
|
|
191
|
-
///
|
|
192
|
-
///
|
|
193
|
-
/// is
|
|
194
|
-
///
|
|
195
|
-
///
|
|
188
|
+
/// `contextmenu` listener on the viewer HOST element — one stable attach
|
|
189
|
+
/// point covering every surface (panels, status bar, sidebars),
|
|
190
|
+
/// independent of the layout reconcile; attached once in `rendered` and
|
|
191
|
+
/// REMOVED in `destroy`, since the host outlives this component's Yew
|
|
192
|
+
/// app. Imperative — not a Yew `oncontextmenu` — because the plugin body
|
|
193
|
+
/// is light-DOM attached by the renderer (its DOM parent is the host,
|
|
194
|
+
/// not the frame), so Yew's delegated handler never matches a
|
|
195
|
+
/// right-click there; a native listener sees every surface — shadow
|
|
196
|
+
/// chrome and slotted light DOM alike — on the composed path.
|
|
196
197
|
_contextmenu_listener: Closure<dyn FnMut(web_sys::Event)>,
|
|
197
198
|
|
|
198
199
|
/// The `<regular-layout>` ELEMENT the layout listeners are attached to.
|
|
@@ -211,6 +212,10 @@ pub struct MainPanel {
|
|
|
211
212
|
/// layout and not yet committed.
|
|
212
213
|
pending_removals: HashSet<String>,
|
|
213
214
|
|
|
215
|
+
/// Ids observed in a committed layout tree, the only model-held panels a
|
|
216
|
+
/// later commit can report closed.
|
|
217
|
+
on_screen: HashSet<String>,
|
|
218
|
+
|
|
214
219
|
/// Per-panel `ResizeObserver`s, keyed by panel id, each observing that
|
|
215
220
|
/// panel's slotted plugin element and resizing only that panel's
|
|
216
221
|
/// `Renderer`. Bound in `BeforeResize` for the DRAGGED panel only (it is
|
|
@@ -226,9 +231,9 @@ pub struct MainPanel {
|
|
|
226
231
|
hidden_tabs: HashSet<String>,
|
|
227
232
|
|
|
228
233
|
/// Open context menu as `(client x, client y, target panel id)`; outer
|
|
229
|
-
/// `None` when closed. A `None` *panel id* is the
|
|
230
|
-
///
|
|
231
|
-
/// [`PanelMenu`](super::panel_menu::PanelMenu) overlay.
|
|
234
|
+
/// `None` when closed. A `None` *panel id* is the target-less menu (no
|
|
235
|
+
/// active panel to resolve to — "New" only). Rendered as a
|
|
236
|
+
/// cursor-anchored [`PanelMenu`](super::panel_menu::PanelMenu) overlay.
|
|
232
237
|
context_menu: Option<(f64, f64, Option<String>)>,
|
|
233
238
|
|
|
234
239
|
/// Id of the currently maximized panel (via `regular-layout.maximize`), or
|
|
@@ -280,27 +285,29 @@ impl Component for MainPanel {
|
|
|
280
285
|
}) as Box<dyn FnMut(web_sys::Event)>);
|
|
281
286
|
|
|
282
287
|
// `preventDefault()` synchronously suspends the layout's resize commit
|
|
283
|
-
// (the event is cancelable); the component then pre-sizes each panel
|
|
284
|
-
// calls `resumeResize` to release it (see
|
|
288
|
+
// (the event is cancelable); the component then pre-sizes each panel
|
|
289
|
+
// and calls `resumeResize` to release it (see
|
|
290
|
+
// `MainPanelMsg::BeforeResize`).
|
|
285
291
|
let before_resize_cb = ctx.link().callback(MainPanelMsg::BeforeResize);
|
|
286
292
|
let before_resize_listener = Closure::wrap(Box::new(move |event: web_sys::Event| {
|
|
287
293
|
event.prevent_default();
|
|
288
294
|
before_resize_cb.emit(event);
|
|
289
295
|
}) as Box<dyn FnMut(web_sys::Event)>);
|
|
290
296
|
|
|
291
|
-
// Imperative `contextmenu` listener: a right-click anywhere in
|
|
292
|
-
//
|
|
293
|
-
//
|
|
294
|
-
//
|
|
295
|
-
//
|
|
296
|
-
//
|
|
297
|
-
//
|
|
298
|
-
//
|
|
299
|
-
//
|
|
300
|
-
//
|
|
297
|
+
// Imperative `contextmenu` listener: a right-click anywhere in the
|
|
298
|
+
// element opens the panel menu — targeting the frame on the event's
|
|
299
|
+
// composed path, or `None` (resolved to the ACTIVE panel, else the
|
|
300
|
+
// stage menu, in `on_context_menu`, where props live) from any
|
|
301
|
+
// other surface. Two pass-throughs keep the NATIVE menu: editable
|
|
302
|
+
// targets (inputs, textareas, contenteditable — cut/copy/paste),
|
|
303
|
+
// and anything inside an open `PortalModal` (every modal host is a
|
|
304
|
+
// light-DOM viewer child in the modal slot — this menu included, so
|
|
305
|
+
// without the carve-out a right-click in any open dropdown would
|
|
306
|
+
// re-open the menu underneath it).
|
|
301
307
|
let contextmenu_cb = ctx
|
|
302
308
|
.link()
|
|
303
309
|
.callback(|(id, x, y)| MainPanelMsg::ContextMenu(id, x, y));
|
|
310
|
+
let viewer_elem = ctx.props().presentation.viewer_elem().clone();
|
|
304
311
|
let contextmenu_listener = Closure::wrap(Box::new(move |event: web_sys::Event| {
|
|
305
312
|
// Shift+right-click passes through to the native browser menu.
|
|
306
313
|
if event.unchecked_ref::<web_sys::MouseEvent>().shift_key() {
|
|
@@ -308,11 +315,34 @@ impl Component for MainPanel {
|
|
|
308
315
|
}
|
|
309
316
|
|
|
310
317
|
let path = event.composed_path();
|
|
318
|
+
let is_editable = path.get(0).dyn_ref::<web_sys::HtmlElement>().is_some_and(
|
|
319
|
+
|el: &web_sys::HtmlElement| {
|
|
320
|
+
el.tag_name().eq_ignore_ascii_case("input")
|
|
321
|
+
|| el.tag_name().eq_ignore_ascii_case("textarea")
|
|
322
|
+
|| el.is_content_editable()
|
|
323
|
+
},
|
|
324
|
+
);
|
|
325
|
+
|
|
326
|
+
if is_editable {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
|
|
311
330
|
let mut panel_id = None;
|
|
312
331
|
for i in 0..path.length() {
|
|
313
332
|
let node = path.get(i);
|
|
314
|
-
|
|
315
|
-
|
|
333
|
+
let Some(el) = node.dyn_ref::<web_sys::Element>() else {
|
|
334
|
+
continue;
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
if el == viewer_elem.unchecked_ref::<web_sys::Element>() {
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if el.slot() == crate::ui::MODAL_SLOT {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if el.tag_name().eq_ignore_ascii_case("regular-layout-frame")
|
|
316
346
|
&& let Some(name) = el.get_attribute("name")
|
|
317
347
|
{
|
|
318
348
|
panel_id = Some(name);
|
|
@@ -320,29 +350,9 @@ impl Component for MainPanel {
|
|
|
320
350
|
}
|
|
321
351
|
}
|
|
322
352
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
.and_then(|t| t.dyn_into::<web_sys::Element>().ok())
|
|
327
|
-
.is_some_and(|el| {
|
|
328
|
-
el.query_selector("regular-layout-frame")
|
|
329
|
-
.ok()
|
|
330
|
-
.flatten()
|
|
331
|
-
.is_none()
|
|
332
|
-
})
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
if let Some(id) = panel_id {
|
|
336
|
-
event.prevent_default();
|
|
337
|
-
let mouse = event.unchecked_ref::<web_sys::MouseEvent>();
|
|
338
|
-
contextmenu_cb.emit((Some(id), mouse.client_x() as f64, mouse.client_y() as f64));
|
|
339
|
-
} else if is_empty_stage() {
|
|
340
|
-
event.prevent_default();
|
|
341
|
-
let mouse = event.unchecked_ref::<web_sys::MouseEvent>();
|
|
342
|
-
contextmenu_cb.emit((None, mouse.client_x() as f64, mouse.client_y() as f64));
|
|
343
|
-
}
|
|
344
|
-
// With panels present, a click outside every frame lets the
|
|
345
|
-
// native menu through.
|
|
353
|
+
event.prevent_default();
|
|
354
|
+
let mouse = event.unchecked_ref::<web_sys::MouseEvent>();
|
|
355
|
+
contextmenu_cb.emit((panel_id, mouse.client_x() as f64, mouse.client_y() as f64));
|
|
346
356
|
}) as Box<dyn FnMut(web_sys::Event)>);
|
|
347
357
|
|
|
348
358
|
let staged_sub = {
|
|
@@ -368,6 +378,7 @@ impl Component for MainPanel {
|
|
|
368
378
|
layout_ref: NodeRef::default(),
|
|
369
379
|
inserted: Vec::new(),
|
|
370
380
|
pending_removals: HashSet::new(),
|
|
381
|
+
on_screen: HashSet::new(),
|
|
371
382
|
_layout_update_listener: listener,
|
|
372
383
|
_layout_select_listener: select_listener,
|
|
373
384
|
_layout_before_resize_listener: before_resize_listener,
|
|
@@ -404,19 +415,23 @@ impl Component for MainPanel {
|
|
|
404
415
|
}
|
|
405
416
|
|
|
406
417
|
fn rendered(&mut self, ctx: &Context<Self>, first_render: bool) {
|
|
407
|
-
// The `contextmenu` listener attaches to the
|
|
408
|
-
// stable attach point covering
|
|
409
|
-
//
|
|
410
|
-
//
|
|
411
|
-
// menu.
|
|
412
|
-
if first_render
|
|
413
|
-
let _ =
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
418
|
+
// The `contextmenu` listener attaches to the viewer HOST element —
|
|
419
|
+
// one stable attach point covering every surface (panels, status
|
|
420
|
+
// bar, sidebars), decoupled from the layout reconcile. Panel
|
|
421
|
+
// right-clicks reach it through their frames on the composed path;
|
|
422
|
+
// everything else resolves to the active panel (or the stage menu).
|
|
423
|
+
if first_render {
|
|
424
|
+
let _ = ctx
|
|
425
|
+
.props()
|
|
426
|
+
.presentation
|
|
427
|
+
.viewer_elem()
|
|
428
|
+
.add_event_listener_with_callback(
|
|
429
|
+
"contextmenu",
|
|
430
|
+
self._contextmenu_listener.as_ref().unchecked_ref(),
|
|
431
|
+
);
|
|
417
432
|
}
|
|
418
433
|
|
|
419
|
-
self.size_staging_wrappers();
|
|
434
|
+
self.size_staging_wrappers(ctx);
|
|
420
435
|
self.reconcile(ctx);
|
|
421
436
|
self.stamp_frame_themes(ctx);
|
|
422
437
|
}
|
|
@@ -425,7 +440,19 @@ impl Component for MainPanel {
|
|
|
425
440
|
self.render(ctx)
|
|
426
441
|
}
|
|
427
442
|
|
|
428
|
-
fn destroy(&mut self,
|
|
443
|
+
fn destroy(&mut self, ctx: &Context<Self>) {
|
|
444
|
+
// The host element outlives this component (`delete()` tears down
|
|
445
|
+
// the Yew app, not the custom element), so the listener must not
|
|
446
|
+
// dangle into a dropped `Closure`.
|
|
447
|
+
let _ = ctx
|
|
448
|
+
.props()
|
|
449
|
+
.presentation
|
|
450
|
+
.viewer_elem()
|
|
451
|
+
.remove_event_listener_with_callback(
|
|
452
|
+
"contextmenu",
|
|
453
|
+
self._contextmenu_listener.as_ref().unchecked_ref(),
|
|
454
|
+
);
|
|
455
|
+
}
|
|
429
456
|
}
|
|
430
457
|
|
|
431
458
|
impl MainPanel {
|