@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,221 @@
|
|
|
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 itertools::Itertools;
|
|
14
|
+
use perspective_client::config::{ColumnType, *};
|
|
15
|
+
use perspective_client::utils::PerspectiveResultExt;
|
|
16
|
+
use web_sys::*;
|
|
17
|
+
use yew::prelude::*;
|
|
18
|
+
|
|
19
|
+
use super::expression_toolbar::*;
|
|
20
|
+
use crate::components::type_icon::TypeIcon;
|
|
21
|
+
use crate::components::viewer::ColumnLocator;
|
|
22
|
+
use crate::dragdrop::*;
|
|
23
|
+
use crate::js::plugin::*;
|
|
24
|
+
use crate::model::*;
|
|
25
|
+
use crate::presentation::Presentation;
|
|
26
|
+
use crate::renderer::*;
|
|
27
|
+
use crate::session::*;
|
|
28
|
+
use crate::*;
|
|
29
|
+
|
|
30
|
+
#[derive(Properties, Clone)]
|
|
31
|
+
pub struct InactiveColumnProps {
|
|
32
|
+
pub idx: usize,
|
|
33
|
+
pub visible: bool,
|
|
34
|
+
pub name: String,
|
|
35
|
+
pub dragdrop: DragDrop,
|
|
36
|
+
pub session: Session,
|
|
37
|
+
pub renderer: Renderer,
|
|
38
|
+
pub presentation: Presentation,
|
|
39
|
+
pub is_editing: bool,
|
|
40
|
+
pub ondragend: Callback<()>,
|
|
41
|
+
pub onselect: Callback<()>,
|
|
42
|
+
pub on_open_expr_panel: Callback<ColumnLocator>,
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
impl PartialEq for InactiveColumnProps {
|
|
46
|
+
/// Equality for `InactiveColumnProps` determines when it should re-render,
|
|
47
|
+
/// which is only when it has changed.
|
|
48
|
+
/// TODO Aggregates
|
|
49
|
+
fn eq(&self, _rhs: &Self) -> bool {
|
|
50
|
+
false
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
derive_model!(Renderer, Session for InactiveColumnProps);
|
|
55
|
+
|
|
56
|
+
impl InactiveColumnProps {
|
|
57
|
+
/// Add a column to the active columns, which corresponds to the `columns`
|
|
58
|
+
/// field of the `JsPerspectiveViewConfig`.
|
|
59
|
+
///
|
|
60
|
+
/// # Arguments
|
|
61
|
+
/// - `name` The name of the column to de-activate, which is a unique ID
|
|
62
|
+
/// with respect to `columns`.
|
|
63
|
+
/// - `shift` whether to toggle or select this column.
|
|
64
|
+
pub fn activate_column(&self, name: String, shift: bool) {
|
|
65
|
+
let mut columns = self.session.get_view_config().columns.clone();
|
|
66
|
+
let max_cols = self
|
|
67
|
+
.renderer
|
|
68
|
+
.metadata()
|
|
69
|
+
.names
|
|
70
|
+
.as_ref()
|
|
71
|
+
.map_or(0, |x| x.len());
|
|
72
|
+
|
|
73
|
+
// Don't treat `None` at the end of the column list as columns, we'll refill
|
|
74
|
+
// these later
|
|
75
|
+
if let Some(last_filled) = columns.iter().rposition(|x| !x.is_none()) {
|
|
76
|
+
columns.truncate(last_filled + 1);
|
|
77
|
+
|
|
78
|
+
let mode = self.renderer.metadata().mode;
|
|
79
|
+
if (mode == ColumnSelectMode::Select) ^ shift {
|
|
80
|
+
columns.clear();
|
|
81
|
+
} else {
|
|
82
|
+
columns.retain(|x| x.as_ref() != Some(&name));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
columns.push(Some(name));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Do this outside the loop so errors dont just become noops
|
|
89
|
+
self.apply_columns(
|
|
90
|
+
columns
|
|
91
|
+
.into_iter()
|
|
92
|
+
.pad_using(max_cols, |_| None)
|
|
93
|
+
.collect::<Vec<_>>(),
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
fn apply_columns(&self, columns: Vec<Option<String>>) {
|
|
98
|
+
let config = ViewConfigUpdate {
|
|
99
|
+
columns: Some(columns),
|
|
100
|
+
..ViewConfigUpdate::default()
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
self.update_and_render(config)
|
|
104
|
+
.map(ApiFuture::spawn)
|
|
105
|
+
.unwrap_or_log();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
pub enum InactiveColumnMsg {
|
|
110
|
+
ActivateColumn(bool),
|
|
111
|
+
MouseEnter(bool),
|
|
112
|
+
MouseLeave(bool),
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
use InactiveColumnMsg::*;
|
|
116
|
+
|
|
117
|
+
#[derive(Default)]
|
|
118
|
+
pub struct InactiveColumn {
|
|
119
|
+
add_expression_ref: NodeRef,
|
|
120
|
+
mouseover: bool,
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
impl Component for InactiveColumn {
|
|
124
|
+
type Message = InactiveColumnMsg;
|
|
125
|
+
type Properties = InactiveColumnProps;
|
|
126
|
+
|
|
127
|
+
fn create(_ctx: &Context<Self>) -> Self {
|
|
128
|
+
Self::default()
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
fn update(&mut self, ctx: &Context<Self>, msg: InactiveColumnMsg) -> bool {
|
|
132
|
+
match msg {
|
|
133
|
+
ActivateColumn(shift_key) => {
|
|
134
|
+
ctx.props()
|
|
135
|
+
.activate_column(ctx.props().name.to_owned(), shift_key);
|
|
136
|
+
ctx.props().onselect.emit(());
|
|
137
|
+
false
|
|
138
|
+
},
|
|
139
|
+
MouseEnter(is_render) => {
|
|
140
|
+
self.mouseover = is_render;
|
|
141
|
+
is_render
|
|
142
|
+
},
|
|
143
|
+
MouseLeave(is_render) => {
|
|
144
|
+
self.mouseover = false;
|
|
145
|
+
is_render
|
|
146
|
+
},
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
fn view(&self, ctx: &Context<Self>) -> Html {
|
|
151
|
+
let col_type = ctx
|
|
152
|
+
.props()
|
|
153
|
+
.session
|
|
154
|
+
.metadata()
|
|
155
|
+
.get_column_table_type(&ctx.props().name)
|
|
156
|
+
.unwrap_or(ColumnType::String);
|
|
157
|
+
|
|
158
|
+
let add_column = ctx
|
|
159
|
+
.link()
|
|
160
|
+
.callback(|event: MouseEvent| InactiveColumnMsg::ActivateColumn(event.shift_key()));
|
|
161
|
+
|
|
162
|
+
let ondragend = ctx.props().ondragend.reform(|_| {});
|
|
163
|
+
let ondragstart = ctx.link().callback({
|
|
164
|
+
let event_name = ctx.props().name.to_owned();
|
|
165
|
+
let dragdrop = ctx.props().dragdrop.clone();
|
|
166
|
+
move |event: DragEvent| {
|
|
167
|
+
dragdrop.set_drag_image(&event).unwrap();
|
|
168
|
+
dragdrop.notify_drag_start(event_name.to_string(), DragEffect::Copy);
|
|
169
|
+
MouseLeave(false)
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
let onmouseout = ctx.link().callback(|_| MouseLeave(true));
|
|
174
|
+
let onmouseover = ctx
|
|
175
|
+
.link()
|
|
176
|
+
.callback(|event: MouseEvent| MouseEnter(event.which() == 0));
|
|
177
|
+
|
|
178
|
+
let is_expression = ctx
|
|
179
|
+
.props()
|
|
180
|
+
.session
|
|
181
|
+
.metadata()
|
|
182
|
+
.is_column_expression(&ctx.props().name);
|
|
183
|
+
|
|
184
|
+
let is_active_class = ctx.props().renderer.metadata().mode.css();
|
|
185
|
+
let mut class = classes!("column-selector-column");
|
|
186
|
+
if !ctx.props().visible {
|
|
187
|
+
class.push("column-selector-column-hidden");
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if self.mouseover {
|
|
191
|
+
class.push("dragdrop-hover");
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
html! {
|
|
195
|
+
<div {class} {onmouseover} {onmouseout} data-index={ctx.props().idx.to_string()}>
|
|
196
|
+
<span class={is_active_class} onmousedown={add_column} />
|
|
197
|
+
<div
|
|
198
|
+
class="column-selector-draggable column-selector-column-title"
|
|
199
|
+
draggable="true"
|
|
200
|
+
ref={&self.add_expression_ref}
|
|
201
|
+
{ondragstart}
|
|
202
|
+
{ondragend}
|
|
203
|
+
>
|
|
204
|
+
<div class="column-selector-column-border">
|
|
205
|
+
<TypeIcon ty={col_type} />
|
|
206
|
+
<span class="column_name">{ ctx.props().name.clone() }</span>
|
|
207
|
+
<span class="column-selector--spacer" />
|
|
208
|
+
if is_expression {
|
|
209
|
+
<ExprEditButton
|
|
210
|
+
name={ctx.props().name.clone()}
|
|
211
|
+
on_open_expr_panel={&ctx.props().on_open_expr_panel}
|
|
212
|
+
is_expression=true
|
|
213
|
+
is_editing={ctx.props().is_editing}
|
|
214
|
+
/>
|
|
215
|
+
}
|
|
216
|
+
</div>
|
|
217
|
+
</div>
|
|
218
|
+
</div>
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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 crate::components::style::LocalStyle;
|
|
16
|
+
use crate::css;
|
|
17
|
+
|
|
18
|
+
#[derive(Default)]
|
|
19
|
+
pub struct InvalidColumn {}
|
|
20
|
+
|
|
21
|
+
impl Component for InvalidColumn {
|
|
22
|
+
type Message = ();
|
|
23
|
+
type Properties = ();
|
|
24
|
+
|
|
25
|
+
fn create(_ctx: &Context<Self>) -> Self {
|
|
26
|
+
Self::default()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
fn view(&self, _ctx: &Context<Self>) -> Html {
|
|
30
|
+
html! {
|
|
31
|
+
<div class="pivot-column column-empty column-invalid">
|
|
32
|
+
<LocalStyle href={css!("empty-column")} />
|
|
33
|
+
<div class="column-invalid-input" />
|
|
34
|
+
</div>
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
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::ColumnType;
|
|
14
|
+
// use perspective_client::ColumnType;
|
|
15
|
+
use web_sys::*;
|
|
16
|
+
use yew::prelude::*;
|
|
17
|
+
|
|
18
|
+
use crate::components::containers::dragdrop_list::*;
|
|
19
|
+
use crate::components::type_icon::TypeIcon;
|
|
20
|
+
use crate::dragdrop::*;
|
|
21
|
+
use crate::session::*;
|
|
22
|
+
|
|
23
|
+
pub struct PivotColumn {}
|
|
24
|
+
|
|
25
|
+
#[derive(Properties)]
|
|
26
|
+
pub struct PivotColumnProps {
|
|
27
|
+
pub session: Session,
|
|
28
|
+
pub column: String,
|
|
29
|
+
pub dragdrop: DragDrop,
|
|
30
|
+
pub action: DragTarget,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
impl PartialEq for PivotColumnProps {
|
|
34
|
+
fn eq(&self, other: &Self) -> bool {
|
|
35
|
+
self.column == other.column && self.action == other.action
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
impl DragDropListItemProps for PivotColumnProps {
|
|
40
|
+
type Item = String;
|
|
41
|
+
|
|
42
|
+
fn get_item(&self) -> String {
|
|
43
|
+
self.column.clone()
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
impl Component for PivotColumn {
|
|
48
|
+
type Message = ();
|
|
49
|
+
type Properties = PivotColumnProps;
|
|
50
|
+
|
|
51
|
+
fn view(&self, ctx: &Context<Self>) -> Html {
|
|
52
|
+
let dragstart = Callback::from({
|
|
53
|
+
let event_name = ctx.props().column.to_owned();
|
|
54
|
+
let dragdrop = ctx.props().dragdrop.clone();
|
|
55
|
+
let action = ctx.props().action;
|
|
56
|
+
move |event: DragEvent| {
|
|
57
|
+
dragdrop.set_drag_image(&event).unwrap();
|
|
58
|
+
dragdrop.notify_drag_start(event_name.to_string(), DragEffect::Move(action))
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
let dragend = Callback::from({
|
|
63
|
+
let dragdrop = ctx.props().dragdrop.clone();
|
|
64
|
+
move |_event| dragdrop.notify_drag_end()
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
let col_type = ctx
|
|
68
|
+
.props()
|
|
69
|
+
.session
|
|
70
|
+
.metadata()
|
|
71
|
+
.get_column_table_type(&ctx.props().column)
|
|
72
|
+
.unwrap_or(ColumnType::Integer);
|
|
73
|
+
|
|
74
|
+
html! {
|
|
75
|
+
<div
|
|
76
|
+
class="pivot-column-draggable"
|
|
77
|
+
draggable="true"
|
|
78
|
+
ondragstart={dragstart}
|
|
79
|
+
ondragend={dragend}
|
|
80
|
+
>
|
|
81
|
+
<div class="pivot-column-border">
|
|
82
|
+
<TypeIcon ty={col_type} />
|
|
83
|
+
// <TypeIcon ty={ColumnType::String} />
|
|
84
|
+
<span class="column_name">{ ctx.props().column.clone() }</span>
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
fn create(_ctx: &Context<Self>) -> Self {
|
|
91
|
+
Self {}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
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::*;
|
|
14
|
+
use perspective_client::utils::PerspectiveResultExt;
|
|
15
|
+
use web_sys::*;
|
|
16
|
+
use yew::prelude::*;
|
|
17
|
+
|
|
18
|
+
use crate::components::containers::dragdrop_list::*;
|
|
19
|
+
use crate::components::type_icon::TypeIcon;
|
|
20
|
+
use crate::dragdrop::*;
|
|
21
|
+
use crate::model::*;
|
|
22
|
+
use crate::renderer::*;
|
|
23
|
+
use crate::session::*;
|
|
24
|
+
use crate::*;
|
|
25
|
+
|
|
26
|
+
/// A `SortColumn` includes the column name and `SortDir` arrow, a clickable
|
|
27
|
+
/// button which cycles through the available `SortDir` states.
|
|
28
|
+
pub struct SortColumn {}
|
|
29
|
+
|
|
30
|
+
#[derive(Properties)]
|
|
31
|
+
pub struct SortColumnProps {
|
|
32
|
+
pub sort: Sort,
|
|
33
|
+
pub idx: usize,
|
|
34
|
+
pub session: Session,
|
|
35
|
+
pub renderer: Renderer,
|
|
36
|
+
pub dragdrop: DragDrop,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
impl PartialEq for SortColumnProps {
|
|
40
|
+
fn eq(&self, other: &Self) -> bool {
|
|
41
|
+
self.sort == other.sort && self.idx == other.idx
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
derive_model!(Renderer, Session for SortColumnProps);
|
|
46
|
+
|
|
47
|
+
impl DragDropListItemProps for SortColumnProps {
|
|
48
|
+
type Item = Sort;
|
|
49
|
+
|
|
50
|
+
fn get_item(&self) -> Sort {
|
|
51
|
+
self.sort.clone()
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
pub enum SortColumnMsg {
|
|
56
|
+
SortDirClick(bool),
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
impl Component for SortColumn {
|
|
60
|
+
type Message = SortColumnMsg;
|
|
61
|
+
type Properties = SortColumnProps;
|
|
62
|
+
|
|
63
|
+
fn create(_ctx: &Context<Self>) -> Self {
|
|
64
|
+
Self {}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
fn update(&mut self, ctx: &Context<Self>, msg: SortColumnMsg) -> bool {
|
|
68
|
+
match msg {
|
|
69
|
+
SortColumnMsg::SortDirClick(shift_key) => {
|
|
70
|
+
let is_split = ctx.props().session.get_view_config().split_by.is_empty();
|
|
71
|
+
let mut sort = ctx.props().session.get_view_config().sort.clone();
|
|
72
|
+
let sort_column = &mut sort.get_mut(ctx.props().idx).expect("Sort on no column");
|
|
73
|
+
sort_column.1 = sort_column.1.cycle(!is_split, shift_key);
|
|
74
|
+
let update = ViewConfigUpdate {
|
|
75
|
+
sort: Some(sort),
|
|
76
|
+
..ViewConfigUpdate::default()
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
ctx.props()
|
|
80
|
+
.update_and_render(update)
|
|
81
|
+
.map(ApiFuture::spawn)
|
|
82
|
+
.unwrap_or_log();
|
|
83
|
+
|
|
84
|
+
false
|
|
85
|
+
},
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
fn view(&self, ctx: &Context<Self>) -> Html {
|
|
90
|
+
let onclick = ctx
|
|
91
|
+
.link()
|
|
92
|
+
.callback(|event: MouseEvent| SortColumnMsg::SortDirClick(event.shift_key()));
|
|
93
|
+
|
|
94
|
+
let dragstart = Callback::from({
|
|
95
|
+
let event_name = ctx.props().sort.0.to_owned();
|
|
96
|
+
let dragdrop = ctx.props().dragdrop.clone();
|
|
97
|
+
move |event: DragEvent| {
|
|
98
|
+
dragdrop.set_drag_image(&event).unwrap();
|
|
99
|
+
dragdrop
|
|
100
|
+
.notify_drag_start(event_name.to_string(), DragEffect::Move(DragTarget::Sort))
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
let dragend = Callback::from({
|
|
105
|
+
let dragdrop = ctx.props().dragdrop.clone();
|
|
106
|
+
move |_event| dragdrop.notify_drag_end()
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
let col_type = ctx
|
|
110
|
+
.props()
|
|
111
|
+
.session
|
|
112
|
+
.metadata()
|
|
113
|
+
.get_column_table_type(&ctx.props().sort.0.to_owned())
|
|
114
|
+
.unwrap_or(ColumnType::Integer);
|
|
115
|
+
|
|
116
|
+
html! {
|
|
117
|
+
<div
|
|
118
|
+
class="pivot-column-draggable"
|
|
119
|
+
draggable="true"
|
|
120
|
+
ondragstart={dragstart}
|
|
121
|
+
ondragend={dragend}
|
|
122
|
+
>
|
|
123
|
+
<div class="pivot-column-border">
|
|
124
|
+
<TypeIcon ty={col_type} />
|
|
125
|
+
// <TypeIcon ty={ColumnType::String} />
|
|
126
|
+
<span class="column_name">{ ctx.props().sort.0.to_owned() }</span>
|
|
127
|
+
<span
|
|
128
|
+
class={format!("sort-icon {}", ctx.props().sort.1)}
|
|
129
|
+
onmousedown={onclick}
|
|
130
|
+
/>
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|