@perspective-dev/viewer 4.0.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/LICENSE.md +193 -0
- package/README.md +4 -0
- package/dist/cdn/perspective-viewer.js +3 -0
- package/dist/cdn/perspective-viewer.js.map +7 -0
- package/dist/css/dracula.css +1 -0
- package/dist/css/gruvbox-dark.css +1 -0
- package/dist/css/gruvbox.css +1 -0
- package/dist/css/icons.css +1 -0
- package/dist/css/intl/de.css +1 -0
- package/dist/css/intl/es.css +1 -0
- package/dist/css/intl/fr.css +1 -0
- package/dist/css/intl/ja.css +1 -0
- package/dist/css/intl/pt.css +1 -0
- package/dist/css/intl/zh.css +1 -0
- package/dist/css/intl.css +1 -0
- package/dist/css/monokai.css +1 -0
- package/dist/css/pro-dark.css +1 -0
- package/dist/css/pro.css +1 -0
- package/dist/css/solarized-dark.css +1 -0
- package/dist/css/solarized.css +1 -0
- package/dist/css/themes.css +1 -0
- package/dist/css/vaporwave.css +1 -0
- package/dist/css/variables.css +0 -0
- package/dist/esm/bootstrap.d.ts +1 -0
- package/dist/esm/extensions.d.ts +70 -0
- package/dist/esm/perspective-viewer.d.ts +39 -0
- package/dist/esm/perspective-viewer.inline.js +3 -0
- package/dist/esm/perspective-viewer.inline.js.map +7 -0
- package/dist/esm/perspective-viewer.js +3 -0
- package/dist/esm/perspective-viewer.js.map +7 -0
- package/dist/esm/plugin.d.ts +195 -0
- package/dist/esm/ts-rs/Aggregate.d.ts +1 -0
- package/dist/esm/ts-rs/ColumnConfigValues.d.ts +31 -0
- package/dist/esm/ts-rs/CustomDatetimeFormat.d.ts +1 -0
- package/dist/esm/ts-rs/CustomDatetimeStyleConfig.d.ts +15 -0
- package/dist/esm/ts-rs/CustomNumberFormatConfig.d.ts +18 -0
- package/dist/esm/ts-rs/DatetimeColorMode.d.ts +1 -0
- package/dist/esm/ts-rs/DatetimeFormatType.d.ts +6 -0
- package/dist/esm/ts-rs/Expressions.d.ts +3 -0
- package/dist/esm/ts-rs/Filter.d.ts +2 -0
- package/dist/esm/ts-rs/FilterReducer.d.ts +1 -0
- package/dist/esm/ts-rs/FilterTerm.d.ts +2 -0
- package/dist/esm/ts-rs/FormatMode.d.ts +1 -0
- package/dist/esm/ts-rs/FormatUnit.d.ts +1 -0
- package/dist/esm/ts-rs/NumberBackgroundMode.d.ts +1 -0
- package/dist/esm/ts-rs/NumberForegroundMode.d.ts +1 -0
- package/dist/esm/ts-rs/OptionalUpdate.d.ts +1 -0
- package/dist/esm/ts-rs/PluginConfig.d.ts +2 -0
- package/dist/esm/ts-rs/RoundingMode.d.ts +1 -0
- package/dist/esm/ts-rs/RoundingPriority.d.ts +1 -0
- package/dist/esm/ts-rs/Scalar.d.ts +5 -0
- package/dist/esm/ts-rs/SignDisplay.d.ts +1 -0
- package/dist/esm/ts-rs/SimpleDatetimeFormat.d.ts +1 -0
- package/dist/esm/ts-rs/SimpleDatetimeStyleConfig.d.ts +6 -0
- package/dist/esm/ts-rs/Sort.d.ts +2 -0
- package/dist/esm/ts-rs/SortDir.d.ts +1 -0
- package/dist/esm/ts-rs/StringColorMode.d.ts +1 -0
- package/dist/esm/ts-rs/TrailingZeroDisplay.d.ts +1 -0
- package/dist/esm/ts-rs/UseGrouping.d.ts +1 -0
- package/dist/esm/ts-rs/ViewerConfigUpdate.d.ts +102 -0
- package/dist/esm/ts-rs/serde_json/JsonValue.d.ts +3 -0
- package/dist/wasm/perspective-viewer.d.ts +1291 -0
- package/dist/wasm/perspective-viewer.js +3883 -0
- package/dist/wasm/perspective-viewer.wasm +0 -0
- package/dist/wasm/perspective-viewer.wasm.d.ts +142 -0
- package/dist/wasm/snippets/perspective-viewer-c69283f6f62a5f14/inline0.js +1 -0
- package/dist/wasm/snippets/perspective-viewer-c69283f6f62a5f14/inline1.js +1 -0
- package/dist/wasm/snippets/perspective-viewer-c69283f6f62a5f14/inline2.js +1 -0
- package/dist/wasm/snippets/perspective-viewer-c69283f6f62a5f14/inline3.js +44 -0
- package/dist/wasm/snippets/perspective-viewer-c69283f6f62a5f14/inline4.js +1 -0
- package/package.json +55 -0
- package/src/less/aggregate-selector.less +72 -0
- package/src/less/column-dropdown.less +95 -0
- package/src/less/column-selector.less +551 -0
- package/src/less/column-settings-panel.less +255 -0
- package/src/less/column-style.less +319 -0
- package/src/less/column-symbol-attributes.less +73 -0
- package/src/less/config-selector.less +363 -0
- package/src/less/containers/dropdown-menu.less +94 -0
- package/src/less/containers/pairs-list.less +46 -0
- package/src/less/containers/radio-list.less +29 -0
- package/src/less/containers/scroll-panel.less +27 -0
- package/src/less/containers/split-panel.less +80 -0
- package/src/less/containers/tabs.less +90 -0
- package/src/less/dom/checkbox.less +100 -0
- package/src/less/dom/scrollbar.less +35 -0
- package/src/less/dom/select.less +63 -0
- package/src/less/empty-column.less +72 -0
- package/src/less/expression-editor.less +152 -0
- package/src/less/filter-dropdown.less +53 -0
- package/src/less/filter-item.less +126 -0
- package/src/less/form/code-editor.less +137 -0
- package/src/less/form/debug.less +88 -0
- package/src/less/function-dropdown.less +45 -0
- package/src/less/plugin-selector.less +173 -0
- package/src/less/render-warning.less +81 -0
- package/src/less/status-bar.less +551 -0
- package/src/less/type-icon.less +68 -0
- package/src/less/viewer.less +368 -0
- package/src/rust/components/column_dropdown.rs +162 -0
- package/src/rust/components/column_selector/active_column.rs +462 -0
- package/src/rust/components/column_selector/add_expression_button.rs +59 -0
- package/src/rust/components/column_selector/aggregate_selector.rs +186 -0
- package/src/rust/components/column_selector/config_selector.rs +674 -0
- package/src/rust/components/column_selector/empty_column.rs +134 -0
- package/src/rust/components/column_selector/expression_toolbar.rs +45 -0
- package/src/rust/components/column_selector/filter_column.rs +530 -0
- package/src/rust/components/column_selector/inactive_column.rs +221 -0
- package/src/rust/components/column_selector/invalid_column.rs +37 -0
- package/src/rust/components/column_selector/pivot_column.rs +93 -0
- package/src/rust/components/column_selector/sort_column.rs +135 -0
- package/src/rust/components/column_selector.rs +426 -0
- package/src/rust/components/column_settings_sidebar/attributes_tab.rs +34 -0
- package/src/rust/components/column_settings_sidebar/mod.rs +17 -0
- package/src/rust/components/column_settings_sidebar/save_settings.rs +68 -0
- package/src/rust/components/column_settings_sidebar/sidebar.rs +396 -0
- package/src/rust/components/column_settings_sidebar/style_tab/column_style.rs +177 -0
- package/src/rust/components/column_settings_sidebar/style_tab/stub.rs +34 -0
- package/src/rust/components/column_settings_sidebar/style_tab/symbol/row_selector.rs +101 -0
- package/src/rust/components/column_settings_sidebar/style_tab/symbol/symbol_config.rs +24 -0
- package/src/rust/components/column_settings_sidebar/style_tab/symbol/symbol_pairs.rs +185 -0
- package/src/rust/components/column_settings_sidebar/style_tab/symbol/symbol_selector.rs +55 -0
- package/src/rust/components/column_settings_sidebar/style_tab/symbol.rs +131 -0
- package/src/rust/components/column_settings_sidebar/style_tab.rs +231 -0
- package/src/rust/components/containers/dragdrop_list.rs +325 -0
- package/src/rust/components/containers/dropdown_menu.rs +104 -0
- package/src/rust/components/containers/kvpair.rs +47 -0
- package/src/rust/components/containers/mod.rs +28 -0
- package/src/rust/components/containers/scroll_panel.rs +311 -0
- package/src/rust/components/containers/scroll_panel_item.rs +111 -0
- package/src/rust/components/containers/select.rs +269 -0
- package/src/rust/components/containers/sidebar.rs +89 -0
- package/src/rust/components/containers/split_panel.rs +483 -0
- package/src/rust/components/containers/tab_list.rs +104 -0
- package/src/rust/components/containers/tests/mod.rs +11 -0
- package/src/rust/components/containers/tests/split_panel.rs +91 -0
- package/src/rust/components/containers/trap_door_panel.rs +50 -0
- package/src/rust/components/copy_dropdown.rs +136 -0
- package/src/rust/components/datetime_column_style/custom.rs +222 -0
- package/src/rust/components/datetime_column_style/simple.rs +122 -0
- package/src/rust/components/datetime_column_style.rs +284 -0
- package/src/rust/components/editable_header.rs +183 -0
- package/src/rust/components/empty_row.rs +169 -0
- package/src/rust/components/error_message.rs +56 -0
- package/src/rust/components/export_dropdown.rs +153 -0
- package/src/rust/components/expression_editor.rs +153 -0
- package/src/rust/components/filter_dropdown.rs +144 -0
- package/src/rust/components/font_loader.rs +254 -0
- package/src/rust/components/form/code_editor.rs +286 -0
- package/src/rust/components/form/color_range_selector.rs +115 -0
- package/src/rust/components/form/color_selector.rs +54 -0
- package/src/rust/components/form/debug.rs +253 -0
- package/src/rust/components/form/highlight.rs +50 -0
- package/src/rust/components/form/mod.rs +29 -0
- package/src/rust/components/form/number_field.rs +72 -0
- package/src/rust/components/form/number_input.rs +45 -0
- package/src/rust/components/form/number_range_field.rs +77 -0
- package/src/rust/components/form/optional_field.rs +53 -0
- package/src/rust/components/form/select_field.rs +104 -0
- package/src/rust/components/function_dropdown.rs +151 -0
- package/src/rust/components/mod.rs +45 -0
- package/src/rust/components/modal.rs +171 -0
- package/src/rust/components/number_column_style.rs +522 -0
- package/src/rust/components/plugin_selector.rs +196 -0
- package/src/rust/components/render_warning.rs +178 -0
- package/src/rust/components/status_bar.rs +315 -0
- package/src/rust/components/status_bar_counter.rs +229 -0
- package/src/rust/components/status_indicator.rs +164 -0
- package/src/rust/components/string_column_style.rs +186 -0
- package/src/rust/components/style/local_style.rs +35 -0
- package/src/rust/components/style/mod.rs +52 -0
- package/src/rust/components/style/style_cache.rs +132 -0
- package/src/rust/components/style/style_provider.rs +65 -0
- package/src/rust/components/style_controls/number_string_format/digits_section.rs +140 -0
- package/src/rust/components/style_controls/number_string_format/misc_section.rs +56 -0
- package/src/rust/components/style_controls/number_string_format/style_section.rs +69 -0
- package/src/rust/components/style_controls/number_string_format/types.rs +31 -0
- package/src/rust/components/style_controls/number_string_format.rs +259 -0
- package/src/rust/components/style_controls.rs +15 -0
- package/src/rust/components/type_icon.rs +53 -0
- package/src/rust/components/viewer.rs +668 -0
- package/src/rust/config/columns_config.rs +132 -0
- package/src/rust/config/datetime_column_style/color_mode.rs +62 -0
- package/src/rust/config/datetime_column_style/custom.rs +121 -0
- package/src/rust/config/datetime_column_style/custom_format.rs +90 -0
- package/src/rust/config/datetime_column_style/simple.rs +55 -0
- package/src/rust/config/datetime_column_style/simple_format.rs +86 -0
- package/src/rust/config/datetime_column_style.rs +104 -0
- package/src/rust/config/mod.rs +30 -0
- package/src/rust/config/number_column_style.rs +138 -0
- package/src/rust/config/number_string_format/enums.rs +298 -0
- package/src/rust/config/number_string_format.rs +269 -0
- package/src/rust/config/string_column_style.rs +140 -0
- package/src/rust/config/view_config.rs +24 -0
- package/src/rust/config/viewer_config.rs +337 -0
- package/src/rust/custom_elements/column_dropdown.rs +123 -0
- package/src/rust/custom_elements/copy_dropdown.rs +112 -0
- package/src/rust/custom_elements/debug_plugin.rs +114 -0
- package/src/rust/custom_elements/export_dropdown.rs +112 -0
- package/src/rust/custom_elements/filter_dropdown.rs +179 -0
- package/src/rust/custom_elements/function_dropdown.rs +115 -0
- package/src/rust/custom_elements/mod.rs +24 -0
- package/src/rust/custom_elements/modal.rs +395 -0
- package/src/rust/custom_elements/viewer.rs +880 -0
- package/src/rust/custom_events.rs +214 -0
- package/src/rust/dragdrop.rs +362 -0
- package/src/rust/exprtk/cursor.rs +81 -0
- package/src/rust/exprtk/mod.rs +17 -0
- package/src/rust/exprtk/tokenize/comment.rs +21 -0
- package/src/rust/exprtk/tokenize/number.rs +44 -0
- package/src/rust/exprtk/tokenize/string.rs +98 -0
- package/src/rust/exprtk/tokenize/symbol.rs +26 -0
- package/src/rust/exprtk/tokenize.rs +190 -0
- package/src/rust/js/clipboard.rs +77 -0
- package/src/rust/js/clipboard_item.rs +21 -0
- package/src/rust/js/intersection_observer.rs +32 -0
- package/src/rust/js/mimetype.rs +42 -0
- package/src/rust/js/mod.rs +29 -0
- package/src/rust/js/plugin.rs +167 -0
- package/src/rust/js/resize_observer.rs +37 -0
- package/src/rust/js/testing.rs +149 -0
- package/src/rust/lib.rs +116 -0
- package/src/rust/model/columns_iter_set.rs +340 -0
- package/src/rust/model/copy_export.rs +157 -0
- package/src/rust/model/create_col.rs +59 -0
- package/src/rust/model/edit_expression.rs +95 -0
- package/src/rust/model/export_app.rs +58 -0
- package/src/rust/model/export_method.rs +151 -0
- package/src/rust/model/get_viewer_config.rs +85 -0
- package/src/rust/model/intersection_observer.rs +81 -0
- package/src/rust/model/is_invalid_drop.rs +36 -0
- package/src/rust/model/mod.rs +93 -0
- package/src/rust/model/plugin_column_styles.rs +106 -0
- package/src/rust/model/resize_observer.rs +98 -0
- package/src/rust/model/restore_and_render.rs +113 -0
- package/src/rust/model/structural.rs +73 -0
- package/src/rust/model/update_and_render.rs +74 -0
- package/src/rust/presentation.rs +370 -0
- package/src/rust/renderer/activate.rs +49 -0
- package/src/rust/renderer/limits.rs +200 -0
- package/src/rust/renderer/plugin_store.rs +45 -0
- package/src/rust/renderer/registry.rs +135 -0
- package/src/rust/renderer/render_timer.rs +185 -0
- package/src/rust/renderer.rs +463 -0
- package/src/rust/session/column_defaults_update.rs +141 -0
- package/src/rust/session/drag_drop_update.rs +179 -0
- package/src/rust/session/metadata.rs +308 -0
- package/src/rust/session/replace_expression_update.rs +131 -0
- package/src/rust/session/view_subscription.rs +189 -0
- package/src/rust/session.rs +794 -0
- package/src/rust/utils/browser/blob.rs +49 -0
- package/src/rust/utils/browser/download.rs +26 -0
- package/src/rust/utils/browser/mod.rs +24 -0
- package/src/rust/utils/browser/request_animation_frame.rs +76 -0
- package/src/rust/utils/browser/selection.rs +79 -0
- package/src/rust/utils/browser/tests/debounce.rs +114 -0
- package/src/rust/utils/browser/tests/mod.rs +13 -0
- package/src/rust/utils/custom_element.rs +85 -0
- package/src/rust/utils/datetime.rs +49 -0
- package/src/rust/utils/debounce.rs +54 -0
- package/src/rust/utils/hooks/mod.rs +15 -0
- package/src/rust/utils/hooks/use_async_callback.rs +53 -0
- package/src/rust/utils/mod.rs +114 -0
- package/src/rust/utils/number_format.rs +48 -0
- package/src/rust/utils/pubsub.rs +222 -0
- package/src/rust/utils/scope.rs +54 -0
- package/src/rust/utils/tee.rs +88 -0
- package/src/rust/utils/tests/mod.rs +14 -0
- package/src/rust/utils/tests/pubsub.rs +95 -0
- package/src/rust/utils/tests/request_animation_frame.rs +42 -0
- package/src/rust/utils/wasm_abi.rs +61 -0
- package/src/rust/utils/weak_scope.rs +39 -0
- package/src/svg/align-scroll-icon.svg +7 -0
- package/src/svg/bg-pattern.png +0 -0
- package/src/svg/boolean-type.svg +3 -0
- package/src/svg/checkbox-checked-icon.svg +7 -0
- package/src/svg/checkbox-hover.svg +4 -0
- package/src/svg/checkbox-off.svg +4 -0
- package/src/svg/checkbox-on.svg +4 -0
- package/src/svg/checkbox-unchecked-icon.svg +3 -0
- package/src/svg/close-icon.svg +6 -0
- package/src/svg/column-settings-icon.svg +6 -0
- package/src/svg/datagrid-select-column.svg +15 -0
- package/src/svg/datagrid-select-region.svg +15 -0
- package/src/svg/datagrid-select-row.svg +13 -0
- package/src/svg/datagrid.svg +13 -0
- package/src/svg/date-type.svg +23 -0
- package/src/svg/downloading.gif +0 -0
- package/src/svg/drag-handle.svg +10 -0
- package/src/svg/drawer-bg-pattern-hidpi.png +0 -0
- package/src/svg/drawer-tab-hover.svg +8 -0
- package/src/svg/drawer-tab-invert-hover.svg +9 -0
- package/src/svg/drawer-tab-invert.svg +8 -0
- package/src/svg/drawer-tab.svg +7 -0
- package/src/svg/dropdown-selector-light.svg +3 -0
- package/src/svg/dropdown-selector.svg +3 -0
- package/src/svg/duplicate-icon.svg +4 -0
- package/src/svg/editable-icon.svg +5 -0
- package/src/svg/export-icon.svg +4 -0
- package/src/svg/expression.svg +10 -0
- package/src/svg/free-scroll-icon.svg +5 -0
- package/src/svg/inactive-mouseover.svg +4 -0
- package/src/svg/mega-menu-icons-candlestick.svg +38 -0
- package/src/svg/mega-menu-icons-datagrid.svg +38 -0
- package/src/svg/mega-menu-icons-heatmap.svg +60 -0
- package/src/svg/mega-menu-icons-map-scatter.svg +43 -0
- package/src/svg/mega-menu-icons-ohlc.svg +40 -0
- package/src/svg/mega-menu-icons-sunburst.svg +39 -0
- package/src/svg/mega-menu-icons-treemap.svg +44 -0
- package/src/svg/mega-menu-icons-x-bar.svg +36 -0
- package/src/svg/mega-menu-icons-x-y-line.svg +38 -0
- package/src/svg/mega-menu-icons-x-y-scatter.svg +72 -0
- package/src/svg/mega-menu-icons-y-area.svg +73 -0
- package/src/svg/mega-menu-icons-y-bar.svg +36 -0
- package/src/svg/mega-menu-icons-y-line.svg +36 -0
- package/src/svg/mega-menu-icons-y-scatter.svg +72 -0
- package/src/svg/number-type.svg +4 -0
- package/src/svg/radio-hover.svg +4 -0
- package/src/svg/radio-off.svg +3 -0
- package/src/svg/radio-on.svg +4 -0
- package/src/svg/read-only-icon.svg +6 -0
- package/src/svg/revert-icon.svg +4 -0
- package/src/svg/sort-abs-asc-icon.svg +3 -0
- package/src/svg/sort-abs-col-asc-icon.svg +3 -0
- package/src/svg/sort-abs-col-desc-icon.svg +3 -0
- package/src/svg/sort-abs-desc-icon.svg +3 -0
- package/src/svg/sort-asc-icon.svg +4 -0
- package/src/svg/sort-col-asc-icon.svg +4 -0
- package/src/svg/sort-col-desc-icon.svg +4 -0
- package/src/svg/sort-desc-icon.svg +4 -0
- package/src/svg/sort-none-icon.svg +3 -0
- package/src/svg/status_error.svg +70 -0
- package/src/svg/status_ok.svg +26 -0
- package/src/svg/string-type.svg +8 -0
- package/src/svg/theme-icon.svg +5 -0
- package/src/svg/updating.gif +0 -0
- package/src/themes/dracula.less +101 -0
- package/src/themes/gruvbox-dark.less +116 -0
- package/src/themes/gruvbox.less +152 -0
- package/src/themes/icons.less +130 -0
- package/src/themes/intl/de.less +102 -0
- package/src/themes/intl/es.less +102 -0
- package/src/themes/intl/fr.less +102 -0
- package/src/themes/intl/ja.less +102 -0
- package/src/themes/intl/pt.less +102 -0
- package/src/themes/intl/zh.less +102 -0
- package/src/themes/intl.less +102 -0
- package/src/themes/monokai.less +107 -0
- package/src/themes/pro-dark.less +147 -0
- package/src/themes/pro.less +186 -0
- package/src/themes/solarized-dark.less +78 -0
- package/src/themes/solarized.less +102 -0
- package/src/themes/themes.less +21 -0
- package/src/themes/vaporwave.less +145 -0
- package/src/themes/variables.less +24 -0
- package/src/ts/bootstrap.ts +26 -0
- package/src/ts/extensions.ts +124 -0
- package/src/ts/perspective-viewer.cdn.ts +19 -0
- package/src/ts/perspective-viewer.inline.ts +23 -0
- package/src/ts/perspective-viewer.ts +59 -0
- package/src/ts/plugin.ts +279 -0
- package/src/ts/ts-rs/Aggregate.ts +3 -0
- package/src/ts/ts-rs/ColumnConfigValues.ts +14 -0
- package/src/ts/ts-rs/CustomDatetimeFormat.ts +3 -0
- package/src/ts/ts-rs/CustomDatetimeStyleConfig.ts +5 -0
- package/src/ts/ts-rs/CustomNumberFormatConfig.ts +8 -0
- package/src/ts/ts-rs/DatetimeColorMode.ts +3 -0
- package/src/ts/ts-rs/DatetimeFormatType.ts +8 -0
- package/src/ts/ts-rs/Expressions.ts +3 -0
- package/src/ts/ts-rs/Filter.ts +4 -0
- package/src/ts/ts-rs/FilterReducer.ts +3 -0
- package/src/ts/ts-rs/FilterTerm.ts +4 -0
- package/src/ts/ts-rs/FormatMode.ts +3 -0
- package/src/ts/ts-rs/FormatUnit.ts +3 -0
- package/src/ts/ts-rs/NumberBackgroundMode.ts +3 -0
- package/src/ts/ts-rs/NumberForegroundMode.ts +3 -0
- package/src/ts/ts-rs/OnUpdateData.ts +8 -0
- package/src/ts/ts-rs/OptionalUpdate.ts +3 -0
- package/src/ts/ts-rs/PluginConfig.ts +4 -0
- package/src/ts/ts-rs/RoundingMode.ts +3 -0
- package/src/ts/ts-rs/RoundingPriority.ts +3 -0
- package/src/ts/ts-rs/Scalar.ts +7 -0
- package/src/ts/ts-rs/SignDisplay.ts +3 -0
- package/src/ts/ts-rs/SimpleDatetimeFormat.ts +3 -0
- package/src/ts/ts-rs/SimpleDatetimeStyleConfig.ts +4 -0
- package/src/ts/ts-rs/Sort.ts +4 -0
- package/src/ts/ts-rs/SortDir.ts +3 -0
- package/src/ts/ts-rs/StringColorMode.ts +3 -0
- package/src/ts/ts-rs/TrailingZeroDisplay.ts +3 -0
- package/src/ts/ts-rs/UseGrouping.ts +3 -0
- package/src/ts/ts-rs/ViewOnUpdateResp.ts +3 -0
- package/src/ts/ts-rs/ViewerConfigUpdate.ts +90 -0
- package/src/ts/ts-rs/serde_json/JsonValue.ts +3 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,196 @@
|
|
|
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 perspective_client::config::ViewConfigUpdate;
|
|
14
|
+
use yew::prelude::*;
|
|
15
|
+
|
|
16
|
+
use super::containers::select::*;
|
|
17
|
+
use super::style::LocalStyle;
|
|
18
|
+
use crate::config::*;
|
|
19
|
+
use crate::js::*;
|
|
20
|
+
use crate::model::*;
|
|
21
|
+
use crate::presentation::Presentation;
|
|
22
|
+
use crate::renderer::*;
|
|
23
|
+
use crate::session::*;
|
|
24
|
+
use crate::utils::*;
|
|
25
|
+
use crate::*;
|
|
26
|
+
|
|
27
|
+
#[derive(Properties, PartialEq)]
|
|
28
|
+
pub struct PluginSelectorProps {
|
|
29
|
+
pub renderer: Renderer,
|
|
30
|
+
pub session: Session,
|
|
31
|
+
pub presentation: Presentation,
|
|
32
|
+
|
|
33
|
+
#[cfg(test)]
|
|
34
|
+
#[prop_or_default]
|
|
35
|
+
pub weak_link: WeakScope<PluginSelector>,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
derive_model!(Renderer, Session, Presentation for PluginSelectorProps);
|
|
39
|
+
|
|
40
|
+
#[derive(Debug)]
|
|
41
|
+
pub enum PluginSelectorMsg {
|
|
42
|
+
ComponentSelectPlugin(String),
|
|
43
|
+
RendererSelectPlugin(String),
|
|
44
|
+
OpenMenu,
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
use PluginSelectorMsg::*;
|
|
48
|
+
|
|
49
|
+
pub struct PluginSelector {
|
|
50
|
+
options: Vec<SelectItem<String>>,
|
|
51
|
+
is_open: bool,
|
|
52
|
+
_plugin_sub: Subscription,
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
impl Component for PluginSelector {
|
|
56
|
+
type Message = PluginSelectorMsg;
|
|
57
|
+
type Properties = PluginSelectorProps;
|
|
58
|
+
|
|
59
|
+
fn create(ctx: &Context<Self>) -> Self {
|
|
60
|
+
let options = generate_plugin_optgroups(&ctx.props().renderer);
|
|
61
|
+
let _plugin_sub = ctx.props().renderer.plugin_changed.add_listener({
|
|
62
|
+
let link = ctx.link().clone();
|
|
63
|
+
move |plugin: JsPerspectiveViewerPlugin| {
|
|
64
|
+
let name = plugin.name();
|
|
65
|
+
link.send_message(PluginSelectorMsg::RendererSelectPlugin(name))
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
Self {
|
|
70
|
+
options,
|
|
71
|
+
is_open: false,
|
|
72
|
+
_plugin_sub,
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool {
|
|
77
|
+
match msg {
|
|
78
|
+
RendererSelectPlugin(_plugin_name) => true,
|
|
79
|
+
ComponentSelectPlugin(plugin_name) => {
|
|
80
|
+
if !ctx.props().session.is_errored() {
|
|
81
|
+
let metadata = ctx
|
|
82
|
+
.props()
|
|
83
|
+
.renderer
|
|
84
|
+
.get_next_plugin_metadata(&PluginUpdate::Update(plugin_name));
|
|
85
|
+
|
|
86
|
+
let mut update = ViewConfigUpdate::default();
|
|
87
|
+
ctx.props().session.set_update_column_defaults(
|
|
88
|
+
&mut update,
|
|
89
|
+
metadata
|
|
90
|
+
.as_ref()
|
|
91
|
+
.unwrap_or(&*ctx.props().renderer.metadata()),
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
if let Ok(task) = ctx.props().update_and_render(update) {
|
|
95
|
+
ApiFuture::spawn(task);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
ctx.props().presentation.set_open_column_settings(None);
|
|
99
|
+
self.is_open = false;
|
|
100
|
+
false
|
|
101
|
+
} else {
|
|
102
|
+
self.is_open = false;
|
|
103
|
+
true
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
OpenMenu => {
|
|
107
|
+
self.is_open = !self.is_open;
|
|
108
|
+
true
|
|
109
|
+
},
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
fn changed(&mut self, _ctx: &Context<Self>, _old: &Self::Properties) -> bool {
|
|
114
|
+
true
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
fn view(&self, ctx: &Context<Self>) -> Html {
|
|
118
|
+
let callback = ctx.link().callback(|_| OpenMenu);
|
|
119
|
+
|
|
120
|
+
let plugin_name = ctx.props().renderer.get_active_plugin().unwrap().name();
|
|
121
|
+
let plugin_name2 = plugin_name.clone();
|
|
122
|
+
let class = if self.is_open { "open" } else { "" };
|
|
123
|
+
let items = self.options.iter().map(|item| match item {
|
|
124
|
+
SelectItem::OptGroup(_cat, items) => html! {
|
|
125
|
+
items.iter().filter(|x| *x != &plugin_name2).map(|x| {
|
|
126
|
+
let callback = ctx.link().callback(ComponentSelectPlugin);
|
|
127
|
+
html! {
|
|
128
|
+
<PluginSelect
|
|
129
|
+
name={ x.to_owned() }
|
|
130
|
+
on_click={ callback } />
|
|
131
|
+
}
|
|
132
|
+
}).collect::<Html>()
|
|
133
|
+
},
|
|
134
|
+
SelectItem::Option(_item) => html! {},
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
html! {
|
|
138
|
+
<>
|
|
139
|
+
<LocalStyle href={css!("plugin-selector")} />
|
|
140
|
+
<div id="plugin_selector_container" {class}>
|
|
141
|
+
<PluginSelect name={plugin_name} on_click={callback} />
|
|
142
|
+
<div id="plugin_selector_border" />
|
|
143
|
+
if self.is_open {
|
|
144
|
+
<div class="plugin-selector-options">{ items.collect::<Html>() }</div>
|
|
145
|
+
}
|
|
146
|
+
</div>
|
|
147
|
+
</>
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/// Generate the opt groups for the plugin selector by collecting by category
|
|
153
|
+
/// then sorting.
|
|
154
|
+
fn generate_plugin_optgroups(renderer: &Renderer) -> Vec<SelectItem<String>> {
|
|
155
|
+
let mut options = renderer
|
|
156
|
+
.get_all_plugin_categories()
|
|
157
|
+
.into_iter()
|
|
158
|
+
.map(|(category, value)| SelectItem::OptGroup(category.into(), value))
|
|
159
|
+
.collect::<Vec<_>>();
|
|
160
|
+
|
|
161
|
+
options.sort_by_key(|x| x.name());
|
|
162
|
+
options
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
#[derive(Properties, PartialEq)]
|
|
166
|
+
struct PluginSelectProps {
|
|
167
|
+
name: String,
|
|
168
|
+
on_click: Callback<String>,
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
#[function_component]
|
|
172
|
+
fn PluginSelect(props: &PluginSelectProps) -> Html {
|
|
173
|
+
let name = props.name.clone().tee::<2>();
|
|
174
|
+
let path: String = props
|
|
175
|
+
.name
|
|
176
|
+
.chars()
|
|
177
|
+
.map(|x| {
|
|
178
|
+
if x.is_alphanumeric() {
|
|
179
|
+
x.to_ascii_lowercase()
|
|
180
|
+
} else {
|
|
181
|
+
'-'
|
|
182
|
+
}
|
|
183
|
+
})
|
|
184
|
+
.collect();
|
|
185
|
+
|
|
186
|
+
html! {
|
|
187
|
+
<div
|
|
188
|
+
class="plugin-select-item"
|
|
189
|
+
data-plugin={name.0}
|
|
190
|
+
style={format!("--default-column-title:var(--plugin-name-{}--content, \"{}\")", path, props.name)}
|
|
191
|
+
onclick={props.on_click.reform(move |_| name.1.clone())}
|
|
192
|
+
>
|
|
193
|
+
<span class="plugin-select-item-name" />
|
|
194
|
+
</div>
|
|
195
|
+
}
|
|
196
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
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 yew::prelude::*;
|
|
14
|
+
|
|
15
|
+
use super::style::LocalStyle;
|
|
16
|
+
use crate::renderer::*;
|
|
17
|
+
use crate::session::*;
|
|
18
|
+
use crate::utils::*;
|
|
19
|
+
use crate::*;
|
|
20
|
+
|
|
21
|
+
#[derive(Properties)]
|
|
22
|
+
pub struct RenderWarningProps {
|
|
23
|
+
pub dimensions: Option<(usize, usize, Option<usize>, Option<usize>)>,
|
|
24
|
+
pub renderer: Renderer,
|
|
25
|
+
pub session: Session,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
impl PartialEq for RenderWarningProps {
|
|
29
|
+
fn eq(&self, other: &Self) -> bool {
|
|
30
|
+
self.dimensions == other.dimensions
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
pub enum RenderWarningMsg {
|
|
35
|
+
DismissWarning,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
pub struct RenderWarning {
|
|
39
|
+
col_warn: Option<(usize, usize)>,
|
|
40
|
+
row_warn: Option<(usize, usize)>,
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
impl RenderWarning {
|
|
44
|
+
fn update_warnings(&mut self, ctx: &Context<Self>) {
|
|
45
|
+
if let Some((num_cols, num_rows, max_cols, max_rows)) = ctx.props().dimensions {
|
|
46
|
+
let count = num_cols * num_rows;
|
|
47
|
+
if max_cols.is_some_and(|x| x < num_cols) {
|
|
48
|
+
self.col_warn = Some((max_cols.unwrap(), num_cols));
|
|
49
|
+
} else {
|
|
50
|
+
self.col_warn = None;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if max_rows.is_some_and(|x| x < num_rows) {
|
|
54
|
+
self.row_warn = Some((num_cols * max_rows.unwrap(), count));
|
|
55
|
+
} else {
|
|
56
|
+
self.row_warn = None;
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
self.col_warn = None;
|
|
60
|
+
self.row_warn = None;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
impl Component for RenderWarning {
|
|
66
|
+
type Message = RenderWarningMsg;
|
|
67
|
+
type Properties = RenderWarningProps;
|
|
68
|
+
|
|
69
|
+
fn create(ctx: &Context<Self>) -> Self {
|
|
70
|
+
// enable_weak_link_test!(props, link);
|
|
71
|
+
let mut elem = Self {
|
|
72
|
+
col_warn: None,
|
|
73
|
+
row_warn: None,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
elem.update_warnings(ctx);
|
|
77
|
+
elem
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool {
|
|
81
|
+
match msg {
|
|
82
|
+
RenderWarningMsg::DismissWarning => {
|
|
83
|
+
clone!(ctx.props().renderer, ctx.props().session);
|
|
84
|
+
ApiFuture::spawn(async move {
|
|
85
|
+
renderer.disable_active_plugin_render_warning();
|
|
86
|
+
renderer.update(&session).await
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
true
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
fn changed(&mut self, ctx: &Context<Self>, _old: &Self::Properties) -> bool {
|
|
94
|
+
self.update_warnings(ctx);
|
|
95
|
+
true
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
fn view(&self, ctx: &Context<Self>) -> Html {
|
|
99
|
+
if self.col_warn.is_some() || self.row_warn.is_some() {
|
|
100
|
+
let warning = match (self.col_warn, self.row_warn) {
|
|
101
|
+
(Some((x, y)), Some((a, b))) => html! {
|
|
102
|
+
<span style="white-space: nowrap">
|
|
103
|
+
{ "Rendering" }
|
|
104
|
+
{ render_pair(x, y) }
|
|
105
|
+
{ "of columns and" }
|
|
106
|
+
{ render_pair(a, b) }
|
|
107
|
+
{ "of points." }
|
|
108
|
+
</span>
|
|
109
|
+
},
|
|
110
|
+
(Some((x, y)), None) => html! {
|
|
111
|
+
<span style="white-space: nowrap">
|
|
112
|
+
{ "Rendering" }
|
|
113
|
+
{ render_pair(x, y) }
|
|
114
|
+
{ "of columns." }
|
|
115
|
+
</span>
|
|
116
|
+
},
|
|
117
|
+
(None, Some((x, y))) => html! {
|
|
118
|
+
<span style="white-space: nowrap">
|
|
119
|
+
{ "Rendering" }
|
|
120
|
+
{ render_pair(x, y) }
|
|
121
|
+
{ "of points." }
|
|
122
|
+
</span>
|
|
123
|
+
},
|
|
124
|
+
_ => html! { <div /> },
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
let onclick = ctx.link().callback(|_| RenderWarningMsg::DismissWarning);
|
|
128
|
+
|
|
129
|
+
html! {
|
|
130
|
+
<>
|
|
131
|
+
<LocalStyle href={css!("render-warning")} />
|
|
132
|
+
<div
|
|
133
|
+
class="plugin_information plugin_information--warning"
|
|
134
|
+
id="plugin_information--size"
|
|
135
|
+
>
|
|
136
|
+
<span class="plugin_information__icon" />
|
|
137
|
+
<span class="plugin_information__text" id="plugin_information_count">
|
|
138
|
+
{ warning }
|
|
139
|
+
</span>
|
|
140
|
+
<span class="plugin_information__actions">
|
|
141
|
+
<span class="plugin_information__action" onmousedown={onclick}>
|
|
142
|
+
{ "Render all points" }
|
|
143
|
+
</span>
|
|
144
|
+
</span>
|
|
145
|
+
</div>
|
|
146
|
+
</>
|
|
147
|
+
}
|
|
148
|
+
} else {
|
|
149
|
+
html! {}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
fn pretty_print_int(i: usize) -> String {
|
|
155
|
+
let mut s = String::new();
|
|
156
|
+
let i_str = i.to_string();
|
|
157
|
+
let a = i_str.chars().rev().enumerate();
|
|
158
|
+
for (idx, val) in a {
|
|
159
|
+
if idx != 0 && idx % 3 == 0 {
|
|
160
|
+
s.insert(0, ',');
|
|
161
|
+
}
|
|
162
|
+
s.insert(0, val);
|
|
163
|
+
}
|
|
164
|
+
s
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
fn render_pair(n: usize, d: usize) -> Html {
|
|
168
|
+
let x = pretty_print_int(n);
|
|
169
|
+
let y = pretty_print_int(d);
|
|
170
|
+
let total = ((n as f64 / d as f64) * 100_f64).floor() as usize;
|
|
171
|
+
html! {
|
|
172
|
+
<span title={format!("${x} / ${y}")} class="plugin_information--overflow-hint">
|
|
173
|
+
{ "\u{00a0}" }
|
|
174
|
+
<span class="plugin_information--overflow-hint-percent">{ format!("{}%", total) }</span>
|
|
175
|
+
{ "\u{00a0}" }
|
|
176
|
+
</span>
|
|
177
|
+
}
|
|
178
|
+
}
|
|
@@ -0,0 +1,315 @@
|
|
|
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::rc::Rc;
|
|
14
|
+
|
|
15
|
+
use wasm_bindgen::JsCast;
|
|
16
|
+
use web_sys::*;
|
|
17
|
+
use yew::prelude::*;
|
|
18
|
+
|
|
19
|
+
use super::status_indicator::StatusIndicator;
|
|
20
|
+
use super::style::LocalStyle;
|
|
21
|
+
use crate::components::containers::select::*;
|
|
22
|
+
use crate::components::status_bar_counter::StatusBarRowsCounter;
|
|
23
|
+
use crate::custom_elements::copy_dropdown::*;
|
|
24
|
+
use crate::custom_elements::export_dropdown::*;
|
|
25
|
+
use crate::presentation::Presentation;
|
|
26
|
+
use crate::renderer::*;
|
|
27
|
+
use crate::session::*;
|
|
28
|
+
#[cfg(test)]
|
|
29
|
+
use crate::utils::WeakScope;
|
|
30
|
+
use crate::utils::*;
|
|
31
|
+
use crate::*;
|
|
32
|
+
|
|
33
|
+
#[derive(Properties, Clone)]
|
|
34
|
+
pub struct StatusBarProps {
|
|
35
|
+
pub id: String,
|
|
36
|
+
pub on_reset: Callback<bool>,
|
|
37
|
+
pub session: Session,
|
|
38
|
+
pub renderer: Renderer,
|
|
39
|
+
pub presentation: Presentation,
|
|
40
|
+
|
|
41
|
+
#[cfg(test)]
|
|
42
|
+
#[prop_or_default]
|
|
43
|
+
pub weak_link: WeakScope<StatusBar>,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
derive_model!(Renderer, Session, Presentation for StatusBarProps);
|
|
47
|
+
|
|
48
|
+
impl PartialEq for StatusBarProps {
|
|
49
|
+
fn eq(&self, other: &Self) -> bool {
|
|
50
|
+
self.id == other.id
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
pub enum StatusBarMsg {
|
|
55
|
+
Reset(bool),
|
|
56
|
+
Export,
|
|
57
|
+
Copy,
|
|
58
|
+
Noop,
|
|
59
|
+
SetThemeConfig((Rc<Vec<String>>, Option<usize>)),
|
|
60
|
+
SetTheme(String),
|
|
61
|
+
ResetTheme,
|
|
62
|
+
// SetError(Option<String>),
|
|
63
|
+
// TableStatsChanged,
|
|
64
|
+
// SetIsUpdating(bool),
|
|
65
|
+
SetTitle(Option<String>),
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/// A toolbar with buttons, and `Table` & `View` status information.
|
|
69
|
+
pub struct StatusBar {
|
|
70
|
+
is_updating: i32,
|
|
71
|
+
theme: Option<String>,
|
|
72
|
+
themes: Rc<Vec<String>>,
|
|
73
|
+
export_ref: NodeRef,
|
|
74
|
+
copy_ref: NodeRef,
|
|
75
|
+
_sub: [Subscription; 2],
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
impl Component for StatusBar {
|
|
79
|
+
type Message = StatusBarMsg;
|
|
80
|
+
type Properties = StatusBarProps;
|
|
81
|
+
|
|
82
|
+
fn create(ctx: &Context<Self>) -> Self {
|
|
83
|
+
let _sub = [
|
|
84
|
+
ctx.props()
|
|
85
|
+
.presentation
|
|
86
|
+
.theme_config_updated
|
|
87
|
+
.add_listener(ctx.link().callback(StatusBarMsg::SetThemeConfig)),
|
|
88
|
+
ctx.props()
|
|
89
|
+
.presentation
|
|
90
|
+
.title_changed
|
|
91
|
+
.add_listener(ctx.link().callback(|_| StatusBarMsg::Noop)),
|
|
92
|
+
];
|
|
93
|
+
|
|
94
|
+
// Fetch initial theme
|
|
95
|
+
let presentation = ctx.props().presentation.clone();
|
|
96
|
+
let on_theme = ctx.link().callback(StatusBarMsg::SetThemeConfig);
|
|
97
|
+
ApiFuture::spawn(async move {
|
|
98
|
+
on_theme.emit(presentation.get_selected_theme_config().await?);
|
|
99
|
+
Ok(())
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
Self {
|
|
103
|
+
_sub,
|
|
104
|
+
theme: None,
|
|
105
|
+
themes: vec![].into(),
|
|
106
|
+
copy_ref: NodeRef::default(),
|
|
107
|
+
export_ref: NodeRef::default(),
|
|
108
|
+
is_updating: 0,
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool {
|
|
113
|
+
match msg {
|
|
114
|
+
StatusBarMsg::Reset(all) => {
|
|
115
|
+
ctx.props().on_reset.emit(all);
|
|
116
|
+
false
|
|
117
|
+
},
|
|
118
|
+
StatusBarMsg::ResetTheme => {
|
|
119
|
+
clone!(
|
|
120
|
+
ctx.props().renderer,
|
|
121
|
+
ctx.props().session,
|
|
122
|
+
ctx.props().presentation
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
ApiFuture::spawn(async move {
|
|
126
|
+
presentation.reset_theme().await?;
|
|
127
|
+
let view = session.get_view().into_apierror()?;
|
|
128
|
+
renderer.restyle_all(&view).await
|
|
129
|
+
});
|
|
130
|
+
true
|
|
131
|
+
},
|
|
132
|
+
StatusBarMsg::SetThemeConfig((themes, index)) => {
|
|
133
|
+
let new_theme = index.and_then(|x| themes.get(x)).cloned();
|
|
134
|
+
let should_render = new_theme != self.theme || self.themes != themes;
|
|
135
|
+
self.theme = new_theme;
|
|
136
|
+
self.themes = themes;
|
|
137
|
+
should_render
|
|
138
|
+
},
|
|
139
|
+
StatusBarMsg::SetTheme(theme_name) => {
|
|
140
|
+
clone!(
|
|
141
|
+
ctx.props().renderer,
|
|
142
|
+
ctx.props().session,
|
|
143
|
+
ctx.props().presentation
|
|
144
|
+
);
|
|
145
|
+
ApiFuture::spawn(async move {
|
|
146
|
+
presentation.set_theme_name(Some(&theme_name)).await?;
|
|
147
|
+
let view = session.get_view().into_apierror()?;
|
|
148
|
+
renderer.restyle_all(&view).await
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
false
|
|
152
|
+
},
|
|
153
|
+
StatusBarMsg::Export => {
|
|
154
|
+
let target = self.export_ref.cast::<HtmlElement>().unwrap();
|
|
155
|
+
ExportDropDownMenuElement::new_from_model(ctx.props()).open(target);
|
|
156
|
+
false
|
|
157
|
+
},
|
|
158
|
+
StatusBarMsg::Copy => {
|
|
159
|
+
let target = self.copy_ref.cast::<HtmlElement>().unwrap();
|
|
160
|
+
CopyDropDownMenuElement::new_from_model(ctx.props()).open(target);
|
|
161
|
+
false
|
|
162
|
+
},
|
|
163
|
+
StatusBarMsg::Noop => true,
|
|
164
|
+
StatusBarMsg::SetTitle(title) => {
|
|
165
|
+
ctx.props().presentation.set_title(title);
|
|
166
|
+
false
|
|
167
|
+
},
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
fn view(&self, ctx: &Context<Self>) -> Html {
|
|
172
|
+
let mut is_updating_class_name = classes!();
|
|
173
|
+
if self.is_updating > 0 {
|
|
174
|
+
is_updating_class_name.push("updating")
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
if ctx.props().presentation.get_title().is_some() {
|
|
178
|
+
is_updating_class_name.push("titled")
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
let reset = ctx
|
|
182
|
+
.link()
|
|
183
|
+
.callback(|event: MouseEvent| StatusBarMsg::Reset(event.shift_key()));
|
|
184
|
+
|
|
185
|
+
let export = ctx.link().callback(|_: MouseEvent| StatusBarMsg::Export);
|
|
186
|
+
let copy = ctx.link().callback(|_: MouseEvent| StatusBarMsg::Copy);
|
|
187
|
+
|
|
188
|
+
let onchange = ctx.link().callback({
|
|
189
|
+
move |input: Event| {
|
|
190
|
+
let title = input
|
|
191
|
+
.target()
|
|
192
|
+
.unwrap()
|
|
193
|
+
.unchecked_into::<HtmlInputElement>()
|
|
194
|
+
.value();
|
|
195
|
+
|
|
196
|
+
let title = if title.trim().is_empty() {
|
|
197
|
+
None
|
|
198
|
+
} else {
|
|
199
|
+
Some(title)
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
StatusBarMsg::SetTitle(title)
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
let is_menu = ctx.props().session.has_table()
|
|
207
|
+
&& (ctx.props().presentation.is_settings_open()
|
|
208
|
+
|| (ctx.props().presentation.get_title().is_some()
|
|
209
|
+
&& !ctx.props().session.is_errored()));
|
|
210
|
+
|
|
211
|
+
if !ctx.props().session.has_table() {
|
|
212
|
+
is_updating_class_name.push("updating");
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
html! {
|
|
216
|
+
<>
|
|
217
|
+
<LocalStyle href={css!("status-bar")} />
|
|
218
|
+
<div id={ctx.props().id.clone()} class={is_updating_class_name}>
|
|
219
|
+
<StatusIndicator
|
|
220
|
+
session={&ctx.props().session}
|
|
221
|
+
renderer={&ctx.props().renderer}
|
|
222
|
+
/>
|
|
223
|
+
if is_menu {
|
|
224
|
+
<label
|
|
225
|
+
class="input-sizer"
|
|
226
|
+
data-value={ctx.props().presentation.get_title().unwrap_or_default()}
|
|
227
|
+
>
|
|
228
|
+
<input
|
|
229
|
+
placeholder=" "
|
|
230
|
+
value={ctx.props().presentation.get_title()}
|
|
231
|
+
size="10"
|
|
232
|
+
{onchange}
|
|
233
|
+
/>
|
|
234
|
+
<span id="status-bar-placeholder" />
|
|
235
|
+
</label>
|
|
236
|
+
}
|
|
237
|
+
<StatusBarRowsCounter session={&ctx.props().session} />
|
|
238
|
+
<div id="spacer" />
|
|
239
|
+
if is_menu {
|
|
240
|
+
<div id="menu-bar" class="section">
|
|
241
|
+
<ThemeSelector
|
|
242
|
+
theme={self.theme.clone()}
|
|
243
|
+
themes={self.themes.clone()}
|
|
244
|
+
on_change={ctx.link().callback(StatusBarMsg::SetTheme)}
|
|
245
|
+
on_reset={ctx.link().callback(|_| StatusBarMsg::ResetTheme)}
|
|
246
|
+
/>
|
|
247
|
+
<div id="plugin-settings"><slot name="plugin-settings" /></div>
|
|
248
|
+
<span class="hover-target">
|
|
249
|
+
<span id="reset" class="button" onmousedown={reset}><span /></span>
|
|
250
|
+
</span>
|
|
251
|
+
<span class="hover-target" ref={&self.export_ref} onmousedown={export}>
|
|
252
|
+
<span id="export" class="button"><span /></span>
|
|
253
|
+
</span>
|
|
254
|
+
<span class="hover-target" ref={&self.copy_ref} onmousedown={copy}>
|
|
255
|
+
<span id="copy" class="button"><span /></span>
|
|
256
|
+
</span>
|
|
257
|
+
</div>
|
|
258
|
+
}
|
|
259
|
+
</div>
|
|
260
|
+
</>
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
#[derive(Properties, PartialEq)]
|
|
266
|
+
pub struct ThemeSelectorProps {
|
|
267
|
+
pub theme: Option<String>,
|
|
268
|
+
pub themes: Rc<Vec<String>>,
|
|
269
|
+
pub on_reset: Callback<()>,
|
|
270
|
+
pub on_change: Callback<String>,
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
#[function_component]
|
|
274
|
+
pub fn ThemeSelector(props: &ThemeSelectorProps) -> Html {
|
|
275
|
+
let is_first = props
|
|
276
|
+
.theme
|
|
277
|
+
.as_ref()
|
|
278
|
+
.and_then(|x| props.themes.first().map(|y| y == x))
|
|
279
|
+
.unwrap_or_default();
|
|
280
|
+
|
|
281
|
+
let values = use_memo(props.themes.clone(), |themes| {
|
|
282
|
+
themes
|
|
283
|
+
.iter()
|
|
284
|
+
.cloned()
|
|
285
|
+
.map(SelectItem::Option)
|
|
286
|
+
.collect::<Vec<_>>()
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
match &props.theme {
|
|
290
|
+
None => html! {},
|
|
291
|
+
Some(selected) => {
|
|
292
|
+
html! {
|
|
293
|
+
if values.len() > 1 {
|
|
294
|
+
<span class="hover-target">
|
|
295
|
+
<div
|
|
296
|
+
id="theme_icon"
|
|
297
|
+
class={if is_first {""} else {"modified"}}
|
|
298
|
+
tabindex="0"
|
|
299
|
+
onclick={props.on_reset.reform(|_| ())}
|
|
300
|
+
/>
|
|
301
|
+
<span id="theme" class="button">
|
|
302
|
+
<Select<String>
|
|
303
|
+
id="theme_selector"
|
|
304
|
+
class="invert"
|
|
305
|
+
{values}
|
|
306
|
+
selected={selected.to_owned()}
|
|
307
|
+
on_select={props.on_change.clone()}
|
|
308
|
+
/>
|
|
309
|
+
</span>
|
|
310
|
+
</span>
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
}
|
|
315
|
+
}
|