@holoviz/panel 1.10.0 → 1.11.0-b.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.
Files changed (56) hide show
  1. package/dist/bundled/bootstraptemplate/bootstrap.css +4 -0
  2. package/dist/bundled/deckglplot/@deck.gl/carto@^9.1.14/dist.min.js +8 -8
  3. package/dist/bundled/deckglplot/maplibre-gl/dist/maplibre-gl.js +2 -2
  4. package/dist/bundled/fastbasetemplate/fast.css +8 -1
  5. package/dist/bundled/filedropper/filepond@^4/dist/filepond.css +1 -1
  6. package/dist/bundled/filedropper/filepond@^4/dist/filepond.esm.min.js +2 -2
  7. package/dist/bundled/licenses/index.json +6 -6
  8. package/dist/bundled/reacttemplate/react.css +4 -0
  9. package/dist/bundled/theme/fast.css +0 -18
  10. package/dist/bundled/vanillatemplate/vanilla.css +4 -0
  11. package/dist/css/progress.css +24 -19
  12. package/dist/lib/models/comm_manager.d.ts +4 -0
  13. package/dist/lib/models/comm_manager.js +76 -18
  14. package/dist/lib/models/comm_manager.js.map +1 -1
  15. package/dist/lib/models/data.d.ts +1 -0
  16. package/dist/lib/models/data.js +47 -18
  17. package/dist/lib/models/data.js.map +1 -1
  18. package/dist/lib/models/html.d.ts +12 -2
  19. package/dist/lib/models/html.js +95 -20
  20. package/dist/lib/models/html.js.map +1 -1
  21. package/dist/lib/models/icon.js +2 -0
  22. package/dist/lib/models/icon.js.map +1 -1
  23. package/dist/lib/models/location.js +3 -0
  24. package/dist/lib/models/location.js.map +1 -1
  25. package/dist/lib/models/plotly.d.ts +15 -1
  26. package/dist/lib/models/plotly.js +99 -33
  27. package/dist/lib/models/plotly.js.map +1 -1
  28. package/dist/lib/models/react_component.js +65 -26
  29. package/dist/lib/models/react_component.js.map +1 -1
  30. package/dist/lib/models/reactive_esm.d.ts +13 -0
  31. package/dist/lib/models/reactive_esm.js +25 -0
  32. package/dist/lib/models/reactive_esm.js.map +1 -1
  33. package/dist/lib/models/reactive_html.js +32 -16
  34. package/dist/lib/models/reactive_html.js.map +1 -1
  35. package/dist/lib/models/resources.d.ts +4 -3
  36. package/dist/lib/models/resources.js +104 -24
  37. package/dist/lib/models/resources.js.map +1 -1
  38. package/dist/lib/models/tabs.d.ts +2 -0
  39. package/dist/lib/models/tabs.js +11 -0
  40. package/dist/lib/models/tabs.js.map +1 -1
  41. package/dist/lib/models/tabulator.d.ts +32 -4
  42. package/dist/lib/models/tabulator.js +279 -101
  43. package/dist/lib/models/tabulator.js.map +1 -1
  44. package/dist/lib/models/vega.d.ts +20 -3
  45. package/dist/lib/models/vega.js +123 -55
  46. package/dist/lib/models/vega.js.map +1 -1
  47. package/dist/lib/styles/progress.css.js +22 -16
  48. package/dist/panel.js +1004 -353
  49. package/dist/panel.js.map +1 -1
  50. package/dist/panel.json +1 -1
  51. package/dist/panel.min.js +24 -24
  52. package/package.json +1 -1
  53. package/dist/css/katex.css +0 -3
  54. package/dist/dts/styles/katex.css.d.ts +0 -4
  55. package/dist/lib/styles/katex.css.d.ts +0 -2
  56. package/dist/lib/styles/katex.css.js +0 -1
package/dist/panel.js CHANGED
@@ -66,7 +66,7 @@
66
66
  __esExport("Button", button_1.Button);
67
67
  var button_icon_1 = require("7e77f478cb") /* ./button_icon */;
68
68
  __esExport("ButtonIcon", button_icon_1.ButtonIcon);
69
- var icon_1 = require("bf77ad153d") /* ./icon */;
69
+ var icon_1 = require("ac804884fa") /* ./icon */;
70
70
  __esExport("ClickableIcon", icon_1.ClickableIcon);
71
71
  var card_1 = require("a668a42a0f") /* ./card */;
72
72
  __esExport("Card", card_1.Card);
@@ -76,13 +76,13 @@
76
76
  __esExport("ChatAreaInput", chatarea_input_1.ChatAreaInput);
77
77
  var column_1 = require("3967d78fb5") /* ./column */;
78
78
  __esExport("Column", column_1.Column);
79
- var comm_manager_1 = require("f8f420cdc3") /* ./comm_manager */;
79
+ var comm_manager_1 = require("5f6e6991cc") /* ./comm_manager */;
80
80
  __esExport("CommManager", comm_manager_1.CommManager);
81
81
  var customselect_1 = require("519009caed") /* ./customselect */;
82
82
  __esExport("CustomSelect", customselect_1.CustomSelect);
83
83
  var multiselect_1 = require("8653ba687c") /* ./multiselect */;
84
84
  __esExport("CustomMultiSelect", multiselect_1.CustomMultiSelect);
85
- var tabulator_1 = require("381057489b") /* ./tabulator */;
85
+ var tabulator_1 = require("ab964e46db") /* ./tabulator */;
86
86
  __esExport("DataTabulator", tabulator_1.DataTabulator);
87
87
  __esExport("TabulatorColumn", tabulator_1.TabulatorColumn);
88
88
  var datetime_picker_1 = require("7408873be7") /* ./datetime_picker */;
@@ -101,7 +101,7 @@
101
101
  __esExport("FileDownload", file_download_1.FileDownload);
102
102
  var file_dropper_1 = require("bff8eeed36") /* ./file_dropper */;
103
103
  __esExport("FileDropper", file_dropper_1.FileDropper);
104
- var html_1 = require("9012c2f5ae") /* ./html */;
104
+ var html_1 = require("e40e09e4dd") /* ./html */;
105
105
  __esExport("HTML", html_1.HTML);
106
106
  var ipywidget_1 = require("fd4c3f6bc4") /* ./ipywidget */;
107
107
  __esExport("IPyWidget", ipywidget_1.IPyWidget);
@@ -111,7 +111,7 @@
111
111
  __esExport("JSONEditor", jsoneditor_1.JSONEditor);
112
112
  var katex_1 = require("052b7b0298") /* ./katex */;
113
113
  __esExport("KaTeX", katex_1.KaTeX);
114
- var location_1 = require("2116677c2d") /* ./location */;
114
+ var location_1 = require("cc871e1a06") /* ./location */;
115
115
  __esExport("Location", location_1.Location);
116
116
  var mathjax_1 = require("07688254ed") /* ./mathjax */;
117
117
  __esExport("MathJax", mathjax_1.MathJax);
@@ -123,7 +123,7 @@
123
123
  __esExport("Perspective", perspective_1.Perspective);
124
124
  var player_1 = require("ed49986321") /* ./player */;
125
125
  __esExport("Player", player_1.Player);
126
- var plotly_1 = require("39230f6818") /* ./plotly */;
126
+ var plotly_1 = require("736be77caa") /* ./plotly */;
127
127
  __esExport("PlotlyPlot", plotly_1.PlotlyPlot);
128
128
  var progress_1 = require("443fb5cf42") /* ./progress */;
129
129
  __esExport("Progress", progress_1.Progress);
@@ -131,13 +131,13 @@
131
131
  __esExport("QuillInput", quill_1.QuillInput);
132
132
  var radio_button_group_1 = require("08a22fed1a") /* ./radio_button_group */;
133
133
  __esExport("RadioButtonGroup", radio_button_group_1.RadioButtonGroup);
134
- var react_component_1 = require("e74ecd40bb") /* ./react_component */;
134
+ var react_component_1 = require("da0e69965d") /* ./react_component */;
135
135
  __esExport("ReactComponent", react_component_1.ReactComponent);
136
- var reactive_html_1 = require("61cc258c24") /* ./reactive_html */;
136
+ var reactive_html_1 = require("44b7d77ba5") /* ./reactive_html */;
137
137
  __esExport("ReactiveHTML", reactive_html_1.ReactiveHTML);
138
- var reactive_esm_1 = require("f3226cbf82") /* ./reactive_esm */;
138
+ var reactive_esm_1 = require("8e484b67b0") /* ./reactive_esm */;
139
139
  __esExport("ReactiveESM", reactive_esm_1.ReactiveESM);
140
- var resources_1 = require("3ec7d872e2") /* ./resources */;
140
+ var resources_1 = require("133ce95cfa") /* ./resources */;
141
141
  __esExport("resources", resources_1.resources);
142
142
  var singleselect_1 = require("3766e0c917") /* ./singleselect */;
143
143
  __esExport("SingleSelect", singleselect_1.SingleSelect);
@@ -145,7 +145,7 @@
145
145
  __esExport("SpeechToText", speech_to_text_1.SpeechToText);
146
146
  var state_1 = require("188544eb0b") /* ./state */;
147
147
  __esExport("State", state_1.State);
148
- var tabs_1 = require("3cba64cc82") /* ./tabs */;
148
+ var tabs_1 = require("c5ac7daa0f") /* ./tabs */;
149
149
  __esExport("Tabs", tabs_1.Tabs);
150
150
  var terminal_1 = require("4fecff5c68") /* ./terminal */;
151
151
  __esExport("Terminal", terminal_1.Terminal);
@@ -163,7 +163,7 @@
163
163
  __esExport("TooltipIcon", tooltip_icon_1.TooltipIcon);
164
164
  var trend_1 = require("eb967020e9") /* ./trend */;
165
165
  __esExport("TrendIndicator", trend_1.TrendIndicator);
166
- var vega_1 = require("03e8d20a08") /* ./vega */;
166
+ var vega_1 = require("f71ac626f9") /* ./vega */;
167
167
  __esExport("VegaPlot", vega_1.VegaPlot);
168
168
  var video_1 = require("e8830cc759") /* ./video */;
169
169
  __esExport("Video", video_1.Video);
@@ -350,7 +350,7 @@
350
350
  const assert_1 = require("@bokehjs/core/util/assert");
351
351
  const widget_1 = require("@bokehjs/models/widgets/widget");
352
352
  const layout_dom_1 = require("@bokehjs/models/layouts/layout_dom");
353
- const resources_1 = require("3ec7d872e2") /* ./resources */;
353
+ const resources_1 = require("133ce95cfa") /* ./resources */;
354
354
  /**
355
355
  * Re-renders a view, including its layout.
356
356
  *
@@ -661,7 +661,7 @@
661
661
  }
662
662
  exports.HTMLBox = HTMLBox;
663
663
  },
664
- "3ec7d872e2": /* models/resources.js */ function _(require, module, exports, __esModule, __esExport) {
664
+ "133ce95cfa": /* models/resources.js */ function _(require, module, exports, __esModule, __esExport) {
665
665
  __esModule();
666
666
  exports.cdn_url = cdn_url;
667
667
  exports.resource_url = resource_url;
@@ -710,6 +710,43 @@
710
710
  url = resource_url(url);
711
711
  return /^[a-z][a-z0-9+.-]*:/i.test(url) ? url : url_key(url);
712
712
  }
713
+ const EXTENSION_PATH = "static/extensions/";
714
+ /**
715
+ * The part of a bundled server extension url
716
+ * (`static/extensions/<name>/bundled/<path>`) that identifies the file
717
+ * wherever it is served from. Other extension files, e.g. an `index.js`,
718
+ * are too generic to match on.
719
+ */
720
+ function extension_tail(url) {
721
+ const match = /static\/extensions\/[^/]+\/(bundled\/.+)$/.exec(url.split(/[?#]/)[0]);
722
+ return match == null ? null : `/${match[1]}`;
723
+ }
724
+ /**
725
+ * Whether a url is already on the page.
726
+ *
727
+ * A host that embeds Panel output itself (Shiny, through jupyter_bokeh)
728
+ * serves the extension files under its own routes, rewriting the urls the
729
+ * eager path rendered. Such a url is matched on its `/bundled/...` tail,
730
+ * which drops the extension name, so a page url ending in the same tail
731
+ * counts as the same file. Not every bundled file is versioned (jquery,
732
+ * theme css, font-awesome), so this is only safe because the urls a spec
733
+ * asks for carry their package version.
734
+ */
735
+ function on_page(urls, url) {
736
+ if (urls.has(url_key(url))) {
737
+ return true;
738
+ }
739
+ const tail = extension_tail(url);
740
+ if (tail == null) {
741
+ return false;
742
+ }
743
+ for (const existing of urls) {
744
+ if (existing.split(/[?#]/)[0].endsWith(tail)) {
745
+ return true;
746
+ }
747
+ }
748
+ return false;
749
+ }
713
750
  function existing_urls(selector, attr) {
714
751
  const urls = new Set();
715
752
  for (const el of document.querySelectorAll(selector)) {
@@ -721,12 +758,39 @@
721
758
  return urls;
722
759
  }
723
760
  const JUPYTER_ENDPOINT = "/panel-preview/";
761
+ /** Server extension paths and their CDN urls, from the specs seen so far. */
762
+ const extension_cdn_map = [];
763
+ function register_cdn_map(cdn_map) {
764
+ for (const [prefix, cdn] of cdn_map ?? []) {
765
+ if (!extension_cdn_map.some(([known]) => known === prefix)) {
766
+ extension_cdn_map.push([prefix, cdn]);
767
+ }
768
+ }
769
+ }
770
+ /**
771
+ * Maps a server extension url to its CDN equivalent, using the map the
772
+ * resource specs carry in `server` mode, for hosts that serve the page
773
+ * without Panel's extension routes.
774
+ */
775
+ function extension_cdn_url(url) {
776
+ const index = url.indexOf(EXTENSION_PATH);
777
+ if (index === -1) {
778
+ return null;
779
+ }
780
+ const path = url.slice(index);
781
+ for (const [prefix, cdn] of extension_cdn_map) {
782
+ if (path.startsWith(prefix)) {
783
+ return cdn + path.slice(prefix.length);
784
+ }
785
+ }
786
+ return null;
787
+ }
724
788
  /**
725
789
  * Maps a Jupyter extension endpoint url to its CDN equivalent, using the
726
790
  * map of endpoint paths to CDN urls the notebook bootstrap publishes
727
- * (Panel's dist, every extension with a CDN and each BokehJS file). Null
728
- * if the url is not served by the endpoint or has no CDN equivalent, e.g.
729
- * in server/served-app contexts, where the bootstrap never runs.
791
+ * (Panel's dist, every extension with a CDN and each BokehJS file). Any
792
+ * other server extension url goes through the map the specs carry. Null
793
+ * if the url has no CDN equivalent.
730
794
  */
731
795
  function cdn_url(url) {
732
796
  const global = globalThis;
@@ -736,7 +800,7 @@
736
800
  }
737
801
  const index = url.indexOf(JUPYTER_ENDPOINT);
738
802
  if (cdn_map == null || index === -1) {
739
- return null;
803
+ return extension_cdn_url(url);
740
804
  }
741
805
  const path = url.slice(index + JUPYTER_ENDPOINT.length);
742
806
  for (const [prefix, cdn] of cdn_map) {
@@ -744,7 +808,7 @@
744
808
  return cdn + path.slice(prefix.length);
745
809
  }
746
810
  }
747
- return null;
811
+ return extension_cdn_url(url);
748
812
  }
749
813
  /**
750
814
  * Loads endpoint urls from the CDN where the endpoint cannot serve them:
@@ -774,30 +838,39 @@
774
838
  function is_endpoint_url(url) {
775
839
  return url.includes(`${JUPYTER_ENDPOINT}static/`);
776
840
  }
777
- function inject(el) {
841
+ function inject(el, wrapped) {
778
842
  return new Promise((resolve, reject) => {
843
+ let retried = null;
779
844
  const attempt = (element) => {
780
845
  element.addEventListener("load", () => resolve(), { once: true });
781
846
  element.addEventListener("error", () => {
782
- const url = element.src || element.href;
847
+ const url = wrapped?.url ?? (element.src || element.href);
783
848
  const fallback = fallback_to_cdn(element, url);
784
849
  if (fallback != null) {
850
+ retried = [url, fallback];
785
851
  element.remove();
786
- if (element instanceof HTMLLinkElement) {
787
- element.href = fallback;
852
+ // A script element only ever runs once, so changing its src and
853
+ // reinserting it never fetches again.
854
+ const retry = document.createElement(element.tagName.toLowerCase());
855
+ for (const { name, value } of Array.from(element.attributes)) {
856
+ retry.setAttribute(name, value);
857
+ }
858
+ if (retry instanceof HTMLLinkElement) {
859
+ retry.href = fallback;
788
860
  }
789
861
  else {
790
- element.src = fallback;
862
+ retry.async = element.async;
863
+ retry.src = wrapped != null ? wrapped.src(fallback) : fallback;
791
864
  }
792
- attempt(element);
793
- document.head.appendChild(element);
865
+ attempt(retry);
866
+ document.head.appendChild(retry);
794
867
  return;
795
868
  }
796
869
  if (is_endpoint_url(url)) {
797
870
  const global = globalThis;
798
871
  global.__panel_jupyter_extension_error__?.();
799
872
  }
800
- reject(new Error(`Failed to load ${url}`));
873
+ reject(new Error(retried == null ? `Failed to load ${url}` : `Failed to load ${retried[0]} or its CDN fallback ${retried[1]}`));
801
874
  }, { once: true });
802
875
  };
803
876
  attempt(el);
@@ -900,10 +973,19 @@
900
973
  el.src = resource_url(url);
901
974
  return inject(el);
902
975
  }
976
+ const blobs = [];
977
+ const src = (target) => {
978
+ const code = `import * as ns from ${JSON.stringify(target)}\nglobalThis[${JSON.stringify(name)}] = ns.default ?? ns\n`;
979
+ const blob = URL.createObjectURL(new Blob([code], { type: "text/javascript" }));
980
+ blobs.push(blob);
981
+ return blob;
982
+ };
903
983
  url = module_url(url);
904
- const code = `import * as ns from ${JSON.stringify(url)}\nglobalThis[${JSON.stringify(name)}] = ns.default ?? ns\n`;
905
- el.src = URL.createObjectURL(new Blob([code], { type: "text/javascript" }));
906
- return inject(el).finally(() => URL.revokeObjectURL(el.src));
984
+ el.src = src(url);
985
+ return inject(el, { url, src: (fallback) => {
986
+ hide_amd_module(fallback);
987
+ return src(fallback);
988
+ } }).finally(() => blobs.forEach((blob) => URL.revokeObjectURL(blob)));
907
989
  }
908
990
  function inject_link(url) {
909
991
  const el = document.createElement("link");
@@ -1045,10 +1127,7 @@
1045
1127
  if (urls.length === 0) {
1046
1128
  return true;
1047
1129
  }
1048
- return urls.every((url) => {
1049
- const key = url_key(url);
1050
- return this.urls.has(key) || (scripts != null && scripts.has(key));
1051
- });
1130
+ return urls.every((url) => this.urls.has(url_key(url)) || (scripts != null && on_page(scripts, url)));
1052
1131
  }
1053
1132
  /**
1054
1133
  * Loads everything a resource spec declares, skipping what is present.
@@ -1057,6 +1136,7 @@
1057
1136
  if (spec == null) {
1058
1137
  return;
1059
1138
  }
1139
+ register_cdn_map(spec.cdn);
1060
1140
  const scripts = existing_urls("script[src]", "src");
1061
1141
  const waits = [];
1062
1142
  const js = [];
@@ -1124,7 +1204,7 @@
1124
1204
  const key = url_key(url);
1125
1205
  let promise = this.urls.get(key);
1126
1206
  if (promise == null) {
1127
- promise = links.has(key) ? Promise.resolve() : inject_link(url);
1207
+ promise = on_page(links, url) ? Promise.resolve() : inject_link(url);
1128
1208
  this.urls.set(key, promise);
1129
1209
  }
1130
1210
  return promise.catch((error) => {
@@ -1160,7 +1240,7 @@
1160
1240
  }
1161
1241
  const key = url_key(url);
1162
1242
  const scripts = existing_urls("script[src]", "src");
1163
- const promise = scripts.has(key) ? Promise.resolve() : inject_script(url);
1243
+ const promise = on_page(scripts, url) ? Promise.resolve() : inject_script(url);
1164
1244
  this.urls.set(key, promise);
1165
1245
  this._shim = promise.catch((e) => {
1166
1246
  this._shim = null;
@@ -1219,7 +1299,7 @@
1219
1299
  const key = url_key(url);
1220
1300
  let promise = this.urls.get(key);
1221
1301
  if (promise == null) {
1222
- promise = scripts.has(key) ? Promise.resolve() : inject_script(url);
1302
+ promise = on_page(scripts, url) ? Promise.resolve() : inject_script(url);
1223
1303
  this.urls.set(key, promise);
1224
1304
  promise.catch(() => this.urls.delete(key));
1225
1305
  }
@@ -1233,7 +1313,7 @@
1233
1313
  const key = url_key(url);
1234
1314
  let promise = this.urls.get(key);
1235
1315
  if (promise == null) {
1236
- promise = scripts.has(key) ? Promise.resolve() : inject_module(url, name);
1316
+ promise = on_page(scripts, url) ? Promise.resolve() : inject_module(url, name);
1237
1317
  this.urls.set(key, promise);
1238
1318
  promise.catch(() => this.urls.delete(key));
1239
1319
  }
@@ -1586,7 +1666,7 @@
1586
1666
  },
1587
1667
  "f4bc4e23b4": /* models/anywidget_component.js */ function _(require, module, exports, __esModule, __esExport) {
1588
1668
  __esModule();
1589
- const reactive_esm_1 = require("f3226cbf82") /* ./reactive_esm */;
1669
+ const reactive_esm_1 = require("8e484b67b0") /* ./reactive_esm */;
1590
1670
  class AnyWidgetModelAdapter {
1591
1671
  constructor(model) {
1592
1672
  this.view = null;
@@ -1746,7 +1826,7 @@
1746
1826
  }
1747
1827
  exports.AnyWidgetComponent = AnyWidgetComponent;
1748
1828
  },
1749
- "f3226cbf82": /* models/reactive_esm.js */ function _(require, module, exports, __esModule, __esExport) {
1829
+ "8e484b67b0": /* models/reactive_esm.js */ function _(require, module, exports, __esModule, __esExport) {
1750
1830
  __esModule();
1751
1831
  exports.model_getter = model_getter;
1752
1832
  exports.model_setter = model_setter;
@@ -1772,9 +1852,9 @@
1772
1852
  const types_1 = require("@bokehjs/core/util/types");
1773
1853
  const ui_element_1 = require("@bokehjs/models/ui/ui_element");
1774
1854
  const event_to_object_1 = require("e5a0036205") /* ./event-to-object */;
1775
- const html_1 = require("9012c2f5ae") /* ./html */;
1855
+ const html_1 = require("e40e09e4dd") /* ./html */;
1776
1856
  const layout_1 = require("00beb93e38") /* ./layout */;
1777
- const resources_1 = require("3ec7d872e2") /* ./resources */;
1857
+ const resources_1 = require("133ce95cfa") /* ./resources */;
1778
1858
  const util_1 = require("aa07eb54cc") /* ./util */;
1779
1859
  const esm_css_1 = tslib_1.__importDefault(require("727a14f76b") /* styles/models/esm.css */);
1780
1860
  // Deliberately module local rather than on the shared resource registry:
@@ -2093,6 +2173,31 @@
2093
2173
  }
2094
2174
  return child_view.el.isConnected;
2095
2175
  }
2176
+ /**
2177
+ * A child view is built, and so listed in `child_views`, as soon as its
2178
+ * model is added, but it is only rendered once the component mounts it,
2179
+ * which for a React component is a later commit. Bokeh assumes a child it
2180
+ * measures has run `update_layout` (a figure reads the panels of the
2181
+ * layout built there), so a layout pass in between, e.g. from a resize
2182
+ * or from another child mounting, would throw on the unmounted child and
2183
+ * abort the pass for every other view. Layout passes therefore only visit
2184
+ * mounted children; `update_layout` still visits all of them.
2185
+ */
2186
+ get layoutable_views() {
2187
+ return super.layoutable_views.filter((view) => this._is_mountable(view) && view._was_built);
2188
+ }
2189
+ update_layout() {
2190
+ this.update_style();
2191
+ for (const child_view of this.child_views) {
2192
+ child_view.parent_style.clear();
2193
+ }
2194
+ for (const child_view of this.child_views) {
2195
+ if (child_view instanceof layout_dom_1.LayoutDOMView) {
2196
+ child_view.update_layout();
2197
+ }
2198
+ }
2199
+ this._update_layout();
2200
+ }
2096
2201
  notify_mount(child, id, remove = false) {
2097
2202
  if (!this._mounted.has(child)) {
2098
2203
  this._mounted.set(child, new Set());
@@ -19080,7 +19185,7 @@ ${namesToRegister
19080
19185
  });
19081
19186
  });
19082
19187
  },
19083
- "9012c2f5ae": /* models/html.js */ function _(require, module, exports, __esModule, __esExport) {
19188
+ "e40e09e4dd": /* models/html.js */ function _(require, module, exports, __esModule, __esExport) {
19084
19189
  __esModule();
19085
19190
  exports.escape_html = escape_html;
19086
19191
  exports.unescape_html = unescape_html;
@@ -19103,9 +19208,54 @@ ${namesToRegister
19103
19208
  const signaling_1 = require("@bokehjs/core/signaling");
19104
19209
  const object_1 = require("@bokehjs/core/util/object");
19105
19210
  const markup_1 = require("@bokehjs/models/widgets/markup");
19211
+ const version_1 = require("@bokehjs/version");
19106
19212
  const layout_1 = require("00beb93e38") /* ./layout */;
19107
19213
  const event_to_object_1 = require("e5a0036205") /* ./event-to-object */;
19214
+ const util_1 = require("aa07eb54cc") /* ./util */;
19108
19215
  const html_css_1 = tslib_1.__importDefault(require("9b8139e439") /* styles/models/html.css */);
19216
+ // Pairs of the delimiters MathJax's TeX finder processes by default
19217
+ const TEX_DELIMITERS = /\$\$[\s\S]*?\$\$|\\\[[\s\S]*?\\\]|\\\([\s\S]*?\\\)/;
19218
+ /**
19219
+ * The url of the bokeh-mathjax bundle matching the BokehJS the page loaded,
19220
+ * whether served by the Bokeh server or the CDN, falling back to the CDN
19221
+ * when BokehJS was inlined.
19222
+ */
19223
+ function mathjax_bundle_url() {
19224
+ for (const script of document.scripts) {
19225
+ const match = /^(.*\/)bokeh(-\d[\w.-]*?)?(\.min)?\.js(?:\?.*)?$/.exec(script.src);
19226
+ if (match != null) {
19227
+ const [, base, version = "", min = ""] = match;
19228
+ return `${base}bokeh-mathjax${version}${min}.js`;
19229
+ }
19230
+ }
19231
+ const channel = /dev|rc/.test(version_1.version) ? "dev" : "release";
19232
+ return `https://cdn.bokeh.org/bokeh/${channel}/bokeh-mathjax-${version_1.version}.min.js`;
19233
+ }
19234
+ let mathjax_loading = null;
19235
+ /**
19236
+ * Loads the bokeh-mathjax bundle for a page that was served without it,
19237
+ * because none of its text contained math when it was rendered, and
19238
+ * points the provider BokehJS widgets share at it.
19239
+ */
19240
+ function load_mathjax(provider) {
19241
+ if (provider.MathJax != null) {
19242
+ return Promise.resolve(true);
19243
+ }
19244
+ if (mathjax_loading == null) {
19245
+ mathjax_loading = (async () => {
19246
+ try {
19247
+ await (0, util_1.loadScript)("text/javascript", mathjax_bundle_url());
19248
+ }
19249
+ catch {
19250
+ return false;
19251
+ }
19252
+ provider.status = "not_started";
19253
+ await provider.fetch();
19254
+ return provider.MathJax != null;
19255
+ })();
19256
+ }
19257
+ return mathjax_loading;
19258
+ }
19109
19259
  const COPY_ICON = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-clipboard"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2" /><path d="M9 3m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v0a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z"/></svg>`;
19110
19260
  const CHECK_ICON = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-check"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M5 12l5 5l10 -10"/></svg>`;
19111
19261
  function searchAllDOMs(node, selector) {
@@ -19310,7 +19460,14 @@ ${namesToRegister
19310
19460
  }
19311
19461
  }
19312
19462
  exports.DOMEvent = DOMEvent;
19463
+ // Only the entities emitted by Python's html.escape, which is all a
19464
+ // text containing no markup needs decoding for.
19465
+ const ESCAPE_ENTITIES_ONLY = /^(?:[^&<\r\0]|&(?:amp|lt|gt|quot|#x27);)*$/;
19313
19466
  function html_decode(input) {
19467
+ if (ESCAPE_ENTITIES_ONLY.test(input)) {
19468
+ // Matches the parser, which drops whitespace before the first character
19469
+ return unescape_html(input).replace(/^[\t\n\f\r ]+/, "");
19470
+ }
19314
19471
  const doc = new DOMParser().parseFromString(input, "text/html");
19315
19472
  return doc.documentElement.textContent;
19316
19473
  }
@@ -19337,6 +19494,8 @@ ${namesToRegister
19337
19494
  // Lowest offset of the text modified since the last DOM update
19338
19495
  _dirty = null;
19339
19496
  _frame = null;
19497
+ // Whether this view waits for the lazily loaded MathJax bundle
19498
+ _mathjax_pending = false;
19340
19499
  _event_listeners = new Map();
19341
19500
  connect_signals() {
19342
19501
  super.connect_signals();
@@ -19348,7 +19507,9 @@ ${namesToRegister
19348
19507
  this.set_html(html);
19349
19508
  });
19350
19509
  this.on_change(visible, () => {
19351
- if (this.model.visible) {
19510
+ // Parents may build child views without rendering them, e.g. collapsed
19511
+ // containers; render() then sets the visibility.
19512
+ if (this.model.visible && this.container != null) {
19352
19513
  this.container.style.visibility = "visible";
19353
19514
  }
19354
19515
  });
@@ -19382,17 +19543,32 @@ ${namesToRegister
19382
19543
  return;
19383
19544
  }
19384
19545
  const html = this.model.stream_text;
19385
- if (!this.model.disable_math && this.contains_tex(html)) {
19386
- this.set_html(this.process_tex());
19387
- }
19388
- else {
19389
- this._update_blocks(html, dirty);
19546
+ this._ensure_mathjax(html);
19547
+ this._update_blocks(html, dirty);
19548
+ }
19549
+ /**
19550
+ * Fetches MathJax when the text contains math but the page was served
19551
+ * without the bundle, typesetting the text once it is available.
19552
+ */
19553
+ _ensure_mathjax(text) {
19554
+ if (this._mathjax_pending || this.model.disable_math ||
19555
+ this.provider.MathJax != null || !TEX_DELIMITERS.test(text)) {
19556
+ return;
19390
19557
  }
19558
+ this._mathjax_pending = true;
19559
+ void load_mathjax(this.provider).then((loaded) => {
19560
+ if (loaded) {
19561
+ this._dirty = null;
19562
+ this.set_html(this.process_tex());
19563
+ }
19564
+ this._mathjax_pending = !loaded;
19565
+ });
19391
19566
  }
19392
19567
  /**
19393
19568
  * Re-renders only the top-level blocks at or after the first
19394
19569
  * modified offset, keeping the DOM (and any text selection) of the
19395
- * preceding blocks intact.
19570
+ * preceding blocks intact. Math is typeset per block, so only the
19571
+ * re-rendered blocks are searched and typeset again.
19396
19572
  */
19397
19573
  _update_blocks(html, dirty) {
19398
19574
  let blocks = this._blocks;
@@ -19417,7 +19593,7 @@ ${namesToRegister
19417
19593
  const parser = document.createElement("div");
19418
19594
  const added = [];
19419
19595
  for (const [start, end] of split_blocks(html, from)) {
19420
- parser.innerHTML = html.slice(start, end);
19596
+ parser.innerHTML = this.typeset(html.slice(start, end));
19421
19597
  const nodes = [...parser.childNodes];
19422
19598
  fragment.append(...nodes);
19423
19599
  added.push(...nodes);
@@ -19493,22 +19669,32 @@ ${namesToRegister
19493
19669
  this.set_html(html);
19494
19670
  }
19495
19671
  style_redraw() {
19496
- if (this.model.visible) {
19672
+ if (this.model.visible && this.container != null) {
19497
19673
  this.container.style.visibility = "visible";
19498
19674
  }
19499
19675
  }
19500
19676
  process_tex() {
19501
- const decoded = html_decode(this.model.text);
19502
- const text = decoded ?? this.model.text;
19503
- if (this.model.disable_math || !this.contains_tex(text)) {
19677
+ const text = html_decode(this.model.text) ?? this.model.text;
19678
+ this._ensure_mathjax(text);
19679
+ return this.typeset(text);
19680
+ }
19681
+ /**
19682
+ * Replaces the TeX found in the text with MathJax SVG output.
19683
+ */
19684
+ typeset(text) {
19685
+ const { MathJax } = this.provider;
19686
+ if (this.model.disable_math || !MathJax) {
19687
+ return text;
19688
+ }
19689
+ const tex_parts = MathJax.find_tex(text);
19690
+ if (tex_parts.length === 0) {
19504
19691
  return text;
19505
19692
  }
19506
- const tex_parts = this.provider.MathJax.find_tex(text);
19507
19693
  const processed_text = [];
19508
19694
  let last_index = 0;
19509
19695
  for (const part of tex_parts) {
19510
19696
  processed_text.push(text.slice(last_index, part.start.n));
19511
- processed_text.push(this.provider.MathJax.tex2svg(part.math, { display: part.display }).outerHTML);
19697
+ processed_text.push(MathJax.tex2svg(part.math, { display: part.display }).outerHTML);
19512
19698
  last_index = part.end.n;
19513
19699
  }
19514
19700
  if (last_index < text.length) {
@@ -19516,12 +19702,6 @@ ${namesToRegister
19516
19702
  }
19517
19703
  return processed_text.join("");
19518
19704
  }
19519
- contains_tex(html) {
19520
- if (!this.provider.MathJax) {
19521
- return false;
19522
- }
19523
- return this.provider.MathJax.find_tex(html).length > 0;
19524
- }
19525
19705
  _remove_event_listeners() {
19526
19706
  for (const [node, callbacks] of this._event_listeners) {
19527
19707
  const el = document.getElementById(node);
@@ -19887,7 +20067,7 @@ ${namesToRegister
19887
20067
  },
19888
20068
  "7e77f478cb": /* models/button_icon.js */ function _(require, module, exports, __esModule, __esExport) {
19889
20069
  __esModule();
19890
- const icon_1 = require("bf77ad153d") /* ./icon */;
20070
+ const icon_1 = require("ac804884fa") /* ./icon */;
19891
20071
  class ButtonIconView extends icon_1.ClickableIconView {
19892
20072
  _click_listener;
19893
20073
  *controls() { }
@@ -19925,7 +20105,7 @@ ${namesToRegister
19925
20105
  }
19926
20106
  exports.ButtonIcon = ButtonIcon;
19927
20107
  },
19928
- "bf77ad153d": /* models/icon.js */ function _(require, module, exports, __esModule, __esExport) {
20108
+ "ac804884fa": /* models/icon.js */ function _(require, module, exports, __esModule, __esExport) {
19929
20109
  __esModule();
19930
20110
  const tooltip_1 = require("@bokehjs/models/ui/tooltip");
19931
20111
  const tabler_icon_1 = require("@bokehjs/models/ui/icons/tabler_icon");
@@ -20049,6 +20229,8 @@ ${namesToRegister
20049
20229
  this.icon_view.remove();
20050
20230
  this.icon_view = icon_view;
20051
20231
  this.was_svg_icon = is_svg_icon;
20232
+ // The size may have changed while the new icon view was built
20233
+ this.update_size();
20052
20234
  this.update_cursor();
20053
20235
  // We need to re-append the new icon view to the DOM
20054
20236
  this.row_div.insertBefore(this.icon_view.el, this.label_el);
@@ -20855,7 +21037,7 @@ ${namesToRegister
20855
21037
  }
20856
21038
  exports.TextAreaInput = TextAreaInput;
20857
21039
  },
20858
- "f8f420cdc3": /* models/comm_manager.js */ function _(require, module, exports, __esModule, __esExport) {
21040
+ "5f6e6991cc": /* models/comm_manager.js */ function _(require, module, exports, __esModule, __esExport) {
20859
21041
  __esModule();
20860
21042
  const document_1 = require("@bokehjs/document");
20861
21043
  const view_1 = require("@bokehjs/core/view");
@@ -20895,9 +21077,14 @@ ${namesToRegister
20895
21077
  else {
20896
21078
  this.ns = window.PyViz;
20897
21079
  this.ns.comm_manager.register_target(this.plot_id, this.comm_id, (msg) => {
20898
- for (const view of this.ns.shared_views.get(this.plot_id)) {
21080
+ for (const view of this.ns.shared_views.get(this.plot_id) ?? []) {
20899
21081
  if (view !== this) {
20900
- view.msg_handler(msg);
21082
+ try {
21083
+ view.msg_handler(msg);
21084
+ }
21085
+ catch (e) {
21086
+ console.error(e);
21087
+ }
20901
21088
  }
20902
21089
  }
20903
21090
  try {
@@ -20907,17 +21094,52 @@ ${namesToRegister
20907
21094
  console.error(e);
20908
21095
  }
20909
21096
  });
20910
- this._client_comm = this.ns.comm_manager.get_client_comm(this.plot_id, this.client_comm_id, (msg) => this.on_ack(msg));
21097
+ this._client_comm = this.ns.comm_manager.get_client_comm(this.plot_id, this.client_comm_id, (msg) => {
21098
+ // Views of the same plot share one client comm and only the view
21099
+ // that opened it receives the acknowledgements
21100
+ for (const view of this.ns.shared_views.get(this.plot_id) ?? []) {
21101
+ if (view !== this) {
21102
+ try {
21103
+ view._unblock();
21104
+ }
21105
+ catch (e) {
21106
+ console.error(e);
21107
+ }
21108
+ }
21109
+ }
21110
+ this.on_ack(msg);
21111
+ });
20911
21112
  this._reconnect = !this._client_comm?.active || false;
20912
- if (this.ns.shared_views == null) {
20913
- this.ns.shared_views = new Map();
20914
- }
20915
- if (this.ns.shared_views.has(this.plot_id)) {
20916
- this.ns.shared_views.get(this.plot_id).push(this);
20917
- }
20918
- else {
20919
- this.ns.shared_views.set(this.plot_id, [this]);
20920
- }
21113
+ this._register_view();
21114
+ }
21115
+ }
21116
+ _register_view() {
21117
+ if (this.ns == null) {
21118
+ return;
21119
+ }
21120
+ if (this.ns.shared_views == null) {
21121
+ this.ns.shared_views = new Map();
21122
+ }
21123
+ const views = this.ns.shared_views.get(this.plot_id);
21124
+ if (views == null) {
21125
+ this.ns.shared_views.set(this.plot_id, [this]);
21126
+ }
21127
+ else if (!views.includes(this)) {
21128
+ views.push(this);
21129
+ }
21130
+ }
21131
+ _unregister_view() {
21132
+ this.document?.remove_on_change(this._document_listener);
21133
+ const views = this.ns?.shared_views?.get(this.plot_id);
21134
+ if (views == null) {
21135
+ return;
21136
+ }
21137
+ const remaining = views.filter((view) => view !== this);
21138
+ if (remaining.length) {
21139
+ this.ns.shared_views.set(this.plot_id, remaining);
21140
+ }
21141
+ else {
21142
+ this.ns.shared_views.delete(this.plot_id);
20921
21143
  }
20922
21144
  }
20923
21145
  _document_listener = (event) => this._document_changed(event);
@@ -20926,8 +21148,20 @@ ${namesToRegister
20926
21148
  if (this.document != null) {
20927
21149
  this.document.on_change(this._document_listener);
20928
21150
  }
21151
+ this._register_view();
21152
+ }
21153
+ // Notebook outputs are cleared rather than destroyed, so a disposed view
21154
+ // is only ever detached from its document
21155
+ _doc_detached() {
21156
+ this._unregister_view();
21157
+ super._doc_detached();
20929
21158
  }
20930
21159
  _document_changed(event) {
21160
+ // Changes applied from a Python patch are not synced; echoing them back
21161
+ // would also resend models Python already knows as new models
21162
+ if (!event.sync) {
21163
+ return;
21164
+ }
20931
21165
  // Filter out changes to attributes that aren't server-visible
20932
21166
  if (event instanceof document_1.ModelChangedEvent && !event.model.properties[event.attr].syncable) {
20933
21167
  return;
@@ -20976,13 +21210,16 @@ ${namesToRegister
20976
21210
  if ((this.document == null) || (this._client_comm == null)) {
20977
21211
  return;
20978
21212
  }
21213
+ if (this._event_buffer.length === 0) {
21214
+ return;
21215
+ }
20979
21216
  const patch = this.document.create_json_patch(this._event_buffer);
20980
21217
  this._event_buffer = [];
20981
21218
  const message = { ...message_1.Message.create("PATCH-DOC", {}, patch) };
20982
21219
  const buffers = [];
20983
21220
  this._extract_buffers(message.content, buffers);
20984
21221
  this._client_comm.send(message, {}, buffers);
20985
- for (const view of this.ns.shared_views.get(this.plot_id)) {
21222
+ for (const view of this.ns.shared_views.get(this.plot_id) ?? []) {
20986
21223
  if (view !== this && view.document != null) {
20987
21224
  view.document.apply_json_patch(patch, [], this.id);
20988
21225
  }
@@ -20990,12 +21227,9 @@ ${namesToRegister
20990
21227
  }
20991
21228
  disconnect_signals() {
20992
21229
  super.disconnect_signals();
20993
- this.ns.shared_views.shared_views.delete(this.plot_id);
21230
+ this._unregister_view();
20994
21231
  }
20995
- on_ack(msg) {
20996
- // Receives acknowledgement from Python, processing event
20997
- // and unblocking Comm if event queue empty
20998
- const metadata = msg.metadata;
21232
+ _unblock() {
20999
21233
  if (this._event_buffer.length > 0) {
21000
21234
  this._blocked = true;
21001
21235
  this._timeout = Date.now() + this.timeout;
@@ -21004,6 +21238,12 @@ ${namesToRegister
21004
21238
  else {
21005
21239
  this._blocked = false;
21006
21240
  }
21241
+ }
21242
+ on_ack(msg) {
21243
+ // Receives acknowledgement from Python, processing event
21244
+ // and unblocking Comm if event queue empty
21245
+ const metadata = msg.metadata;
21246
+ this._unblock();
21007
21247
  if ((metadata.msg_type == "Ready") && metadata.content) {
21008
21248
  // eslint-disable-next-line no-console
21009
21249
  console.log("Python callback returned following output:", metadata.content);
@@ -21157,7 +21397,7 @@ ${namesToRegister
21157
21397
  }
21158
21398
  exports.CustomMultiSelect = CustomMultiSelect;
21159
21399
  },
21160
- "381057489b": /* models/tabulator.js */ function _(require, module, exports, __esModule, __esExport) {
21400
+ "ab964e46db": /* models/tabulator.js */ function _(require, module, exports, __esModule, __esExport) {
21161
21401
  __esModule();
21162
21402
  const tslib_1 = require("tslib");
21163
21403
  const dom_1 = require("@bokehjs/core/dom");
@@ -21169,10 +21409,11 @@ ${namesToRegister
21169
21409
  const kinds_1 = require("@bokehjs/core/kinds");
21170
21410
  const model_1 = require("@bokehjs/model");
21171
21411
  const column_data_source_1 = require("@bokehjs/models/sources/column_data_source");
21412
+ const events_1 = require("@bokehjs/document/events");
21172
21413
  const debounce_1 = require("99a25e6992") /* debounce */;
21173
21414
  const cell_formatters_1 = require("254387d0dc") /* ./cell_formatters */;
21174
- const comm_manager_1 = require("f8f420cdc3") /* ./comm_manager */;
21175
- const data_1 = require("be689f0377") /* ./data */;
21415
+ const comm_manager_1 = require("5f6e6991cc") /* ./comm_manager */;
21416
+ const data_1 = require("ce212d2be6") /* ./data */;
21176
21417
  const layout_1 = require("00beb93e38") /* ./layout */;
21177
21418
  const util_1 = require("aa07eb54cc") /* ./util */;
21178
21419
  const tabulator_css_1 = tslib_1.__importDefault(require("b0fdc4e99b") /* styles/models/tabulator.css */);
@@ -21289,7 +21530,7 @@ ${namesToRegister
21289
21530
  }
21290
21531
  }
21291
21532
  }
21292
- else {
21533
+ else if (agg) {
21293
21534
  summary[column.field] = val;
21294
21535
  }
21295
21536
  }
@@ -21336,7 +21577,7 @@ ${namesToRegister
21336
21577
  }
21337
21578
  }
21338
21579
  else {
21339
- aggs.push("sum");
21580
+ aggs.push("");
21340
21581
  }
21341
21582
  }
21342
21583
  summarize(grouped, columns, aggs);
@@ -21547,6 +21788,30 @@ ${namesToRegister
21547
21788
  }
21548
21789
  return { ...group, columns: group_columns };
21549
21790
  }
21791
+ const set_cache = new WeakMap();
21792
+ /** Tabulator queries membership once per row, so index arrays are looked up as sets. */
21793
+ function as_set(indices) {
21794
+ let indices_set = set_cache.get(indices);
21795
+ if (indices_set === undefined) {
21796
+ indices_set = new Set(indices);
21797
+ set_cache.set(indices, indices_set);
21798
+ }
21799
+ return indices_set;
21800
+ }
21801
+ /** Dicts with numeric keys deserialize as Maps, empty ones as plain objects. */
21802
+ function lookup(mapping, key) {
21803
+ if (mapping == null) {
21804
+ return null;
21805
+ }
21806
+ return mapping instanceof Map ? (mapping.get(key) ?? null) : (mapping[key] ?? null);
21807
+ }
21808
+ function stream_length(data) {
21809
+ const columns = data instanceof Map ? [...data.values()] : Object.values(data);
21810
+ for (const column of columns) {
21811
+ return column.shape != null ? column.shape[0] : column.length;
21812
+ }
21813
+ return null;
21814
+ }
21550
21815
  /** Ignore Tabulator redraw after `after_resize` when `this.el` client size changes by at most this many pixels per axis. */
21551
21816
  const EL_CLIENT_RESIZE_EPSILON_PX = 3;
21552
21817
  /**
@@ -21555,6 +21820,7 @@ ${namesToRegister
21555
21820
  * ready chain pending forever, which would otherwise block every later redraw.
21556
21821
  */
21557
21822
  const ROOT_READY_TIMEOUT_MS = 250;
21823
+ const RESIZE_BLOCKED_FRAMES = 10;
21558
21824
  class DataTabulatorView extends layout_1.HTMLBoxView {
21559
21825
  tabulator;
21560
21826
  columns = new Map();
@@ -21568,13 +21834,18 @@ ${namesToRegister
21568
21834
  _selection_updating = false;
21569
21835
  _selection_pending = true;
21570
21836
  _last_selected_row = null;
21571
- _initializing;
21837
+ _initializing = true;
21572
21838
  _lastVerticalScrollbarTopPosition = 0;
21573
21839
  _lastHorizontalScrollbarLeftPosition = 0;
21574
- _applied_styles = false;
21840
+ /** Bumped when `cell_styles` changes; cells styled with an older version are restyled when visible. */
21841
+ _styles_version = 0;
21842
+ _styled_cells = new WeakMap();
21575
21843
  _building = false;
21576
21844
  _pending_data = false;
21845
+ /** A data update in flight; its `renderComplete` must not run `postUpdate` a second time. */
21846
+ _updating_data = false;
21577
21847
  _redrawing = false;
21848
+ _resized_columns = new Map();
21578
21849
  /** Coalesced resize redraw; waits for `this.root.ready` (Bokeh view async chain) before redrawing. */
21579
21850
  _resize_pending = false;
21580
21851
  _resize_flush = null;
@@ -21610,19 +21881,13 @@ ${namesToRegister
21610
21881
  if (this.tabulator == null) {
21611
21882
  return;
21612
21883
  }
21613
- // The first cell is the cell of the frozen _index column.
21884
+ const expanded = as_set(this.model.expanded);
21885
+ // The first cell is the cell of the frozen _index column, the second
21886
+ // holds the expand icon, which must follow changes made from Python.
21614
21887
  for (const row of this.tabulator.rowManager.getRows()) {
21615
- if (row.cells.length > 0) {
21888
+ if (row.cells.length > 1) {
21616
21889
  row.cells[0].layoutElement();
21617
- }
21618
- }
21619
- // Make sure the expand icon is changed when expanded is
21620
- // changed from Python.
21621
- for (const row of this.tabulator.rowManager.getRows()) {
21622
- if (row.cells.length > 0) {
21623
- const index = row.data._index;
21624
- const icon = this.model.expanded.includes(index) ? "▼" : "►";
21625
- row.cells[1].element.innerText = icon;
21890
+ row.cells[1].element.innerText = expanded.has(row.data._index) ? "▼" : "►";
21626
21891
  }
21627
21892
  }
21628
21893
  // If content is embedded, views may not have been
@@ -21633,18 +21898,12 @@ ${namesToRegister
21633
21898
  }
21634
21899
  });
21635
21900
  this.on_change(cell_styles, () => {
21636
- if (this._applied_styles) {
21637
- this.record_scroll();
21638
- this._updating_scroll = true;
21639
- this.tabulator.redraw(true);
21640
- this._updating_scroll = false;
21641
- }
21642
- this.restore_scroll();
21901
+ this._styles_version += 1;
21643
21902
  this.setStyles();
21644
21903
  });
21645
21904
  this.on_change(hidden_columns, () => {
21646
21905
  this.setHidden();
21647
- this.tabulator.redraw(true);
21906
+ this.tabulator.columnManager.redraw(false);
21648
21907
  });
21649
21908
  this.on_change(page_size, () => this.setPageSize());
21650
21909
  this.on_change(page, () => {
@@ -21658,7 +21917,7 @@ ${namesToRegister
21658
21917
  this.on_change(sorters, () => this.setSorters());
21659
21918
  this.on_change(theme_classes, () => this.setCSSClasses(this.tabulator.element));
21660
21919
  this.on_change(this.model.source.properties.data, () => {
21661
- if (this.tabulator === undefined) {
21920
+ if (this.tabulator == null) {
21662
21921
  return;
21663
21922
  }
21664
21923
  this._restore_scroll = "horizontal";
@@ -21666,26 +21925,38 @@ ${namesToRegister
21666
21925
  // The scroll event of a scroll just before may not have been handled yet.
21667
21926
  this.record_scroll();
21668
21927
  this._updating_scroll = true;
21669
- void this.setData().then(() => {
21928
+ this._updating_data = true;
21929
+ void this.setData().finally(() => {
21930
+ this._updating_data = false;
21931
+ }).then(() => {
21670
21932
  this._selection_updating = false;
21933
+ this.refitColumns();
21671
21934
  this.postUpdate();
21672
21935
  this.restore_scroll();
21673
21936
  });
21674
21937
  });
21675
- this.connect(this.model.source.streaming, () => this.addData());
21676
- this.connect(this.model.source.patching, () => {
21677
- const inds = this.model.source.selected.indices;
21678
- this.record_scroll();
21679
- this._updating_scroll = true;
21680
- this.updateOrAddData();
21681
- this._updating_scroll = false;
21682
- // Restore indices since updating data may have reset checkbox column
21683
- this.model.source.selected.indices = inds;
21684
- this.restore_scroll();
21685
- });
21938
+ // The streaming signal carries no payload; the document event also tells how
21939
+ // many rows were streamed and the rollover, which decide whether rows can be appended.
21940
+ const doc = this.model.document;
21941
+ if (doc != null) {
21942
+ doc.on_change(this._on_document_change);
21943
+ }
21944
+ else {
21945
+ this.connect(this.model.source.streaming, () => this.addData(null, null));
21946
+ }
21947
+ this.connect(this.model.source.patching, (indices) => this.updateOrAddData(indices));
21686
21948
  this.connect(this.model.source.selected.change, () => this.setSelection());
21687
21949
  this.connect(this.model.source.selected.properties.indices.change, () => this.setSelection());
21688
21950
  }
21951
+ disconnect_signals() {
21952
+ this.model.document?.remove_on_change(this._on_document_change);
21953
+ super.disconnect_signals();
21954
+ }
21955
+ _on_document_change = (event) => {
21956
+ if (event instanceof events_1.ColumnsStreamedEvent && event.model === this.model.source && event.attr === "data") {
21957
+ this.addData(event.data, event.rollover ?? null);
21958
+ }
21959
+ };
21689
21960
  get groupBy() {
21690
21961
  const groupby = (data) => {
21691
21962
  const groups = [];
@@ -21702,19 +21973,36 @@ ${namesToRegister
21702
21973
  if (this.model.sorters.length > 0) {
21703
21974
  sorters.push({ column: "_index", dir: "asc" });
21704
21975
  }
21705
- for (const sort of this.model.sorters.reverse()) {
21706
- if (sort.column === undefined) {
21707
- sort.column = sort.field;
21708
- }
21709
- sorters.push(sort);
21976
+ // Copy, the model array must not be reversed in place.
21977
+ for (const sort of [...this.model.sorters].reverse()) {
21978
+ sorters.push(sort.column === undefined ? { ...sort, column: sort.field } : sort);
21710
21979
  }
21711
21980
  return sorters;
21712
21981
  }
21713
21982
  invalidate_render() {
21714
21983
  this.tabulator?.destroy();
21715
21984
  this.tabulator = null;
21985
+ this._resized_columns.clear();
21716
21986
  this.rerender_();
21717
21987
  }
21988
+ refitColumns(field) {
21989
+ if (this._building || this.tabulator == null || !this.model.layout.startsWith("fit_data")) {
21990
+ return;
21991
+ }
21992
+ if (field != null && this.model.layout !== "fit_data_stretch") {
21993
+ // Measuring a single column costs a fraction of re-measuring them all.
21994
+ const column = this.tabulator.getColumn(field);
21995
+ if (column != null && !this._resized_columns.has(field) && column.getDefinition().width == null) {
21996
+ column.setWidth(true);
21997
+ }
21998
+ return;
21999
+ }
22000
+ this.tabulator.columnManager.layoutRefresh(true);
22001
+ // The refit discards the widths of columns the user has dragged.
22002
+ for (const [name, width] of this._resized_columns) {
22003
+ this.tabulator.getColumn(name)?.setWidth(width);
22004
+ }
22005
+ }
21718
22006
  redraw(columns = true, rows = true) {
21719
22007
  if (this._building || this.tabulator == null || this._redrawing) {
21720
22008
  return;
@@ -21779,6 +22067,7 @@ ${namesToRegister
21779
22067
  });
21780
22068
  }
21781
22069
  async _flush_resize_when_root_ready() {
22070
+ let blocked = 0;
21782
22071
  while (true) {
21783
22072
  if (!this._resize_pending) {
21784
22073
  return;
@@ -21798,7 +22087,9 @@ ${namesToRegister
21798
22087
  this.is_drawing ||
21799
22088
  this._has_active_editor() ||
21800
22089
  !this.stylesheets_settled) {
21801
- await (0, defer_1.defer)();
22090
+ // `root.ready` is usually already resolved, so a blocking condition that persists
22091
+ // would otherwise spin this loop; back off once it outlasts a few frames.
22092
+ await (blocked++ < RESIZE_BLOCKED_FRAMES ? (0, defer_1.paint)() : (0, defer_1.delay)(ROOT_READY_TIMEOUT_MS));
21802
22093
  continue;
21803
22094
  }
21804
22095
  this._resize_pending = false;
@@ -21818,11 +22109,14 @@ ${namesToRegister
21818
22109
  this.record_scroll();
21819
22110
  this._updating_scroll = true;
21820
22111
  this.redraw(true, true);
22112
+ this._updating_scroll = false;
22113
+ this._pending_scroll_restores += 1;
21821
22114
  requestAnimationFrame(() => {
21822
22115
  this._initializing = false;
21823
22116
  if (this._selection_pending) {
21824
22117
  this.setSelection();
21825
22118
  }
22119
+ this._pending_scroll_restores -= 1;
21826
22120
  this.restore_scroll();
21827
22121
  this.recompute_page_size();
21828
22122
  });
@@ -21927,20 +22221,20 @@ ${namesToRegister
21927
22221
  // Rendering callbacks
21928
22222
  this.tabulator.on("selectableRowsCheck", (row) => {
21929
22223
  const selectable = this.model.selectable_rows;
21930
- return (selectable == null) || selectable.includes(row._row.data._index);
22224
+ return (selectable == null) || as_set(selectable).has(row._row.data._index);
21931
22225
  });
21932
22226
  this.tabulator.on("tooltips", (cell) => {
21933
22227
  return `${cell.getColumn().getField()}: ${cell.getValue()}`;
21934
22228
  });
21935
- this.tabulator.on("scrollVertical", (0, debounce_1.debounce)(() => {
21936
- this.setStyles();
21937
- }, 50, false));
22229
+ // Rows scrolled back into view reuse their elements, so restyle them when `cell_styles` changed since.
22230
+ this.tabulator.on("scrollVertical", () => this.setStyles());
21938
22231
  // Sync state with model
21939
22232
  this.tabulator.on("rowSelectionChanged", (data, rows, selected, deselected) => {
21940
22233
  this.rowSelectionChanged(data, rows, selected, deselected);
21941
22234
  });
21942
22235
  this.tabulator.on("rowClick", (e, row) => this.rowClicked(e, row));
21943
22236
  this.tabulator.on("cellEdited", (cell) => this.cellEdited(cell));
22237
+ this.tabulator.on("columnResized", (column) => this._resized_columns.set(column.getField(), column.getWidth()));
21944
22238
  this.tabulator.on("dataFiltering", (filters) => {
21945
22239
  this.record_scroll();
21946
22240
  this.model.filters = filters;
@@ -21962,7 +22256,7 @@ ${namesToRegister
21962
22256
  this.updatePage(pageno);
21963
22257
  });
21964
22258
  this.tabulator.on("renderComplete", () => {
21965
- if (this._building) {
22259
+ if (this._building || this._updating_data) {
21966
22260
  return;
21967
22261
  }
21968
22262
  this.postUpdate();
@@ -22005,7 +22299,10 @@ ${namesToRegister
22005
22299
  this._initializing = this._building = false;
22006
22300
  this.setVisibility();
22007
22301
  if (this._pending_data) {
22008
- void this.setData().then(() => this.postUpdate());
22302
+ this._updating_data = true;
22303
+ void this.setData().finally(() => {
22304
+ this._updating_data = false;
22305
+ }).then(() => this.postUpdate());
22009
22306
  }
22010
22307
  this._request_resize_redraw();
22011
22308
  }
@@ -22107,7 +22404,8 @@ ${namesToRegister
22107
22404
  }
22108
22405
  getConfiguration() {
22109
22406
  // Only use selectable mode if explicitly requested otherwise manually handle selections
22110
- const selectableRows = this.model.select_mode === "toggle" ? true : NaN;
22407
+ // Tabulator only skips marking rows as selectable (class and hover styling) for exactly false
22408
+ const selectableRows = this.model.select_mode === "toggle" ? true : (this.model.select_mode === false ? false : NaN);
22111
22409
  const configuration = {
22112
22410
  ...(0, util_1.transformJsPlaceholders)(this.model.configuration),
22113
22411
  index: "_index",
@@ -22124,9 +22422,12 @@ ${namesToRegister
22124
22422
  popupContainer: this.model.container_popup && this.container,
22125
22423
  groupBy: this.groupBy,
22126
22424
  frozenRows: (row) => {
22127
- return (this.model.frozen_rows.length > 0) ? this.model.frozen_rows.includes(row._row.data._index) : false;
22425
+ return (this.model.frozen_rows.length > 0) ? as_set(this.model.frozen_rows).has(row._row.data._index) : false;
22426
+ },
22427
+ rowFormatter: (row) => {
22428
+ this._style_row(row);
22429
+ this._render_row(row, false);
22128
22430
  },
22129
- rowFormatter: (row) => this._render_row(row, false),
22130
22431
  };
22131
22432
  if (this.model.max_height != null) {
22132
22433
  configuration.maxHeight = this.model.max_height;
@@ -22185,7 +22486,7 @@ ${namesToRegister
22185
22486
  }
22186
22487
  _render_row(row, resize = true) {
22187
22488
  const index = row._row?.data._index;
22188
- if (!this.model.expanded.includes(index)) {
22489
+ if (!as_set(this.model.expanded).has(index)) {
22189
22490
  return;
22190
22491
  }
22191
22492
  const model = this.get_child(index);
@@ -22195,8 +22496,6 @@ ${namesToRegister
22195
22496
  }
22196
22497
  (0, util_1.schedule_when)(() => {
22197
22498
  const rowEl = row.getElement();
22198
- const style = getComputedStyle(this.tabulator.element.children[1].children[0]);
22199
- const bg = style.backgroundColor;
22200
22499
  const neg_margin = rowEl.style.paddingLeft ? `-${rowEl.style.paddingLeft}` : "0";
22201
22500
  const prev_child = rowEl.children[rowEl.children.length - 1];
22202
22501
  let viewEl;
@@ -22207,6 +22506,7 @@ ${namesToRegister
22207
22506
  }
22208
22507
  }
22209
22508
  else {
22509
+ const bg = getComputedStyle(this.tabulator.element.children[1].children[0]).backgroundColor;
22210
22510
  viewEl = (0, dom_2.div)({ class: "row-content", style: { background_color: bg, margin_left: neg_margin, max_width: "100%", overflow_x: "hidden" } });
22211
22511
  rowEl.appendChild(viewEl);
22212
22512
  }
@@ -22232,8 +22532,7 @@ ${namesToRegister
22232
22532
  }
22233
22533
  _expand_render(cell) {
22234
22534
  const index = cell._cell.row.data._index;
22235
- const icon = this.model.expanded.indexOf(index) < 0 ? "►" : "▼";
22236
- return icon;
22535
+ return as_set(this.model.expanded).has(index) ? "▼" : "►";
22237
22536
  }
22238
22537
  _update_expand(cell) {
22239
22538
  const index = cell._cell.row.data._index;
@@ -22483,12 +22782,48 @@ ${namesToRegister
22483
22782
  return this.tabulator.setData(data);
22484
22783
  }
22485
22784
  }
22486
- addData() {
22785
+ /** Whether rows can be added or updated in place rather than rebuilding the whole table. */
22786
+ get can_update_in_place() {
22787
+ return (this.tabulator != null &&
22788
+ this.tabulator.initialized &&
22789
+ !this._initializing &&
22790
+ !this._building &&
22791
+ !this._pending_data &&
22792
+ !this.model.configuration.dataTree);
22793
+ }
22794
+ /**
22795
+ * Appends the streamed rows. Rolling over drops leading rows and shifts every
22796
+ * `_index`, so that case (and anything out of sync) rebuilds the table.
22797
+ */
22798
+ addData(streamed, rollover) {
22799
+ if (this.tabulator == null) {
22800
+ return;
22801
+ }
22487
22802
  const rows = this.tabulator.rowManager.getRows();
22488
22803
  const last_row = rows[rows.length - 1];
22489
22804
  const start = ((last_row?.data._index) || 0);
22805
+ const total = this.model.source.get_length() ?? 0;
22806
+ const n_streamed = streamed == null ? null : stream_length(streamed);
22807
+ const append = (n_streamed != null &&
22808
+ this.can_update_in_place &&
22809
+ rows.length + n_streamed === total &&
22810
+ (rollover == null || total <= rollover));
22490
22811
  this._updating_page = true;
22491
- void this.setData().then(() => {
22812
+ let update;
22813
+ if (append) {
22814
+ this._updating_data = true;
22815
+ try {
22816
+ this._append_rows((0, data_1.transform_cds_to_records)(this.model.source, true, rows.length));
22817
+ }
22818
+ finally {
22819
+ this._updating_data = false;
22820
+ }
22821
+ update = Promise.resolve();
22822
+ }
22823
+ else {
22824
+ update = this.setData();
22825
+ }
22826
+ void update.then(() => {
22492
22827
  if (this.model.follow) {
22493
22828
  if (this.model.pagination) {
22494
22829
  this.tabulator.setPage(Math.ceil(this.tabulator.rowManager.getDataCount() / (this.model.page_size || 20)));
@@ -22500,6 +22835,40 @@ ${namesToRegister
22500
22835
  this._updating_page = false;
22501
22836
  });
22502
22837
  }
22838
+ /**
22839
+ * Tabulator's `addData` copies the active rows array and, with pagination,
22840
+ * refreshes the whole data pipeline once per added row, which makes appending
22841
+ * a batch slower than rebuilding the table. This appends rows the way
22842
+ * `RowManager.addRows` does but refreshes once.
22843
+ */
22844
+ _append_rows(records) {
22845
+ const manager = this.tabulator.rowManager;
22846
+ // With pagination Tabulator places new rows on the current page unless the
22847
+ // preceding row is given explicitly.
22848
+ let after = this.model.pagination == null ? undefined : manager.rows[manager.rows.length - 1];
22849
+ const { setActiveRows, refreshActiveData } = manager;
22850
+ manager.setActiveRows = () => { };
22851
+ manager.refreshActiveData = () => { };
22852
+ try {
22853
+ for (const record of records) {
22854
+ const row = manager.addRow(record, false, after, true);
22855
+ manager.dispatch("row-added", row, record, false, after);
22856
+ if (after !== undefined) {
22857
+ after = row;
22858
+ }
22859
+ }
22860
+ }
22861
+ finally {
22862
+ manager.setActiveRows = setActiveRows;
22863
+ manager.refreshActiveData = refreshActiveData;
22864
+ }
22865
+ manager.setActiveRows(manager.activeRows);
22866
+ manager.refreshActiveData(false, false, true);
22867
+ manager.regenerateRowPositions();
22868
+ if (manager.displayRowsCount) {
22869
+ manager._clearPlaceholder();
22870
+ }
22871
+ }
22503
22872
  postUpdate() {
22504
22873
  this.setSelection();
22505
22874
  this.setStyles();
@@ -22508,20 +22877,52 @@ ${namesToRegister
22508
22877
  this.restore_scroll(restore !== "vertical", restore !== "horizontal");
22509
22878
  this._restore_scroll = false;
22510
22879
  }
22511
- updateOrAddData() {
22880
+ /** Updates the patched rows in place; patches touching most rows rebuild the table instead. */
22881
+ updateOrAddData(indices) {
22512
22882
  // To avoid double updating the tabulator data
22513
- if (this._tabulator_cell_updating) {
22883
+ if (this._tabulator_cell_updating || this.tabulator == null) {
22514
22884
  return;
22515
22885
  }
22886
+ const rows = this.tabulator.rowManager.getRows().length;
22887
+ if (this.can_update_in_place &&
22888
+ // Tabulator does not regroup rows whose data is updated in place.
22889
+ !this.tabulator.options.groupBy &&
22890
+ (0, types_1.isArray)(indices) &&
22891
+ indices.length > 0 &&
22892
+ indices.length * 2 < rows &&
22893
+ indices.every(types_1.isNumber)) {
22894
+ const records = (0, data_1.transform_cds_rows_to_records)(this.model.source, indices, true);
22895
+ if (records.length === indices.length) {
22896
+ // Rows updated in place are not re-sorted or re-filtered, refreshing
22897
+ // the filter re-runs the filter and sort stages of the data pipeline.
22898
+ const refresh = this.tabulator.getSorters().length > 0 || this.tabulator.getFilters(true).length > 0;
22899
+ this.tabulator.updateData(records).then(() => {
22900
+ if (refresh) {
22901
+ this.tabulator.refreshFilter();
22902
+ }
22903
+ }).catch(() => this.replaceData());
22904
+ return;
22905
+ }
22906
+ }
22907
+ this.replaceData();
22908
+ }
22909
+ replaceData() {
22910
+ const inds = this.model.source.selected.indices;
22911
+ this.record_scroll();
22912
+ this._updating_scroll = true;
22516
22913
  // Temporarily set minHeight to avoid "scroll-to-top" issues caused
22517
22914
  // by Tabulator JS entirely destroying the table when .setData is called.
22518
22915
  // Inspired by https://github.com/olifolkerd/tabulator/issues/4155
22519
22916
  const prev_minheight = this.tabulator.element.style.minHeight;
22520
22917
  this.tabulator.element.style.minHeight = `${this.tabulator.element.offsetHeight}px`;
22521
- const data = (0, data_1.transform_cds_to_records)(this.model.source, true);
22918
+ const data = this.getData();
22522
22919
  this.tabulator.setData(data).then(() => {
22523
22920
  this.tabulator.element.style.minHeight = prev_minheight;
22524
22921
  });
22922
+ this._updating_scroll = false;
22923
+ // Restore indices since updating data may have reset checkbox column
22924
+ this.model.source.selected.indices = inds;
22925
+ this.restore_scroll();
22525
22926
  }
22526
22927
  setFrozen() {
22527
22928
  for (const row of this.model.frozen_rows) {
@@ -22545,41 +22946,54 @@ ${namesToRegister
22545
22946
  }
22546
22947
  this.tabulator.setSort(this.sorters);
22547
22948
  }
22949
+ /** Styles the rendered rows; rows rendered later are styled by the `rowFormatter`. */
22548
22950
  setStyles() {
22549
- const style_data = this.model.cell_styles.data;
22550
- if (this.tabulator == null || this.tabulator.getDataCount() == 0 || style_data == null || !style_data.size) {
22951
+ if (this.tabulator == null || this.tabulator.rowManager.renderer == null) {
22551
22952
  return;
22552
22953
  }
22553
- this._applied_styles = false;
22554
- for (const r of style_data.keys()) {
22555
- const row_style = style_data.get(r);
22556
- const row = this.tabulator.getRow(r);
22557
- if (!row) {
22954
+ // Chained so frozen rows, which sit outside the scrolled rows, are included.
22955
+ for (const row of this.tabulator.rowManager.getVisibleRows(true, true)) {
22956
+ if (row.type === "row") {
22957
+ this._style_row(row.getComponent());
22958
+ }
22959
+ }
22960
+ }
22961
+ _style_row(row) {
22962
+ const version = this._styles_version;
22963
+ const index = row._row?.data._index;
22964
+ const row_style = index == null ? null : lookup(this.model.cell_styles.data, index);
22965
+ for (const cell of row._row?.cells ?? []) {
22966
+ const element = cell.element;
22967
+ if (element == null) {
22558
22968
  continue;
22559
22969
  }
22560
- const cells = row._row.cells;
22561
- for (const c of row_style.keys()) {
22562
- const style = row_style.get(c);
22563
- const cell = cells[c];
22564
- if (cell == null || !style.length) {
22970
+ const styled = this._styled_cells.get(element);
22971
+ if (styled != null && styled.version === version) {
22972
+ continue;
22973
+ }
22974
+ if (styled != null) {
22975
+ for (const prop of styled.props) {
22976
+ element.style.removeProperty(prop);
22977
+ }
22978
+ this._styled_cells.delete(element);
22979
+ }
22980
+ const style = lookup(row_style, cell.column.field);
22981
+ const props = [];
22982
+ for (const s of style ?? []) {
22983
+ let prop, value;
22984
+ if ((0, types_1.isArray)(s)) {
22985
+ [prop, value] = s;
22986
+ }
22987
+ else if (!s.includes(":")) {
22565
22988
  continue;
22566
22989
  }
22567
- const element = cell.element;
22568
- for (const s of style) {
22569
- let prop, value;
22570
- if ((0, types_1.isArray)(s)) {
22571
- [prop, value] = s;
22572
- }
22573
- else if (!s.includes(":")) {
22574
- continue;
22575
- }
22576
- else {
22577
- [prop, value] = s.split(":");
22578
- }
22579
- element.style.setProperty(prop, value.trimLeft());
22580
- this._applied_styles = true;
22990
+ else {
22991
+ [prop, value] = s.split(":");
22581
22992
  }
22993
+ element.style.setProperty(prop, value.trimLeft());
22994
+ props.push(prop);
22582
22995
  }
22996
+ this._styled_cells.set(element, { version, props });
22583
22997
  }
22584
22998
  }
22585
22999
  setHidden() {
@@ -22631,10 +23045,13 @@ ${namesToRegister
22631
23045
  this._selection_updating = true;
22632
23046
  this.tabulator.deselectRow();
22633
23047
  this.tabulator.selectRow(indices);
22634
- for (const index of indices) {
22635
- const row = this.tabulator.rowManager.findRow(index);
22636
- if (row) {
22637
- this.tabulator.scrollToRow(index, "center", false).catch(() => { });
23048
+ // Scroll once, to the last selected row that is displayed (e.g. on the current page).
23049
+ const displayed = new Set(this.tabulator.rowManager.getDisplayRows());
23050
+ for (let i = indices.length - 1; i >= 0; i--) {
23051
+ const row = this.tabulator.rowManager.findRow(indices[i]);
23052
+ if (row && displayed.has(row)) {
23053
+ this.tabulator.scrollToRow(indices[i], "center", false).catch(() => { });
23054
+ break;
22638
23055
  }
22639
23056
  }
22640
23057
  this._selection_updating = false;
@@ -22756,14 +23173,12 @@ ${namesToRegister
22756
23173
  this._selection_updating = false;
22757
23174
  }
22758
23175
  _filter_selected(indices) {
22759
- const filtered = [];
22760
- for (const ind of indices) {
22761
- if (this.model.selectable_rows == null ||
22762
- this.model.selectable_rows.indexOf(ind) >= 0) {
22763
- filtered.push(ind);
22764
- }
23176
+ const selectable = this.model.selectable_rows;
23177
+ if (selectable == null) {
23178
+ return [...indices];
22765
23179
  }
22766
- return filtered;
23180
+ const selectable_set = as_set(selectable);
23181
+ return indices.filter((ind) => selectable_set.has(ind));
22767
23182
  }
22768
23183
  rowSelectionChanged(data, _row, selected, deselected) {
22769
23184
  if (this._selection_updating ||
@@ -22799,7 +23214,9 @@ ${namesToRegister
22799
23214
  const index = cell.getData()._index;
22800
23215
  const value = cell._cell.value;
22801
23216
  const key = `${field}:${index}`;
22802
- if (column_def.validator === "numeric" && value === "") {
23217
+ const column = this.model.source.get_column(field);
23218
+ const nullable = Array.isArray(column) || column instanceof Float64Array || column instanceof Float32Array;
23219
+ if (nullable && (column_def.validator === "numeric" || column_def.validator === "integer") && value === "") {
22803
23220
  // setValue below re-triggers cellEdited recursively for the actual
22804
23221
  // (NaN) edit. By then cell._cell.oldValue has already been overwritten
22805
23222
  // with this now-discarded "" attempt, so the true pre-edit value is
@@ -22823,6 +23240,7 @@ ${namesToRegister
22823
23240
  comm_manager_1.comm_settings.debounce = true;
22824
23241
  this._tabulator_cell_updating = false;
22825
23242
  }
23243
+ this.refitColumns(field);
22826
23244
  this.tabulator.scrollToRow(index, "top", false);
22827
23245
  }
22828
23246
  }
@@ -23339,38 +23757,68 @@ ${namesToRegister
23339
23757
  };
23340
23758
  module.exports = _;
23341
23759
  },
23342
- "be689f0377": /* models/data.js */ function _(require, module, exports, __esModule, __esExport) {
23760
+ "ce212d2be6": /* models/data.js */ function _(require, module, exports, __esModule, __esExport) {
23343
23761
  __esModule();
23344
23762
  exports.transform_cds_to_records = transform_cds_to_records;
23763
+ exports.transform_cds_rows_to_records = transform_cds_rows_to_records;
23345
23764
  exports.dict_to_records = dict_to_records;
23346
23765
  const types_1 = require("@bokehjs/core/util/types");
23347
- function transform_cds_to_records(cds, addId = false, start = 0) {
23348
- const data = [];
23766
+ function cds_record_builder(cds, addId) {
23349
23767
  const columns = cds.columns();
23350
23768
  const cdsLength = cds.get_length();
23351
23769
  if (columns.length === 0 || cdsLength === null) {
23352
- return [];
23770
+ return null;
23353
23771
  }
23354
- for (let i = start; i < cdsLength; i++) {
23772
+ const accessors = [];
23773
+ for (const column of columns) {
23774
+ const array = cds.get_array(column);
23775
+ const shape = (array[0] == null || array[0].shape == null) ? null : array[0].shape;
23776
+ if (shape != null && shape.length > 1 && (0, types_1.isNumber)(shape[0])) {
23777
+ const width = shape[1];
23778
+ accessors.push([column, (i) => array.slice(i * width, i * width + width)]);
23779
+ }
23780
+ else if (array.length != cdsLength && (array.length % cdsLength === 0)) {
23781
+ const offset = array.length / cdsLength;
23782
+ accessors.push([column, (i) => array.slice(i * offset, i * offset + offset)]);
23783
+ }
23784
+ else {
23785
+ accessors.push([column, (i) => array[i]]);
23786
+ }
23787
+ }
23788
+ return (i) => {
23355
23789
  const item = {};
23356
- for (const column of columns) {
23357
- const array = cds.get_array(column);
23358
- const shape = (array[0] == null || array[0].shape == null) ? null : array[0].shape;
23359
- if (shape != null && shape.length > 1 && (0, types_1.isNumber)(shape[0])) {
23360
- item[column] = array.slice(i * shape[1], i * shape[1] + shape[1]);
23361
- }
23362
- else if (array.length != cdsLength && (array.length % cdsLength === 0)) {
23363
- const offset = array.length / cdsLength;
23364
- item[column] = array.slice(i * offset, i * offset + offset);
23365
- }
23366
- else {
23367
- item[column] = array[i];
23368
- }
23790
+ for (const [column, get] of accessors) {
23791
+ item[column] = get(i);
23369
23792
  }
23370
23793
  if (addId) {
23371
23794
  item._index = i;
23372
23795
  }
23373
- data.push(item);
23796
+ return item;
23797
+ };
23798
+ }
23799
+ function transform_cds_to_records(cds, addId = false, start = 0) {
23800
+ const build = cds_record_builder(cds, addId);
23801
+ if (build === null) {
23802
+ return [];
23803
+ }
23804
+ const data = [];
23805
+ const cdsLength = cds.get_length() ?? 0;
23806
+ for (let i = start; i < cdsLength; i++) {
23807
+ data.push(build(i));
23808
+ }
23809
+ return data;
23810
+ }
23811
+ function transform_cds_rows_to_records(cds, indices, addId = false) {
23812
+ const build = cds_record_builder(cds, addId);
23813
+ if (build === null) {
23814
+ return [];
23815
+ }
23816
+ const cdsLength = cds.get_length() ?? 0;
23817
+ const data = [];
23818
+ for (const i of indices) {
23819
+ if (i >= 0 && i < cdsLength) {
23820
+ data.push(build(i));
23821
+ }
23374
23822
  }
23375
23823
  return data;
23376
23824
  }
@@ -26309,10 +26757,10 @@ ${namesToRegister
26309
26757
  const layout_dom_1 = require("@bokehjs/models/layouts/layout_dom");
26310
26758
  const column_data_source_1 = require("@bokehjs/models/sources/column_data_source");
26311
26759
  const debounce_1 = require("99a25e6992") /* debounce */;
26312
- const data_1 = require("be689f0377") /* ./data */;
26760
+ const data_1 = require("ce212d2be6") /* ./data */;
26313
26761
  const layout_1 = require("00beb93e38") /* ./layout */;
26314
26762
  const lumagl_1 = require("16d69e2b49") /* ./lumagl */;
26315
- const resources_1 = require("3ec7d872e2") /* ./resources */;
26763
+ const resources_1 = require("133ce95cfa") /* ./resources */;
26316
26764
  const tooltips_1 = require("f8f8ea4284") /* ./tooltips */;
26317
26765
  function extractClasses() {
26318
26766
  // Get classes for registration from standalone deck.gl
@@ -29022,7 +29470,7 @@ ${namesToRegister
29022
29470
  const input_widget_1 = require("@bokehjs/models/widgets/input_widget");
29023
29471
  const inputs = tslib_1.__importStar(require("@bokehjs/styles/widgets/inputs.css"));
29024
29472
  const filedropper_css_1 = tslib_1.__importDefault(require("c03dd3c931") /* styles/models/filedropper.css */);
29025
- const resources_1 = require("3ec7d872e2") /* ./resources */;
29473
+ const resources_1 = require("133ce95cfa") /* ./resources */;
29026
29474
  class UploadEvent extends bokeh_events_1.ModelEvent {
29027
29475
  data;
29028
29476
  constructor(data) {
@@ -29678,7 +30126,7 @@ ${namesToRegister
29678
30126
  __esModule();
29679
30127
  const markup_1 = require("@bokehjs/models/widgets/markup");
29680
30128
  const layout_1 = require("00beb93e38") /* ./layout */;
29681
- const resources_1 = require("3ec7d872e2") /* ./resources */;
30129
+ const resources_1 = require("133ce95cfa") /* ./resources */;
29682
30130
  class KaTeXView extends layout_1.PanelMarkupView {
29683
30131
  connect_signals() {
29684
30132
  super.connect_signals();
@@ -29718,7 +30166,7 @@ ${namesToRegister
29718
30166
  }
29719
30167
  exports.KaTeX = KaTeX;
29720
30168
  },
29721
- "2116677c2d": /* models/location.js */ function _(require, module, exports, __esModule, __esExport) {
30169
+ "cc871e1a06": /* models/location.js */ function _(require, module, exports, __esModule, __esExport) {
29722
30170
  __esModule();
29723
30171
  const view_1 = require("@bokehjs/core/view");
29724
30172
  const model_1 = require("@bokehjs/model");
@@ -29789,6 +30237,9 @@ ${namesToRegister
29789
30237
  update(change) {
29790
30238
  const url = `${this.model.pathname}${this.model.search}${this.model.hash}`;
29791
30239
  if (change === "reload") {
30240
+ if (!this.model.reload) {
30241
+ return;
30242
+ }
29792
30243
  window.history.pushState({}, "", url);
29793
30244
  this.model.href = window.location.href;
29794
30245
  window.location.reload();
@@ -29886,7 +30337,7 @@ ${namesToRegister
29886
30337
  const ui_element_1 = require("@bokehjs/models/ui/ui_element");
29887
30338
  const types_1 = require("@bokehjs/core/util/types");
29888
30339
  const modal_css_1 = tslib_1.__importDefault(require("be4b4352c6") /* styles/models/modal.css */);
29889
- const resources_1 = require("3ec7d872e2") /* ./resources */;
30340
+ const resources_1 = require("133ce95cfa") /* ./resources */;
29890
30341
  let ModalDialogEvent = ModalDialogEvent_1 = class ModalDialogEvent extends bokeh_events_1.ModelEvent {
29891
30342
  model;
29892
30343
  open;
@@ -30043,7 +30494,7 @@ ${namesToRegister
30043
30494
  __esModule();
30044
30495
  const markup_1 = require("@bokehjs/models/widgets/markup");
30045
30496
  const layout_1 = require("00beb93e38") /* ./layout */;
30046
- const html_1 = require("9012c2f5ae") /* ./html */;
30497
+ const html_1 = require("e40e09e4dd") /* ./html */;
30047
30498
  class PDFView extends layout_1.PanelMarkupView {
30048
30499
  connect_signals() {
30049
30500
  super.connect_signals();
@@ -30410,7 +30861,7 @@ ${namesToRegister
30410
30861
  .psp-header-group-corner
30411
30862
  ){box-shadow:1px 0px var(--inactive--color, #eaedef), 0px 10px 0 -9px var(--inactive--color, #eaedef);}.psp-header-leaf.psp-header-border{box-shadow:5px -4px 0px -4px var(--inactive--color, #eaedef);}tr:only-child th{box-shadow:none !important;}regular-table tbody tr:hover th.psp-tree-leaf:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover th.psp-tree-label:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover td:not(.psp-row-selected):not(.psp-row-subselected){border-color:var(--rt-hover--border-color, #c5c9d080) !important;background-color:transparent;box-shadow:0px 1px 0px var(--rt-hover--border-color, #c5c9d080), 0px 3px 0px rgba(0, 0, 0, 0.05), 0px 5px 0px rgba(0, 0, 0, 0.01);}regular-table tbody tr:hover + tr th.psp-tree-leaf:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover + tr th.psp-tree-label:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover + tr td:not(.psp-row-selected):not(.psp-row-subselected){border-top-color:transparent;}regular-table tbody tr th:first-child:not(:empty),regular-table tbody tr th:first-child:empty + th:not(:empty),regular-table tbody tr th:first-child:empty ~ th:empty + th:not(:empty),regular-table tbody tr td:first-child{border-left-width:1px;border-left-color:transparent;}regular-table tbody tr th:last-child,regular-table tbody tr td:last-child{border-right-width:1px;border-right-color:transparent;}regular-table tbody tr:hover{color:#161616;}regular-table tbody tr:hover th:first-child:not(:empty),regular-table tbody tr:hover th:first-child:empty + th:not(:empty),regular-table tbody tr:hover th:first-child:empty ~ th:empty + th:not(:empty),regular-table tbody tr:hover td:first-child{border-left-color:var(--rt-hover--border-color, #c5c9d080) !important;}regular-table tbody tr:hover th:last-child,regular-table tbody tr:hover td:last-child{border-right-color:var(--rt-hover--border-color, #c5c9d080) !important;}perspective-viewer[settings] regular-table .psp-header-leaf{height:36px;vertical-align:top;padding-top:2px;}perspective-viewer[settings] regular-table .psp-header-leaf:not(.psp-header-corner):before{font-family:var(--button--font-family, inherit);content:var(--column-style-open-button--content, var(--config-button-icon--content, '\u1f527'));position:absolute;width:calc(100% - 8px);left:5px;bottom:0px;color:var(--inactive--color, #b4b7be);}perspective-viewer[settings] regular-table .psp-header-leaf.psp-menu-enabled:not(.psp-header-corner):before{color:inherit;cursor:pointer;}perspective-viewer[settings] regular-table .psp-header-leaf.psp-menu-open:not(.psp-header-corner){pointer-events:none;}perspective-viewer[settings] regular-table .psp-header-leaf.psp-menu-open:not(.psp-header-corner):before{content:var(--column-style-close-button--content, 'X');}perspective-viewer[settings] regular-table .psp-header-leaf.psp-menu-enabled:hover:before{color:#338dcd;}perspective-viewer[settings] regular-table .psp-header-leaf .rt-column-resize{height:18px;}.psp-row-selected,:hover .psp-row-selected,:hover th.psp-tree-leaf.psp-row-selected,:hover th.psp-tree-label.psp-row-selected{color:white !important;background-color:#ea7319 !important;border-color:#ea7319 !important;}.psp-row-selected.psp-tree-label:not(:hover):before{color:white;}.psp-row-subselected,:hover .psp-row-subselected,:hover th.psp-tree-leaf.psp-row-subselected,:hover th.psp-tree-label.psp-row-subselected{background:rgba(234, 115, 25, 0.2) !important;}.psp-error{color:red;}td:focus{outline:#666;outline-style:dotted;outline-width:1px;}perspective-viewer.dragging regular-table{pointer-events:none;}.psp-header-border:last-child{border-right-width:0px;}.psp-header-sort-desc:after{font-family:var(--button--font-family, inherit);font-size:10px;content:var(--sort-order-desc--content, '\u2193');}.psp-header-sort-asc:after{font-family:var(--button--font-family, inherit);font-size:10px;content:var(--sort-order-asc--content, '\u2191');}.psp-header-sort-col-desc:after{font-family:var(--button--font-family, inherit);font-size:10px;content:var(--sort-order-col-desc--content, '\u2190');}.psp-header-sort-col-asc:after{font-family:var(--button--font-family, inherit);font-size:10px;content:var(--sort-order-col-asc--content, '\u2192');}tbody th:last-of-type{border-right:1px solid #eaedef;overflow:hidden;text-overflow:ellipsis;}tbody th:empty{background-image:linear-gradient(to right, transparent 9px, #eee 10px, transparent 11px);background-repeat:no-repeat;min-width:20px;max-width:20px;pointer-events:none;}.psp-tree-label{max-width:0px;min-width:0px;}.psp-tree-label:before{color:#ccc;font-family:var(--button--font-family, inherit);padding-right:11px;vertical-align:-1px;}.psp-tree-label-expand:before{content:var(--tree-label-expand--content, '+');}.psp-tree-label-collapse:before{content:var(--tree-label-collapse--content, '-');}.psp-tree-label:hover:before{color:#338dcd;text-shadow:0px 0px 5px #338dcd;}regular-table thead tr:last-child th{border-bottom-width:1px;border-bottom-color:var(--inactive--color, #eaedef);}.psp-tree-leaf{padding-left:24px;}.psp-align-right{text-align:right;}.psp-align-left{text-align:left;}.psp-positive:not(:focus){color:var(--rt-pos-cell--color, #338dcd);}.psp-negative:not(:focus){color:var(--rt-neg-cell--color, #ff5942);}regular-table table tbody td{min-width:52px !important;}.psp-is-width-override .rt-column-resize,.rt-column-resize:hover{border:1px dashed #999;border-bottom-width:0px;border-left-width:0px;}.psp-bool-type{font-family:var(--button--font-family, 'Material Icons');}.boolean-editable{cursor:pointer;}regular-table table{user-select:none;color:#161616;border-collapse:separate;}regular-table table th{font-weight:400;}regular-table table td,regular-table table th{border-color:#eaedef;height:23px;}regular-table table .psp-header-group{text-overflow:ellipsis;}regular-table table .psp-header-leaf{border-bottom-width:0px;}regular-table table td,regular-table table th.psp-tree-label,regular-table table th.psp-tree-label,regular-table table th.psp-tree-leaf,regular-table table tbody tr:first-child th{border-style:solid;border-width:0px;border-top-width:1px;}regular-table table tbody th:empty{background-position:0px -10px;}@keyframes pulse_pos{0%{background-color:var(--pulse--background-color-start, rgba(0, 128, 255, 0.5));}100%{background-color:var(--pulse--background-color-end, rgba(0, 128, 255, 0));}}@keyframes pulse_pos2{0%{background-color:var(--pulse--background-color-start, rgba(0, 128, 255, 0.5));}100%{background-color:var(--pulse--background-color-end, rgba(0, 128, 255, 0));}}@keyframes pulse_neg{0%{background-color:var(--pulse--background-color-start, rgba(255, 25, 0, 0.5));}100%{background-color:var(--pulse--background-color-end, rgba(255, 25, 0, 0));}}@keyframes pulse_neg2{0%{background-color:var(--pulse--background-color-start, rgba(255, 25, 0, 0.5));}100%{background-color:var(--pulse--background-color-end, rgba(255, 25, 0, 0));}}`;
30412
30863
  },
30413
- "39230f6818": /* models/plotly.js */ function _(require, module, exports, __esModule, __esExport) {
30864
+ "736be77caa": /* models/plotly.js */ function _(require, module, exports, __esModule, __esExport) {
30414
30865
  __esModule();
30415
30866
  const tslib_1 = require("tslib");
30416
30867
  const bokeh_events_1 = require("@bokehjs/core/bokeh_events");
@@ -30454,6 +30905,18 @@ ${namesToRegister
30454
30905
  }
30455
30906
  }
30456
30907
  exports.PlotlyEvent = PlotlyEvent;
30908
+ const decodeUndefined = (obj) => {
30909
+ if (obj === "_undefined_") {
30910
+ return undefined;
30911
+ }
30912
+ else if (Array.isArray(obj)) {
30913
+ return obj.map(decodeUndefined);
30914
+ }
30915
+ else if ((0, types_1.isPlainObject)(obj)) {
30916
+ return Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, decodeUndefined(v)]));
30917
+ }
30918
+ return obj;
30919
+ };
30457
30920
  const filterEventData = (gd, eventData, event) => {
30458
30921
  // Ported from dash-core-components/src/components/Graph.react.js
30459
30922
  const filteredEventData = Array.isArray(eventData) ? [] : {};
@@ -30514,8 +30977,12 @@ ${namesToRegister
30514
30977
  const pointData = {};
30515
30978
  for (const property in fullPoint) {
30516
30979
  const val = fullPoint[property];
30980
+ // Arrays of primitives (e.g. multicategory x, heatmap pointNumber)
30981
+ // are safe; arrays holding objects may be circular or huge.
30982
+ const isPrimitiveArray = Array.isArray(val) &&
30983
+ val.every((v) => v === null || typeof v !== "object");
30517
30984
  if (fullPoint.hasOwnProperty(property) &&
30518
- !Array.isArray(val) && !(0, types_1.isPlainObject)(val) &&
30985
+ (isPrimitiveArray || (!Array.isArray(val) && !(0, types_1.isPlainObject)(val))) &&
30519
30986
  val !== undefined) {
30520
30987
  pointData[property] = val;
30521
30988
  }
@@ -30568,13 +31035,18 @@ ${namesToRegister
30568
31035
  _rendered = false;
30569
31036
  _reacting = false;
30570
31037
  _relayouting = false;
31038
+ _model_restyles = 0;
30571
31039
  _hoverdata = null;
30572
31040
  container;
30573
- _watched_sources;
30574
31041
  _end_relayouting = (0, debounce_1.debounce)(() => {
30575
31042
  this._relayouting = false;
30576
31043
  }, 2000, false);
30577
31044
  _throttled_resize;
31045
+ // Frames handed to Plotly for the current plot
31046
+ _frames = null;
31047
+ _plot_promise = null;
31048
+ _plot_scheduled = false;
31049
+ _new_plot = false;
30578
31050
  initialize() {
30579
31051
  super.initialize();
30580
31052
  this._throttled_resize = (0, util_1.throttle)(() => this.resize_layout(), 25);
@@ -30582,13 +31054,11 @@ ${namesToRegister
30582
31054
  connect_signals() {
30583
31055
  super.connect_signals();
30584
31056
  const { data, data_sources, layout, relayout, restyle, viewport_update_policy, viewport_update_throttle, _render_count, frames, viewport, } = this.model.properties;
30585
- this.on_change([data, data_sources, layout], () => {
30586
- const render_count = this.model._render_count;
30587
- setTimeout(() => {
30588
- if (this.model._render_count === render_count) {
30589
- this.model._render_count += 1;
30590
- }
30591
- }, 250);
31057
+ this.on_change([data, data_sources, layout, _render_count], () => {
31058
+ this._schedule_plot();
31059
+ });
31060
+ this.on_change(frames, () => {
31061
+ this._schedule_plot(true);
30592
31062
  });
30593
31063
  this.on_change(relayout, () => {
30594
31064
  if (this.model.relayout == null) {
@@ -30601,7 +31071,11 @@ ${namesToRegister
30601
31071
  if (this.model.restyle == null) {
30602
31072
  return;
30603
31073
  }
30604
- window.Plotly.restyle(this.container, this.model.restyle.data, this.model.restyle.traces);
31074
+ const data = decodeUndefined(this.model.restyle.data);
31075
+ this._model_restyles += 1;
31076
+ window.Plotly.restyle(this.container, data, this.model.restyle.traces).finally(() => {
31077
+ this._model_restyles -= 1;
31078
+ });
30605
31079
  this.model.restyle = null;
30606
31080
  });
30607
31081
  this.on_change(viewport_update_policy, () => {
@@ -30610,16 +31084,28 @@ ${namesToRegister
30610
31084
  this.on_change(viewport_update_throttle, () => {
30611
31085
  this._updateSetViewportFunction();
30612
31086
  });
30613
- this.on_change(_render_count, () => {
30614
- this.plot();
30615
- });
30616
- this.on_change(frames, () => {
30617
- this.plot(true);
30618
- });
30619
31087
  this.on_change(viewport, () => {
30620
31088
  this._updateViewportFromProperty();
30621
31089
  });
30622
31090
  }
31091
+ /**
31092
+ * Plots once all changes applied in the current task have been
31093
+ * processed, waiting for a plot in progress to finish first.
31094
+ */
31095
+ _schedule_plot(new_plot = false) {
31096
+ this._new_plot ||= new_plot;
31097
+ if (this._plot_scheduled) {
31098
+ return;
31099
+ }
31100
+ this._plot_scheduled = true;
31101
+ const run = () => {
31102
+ this._plot_scheduled = false;
31103
+ const replot = this._new_plot;
31104
+ this._new_plot = false;
31105
+ this._plot_promise = this.plot(replot);
31106
+ };
31107
+ (this._plot_promise ?? Promise.resolve()).then(run, run);
31108
+ }
30623
31109
  stylesheets() {
30624
31110
  return [...super.stylesheets(), plotly_css_1.default];
30625
31111
  }
@@ -30635,7 +31121,7 @@ ${namesToRegister
30635
31121
  (0, layout_1.set_size)(this.container, this.model);
30636
31122
  this._rendered = false;
30637
31123
  this.watch_stylesheets();
30638
- this.plot(true).then(() => {
31124
+ this._plot_promise = this.plot(true).then(() => {
30639
31125
  this.shadow_el.appendChild(this.container);
30640
31126
  this._rendered = true;
30641
31127
  this.resize_layout();
@@ -30644,6 +31130,15 @@ ${namesToRegister
30644
31130
  }
30645
31131
  });
30646
31132
  }
31133
+ /**
31134
+ * The plot size derived from the model and the element, or null while
31135
+ * the element is not laid out.
31136
+ */
31137
+ _plot_size() {
31138
+ const width = Math.min(this.model.width || this.el.clientWidth, this.model.max_width || Infinity);
31139
+ const height = Math.min(this.model.height || this.el.clientHeight, this.model.max_height || Infinity);
31140
+ return width > 0 && height > 0 ? [width, height] : null;
31141
+ }
30647
31142
  style_redraw() {
30648
31143
  this.resize_layout();
30649
31144
  }
@@ -30653,6 +31148,11 @@ ${namesToRegister
30653
31148
  }
30654
31149
  const width = Math.min(this.model.width || this.el.clientWidth, this.model.max_width || Infinity);
30655
31150
  const height = Math.min(this.model.height || this.el.clientHeight, this.model.max_height || Infinity);
31151
+ // A relayout resets the hover state, dropping clicks right after it
31152
+ const { layout } = this.container;
31153
+ if (layout != null && layout.width === width && layout.height === height) {
31154
+ return;
31155
+ }
30656
31156
  window.Plotly.relayout(this.container, { width, height });
30657
31157
  }
30658
31158
  after_layout() {
@@ -30678,6 +31178,13 @@ ${namesToRegister
30678
31178
  }
30679
31179
  }, {});
30680
31180
  }
31181
+ // Sizing the plot up front saves the relayout resize_layout would
31182
+ // otherwise issue after every update.
31183
+ const size = this._rendered ? this._plot_size() : null;
31184
+ if (size != null) {
31185
+ newLayout.width ??= size[0];
31186
+ newLayout.height ??= size[1];
31187
+ }
30681
31188
  return newLayout;
30682
31189
  }
30683
31190
  _install_callbacks() {
@@ -30698,6 +31205,10 @@ ${namesToRegister
30698
31205
  });
30699
31206
  // - plotly_restyle
30700
31207
  this.container.on("plotly_restyle", (eventData) => {
31208
+ // Echoing a restyle sent by Python could arrive after a newer update and revert it
31209
+ if (this._model_restyles > 0) {
31210
+ return;
31211
+ }
30701
31212
  this.model.restyle_data = filterEventData(this.container, eventData, "restyle");
30702
31213
  this._updateViewportProperty();
30703
31214
  });
@@ -30761,26 +31272,32 @@ ${namesToRegister
30761
31272
  }
30762
31273
  const data = this._trace_data();
30763
31274
  const newLayout = this._layout_data();
31275
+ const { config, frames } = this.model;
30764
31276
  this._reacting = true;
30765
- if (new_plot) {
30766
- const obj = { data, layout: newLayout, config: this.model.config, frames: this.model.frames };
30767
- await window.Plotly.newPlot(this.container, obj);
30768
- }
30769
- else {
30770
- await window.Plotly.react(this.container, data, newLayout, this.model.config);
30771
- if (this.model.frames != null) {
30772
- await window.Plotly.addFrames(this.container, this.model.frames);
31277
+ try {
31278
+ if (new_plot || !this._plotInitialized) {
31279
+ await window.Plotly.newPlot(this.container, { data, layout: newLayout, config, frames });
31280
+ }
31281
+ else if (frames !== this._frames) {
31282
+ // Passing frames makes react replace the existing ones
31283
+ await window.Plotly.react(this.container, { data, layout: newLayout, config, frames });
31284
+ }
31285
+ else {
31286
+ await window.Plotly.react(this.container, data, newLayout, config);
31287
+ }
31288
+ this._frames = frames;
31289
+ this._updateSetViewportFunction();
31290
+ this._updateViewportProperty();
31291
+ if (!this._plotInitialized) {
31292
+ this._install_callbacks();
31293
+ }
31294
+ else if (!_isHidden(this.container)) {
31295
+ this.resize_layout();
30773
31296
  }
30774
31297
  }
30775
- this._updateSetViewportFunction();
30776
- this._updateViewportProperty();
30777
- if (!this._plotInitialized) {
30778
- this._install_callbacks();
30779
- }
30780
- else if (!_isHidden(this.container)) {
30781
- window.Plotly.Plots.resize(this.container);
31298
+ finally {
31299
+ this._reacting = false;
30782
31300
  }
30783
- this._reacting = false;
30784
31301
  this._plotInitialized = true;
30785
31302
  }
30786
31303
  _get_trace(index, update) {
@@ -31300,7 +31817,7 @@ ${namesToRegister
31300
31817
  }
31301
31818
  exports.RadioButtonGroup = RadioButtonGroup;
31302
31819
  },
31303
- "e74ecd40bb": /* models/react_component.js */ function _(require, module, exports, __esModule, __esExport) {
31820
+ "da0e69965d": /* models/react_component.js */ function _(require, module, exports, __esModule, __esExport) {
31304
31821
  __esModule();
31305
31822
  const build_views_1 = require("@bokehjs/core/build_views");
31306
31823
  const view_1 = require("@bokehjs/core/view");
@@ -31308,7 +31825,7 @@ ${namesToRegister
31308
31825
  const array_1 = require("@bokehjs/core/util/array");
31309
31826
  const assert_1 = require("@bokehjs/core/util/assert");
31310
31827
  const types_1 = require("@bokehjs/core/util/types");
31311
- const reactive_esm_1 = require("f3226cbf82") /* ./reactive_esm */;
31828
+ const reactive_esm_1 = require("8e484b67b0") /* ./reactive_esm */;
31312
31829
  class HostedStyleSheet extends dom_1.InlineStyleSheet {
31313
31830
  persistent;
31314
31831
  host_id;
@@ -31385,7 +31902,10 @@ ${namesToRegister
31385
31902
  return this.model.use_shadow_dom || !(this.parent instanceof ReactComponentView);
31386
31903
  }
31387
31904
  render_esm() {
31388
- if (this.model.compiled === null || this.model.render_module === null || this.container == null) {
31905
+ // A removed view is never mounted and has already settled its promise in
31906
+ // `remove()`, so a new one, e.g. from a parent re-rendering a stale child
31907
+ // view, would block the root's `ready` for good.
31908
+ if (this.is_destroyed || this.model.compiled === null || this.model.render_module === null || this.container == null) {
31389
31909
  return;
31390
31910
  }
31391
31911
  this._rendered = false;
@@ -31948,6 +32468,61 @@ export default {React, createRoot}`;
31948
32468
  function css_class_name(class_name) {
31949
32469
  return class_name.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
31950
32470
  }
32471
+ // A repeated model shares one view, whose element can only be mounted once.
32472
+ function unique_models(models) {
32473
+ const seen = new Set();
32474
+ return models.filter((model) => {
32475
+ if (seen.has(model.id)) {
32476
+ return false;
32477
+ }
32478
+ seen.add(model.id);
32479
+ return true;
32480
+ });
32481
+ }
32482
+ function model_value(model, attr) {
32483
+ const prop = model.property(attr);
32484
+ return prop.is_unset ? undefined : prop.get_value();
32485
+ }
32486
+ /**
32487
+ * Binds a model property to React through `useSyncExternalStore`, so the
32488
+ * model is the only source of truth: the setter writes to the model and every
32489
+ * render reads the model's current value, including changes that landed
32490
+ * before the subscription was registered.
32491
+ */
32492
+ function use_model_state(React, react_proxy, prop, model, attr) {
32493
+ const subscribe = React.useCallback((notify) => {
32494
+ react_proxy.on(prop, notify, true);
32495
+ return () => react_proxy.off(prop, notify);
32496
+ }, [model, prop]);
32497
+ const value = React.useSyncExternalStore(subscribe, () => model_value(model, attr));
32498
+ const setValue = React.useCallback((update) => {
32499
+ const current = model_value(model, attr);
32500
+ const next = typeof update === "function" ? update(current) : update;
32501
+ if (!Object.is(next, current)) {
32502
+ model.setv({ [attr]: next });
32503
+ }
32504
+ }, [model, attr]);
32505
+ return [value, setValue];
32506
+ }
32507
+ /**
32508
+ * A param.Event is a trigger, not a value, so it is exposed as a local
32509
+ * counter that increments each time the event fires and is never written
32510
+ * back to the model.
32511
+ */
32512
+ function use_event_state(React, react_proxy, prop, model, attr) {
32513
+ const [count, setCount] = React.useState(() => model_value(model, attr));
32514
+ React.useEffect(() => {
32515
+ const cb = () => {
32516
+ if (model_value(model, attr)) {
32517
+ setCount((v) => v + 1);
32518
+ model.setv({ [attr]: false });
32519
+ }
32520
+ };
32521
+ react_proxy.on(prop, cb, true);
32522
+ return () => react_proxy.off(prop, cb);
32523
+ }, [model, prop]);
32524
+ return [count, setCount];
32525
+ }
31951
32526
  function react_model_proxy(view, libs, Child) {
31952
32527
  const { React } = libs;
31953
32528
  const react_proxy = new Proxy(view, {
@@ -31975,29 +32550,10 @@ export default {React, createRoot}`;
31975
32550
  if (model == null || model.attributes == null || !(attr in model.attributes)) {
31976
32551
  throw ReferenceError(`Could not resolve ${prop} on ${target.model.class_name}`);
31977
32552
  }
31978
- const [value, setValue] = React.useState(model.attributes[attr]);
31979
- React.useEffect(() => {
31980
- const cb = () => {
31981
- if (target.model.events.includes(attr)) {
31982
- model.attributes[attr] && (setValue((v) => v + 1) || model.setv({ [attr]: false }));
31983
- }
31984
- else {
31985
- setValue(model.attributes[attr]);
31986
- }
31987
- };
31988
- react_proxy.on(prop, cb, true);
31989
- return () => react_proxy.off(prop, cb);
31990
- }, []);
31991
- const initialized = React.useRef(false);
31992
- React.useEffect(() => {
31993
- if (!target.model.events.includes(attr) && initialized.current) {
31994
- model.setv({ [attr]: value });
31995
- }
31996
- else {
31997
- initialized.current = true;
31998
- }
31999
- }, [value]);
32000
- return [value, setValue];
32553
+ if (target.model.events.includes(attr)) {
32554
+ return use_event_state(React, react_proxy, prop, model, attr);
32555
+ }
32556
+ return use_model_state(React, react_proxy, prop, model, attr);
32001
32557
  };
32002
32558
  }
32003
32559
  else if (name === "get_child") {
@@ -32007,12 +32563,12 @@ export default {React, createRoot}`;
32007
32563
  if (!(0, types_1.isArray)(value)) {
32008
32564
  return React.createElement(Child, { parent: target, name: child });
32009
32565
  }
32010
- const [children_state, set_children] = React.useState(() => value.map((model) => React.createElement(Child, { parent: target, name: child, key: model.id, id: model.id, model })));
32566
+ const [children_state, set_children] = React.useState(() => unique_models(value).map((model) => React.createElement(Child, { parent: target, name: child, key: model.id, id: model.id, model })));
32011
32567
  React.useEffect(() => {
32012
32568
  // Compares against the latest state, not the closure's initial
32013
32569
  // one, and catches lists that only shrank.
32014
32570
  const cb = () => {
32015
- const current_models = data_model.attributes[child];
32571
+ const current_models = unique_models(data_model.attributes[child]);
32016
32572
  set_children((previous) => {
32017
32573
  if (previous.length === current_models.length &&
32018
32574
  current_models.every((model, i) => model.id === previous[i].props.id)) {
@@ -32149,7 +32705,7 @@ ${compiled}`;
32149
32705
  }
32150
32706
  exports.ReactComponent = ReactComponent;
32151
32707
  },
32152
- "61cc258c24": /* models/reactive_html.js */ function _(require, module, exports, __esModule, __esExport) {
32708
+ "44b7d77ba5": /* models/reactive_html.js */ function _(require, module, exports, __esModule, __esExport) {
32153
32709
  __esModule();
32154
32710
  const preact_1 = require("ed32986312") /* preact */;
32155
32711
  const hooks_1 = require("691acbd345") /* preact/hooks */;
@@ -32161,9 +32717,9 @@ ${compiled}`;
32161
32717
  const object_1 = require("@bokehjs/core/util/object");
32162
32718
  const model_1 = require("@bokehjs/model");
32163
32719
  const ui_element_1 = require("@bokehjs/models/ui/ui_element");
32164
- const data_1 = require("be689f0377") /* ./data */;
32720
+ const data_1 = require("ce212d2be6") /* ./data */;
32165
32721
  const event_to_object_1 = require("e5a0036205") /* ./event-to-object */;
32166
- const html_1 = require("9012c2f5ae") /* ./html */;
32722
+ const html_1 = require("e40e09e4dd") /* ./html */;
32167
32723
  const layout_1 = require("00beb93e38") /* ./layout */;
32168
32724
  const util_1 = require("aa07eb54cc") /* ./util */;
32169
32725
  function serialize_attrs(attrs) {
@@ -32394,7 +32950,7 @@ ${compiled}`;
32394
32950
  }
32395
32951
  _render_child(child, el) {
32396
32952
  if ((0, types_1.isString)(child)) {
32397
- el.innerHTML = (0, html_1.html_decode)(child) ?? child;
32953
+ el.innerHTML = child;
32398
32954
  }
32399
32955
  else {
32400
32956
  const view = this._child_views.get(child);
@@ -32459,6 +33015,7 @@ ${compiled}`;
32459
33015
  let htm = literal.replace(/[`]/g, "\\$&");
32460
33016
  let collected_callbacks = "";
32461
33017
  const methods = [];
33018
+ const targets = {};
32462
33019
  for (const [el_name, callbacks] of (0, object_1.entries)(this.model.callbacks)) {
32463
33020
  for (const [cb, method] of callbacks) {
32464
33021
  let definition;
@@ -32479,21 +33036,9 @@ ${compiled}`;
32479
33036
  `;
32480
33037
  }
32481
33038
  else {
32482
- definition = `
32483
- const ${method} = (event) => {
32484
- let elname = "${el_name}"
32485
- if (RegExp("\{\{.*loop\.index.*\}\}").test(elname)) {
32486
- const pattern = RegExp(elname.replace(/\{\{(.+?)\}\}/g, String.fromCharCode(92) + "d+"))
32487
- for (const p of event.path) {
32488
- if (pattern.exec(p.id) != null) {
32489
- elname = p.id.split("-").slice(null, -1).join("-")
32490
- break
32491
- }
32492
- }
32493
- }
32494
- view._send_event(elname, "${cb}", event)
32495
- }
32496
- `;
33039
+ targets[method] = targets[method] ?? [];
33040
+ targets[method].push([el_name, cb]);
33041
+ continue;
32497
33042
  }
32498
33043
  if (methods.indexOf(method) > -1) {
32499
33044
  continue;
@@ -32502,6 +33047,33 @@ ${compiled}`;
32502
33047
  collected_callbacks += definition;
32503
33048
  }
32504
33049
  }
33050
+ for (const [method, method_targets] of (0, object_1.entries)(targets)) {
33051
+ // Nodes sharing a callback must resolve the node from the event
33052
+ // path, since only a single function is defined per method name.
33053
+ collected_callbacks += `
33054
+ const ${method} = (event) => {
33055
+ const targets = ${JSON.stringify(method_targets)}
33056
+ let [elname, cb] = targets[0]
33057
+ // currentTarget is the node the listener is attached to, which
33058
+ // differs from the innermost path element for nested nodes.
33059
+ const candidates = [event.currentTarget, ...event.composedPath()]
33060
+ const typed = targets.filter(([, c]) => c === "on" + event.type)
33061
+ const options = typed.length ? typed : targets
33062
+ for (const p of candidates) {
33063
+ const match = p == null ? null : options.find(([name]) => {
33064
+ const pattern = name.replace(/\\{\\{(.+?)\\}\\}/g, String.fromCharCode(92) + "d+")
33065
+ return RegExp("^" + pattern + "(-[0-9]+)*-[^-]+$").test(p.id)
33066
+ })
33067
+ if (match != null) {
33068
+ elname = p.id.split("-").slice(null, -1).join("-")
33069
+ cb = match[1]
33070
+ break
33071
+ }
33072
+ }
33073
+ view._send_event(elname, cb, event)
33074
+ }
33075
+ `;
33076
+ }
32505
33077
  htm = htm
32506
33078
  .replaceAll("${model.", "$-{model.")
32507
33079
  .replaceAll("${", "${data.")
@@ -33500,7 +34072,7 @@ ${compiled}`;
33500
34072
  }
33501
34073
  exports.State = State;
33502
34074
  },
33503
- "3cba64cc82": /* models/tabs.js */ function _(require, module, exports, __esModule, __esExport) {
34075
+ "c5ac7daa0f": /* models/tabs.js */ function _(require, module, exports, __esModule, __esExport) {
33504
34076
  __esModule();
33505
34077
  const tslib_1 = require("tslib");
33506
34078
  const tabs = tslib_1.__importStar(require("@bokehjs/styles/tabs.css"));
@@ -33522,8 +34094,19 @@ ${compiled}`;
33522
34094
  element.setAttribute("aria-hidden", "true");
33523
34095
  }
33524
34096
  class TabsView extends tabs_1.TabsView {
34097
+ _children_update = Promise.resolve();
34098
+ // build_views is not reentrant
34099
+ update_children() {
34100
+ const update = this._children_update.then(() => super.update_children());
34101
+ this._children_update = update.catch(() => { });
34102
+ return update;
34103
+ }
33525
34104
  connect_signals() {
33526
34105
  super.connect_signals();
34106
+ this.on_transitive_change(this.model.properties.tabs, () => {
34107
+ this._update_headers();
34108
+ this.update_active();
34109
+ }, { signal: (tab) => tab.properties.title.change });
33527
34110
  let view = this;
33528
34111
  while (view != null) {
33529
34112
  if (view.model.type.endsWith("Tabs")) {
@@ -33980,7 +34563,7 @@ ${compiled}`;
33980
34563
  },
33981
34564
  "49efbd99ad": /* models/toggle_icon.js */ function _(require, module, exports, __esModule, __esExport) {
33982
34565
  __esModule();
33983
- const icon_1 = require("bf77ad153d") /* ./icon */;
34566
+ const icon_1 = require("ac804884fa") /* ./icon */;
33984
34567
  class ToggleIconView extends icon_1.ClickableIconView {
33985
34568
  *controls() { }
33986
34569
  click() {
@@ -34320,14 +34903,14 @@ ${compiled}`;
34320
34903
  }
34321
34904
  exports.TrendIndicator = TrendIndicator;
34322
34905
  },
34323
- "03e8d20a08": /* models/vega.js */ function _(require, module, exports, __esModule, __esExport) {
34906
+ "f71ac626f9": /* models/vega.js */ function _(require, module, exports, __esModule, __esExport) {
34324
34907
  __esModule();
34325
34908
  const dom_1 = require("@bokehjs/core/dom");
34326
34909
  const bokeh_events_1 = require("@bokehjs/core/bokeh_events");
34327
34910
  const types_1 = require("@bokehjs/core/util/types");
34328
34911
  const layout_dom_1 = require("@bokehjs/models/layouts/layout_dom");
34329
34912
  const layout_1 = require("00beb93e38") /* ./layout */;
34330
- const resources_1 = require("3ec7d872e2") /* ./resources */;
34913
+ const resources_1 = require("133ce95cfa") /* ./resources */;
34331
34914
  const debounce_1 = require("99a25e6992") /* debounce */;
34332
34915
  class VegaEvent extends bokeh_events_1.ModelEvent {
34333
34916
  data;
@@ -34346,9 +34929,13 @@ ${compiled}`;
34346
34929
  class VegaPlotView extends layout_dom_1.LayoutDOMView {
34347
34930
  vega_view;
34348
34931
  container;
34349
- _callbacks;
34350
- _connected;
34932
+ _connected = new Set();
34933
+ _listeners = new Set();
34934
+ _dirty_sources = new Set();
34935
+ _data_update = null;
34351
34936
  _replot;
34937
+ _replot_pending = false;
34938
+ _embed_id = 0;
34352
34939
  _resize;
34353
34940
  _rendered = false;
34354
34941
  async lazy_initialize() {
@@ -34363,34 +34950,72 @@ ${compiled}`;
34363
34950
  const { data, show_actions, theme, data_sources, events } = this.model.properties;
34364
34951
  this._replot = (0, debounce_1.debounce)(() => this._plot(), 20);
34365
34952
  this.on_change([data, show_actions, theme], () => {
34953
+ this._replot_pending = true;
34366
34954
  this._replot();
34367
34955
  });
34368
34956
  this.on_change(data_sources, () => this._connect_sources());
34369
- this.on_change(events, () => {
34370
- for (const event of this.model.events) {
34371
- if (this._callbacks.indexOf(event) > -1) {
34372
- continue;
34373
- }
34374
- this._callbacks.push(event);
34375
- const callback = (name, value) => this._dispatch_event(name, value);
34376
- const timeout = this.model.throttle[event] || 20;
34377
- this.vega_view.addSignalListener(event, (0, debounce_1.debounce)(callback, timeout, false));
34378
- }
34379
- });
34380
- this._connected = [];
34957
+ this.on_change(events, () => this._add_listeners());
34381
34958
  this._connect_sources();
34382
34959
  }
34383
34960
  _connect_sources() {
34384
- for (const ds in this.model.data_sources) {
34385
- const cds = this.model.data_sources[ds];
34386
- if (this._connected.indexOf(ds) < 0) {
34387
- this.connect(cds.properties.data.change, () => this._replot());
34388
- this._connected.push(ds);
34961
+ for (const name in this.model.data_sources) {
34962
+ const cds = this.model.data_sources[name];
34963
+ if (!this._connected.has(cds)) {
34964
+ this.connect(cds.properties.data.change, () => this._source_changed(name));
34965
+ this._connected.add(cds);
34389
34966
  }
34390
34967
  }
34391
34968
  }
34969
+ /**
34970
+ * Pushes changed datasets into the existing Vega View rather than
34971
+ * recompiling the spec, coalescing changes made in the same patch.
34972
+ */
34973
+ _source_changed(name) {
34974
+ this._dirty_sources.add(name);
34975
+ if (this._data_update == null) {
34976
+ this._data_update = Promise.resolve().then(() => {
34977
+ this._data_update = null;
34978
+ this._update_data();
34979
+ });
34980
+ }
34981
+ }
34982
+ _update_data() {
34983
+ if (this._dirty_sources.size === 0 || this._replot_pending) {
34984
+ this._dirty_sources.clear();
34985
+ return;
34986
+ }
34987
+ const view = this.vega_view;
34988
+ if (view == null) {
34989
+ // Applied once the embed in flight resolves, or fetched by render()
34990
+ return;
34991
+ }
34992
+ const names = [...this._dirty_sources];
34993
+ this._dirty_sources.clear();
34994
+ for (const name of names) {
34995
+ const cds = this.model.data_sources[name];
34996
+ if (cds == null) {
34997
+ continue;
34998
+ }
34999
+ const values = this._fetch_dataset(cds);
35000
+ const dataset = this._store_values(name, values);
35001
+ try {
35002
+ view.data(dataset, values);
35003
+ }
35004
+ catch {
35005
+ // The dataset is not part of the compiled dataflow (e.g. the spec
35006
+ // was restructured), so fall back to re-embedding the spec.
35007
+ this._replot_pending = true;
35008
+ this._replot();
35009
+ return;
35010
+ }
35011
+ }
35012
+ view.runAsync();
35013
+ }
34392
35014
  remove() {
35015
+ // Also discards the result of an embed still in flight
35016
+ this._embed_id++;
34393
35017
  this.vega_view?.finalize();
35018
+ this.vega_view = null;
34394
35019
  super.remove();
34395
35020
  }
34396
35021
  _dispatch_event(name, value) {
@@ -34413,22 +35038,40 @@ ${compiled}`;
34413
35038
  }
34414
35039
  this.model.trigger_event(new VegaEvent({ type: name, value }));
34415
35040
  }
34416
- _fetch_datasets() {
34417
- const datasets = {};
34418
- for (const ds in this.model.data_sources) {
34419
- const cds = this.model.data_sources[ds];
34420
- const data = [];
34421
- const columns = cds.columns();
34422
- for (let i = 0; i < cds.get_length(); i++) {
34423
- const item = {};
34424
- for (const column of columns) {
34425
- item[column] = cds.data[column][i];
35041
+ _fetch_dataset(cds) {
35042
+ const data = [];
35043
+ const columns = cds.columns();
35044
+ for (let i = 0; i < cds.get_length(); i++) {
35045
+ const item = {};
35046
+ for (const column of columns) {
35047
+ item[column] = cds.data[column][i];
35048
+ }
35049
+ data.push(item);
35050
+ }
35051
+ return data;
35052
+ }
35053
+ /**
35054
+ * Writes the values of a data source into the spec, returning the name
35055
+ * of the dataset they end up in once the spec is compiled by Vega.
35056
+ */
35057
+ _store_values(name, values) {
35058
+ const { data } = this.model;
35059
+ if (name === "data" && data.data != null && !(0, types_1.isArray)(data.data)) {
35060
+ data.data.values = values;
35061
+ return data.data.name ?? "source_0";
35062
+ }
35063
+ if (data.data != null) {
35064
+ const data_objs = (0, types_1.isArray)(data.data) ? data.data : [data.data];
35065
+ for (const d of data_objs) {
35066
+ if (d.name === name) {
35067
+ d.values = values;
35068
+ return name;
34426
35069
  }
34427
- data.push(item);
34428
35070
  }
34429
- datasets[ds] = data;
34430
35071
  }
34431
- return datasets;
35072
+ data.datasets = data.datasets ?? {};
35073
+ data.datasets[name] = values;
35074
+ return name;
34432
35075
  }
34433
35076
  get child_models() {
34434
35077
  return [];
@@ -34438,44 +35081,52 @@ ${compiled}`;
34438
35081
  this._rendered = false;
34439
35082
  this.container = (0, dom_1.div)();
34440
35083
  (0, layout_1.set_size)(this.container, this.model);
34441
- this._callbacks = [];
34442
35084
  this._plot();
34443
35085
  this.shadow_el.append(this.container);
34444
35086
  }
34445
35087
  _plot() {
35088
+ this._replot_pending = false;
34446
35089
  const data = this.model.data;
34447
35090
  if ((data == null) || !window.vegaEmbed) {
34448
35091
  return;
34449
35092
  }
34450
- if (this.model.data_sources && (Object.keys(this.model.data_sources).length > 0)) {
34451
- const datasets = this._fetch_datasets();
34452
- if ("data" in datasets) {
34453
- data.data.values = datasets.data;
34454
- delete datasets.data;
34455
- }
34456
- if (data.data != null) {
34457
- const data_objs = (0, types_1.isArray)(data.data) ? data.data : [data.data];
34458
- for (const d of data_objs) {
34459
- if (d.name in datasets) {
34460
- d.values = datasets[d.name];
34461
- delete datasets[d.name];
34462
- }
34463
- }
34464
- }
34465
- this.model.data.datasets = datasets;
35093
+ for (const name in this.model.data_sources) {
35094
+ this._store_values(name, this._fetch_dataset(this.model.data_sources[name]));
34466
35095
  }
35096
+ this._dirty_sources.clear();
34467
35097
  const config = { actions: this.model.show_actions, theme: this.model.theme };
35098
+ // vegaEmbed replaces the container contents but leaves the previous
35099
+ // View (and its timers and listeners) running, so finalize it here.
35100
+ this.vega_view?.finalize();
35101
+ this.vega_view = null;
35102
+ this._listeners.clear();
35103
+ const embed_id = ++this._embed_id;
34468
35104
  window.vegaEmbed(this.container, this.model.data, config).then((result) => {
35105
+ if (embed_id !== this._embed_id) {
35106
+ result.view.finalize();
35107
+ return;
35108
+ }
34469
35109
  this.vega_view = result.view;
34470
35110
  this._resize = (0, debounce_1.debounce)(() => this.resize_view(result.view), 50);
34471
- const callback = (name, value) => this._dispatch_event(name, value);
34472
- for (const event of this.model.events) {
34473
- this._callbacks.push(event);
34474
- const timeout = this.model.throttle[event] || 20;
34475
- this.vega_view.addSignalListener(event, (0, debounce_1.debounce)(callback, timeout, false));
34476
- }
35111
+ this._add_listeners();
35112
+ this._update_data();
34477
35113
  });
34478
35114
  }
35115
+ _add_listeners() {
35116
+ const view = this.vega_view;
35117
+ if (view == null) {
35118
+ return;
35119
+ }
35120
+ for (const event of this.model.events) {
35121
+ if (this._listeners.has(event)) {
35122
+ continue;
35123
+ }
35124
+ this._listeners.add(event);
35125
+ const callback = (name, value) => this._dispatch_event(name, value);
35126
+ const timeout = this.model.throttle[event] || 20;
35127
+ view.addSignalListener(event, (0, debounce_1.debounce)(callback, timeout, false));
35128
+ }
35129
+ }
34479
35130
  after_layout() {
34480
35131
  super.after_layout();
34481
35132
  if (this.vega_view != null) {
@@ -36636,5 +37287,5 @@ ${compiled}`;
36636
37287
  util_1.vtkns.FullScreenRenderWindowSynchronized = FullScreenRenderWindowSynchronized;
36637
37288
  }
36638
37289
  },
36639
- }, "4e90918c0a", {"index":"4e90918c0a","models/index":"36236053e8","models/ace":"7b034b2ba5","models/layout":"00beb93e38","models/resources":"3ec7d872e2","models/util":"aa07eb54cc","models/anywidget_component":"f4bc4e23b4","models/reactive_esm":"f3226cbf82","models/event-to-object":"e5a0036205","models/html":"9012c2f5ae","styles/models/html.css":"9b8139e439","styles/models/esm.css":"727a14f76b","models/audio":"fdf76c2b8b","models/browser":"f25f215a58","models/button":"29120fca73","models/button_icon":"7e77f478cb","models/icon":"bf77ad153d","models/card":"a668a42a0f","models/column":"3967d78fb5","styles/models/card.css":"6342ac8e26","models/checkbox_button_group":"138d8a2ed1","models/chatarea_input":"a9ce3554f5","models/textarea_input":"2f8fe6797e","models/comm_manager":"f8f420cdc3","models/customselect":"519009caed","models/multiselect":"8653ba687c","models/tabulator":"381057489b","models/cell_formatters":"254387d0dc","models/data":"be689f0377","styles/models/tabulator.css":"b0fdc4e99b","models/datetime_picker":"7408873be7","models/datetime_slider":"47671196f6","models/deckgl":"609f06c18b","models/lumagl":"16d69e2b49","models/tooltips":"f8f8ea4284","models/discrete_player":"eee856b107","models/player":"ed49986321","models/echarts":"df5e7d36e5","models/feed":"56255f9c11","models/file_download":"a7746def5a","models/file_dropper":"bff8eeed36","styles/models/filedropper.css":"c03dd3c931","models/ipywidget":"fd4c3f6bc4","models/json":"19285971d9","models/jsoneditor":"372d3e3a52","styles/models/jsoneditor.css":"317a12d360","models/katex":"052b7b0298","models/location":"2116677c2d","models/mathjax":"07688254ed","models/modal":"37ed29726e","styles/models/modal.css":"be4b4352c6","models/pdf":"87a65d7fb5","models/perspective":"7a00e4d590","styles/models/perspective.css":"2e2913ea54","models/plotly":"39230f6818","styles/models/plotly.css":"3d56c75186","models/progress":"443fb5cf42","models/quill":"3df70ba3b3","models/radio_button_group":"08a22fed1a","models/react_component":"e74ecd40bb","models/reactive_html":"61cc258c24","models/singleselect":"3766e0c917","models/speech_to_text":"95fa78f501","models/state":"188544eb0b","models/tabs":"3cba64cc82","models/terminal":"4fecff5c68","models/text_input":"e9d16ed037","models/text_to_speech":"1fb38b62cd","models/time_picker":"5e05e2d651","models/toggle_icon":"49efbd99ad","models/tooltip_icon":"aad04f1876","models/trend":"eb967020e9","models/vega":"03e8d20a08","models/video":"e8830cc759","styles/models/video.css":"dfe21e6f1b","models/videostream":"73b5826147","models/vizzu":"e8cb25b7b8","models/vtk/index":"c51f25e2a7","models/vtk/vtkjs":"f0476173e2","models/vtk/vtklayout":"d44e946ae8","models/vtk/util":"df9946ff52","models/vtk/vtkcolorbar":"db98967aab","models/vtk/vtkaxes":"a9b2ad3ad4","models/vtk/vtkvolume":"2d0f1e4d96","models/vtk/vtksynchronized":"04077eec70","models/vtk/panel_fullscreen_renwin_sync":"5e89c7b3eb"}, {});});
37290
+ }, "4e90918c0a", {"index":"4e90918c0a","models/index":"36236053e8","models/ace":"7b034b2ba5","models/layout":"00beb93e38","models/resources":"133ce95cfa","models/util":"aa07eb54cc","models/anywidget_component":"f4bc4e23b4","models/reactive_esm":"8e484b67b0","models/event-to-object":"e5a0036205","models/html":"e40e09e4dd","styles/models/html.css":"9b8139e439","styles/models/esm.css":"727a14f76b","models/audio":"fdf76c2b8b","models/browser":"f25f215a58","models/button":"29120fca73","models/button_icon":"7e77f478cb","models/icon":"ac804884fa","models/card":"a668a42a0f","models/column":"3967d78fb5","styles/models/card.css":"6342ac8e26","models/checkbox_button_group":"138d8a2ed1","models/chatarea_input":"a9ce3554f5","models/textarea_input":"2f8fe6797e","models/comm_manager":"5f6e6991cc","models/customselect":"519009caed","models/multiselect":"8653ba687c","models/tabulator":"ab964e46db","models/cell_formatters":"254387d0dc","models/data":"ce212d2be6","styles/models/tabulator.css":"b0fdc4e99b","models/datetime_picker":"7408873be7","models/datetime_slider":"47671196f6","models/deckgl":"609f06c18b","models/lumagl":"16d69e2b49","models/tooltips":"f8f8ea4284","models/discrete_player":"eee856b107","models/player":"ed49986321","models/echarts":"df5e7d36e5","models/feed":"56255f9c11","models/file_download":"a7746def5a","models/file_dropper":"bff8eeed36","styles/models/filedropper.css":"c03dd3c931","models/ipywidget":"fd4c3f6bc4","models/json":"19285971d9","models/jsoneditor":"372d3e3a52","styles/models/jsoneditor.css":"317a12d360","models/katex":"052b7b0298","models/location":"cc871e1a06","models/mathjax":"07688254ed","models/modal":"37ed29726e","styles/models/modal.css":"be4b4352c6","models/pdf":"87a65d7fb5","models/perspective":"7a00e4d590","styles/models/perspective.css":"2e2913ea54","models/plotly":"736be77caa","styles/models/plotly.css":"3d56c75186","models/progress":"443fb5cf42","models/quill":"3df70ba3b3","models/radio_button_group":"08a22fed1a","models/react_component":"da0e69965d","models/reactive_html":"44b7d77ba5","models/singleselect":"3766e0c917","models/speech_to_text":"95fa78f501","models/state":"188544eb0b","models/tabs":"c5ac7daa0f","models/terminal":"4fecff5c68","models/text_input":"e9d16ed037","models/text_to_speech":"1fb38b62cd","models/time_picker":"5e05e2d651","models/toggle_icon":"49efbd99ad","models/tooltip_icon":"aad04f1876","models/trend":"eb967020e9","models/vega":"f71ac626f9","models/video":"e8830cc759","styles/models/video.css":"dfe21e6f1b","models/videostream":"73b5826147","models/vizzu":"e8cb25b7b8","models/vtk/index":"c51f25e2a7","models/vtk/vtkjs":"f0476173e2","models/vtk/vtklayout":"d44e946ae8","models/vtk/util":"df9946ff52","models/vtk/vtkcolorbar":"db98967aab","models/vtk/vtkaxes":"a9b2ad3ad4","models/vtk/vtkvolume":"2d0f1e4d96","models/vtk/vtksynchronized":"04077eec70","models/vtk/panel_fullscreen_renwin_sync":"5e89c7b3eb"}, {});});
36640
37291
  //# sourceMappingURL=panel.js.map