@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,229 @@
|
|
|
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::*;
|
|
14
|
+
use yew::prelude::*;
|
|
15
|
+
|
|
16
|
+
use crate::session::{Session, ViewStats};
|
|
17
|
+
use crate::utils::{AddListener, ToFormattedString};
|
|
18
|
+
|
|
19
|
+
#[derive(Properties, PartialEq)]
|
|
20
|
+
pub struct StatusBarRowsCounterProps {
|
|
21
|
+
pub session: Session,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
#[function_component]
|
|
25
|
+
pub fn StatusBarRowsCounter(props: &StatusBarRowsCounterProps) -> Html {
|
|
26
|
+
let stats = use_state_eq(|| props.session.get_table_stats());
|
|
27
|
+
use_effect_with(
|
|
28
|
+
(props.session.clone(), stats.setter()),
|
|
29
|
+
|(session, set_stats)| {
|
|
30
|
+
let sub = session.stats_changed.add_listener({
|
|
31
|
+
clone!(session, set_stats);
|
|
32
|
+
move |_| set_stats.set(session.get_table_stats())
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
|| drop(sub)
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
match props.session.get_table_stats() {
|
|
40
|
+
Some(
|
|
41
|
+
ViewStats {
|
|
42
|
+
num_table_cells: Some((tr, tc)),
|
|
43
|
+
num_view_cells: Some((vr, vc)),
|
|
44
|
+
is_group_by: true,
|
|
45
|
+
..
|
|
46
|
+
}
|
|
47
|
+
| ViewStats {
|
|
48
|
+
num_table_cells: Some((tr, tc)),
|
|
49
|
+
num_view_cells: Some((vr, vc)),
|
|
50
|
+
is_filtered: true,
|
|
51
|
+
..
|
|
52
|
+
},
|
|
53
|
+
) if vc != tc => {
|
|
54
|
+
let vrows = vr.to_formatted_string();
|
|
55
|
+
let nrows = tr.to_formatted_string();
|
|
56
|
+
let vcols = vc.to_formatted_string();
|
|
57
|
+
let ncols = tc.to_formatted_string();
|
|
58
|
+
html! {
|
|
59
|
+
<span id="rows">
|
|
60
|
+
{ vrows }
|
|
61
|
+
<span>{ format!(" ({}) x ", nrows) }</span>
|
|
62
|
+
{ vcols }
|
|
63
|
+
<span>{ format!(" ({})", ncols) }</span>
|
|
64
|
+
</span>
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
Some(
|
|
69
|
+
ViewStats {
|
|
70
|
+
num_table_cells: Some((tr, _)),
|
|
71
|
+
num_view_cells: Some((vr, vc)),
|
|
72
|
+
is_group_by: true,
|
|
73
|
+
..
|
|
74
|
+
}
|
|
75
|
+
| ViewStats {
|
|
76
|
+
num_table_cells: Some((tr, _)),
|
|
77
|
+
num_view_cells: Some((vr, vc)),
|
|
78
|
+
is_filtered: true,
|
|
79
|
+
..
|
|
80
|
+
},
|
|
81
|
+
) => {
|
|
82
|
+
let vrows = vr.to_formatted_string();
|
|
83
|
+
let nrows = tr.to_formatted_string();
|
|
84
|
+
let vcols = vc.to_formatted_string();
|
|
85
|
+
html! {
|
|
86
|
+
<span id="rows">{ vrows }<span>{ format!(" ({}) x ", nrows) }</span>{ vcols }</span>
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
Some(ViewStats {
|
|
91
|
+
num_table_cells: Some((_, tc)),
|
|
92
|
+
num_view_cells: Some((vr, vc)),
|
|
93
|
+
..
|
|
94
|
+
}) if vc != tc => {
|
|
95
|
+
let vrows = vr.to_formatted_string();
|
|
96
|
+
let vcols = vc.to_formatted_string();
|
|
97
|
+
let ncols = tc.to_formatted_string();
|
|
98
|
+
html! {
|
|
99
|
+
<span id="rows">
|
|
100
|
+
{ vrows }
|
|
101
|
+
<span>{ " x " }</span>
|
|
102
|
+
{ vcols }
|
|
103
|
+
<span>{ format!(" ({})", ncols) }</span>
|
|
104
|
+
</span>
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
Some(ViewStats {
|
|
109
|
+
num_table_cells: Some((tr, tc)),
|
|
110
|
+
..
|
|
111
|
+
}) => {
|
|
112
|
+
let nrows = tr.to_formatted_string();
|
|
113
|
+
let ncols = tc.to_formatted_string();
|
|
114
|
+
html! { <span id="rows">{ nrows }<span>{ " x " }</span>{ ncols }</span> }
|
|
115
|
+
},
|
|
116
|
+
Some(ViewStats {
|
|
117
|
+
num_table_cells: None,
|
|
118
|
+
..
|
|
119
|
+
}) => html! { <span /> },
|
|
120
|
+
None => html! { <span /> },
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// /// A label widget which displays a row count and a "projection" count, the
|
|
125
|
+
// /// number of rows in the `View` which includes aggregate rows.
|
|
126
|
+
// pub struct StatusBarRowsCounter {}
|
|
127
|
+
|
|
128
|
+
// impl Component for StatusBarRowsCounter {
|
|
129
|
+
// type Message = ();
|
|
130
|
+
// type Properties = ();
|
|
131
|
+
|
|
132
|
+
// fn create(_ctx: &Context<Self>) -> Self {
|
|
133
|
+
// Self {}
|
|
134
|
+
// }
|
|
135
|
+
|
|
136
|
+
// fn update(&mut self, _ctx: &Context<Self>, _msg: Self::Message) -> bool {
|
|
137
|
+
// false
|
|
138
|
+
// }
|
|
139
|
+
|
|
140
|
+
// fn view(&self, ctx: &Context<Self>) -> Html {
|
|
141
|
+
// match &ctx.props().stats {
|
|
142
|
+
// Some(
|
|
143
|
+
// ViewStats {
|
|
144
|
+
// num_table_cells: Some((tr, tc)),
|
|
145
|
+
// num_view_cells: Some((vr, vc)),
|
|
146
|
+
// is_group_by: true,
|
|
147
|
+
// ..
|
|
148
|
+
// }
|
|
149
|
+
// | ViewStats {
|
|
150
|
+
// num_table_cells: Some((tr, tc)),
|
|
151
|
+
// num_view_cells: Some((vr, vc)),
|
|
152
|
+
// is_filtered: true,
|
|
153
|
+
// ..
|
|
154
|
+
// },
|
|
155
|
+
// ) if vc != tc => {
|
|
156
|
+
// let vrows = vr.to_formatted_string();
|
|
157
|
+
// let nrows = tr.to_formatted_string();
|
|
158
|
+
// let vcols = vc.to_formatted_string();
|
|
159
|
+
// let ncols = tc.to_formatted_string();
|
|
160
|
+
// html! {
|
|
161
|
+
// <span id="rows">
|
|
162
|
+
// { vrows }
|
|
163
|
+
// <span>{ format!(" ({}) x ", nrows) }</span>
|
|
164
|
+
// { vcols }
|
|
165
|
+
// <span>{ format!(" ({})", ncols) }</span>
|
|
166
|
+
// </span>
|
|
167
|
+
// }
|
|
168
|
+
// },
|
|
169
|
+
|
|
170
|
+
// Some(
|
|
171
|
+
// ViewStats {
|
|
172
|
+
// num_table_cells: Some((tr, _)),
|
|
173
|
+
// num_view_cells: Some((vr, vc)),
|
|
174
|
+
// is_group_by: true,
|
|
175
|
+
// ..
|
|
176
|
+
// }
|
|
177
|
+
// | ViewStats {
|
|
178
|
+
// num_table_cells: Some((tr, _)),
|
|
179
|
+
// num_view_cells: Some((vr, vc)),
|
|
180
|
+
// is_filtered: true,
|
|
181
|
+
// ..
|
|
182
|
+
// },
|
|
183
|
+
// ) => {
|
|
184
|
+
// let vrows = vr.to_formatted_string();
|
|
185
|
+
// let nrows = tr.to_formatted_string();
|
|
186
|
+
// let vcols = vc.to_formatted_string();
|
|
187
|
+
// html! {
|
|
188
|
+
// <span id="rows">
|
|
189
|
+
// { vrows }
|
|
190
|
+
// <span>{ format!(" ({}) x ", nrows) }</span>
|
|
191
|
+
// { vcols }
|
|
192
|
+
// </span>
|
|
193
|
+
// }
|
|
194
|
+
// },
|
|
195
|
+
|
|
196
|
+
// Some(ViewStats {
|
|
197
|
+
// num_table_cells: Some((_, tc)),
|
|
198
|
+
// num_view_cells: Some((vr, vc)),
|
|
199
|
+
// ..
|
|
200
|
+
// }) if vc != tc => {
|
|
201
|
+
// let vrows = vr.to_formatted_string();
|
|
202
|
+
// let vcols = vc.to_formatted_string();
|
|
203
|
+
// let ncols = tc.to_formatted_string();
|
|
204
|
+
// html! {
|
|
205
|
+
// <span id="rows">
|
|
206
|
+
// { vrows }
|
|
207
|
+
// <span>{ " x " }</span>
|
|
208
|
+
// { vcols }
|
|
209
|
+
// <span>{ format!(" ({})", ncols) }</span>
|
|
210
|
+
// </span>
|
|
211
|
+
// }
|
|
212
|
+
// },
|
|
213
|
+
|
|
214
|
+
// Some(ViewStats {
|
|
215
|
+
// num_table_cells: Some((tr, tc)),
|
|
216
|
+
// ..
|
|
217
|
+
// }) => {
|
|
218
|
+
// let nrows = tr.to_formatted_string();
|
|
219
|
+
// let ncols = tc.to_formatted_string();
|
|
220
|
+
// html! { <span id="rows">{ nrows }<span>{ " x " }</span>{
|
|
221
|
+
// ncols }</span> } },
|
|
222
|
+
// Some(ViewStats {
|
|
223
|
+
// num_table_cells: None,
|
|
224
|
+
// ..
|
|
225
|
+
// }) => html! { <span /> },
|
|
226
|
+
// None => html! { <span /> },
|
|
227
|
+
// }
|
|
228
|
+
// }
|
|
229
|
+
// }
|
|
@@ -0,0 +1,164 @@
|
|
|
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 web_sys::*;
|
|
15
|
+
use yew::prelude::*;
|
|
16
|
+
|
|
17
|
+
use crate::model::UpdateAndRender;
|
|
18
|
+
use crate::renderer::*;
|
|
19
|
+
use crate::session::*;
|
|
20
|
+
use crate::utils::*;
|
|
21
|
+
use crate::*;
|
|
22
|
+
|
|
23
|
+
#[derive(Clone, Default, Debug, PartialEq)]
|
|
24
|
+
enum StatusIconState {
|
|
25
|
+
Loading,
|
|
26
|
+
Updating(u32),
|
|
27
|
+
Errored(String, String, &'static str),
|
|
28
|
+
Normal,
|
|
29
|
+
|
|
30
|
+
#[default]
|
|
31
|
+
Unititialized,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
#[derive(Clone, Debug)]
|
|
35
|
+
enum StatusIconStateAction {
|
|
36
|
+
Increment,
|
|
37
|
+
Decrement,
|
|
38
|
+
Load(Option<ViewStats>),
|
|
39
|
+
SetError(ApiError),
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
impl Reducible for StatusIconState {
|
|
43
|
+
type Action = StatusIconStateAction;
|
|
44
|
+
|
|
45
|
+
fn reduce(self: std::rc::Rc<Self>, action: Self::Action) -> std::rc::Rc<Self> {
|
|
46
|
+
let new_status = match (&*self, action.clone()) {
|
|
47
|
+
(StatusIconState::Updating(x), StatusIconStateAction::Increment) => {
|
|
48
|
+
Self::Updating(x + 1)
|
|
49
|
+
},
|
|
50
|
+
(StatusIconState::Updating(x), StatusIconStateAction::Decrement) if *x > 1 => {
|
|
51
|
+
Self::Updating(x - 1)
|
|
52
|
+
},
|
|
53
|
+
(_, StatusIconStateAction::Load(stats)) => {
|
|
54
|
+
if stats.and_then(|x| x.num_table_cells).is_some() {
|
|
55
|
+
StatusIconState::Normal
|
|
56
|
+
} else {
|
|
57
|
+
Self::Loading
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
(_, StatusIconStateAction::SetError(e)) => {
|
|
61
|
+
Self::Errored(e.message(), e.stacktrace(), e.kind())
|
|
62
|
+
},
|
|
63
|
+
(
|
|
64
|
+
StatusIconState::Loading,
|
|
65
|
+
StatusIconStateAction::Increment | StatusIconStateAction::Decrement,
|
|
66
|
+
) => StatusIconState::Loading,
|
|
67
|
+
(_, StatusIconStateAction::Increment) => Self::Updating(1),
|
|
68
|
+
(_, StatusIconStateAction::Decrement) => StatusIconState::Normal,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
new_status.into()
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
#[extend::ext]
|
|
76
|
+
impl<T: Reducible + 'static> UseReducerDispatcher<T> {
|
|
77
|
+
fn callback<U>(&self, action: impl Fn(U) -> T::Action + 'static) -> Callback<U> {
|
|
78
|
+
let dispatcher = self.clone();
|
|
79
|
+
Callback::from(move |event| dispatcher.dispatch(action(event)))
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
#[derive(Clone, Properties, PartialEq)]
|
|
84
|
+
pub struct StatusIndicatorProps {
|
|
85
|
+
pub session: Session,
|
|
86
|
+
pub renderer: Renderer,
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
derive_model!(Session, Renderer for StatusIndicatorProps);
|
|
90
|
+
|
|
91
|
+
/// An indicator component which displays the current status of the perspective
|
|
92
|
+
/// server as an icon. This indicator also functions as a button to invoke the
|
|
93
|
+
/// reconnect callback when in an error state.
|
|
94
|
+
#[function_component]
|
|
95
|
+
pub fn StatusIndicator(props: &StatusIndicatorProps) -> Html {
|
|
96
|
+
let state = use_reducer_eq(|| {
|
|
97
|
+
if let Some(err) = props.session.get_error() {
|
|
98
|
+
StatusIconState::Errored(err.message(), err.stacktrace(), err.kind())
|
|
99
|
+
} else {
|
|
100
|
+
StatusIconState::Normal
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
use_effect_with(
|
|
105
|
+
(props.session.clone(), state.dispatcher()),
|
|
106
|
+
|(session, set_state)| {
|
|
107
|
+
let subs = [
|
|
108
|
+
session
|
|
109
|
+
.table_errored
|
|
110
|
+
.add_listener(set_state.callback(StatusIconStateAction::SetError)),
|
|
111
|
+
session
|
|
112
|
+
.stats_changed
|
|
113
|
+
.add_listener(set_state.callback(StatusIconStateAction::Load)),
|
|
114
|
+
session
|
|
115
|
+
.view_config_changed
|
|
116
|
+
.add_listener(set_state.callback(|_| StatusIconStateAction::Increment)),
|
|
117
|
+
session
|
|
118
|
+
.view_created
|
|
119
|
+
.add_listener(set_state.callback(|_| StatusIconStateAction::Decrement)),
|
|
120
|
+
];
|
|
121
|
+
|
|
122
|
+
move || drop(subs)
|
|
123
|
+
},
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
let onclick = use_async_callback(
|
|
127
|
+
(props.clone(), state.clone()),
|
|
128
|
+
async move |_: MouseEvent, (props, state)| {
|
|
129
|
+
if let StatusIconState::Errored(..) = &**state {
|
|
130
|
+
props.session.reconnect().await?;
|
|
131
|
+
let cfg = ViewConfigUpdate::default();
|
|
132
|
+
props.update_and_render(cfg)?.await?;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
Ok::<_, ApiError>(())
|
|
136
|
+
},
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
let class_name = match (&*state, props.session.is_reconnect()) {
|
|
140
|
+
(StatusIconState::Errored(..), true) => "errored",
|
|
141
|
+
(StatusIconState::Errored(..), false) => "errored disabled",
|
|
142
|
+
(StatusIconState::Normal, _) => "connected",
|
|
143
|
+
(StatusIconState::Updating(_), _) => "updating",
|
|
144
|
+
(StatusIconState::Loading, _) => "loading",
|
|
145
|
+
(StatusIconState::Unititialized, _) => "uninitialized",
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
html! {
|
|
149
|
+
<>
|
|
150
|
+
<div class="section">
|
|
151
|
+
<div id="status_reconnect" class={class_name} {onclick}>
|
|
152
|
+
<span id="status" class={class_name} />
|
|
153
|
+
<span id="status_updating" class={class_name} />
|
|
154
|
+
</div>
|
|
155
|
+
if let StatusIconState::Errored(err, stack, kind) = &*state {
|
|
156
|
+
<div class="error-dialog">
|
|
157
|
+
<div class="error-dialog-message">{ format!("{} {}", kind, err) }</div>
|
|
158
|
+
<div class="error-dialog-stack">{ stack }</div>
|
|
159
|
+
</div>
|
|
160
|
+
}
|
|
161
|
+
</div>
|
|
162
|
+
</>
|
|
163
|
+
}
|
|
164
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
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
|
+
use yew::*;
|
|
15
|
+
|
|
16
|
+
use super::form::color_selector::*;
|
|
17
|
+
use super::modal::{ModalLink, SetModalLink};
|
|
18
|
+
use super::style::LocalStyle;
|
|
19
|
+
use crate::components::form::select_field::SelectEnumField;
|
|
20
|
+
use crate::config::*;
|
|
21
|
+
use crate::utils::WeakScope;
|
|
22
|
+
use crate::*;
|
|
23
|
+
|
|
24
|
+
pub enum StringColumnStyleMsg {
|
|
25
|
+
Reset(StringColumnStyleConfig),
|
|
26
|
+
FormatChanged(Option<FormatMode>),
|
|
27
|
+
ColorModeChanged(Option<StringColorMode>),
|
|
28
|
+
ColorChanged(String),
|
|
29
|
+
ColorReset,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#[derive(Properties)]
|
|
33
|
+
pub struct StringColumnStyleProps {
|
|
34
|
+
pub config: Option<StringColumnStyleConfig>,
|
|
35
|
+
pub default_config: StringColumnStyleDefaultConfig,
|
|
36
|
+
|
|
37
|
+
#[prop_or_default]
|
|
38
|
+
pub on_change: Callback<ColumnConfigValueUpdate>,
|
|
39
|
+
|
|
40
|
+
#[prop_or_default]
|
|
41
|
+
weak_link: WeakScope<StringColumnStyle>,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
impl ModalLink<StringColumnStyle> for StringColumnStyleProps {
|
|
45
|
+
fn weak_link(&self) -> &'_ WeakScope<StringColumnStyle> {
|
|
46
|
+
&self.weak_link
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
impl PartialEq for StringColumnStyleProps {
|
|
51
|
+
fn eq(&self, _other: &Self) -> bool {
|
|
52
|
+
false
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/// A component for the style form control for [`String`] columns.
|
|
57
|
+
pub struct StringColumnStyle {
|
|
58
|
+
config: StringColumnStyleConfig,
|
|
59
|
+
default_config: StringColumnStyleDefaultConfig,
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
impl StringColumnStyle {
|
|
63
|
+
/// When this config has changed, we must signal the wrapper element.
|
|
64
|
+
fn dispatch_config(&self, ctx: &Context<Self>) {
|
|
65
|
+
let update = Some(self.config.clone()).filter(|x| x != &StringColumnStyleConfig::default());
|
|
66
|
+
ctx.props()
|
|
67
|
+
.on_change
|
|
68
|
+
.emit(ColumnConfigValueUpdate::DatagridStringStyle(update));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/// Generate a color selector component for a specific `StringColorMode`
|
|
72
|
+
/// variant.
|
|
73
|
+
fn color_select_row(&self, ctx: &Context<Self>, mode: &StringColorMode, title: &str) -> Html {
|
|
74
|
+
let on_color = ctx.link().callback(StringColumnStyleMsg::ColorChanged);
|
|
75
|
+
let color = self
|
|
76
|
+
.config
|
|
77
|
+
.color
|
|
78
|
+
.clone()
|
|
79
|
+
.unwrap_or_else(|| self.default_config.color.to_owned());
|
|
80
|
+
|
|
81
|
+
let color_props = props!(ColorProps {
|
|
82
|
+
title: title.to_owned(),
|
|
83
|
+
on_color,
|
|
84
|
+
is_modified: color != self.default_config.color,
|
|
85
|
+
color,
|
|
86
|
+
on_reset: ctx.link().callback(|_| StringColumnStyleMsg::ColorReset)
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
if &self.config.string_color_mode == mode {
|
|
90
|
+
html! { <div class="row"><ColorSelector ..color_props /></div> }
|
|
91
|
+
} else {
|
|
92
|
+
html! {}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
impl Component for StringColumnStyle {
|
|
98
|
+
type Message = StringColumnStyleMsg;
|
|
99
|
+
type Properties = StringColumnStyleProps;
|
|
100
|
+
|
|
101
|
+
fn create(ctx: &Context<Self>) -> Self {
|
|
102
|
+
ctx.set_modal_link();
|
|
103
|
+
Self {
|
|
104
|
+
config: ctx.props().config.clone().unwrap_or_default(),
|
|
105
|
+
default_config: ctx.props().default_config.clone(),
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Always re-render when config changes.
|
|
110
|
+
fn changed(&mut self, ctx: &Context<Self>, _old: &Self::Properties) -> bool {
|
|
111
|
+
let mut new_config = ctx.props().config.clone().unwrap_or_default();
|
|
112
|
+
if self.config != new_config {
|
|
113
|
+
std::mem::swap(&mut self.config, &mut new_config);
|
|
114
|
+
true
|
|
115
|
+
} else {
|
|
116
|
+
false
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool {
|
|
121
|
+
match msg {
|
|
122
|
+
StringColumnStyleMsg::Reset(config) => {
|
|
123
|
+
self.config = config;
|
|
124
|
+
true
|
|
125
|
+
},
|
|
126
|
+
StringColumnStyleMsg::FormatChanged(val) => {
|
|
127
|
+
self.config.format = val.unwrap_or_default();
|
|
128
|
+
self.dispatch_config(ctx);
|
|
129
|
+
true
|
|
130
|
+
},
|
|
131
|
+
StringColumnStyleMsg::ColorModeChanged(mode) => {
|
|
132
|
+
self.config.string_color_mode = mode.unwrap_or_default();
|
|
133
|
+
self.dispatch_config(ctx);
|
|
134
|
+
true
|
|
135
|
+
},
|
|
136
|
+
StringColumnStyleMsg::ColorChanged(color) => {
|
|
137
|
+
self.config.color = Some(color);
|
|
138
|
+
self.dispatch_config(ctx);
|
|
139
|
+
true
|
|
140
|
+
},
|
|
141
|
+
StringColumnStyleMsg::ColorReset => {
|
|
142
|
+
self.config.color = Some(self.default_config.color.clone());
|
|
143
|
+
self.dispatch_config(ctx);
|
|
144
|
+
true
|
|
145
|
+
},
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
fn view(&self, ctx: &Context<Self>) -> Html {
|
|
150
|
+
let format_mode_selected = self.config.format;
|
|
151
|
+
let format_mode_changed = ctx.link().callback(StringColumnStyleMsg::FormatChanged);
|
|
152
|
+
let selected_color_mode = self.config.string_color_mode;
|
|
153
|
+
let color_mode_changed = ctx.link().callback(StringColumnStyleMsg::ColorModeChanged);
|
|
154
|
+
let color_controls = match selected_color_mode {
|
|
155
|
+
StringColorMode::Foreground => {
|
|
156
|
+
self.color_select_row(ctx, &StringColorMode::Foreground, "foreground-label")
|
|
157
|
+
},
|
|
158
|
+
StringColorMode::Background => {
|
|
159
|
+
self.color_select_row(ctx, &StringColorMode::Background, "background-label")
|
|
160
|
+
},
|
|
161
|
+
StringColorMode::Series => {
|
|
162
|
+
self.color_select_row(ctx, &StringColorMode::Series, "series-label")
|
|
163
|
+
},
|
|
164
|
+
StringColorMode::None => html! {},
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
html! {
|
|
168
|
+
<>
|
|
169
|
+
<LocalStyle href={css!("column-style")} />
|
|
170
|
+
<div id="column-style-container" class="string-column-style-container">
|
|
171
|
+
<SelectEnumField<FormatMode>
|
|
172
|
+
label="format"
|
|
173
|
+
on_change={format_mode_changed}
|
|
174
|
+
current_value={format_mode_selected}
|
|
175
|
+
/>
|
|
176
|
+
<SelectEnumField<StringColorMode>
|
|
177
|
+
label="color"
|
|
178
|
+
on_change={color_mode_changed}
|
|
179
|
+
current_value={selected_color_mode}
|
|
180
|
+
/>
|
|
181
|
+
{ color_controls }
|
|
182
|
+
</div>
|
|
183
|
+
</>
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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_cache::*;
|
|
16
|
+
|
|
17
|
+
#[derive(Properties)]
|
|
18
|
+
pub struct LocalStyleProps {
|
|
19
|
+
pub href: (&'static str, &'static str),
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
impl PartialEq for LocalStyleProps {
|
|
23
|
+
fn eq(&self, _other: &Self) -> bool {
|
|
24
|
+
true
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
#[function_component(LocalStyle)]
|
|
29
|
+
pub fn local_style(props: &LocalStyleProps) -> Html {
|
|
30
|
+
if let Some(cache) = use_context::<StyleCache>() {
|
|
31
|
+
cache.add_style(props.href.0, props.href.1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
html! {}
|
|
35
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
//! A micro-framework for associating local CSS snippets with `yew::Component`s
|
|
14
|
+
//! in a Custom Element's `ShadowRoot`.
|
|
15
|
+
//!
|
|
16
|
+
//! Embedding a `<LocalStyle>` element will only create the underlying `<style>`
|
|
17
|
+
//! tag once (when `Component::view()` is called the first time), even if
|
|
18
|
+
//! multiple copies of the `Component` exist in the tree.
|
|
19
|
+
//!
|
|
20
|
+
//! # Example
|
|
21
|
+
//!
|
|
22
|
+
//! ```
|
|
23
|
+
//! html! {
|
|
24
|
+
//! <StyleProvider>
|
|
25
|
+
//! <LocalStyle href={ css!("my-style") } />
|
|
26
|
+
//! <h1>{ "I am styled!" }</h1>
|
|
27
|
+
//! </StyleProvider>
|
|
28
|
+
//! }
|
|
29
|
+
//! ```
|
|
30
|
+
|
|
31
|
+
mod local_style;
|
|
32
|
+
mod style_cache;
|
|
33
|
+
mod style_provider;
|
|
34
|
+
|
|
35
|
+
pub use local_style::LocalStyle;
|
|
36
|
+
pub use style_provider::StyleProvider;
|
|
37
|
+
|
|
38
|
+
#[macro_export]
|
|
39
|
+
macro_rules! css {
|
|
40
|
+
($name:expr) => {{
|
|
41
|
+
(
|
|
42
|
+
$name,
|
|
43
|
+
include_str!(concat!(env!("OUT_DIR"), "/css/", $name, ".css")),
|
|
44
|
+
)
|
|
45
|
+
}};
|
|
46
|
+
($path:expr, $name:expr) => {{
|
|
47
|
+
(
|
|
48
|
+
$name,
|
|
49
|
+
include_str!(concat!(env!("OUT_DIR"), "/", $path, "/", $name, ".css")),
|
|
50
|
+
)
|
|
51
|
+
}};
|
|
52
|
+
}
|