@yuneta/gobj-ui 7.26.13 → 7.26.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -130,8 +130,18 @@ checkout and publish.
130
130
  npm install
131
131
  npm run build # vite -> dist/ (ES/CJS/UMD/IIFE, min + non-min)
132
132
  npm test # vitest (v2/main only; v1 has no test target)
133
+ npm run qa-history # the shell's browser history in REAL Chromium and Firefox
133
134
  ```
134
135
 
136
+ `npm run qa-history` (`scripts/qa-history.mjs`) starts the test-app's vite
137
+ dev server and drives its `/history` chapter: a panel with no dock and
138
+ `keep_on_navigate` over a view that writes its position with a `replace`.
139
+ Back must close the panel and keep the position, the panel's x must keep it,
140
+ and a dialog action that closes the panel and navigates in the same turn must
141
+ keep the navigation. The unit tests drive a MODEL of the history; this is the
142
+ check in the browsers themselves. Run it after any change to the overlay
143
+ history of `C_YUI_SHELL`. Playwright and its browsers come from the test-app.
144
+
135
145
  `dist/` is gitignored. v1 consumers get `dist/` from the **published** npm
136
146
  tarball; v2 consumers import source files by specifier, whether they resolve
137
147
  them from the checkout or from the tarball's `src/`. Rebuild `dist/` to
@@ -978,6 +978,8 @@ var PRIVATE_DATA$22 = {
978
978
  markers_after_hashchange: false,
979
979
  restore_hash: "",
980
980
  skip_hash: "",
981
+ deferred_route: "",
982
+ deferred_timer: null,
981
983
  popstate_handler: null,
982
984
  avatar_provider: null,
983
985
  avatar_nodes: [],
@@ -1085,14 +1087,22 @@ function mt_start$20(gobj) {
1085
1087
  if (top.marker_pending || top.no_marker) return;
1086
1088
  if (window.location.hash !== top.hash && window.location.hash !== top.below_hash) return;
1087
1089
  let st = ev && ev.state;
1088
- if (st && st.__yui_overlay__ === top.id) return;
1089
- if (st && st.__yui_overlay__ > top.id && !p.overlay_stack.some((e) => e.id === st.__yui_overlay__)) return;
1090
+ if (!st) return;
1091
+ if (st.__yui_overlay__ === top.id) return;
1092
+ if (st.__yui_overlay__ > top.id && !p.overlay_stack.some((e) => e.id === st.__yui_overlay__)) return;
1090
1093
  p.overlay_stack.pop();
1091
1094
  try {
1092
1095
  top.close();
1093
1096
  } catch (e) {
1094
1097
  (0, _yuneta_gobj_js.log_warning)(`C_YUI_SHELL: overlay close on Back failed: ${e}`);
1095
1098
  }
1099
+ if (typeof top.below_hash === "string" && top.hash !== top.below_hash && window.location.hash === top.below_hash) try {
1100
+ window.history.replaceState(window.history.state, "", top.hash);
1101
+ p.skip_hash = top.hash;
1102
+ p.last_hash = top.hash;
1103
+ } catch (e) {
1104
+ (0, _yuneta_gobj_js.log_warning)(`C_YUI_SHELL: restoring '${top.hash}' failed: ${e}`);
1105
+ }
1096
1106
  };
1097
1107
  window.addEventListener("popstate", priv.popstate_handler);
1098
1108
  }
@@ -1138,6 +1148,8 @@ function mt_stop$20(gobj) {
1138
1148
  priv.markers_after_hashchange = false;
1139
1149
  priv.restore_hash = "";
1140
1150
  priv.skip_hash = "";
1151
+ priv.deferred_route = "";
1152
+ clear_deferred_timer(gobj);
1141
1153
  if (priv.keydown_handler) {
1142
1154
  window.removeEventListener("keydown", priv.keydown_handler);
1143
1155
  priv.keydown_handler = null;
@@ -2547,6 +2559,11 @@ function push_overlay_history(gobj, close, opts) {
2547
2559
  function push_overlay_marker(gobj, entry) {
2548
2560
  let priv = gobj.priv;
2549
2561
  entry.below_hash = window.location.hash;
2562
+ if (window.history.state === null) try {
2563
+ window.history.replaceState({ __yui_below__: entry.id }, "");
2564
+ } catch (e) {
2565
+ (0, _yuneta_gobj_js.log_warning)(`C_YUI_SHELL: stamping the entry under an overlay failed: ${e}`);
2566
+ }
2550
2567
  try {
2551
2568
  window.history.pushState({ __yui_overlay__: entry.id }, "");
2552
2569
  } catch (e) {
@@ -2563,6 +2580,35 @@ function drop_expected_pops(gobj) {
2563
2580
  (0, _yuneta_gobj_js.log_warning)(`C_YUI_SHELL: ${priv.expected_pops} history.back() of ours did not land on '${priv.expected_pop_hash}' (now '${window.location.hash}'), dropped`);
2564
2581
  priv.expected_pops = 0;
2565
2582
  priv.expected_pop_hash = "";
2583
+ clear_deferred_timer(gobj);
2584
+ if (priv.deferred_route) {
2585
+ (0, _yuneta_gobj_js.log_warning)(`C_YUI_SHELL: route '${priv.deferred_route}' waited for that back() and is dropped: the history moved on to '${window.location.hash}'`);
2586
+ priv.deferred_route = "";
2587
+ }
2588
+ }
2589
+ var DEFERRED_ROUTE_WAIT_MS = 1e3;
2590
+ function defer_route(gobj, route) {
2591
+ let priv = gobj.priv;
2592
+ if (priv.deferred_route && priv.deferred_route !== route) (0, _yuneta_gobj_js.log_warning)(`C_YUI_SHELL: route '${priv.deferred_route}' waiting for a back() of ours is replaced by '${route}'`);
2593
+ priv.deferred_route = route;
2594
+ if (!priv.deferred_timer) priv.deferred_timer = window.setTimeout(() => {
2595
+ let p = gobj.priv;
2596
+ if (!p) return;
2597
+ p.deferred_timer = null;
2598
+ if (p.expected_pops === 0) return;
2599
+ (0, _yuneta_gobj_js.log_warning)(`C_YUI_SHELL: ${p.expected_pops} history.back() of ours did not land in ${DEFERRED_ROUTE_WAIT_MS} ms, given up`);
2600
+ p.expected_pops = 0;
2601
+ p.expected_pop_hash = "";
2602
+ p.restore_hash = "";
2603
+ push_pending_markers(gobj);
2604
+ }, DEFERRED_ROUTE_WAIT_MS);
2605
+ }
2606
+ function clear_deferred_timer(gobj) {
2607
+ let priv = gobj.priv;
2608
+ if (priv.deferred_timer) {
2609
+ window.clearTimeout(priv.deferred_timer);
2610
+ priv.deferred_timer = null;
2611
+ }
2566
2612
  }
2567
2613
  function push_pending_markers(gobj) {
2568
2614
  let priv = gobj.priv;
@@ -2573,6 +2619,12 @@ function push_pending_markers(gobj) {
2573
2619
  entry.hash = window.location.hash;
2574
2620
  push_overlay_marker(gobj, entry);
2575
2621
  }
2622
+ clear_deferred_timer(gobj);
2623
+ if (priv.deferred_route) {
2624
+ let route = priv.deferred_route;
2625
+ priv.deferred_route = "";
2626
+ yui_shell_navigate(gobj, route);
2627
+ }
2576
2628
  }
2577
2629
  function overlay_dismissed(gobj, entry) {
2578
2630
  let priv = gobj.priv;
@@ -2696,6 +2748,10 @@ function ac_nav_clicked(gobj, event, kw, src) {
2696
2748
  }
2697
2749
  route = remembered_position(gobj, route);
2698
2750
  if ((0, _yuneta_gobj_js.gobj_read_attr)(gobj, "use_hash") && !route_restores_url(gobj, route)) {
2751
+ if (gobj.priv.expected_pops > 0) {
2752
+ defer_route(gobj, route);
2753
+ return 0;
2754
+ }
2699
2755
  let target_hash = route_to_hash(route);
2700
2756
  if (window.location.hash !== target_hash) window.location.hash = target_hash;
2701
2757
  else navigate_to(gobj, route);
@@ -2935,6 +2991,11 @@ function yui_shell_of(gobj) {
2935
2991
  ************************************************************/
2936
2992
  function yui_shell_navigate(shell_gobj, route, opts) {
2937
2993
  if (!(opts && opts.replace) && (0, _yuneta_gobj_js.gobj_read_attr)(shell_gobj, "use_hash")) {
2994
+ let priv = shell_gobj.priv;
2995
+ if (priv && priv.expected_pops > 0) {
2996
+ defer_route(shell_gobj, route);
2997
+ return;
2998
+ }
2938
2999
  let target_hash = route_to_hash(route);
2939
3000
  if (window.location.hash !== target_hash) {
2940
3001
  window.location.hash = target_hash;
@@ -4962,21 +5023,13 @@ function chip_lead(icon) {
4962
5023
  * trace dumps it), so the window travels in it as its FULL NAME,
4963
5024
  * which the trace can print, and the gobj is the event's src --
4964
5025
  * every sender is the window itself. Up to 7.26.9 the kw carried
4965
- * the gobj; that is still taken, with a warning, for this release.
5026
+ * the gobj; since 7.26.14 that is refused.
4966
5027
  ************************************************************/
4967
- var warned_gobj_in_kw = false;
4968
5028
  function window_of(gobj, event, kw, src) {
4969
5029
  let w = kw && kw.window;
4970
5030
  if ((0, _yuneta_gobj_js.is_gobj)(w)) {
4971
- if (!warned_gobj_in_kw) {
4972
- warned_gobj_in_kw = true;
4973
- (0, _yuneta_gobj_js.log_warning)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: ${event} carries the window gobj in its kw: send {window: gobj_full_name(window)} from the window`);
4974
- }
4975
- if (w !== src) {
4976
- (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: ${event}: window '${(0, _yuneta_gobj_js.gobj_full_name)(w)}' is not the src of the event (${(0, _yuneta_gobj_js.is_gobj)(src) ? (0, _yuneta_gobj_js.gobj_full_name)(src) : String(src)})`);
4977
- return null;
4978
- }
4979
- return w;
5031
+ (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: ${event} carries the window gobj in its kw: send {window: gobj_full_name(window)} from the window`);
5032
+ return null;
4980
5033
  }
4981
5034
  if (!(0, _yuneta_gobj_js.is_gobj)(src) || (0, _yuneta_gobj_js.gobj_full_name)(src) !== w) {
4982
5035
  (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: ${event}: window '${w}' is not the src of the event (${(0, _yuneta_gobj_js.is_gobj)(src) ? (0, _yuneta_gobj_js.gobj_full_name)(src) : String(src)})`);
@@ -60646,6 +60699,22 @@ function css_color_or_null(value) {
60646
60699
  * All Rights Reserved.
60647
60700
  ***********************************************************************/
60648
60701
  /***************************************************************
60702
+ * The markup of one toolbar item. Everything that goes into it is
60703
+ * escaped, the read-out branch too: its text, title and value are
60704
+ * values (a zoom figure, a translated title), never markup.
60705
+ ***************************************************************/
60706
+ function toolbar_item_html(item) {
60707
+ if (item.separator) return `<div class="g6-toolbar-sep" aria-hidden="true"></div>`;
60708
+ const extra_class = item.className ? ` ${(0, _yuneta_gobj_js.escapeHtml)(String(item.className))}` : "";
60709
+ const title = (0, _yuneta_gobj_js.escapeHtml)(String(item.title ?? ""));
60710
+ if (item.readout) return `<div class="g6-toolbar-readout${extra_class}" title="${title}" aria-label="${title}">${(0, _yuneta_gobj_js.escapeHtml)(String(item.text ?? ""))}</div>`;
60711
+ const disabled = item.disabled ? " disabled" : "";
60712
+ const is_text = item.text !== void 0;
60713
+ const kind_class = is_text ? " g6-toolbar-item-text" : "";
60714
+ const body = is_text ? `<span class="g6-toolbar-text">${(0, _yuneta_gobj_js.escapeHtml)(String(item.text))}</span>` : `<svg aria-hidden="true" focusable="false"><use xlink:href="#${(0, _yuneta_gobj_js.escapeHtml)(String(item.id))}"></use></svg>`;
60715
+ return `<div class="g6-toolbar-item${kind_class}${extra_class}" value="${(0, _yuneta_gobj_js.escapeHtml)(String(item.value))}" title="${title}" aria-label="${title}"${disabled}>${body}</div>`;
60716
+ }
60717
+ /***************************************************************
60649
60718
  * YuiToolbar — G6 Toolbar subclass that adds per-item className
60650
60719
  * and disabled support, plus three item kinds G6 does not have.
60651
60720
  *
@@ -60671,17 +60740,7 @@ function css_color_or_null(value) {
60671
60740
  ***************************************************************/
60672
60741
  var YuiToolbar = class extends _antv_g6.Toolbar {
60673
60742
  async getDOMContent() {
60674
- return (await this.options.getItems()).map((item) => {
60675
- if (item.separator) return `<div class="g6-toolbar-sep" aria-hidden="true"></div>`;
60676
- const extra_class = item.className ? ` ${(0, _yuneta_gobj_js.escapeHtml)(String(item.className))}` : "";
60677
- const title = (0, _yuneta_gobj_js.escapeHtml)(String(item.title ?? ""));
60678
- if (item.readout) return `<div class="g6-toolbar-readout${extra_class}" title="${title}" aria-label="${title}">${(0, _yuneta_gobj_js.escapeHtml)(String(item.text ?? ""))}</div>`;
60679
- const disabled = item.disabled ? " disabled" : "";
60680
- const is_text = item.text !== void 0;
60681
- const kind_class = is_text ? " g6-toolbar-item-text" : "";
60682
- const body = is_text ? `<span class="g6-toolbar-text">${(0, _yuneta_gobj_js.escapeHtml)(String(item.text))}</span>` : `<svg aria-hidden="true" focusable="false"><use xlink:href="#${(0, _yuneta_gobj_js.escapeHtml)(String(item.id))}"></use></svg>`;
60683
- return `<div class="g6-toolbar-item${kind_class}${extra_class}" value="${(0, _yuneta_gobj_js.escapeHtml)(String(item.value))}" title="${title}" aria-label="${title}"${disabled}>${body}</div>`;
60684
- }).join("");
60743
+ return (await this.options.getItems()).map(toolbar_item_html).join("");
60685
60744
  }
60686
60745
  };
60687
60746
  (0, _antv_g6.register)(_antv_g6.ExtensionCategory.PLUGIN, "yui-toolbar", YuiToolbar);
@@ -70876,6 +70935,19 @@ var LEGEND_COUNT_STYLE = "margin-left:.4rem; font-size:.875rem; opacity:.8;";
70876
70935
  var LEGEND_MAIN_NAME_STYLE = LEGEND_NAME_STYLE + " font-weight:700;";
70877
70936
  var LEGEND_STAR_MAIN_STYLE = LEGEND_GLYPH_STYLE + " color:var(--bulma-warning-on-scheme, var(--bulma-warning, #ffdd57));";
70878
70937
  var LEGEND_FOCUSED_STYLE = "box-shadow: inset 0 0 0 2px var(--bulma-text, #2e333d);";
70938
+ /************************************************************
70939
+ * The name of a topic in the legend: schema data, never markup.
70940
+ ************************************************************/
70941
+ function legend_name_item(topic_name, is_main, hidden) {
70942
+ return [
70943
+ "span",
70944
+ {
70945
+ class: "GRAPH_LEGEND_NAME",
70946
+ style: (is_main ? LEGEND_MAIN_NAME_STYLE : LEGEND_NAME_STYLE) + (hidden ? " text-decoration:line-through; opacity:.6;" : "")
70947
+ },
70948
+ text_node(topic_name)
70949
+ ];
70950
+ }
70879
70951
  function refresh_legend(gobj) {
70880
70952
  let priv = gobj.priv;
70881
70953
  let $container = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "$container");
@@ -70898,14 +70970,7 @@ function refresh_legend(gobj) {
70898
70970
  controls.push(["span", {
70899
70971
  class: "GRAPH_LEGEND_SWATCH",
70900
70972
  style: `display:inline-block; width:.8rem; height:.8rem; border-radius:3px; margin-right:.35rem; flex:0 0 auto; background:${entry.color || "#94a3b8"}; border:1px solid rgba(0,0,0,.25);` + (hidden ? "opacity:.35;" : "")
70901
- }], [
70902
- "span",
70903
- {
70904
- class: "GRAPH_LEGEND_NAME",
70905
- style: (is_main ? LEGEND_MAIN_NAME_STYLE : LEGEND_NAME_STYLE) + (hidden ? " text-decoration:line-through; opacity:.6;" : "")
70906
- },
70907
- text_node(topic_name)
70908
- ], [
70973
+ }], legend_name_item(topic_name, is_main, hidden), [
70909
70974
  "span",
70910
70975
  {
70911
70976
  class: "GRAPH_LEGEND_COUNT",
@@ -973,6 +973,8 @@ var PRIVATE_DATA$22 = {
973
973
  markers_after_hashchange: false,
974
974
  restore_hash: "",
975
975
  skip_hash: "",
976
+ deferred_route: "",
977
+ deferred_timer: null,
976
978
  popstate_handler: null,
977
979
  avatar_provider: null,
978
980
  avatar_nodes: [],
@@ -1080,14 +1082,22 @@ function mt_start$20(gobj) {
1080
1082
  if (top.marker_pending || top.no_marker) return;
1081
1083
  if (window.location.hash !== top.hash && window.location.hash !== top.below_hash) return;
1082
1084
  let st = ev && ev.state;
1083
- if (st && st.__yui_overlay__ === top.id) return;
1084
- if (st && st.__yui_overlay__ > top.id && !p.overlay_stack.some((e) => e.id === st.__yui_overlay__)) return;
1085
+ if (!st) return;
1086
+ if (st.__yui_overlay__ === top.id) return;
1087
+ if (st.__yui_overlay__ > top.id && !p.overlay_stack.some((e) => e.id === st.__yui_overlay__)) return;
1085
1088
  p.overlay_stack.pop();
1086
1089
  try {
1087
1090
  top.close();
1088
1091
  } catch (e) {
1089
1092
  log_warning(`C_YUI_SHELL: overlay close on Back failed: ${e}`);
1090
1093
  }
1094
+ if (typeof top.below_hash === "string" && top.hash !== top.below_hash && window.location.hash === top.below_hash) try {
1095
+ window.history.replaceState(window.history.state, "", top.hash);
1096
+ p.skip_hash = top.hash;
1097
+ p.last_hash = top.hash;
1098
+ } catch (e) {
1099
+ log_warning(`C_YUI_SHELL: restoring '${top.hash}' failed: ${e}`);
1100
+ }
1091
1101
  };
1092
1102
  window.addEventListener("popstate", priv.popstate_handler);
1093
1103
  }
@@ -1133,6 +1143,8 @@ function mt_stop$20(gobj) {
1133
1143
  priv.markers_after_hashchange = false;
1134
1144
  priv.restore_hash = "";
1135
1145
  priv.skip_hash = "";
1146
+ priv.deferred_route = "";
1147
+ clear_deferred_timer(gobj);
1136
1148
  if (priv.keydown_handler) {
1137
1149
  window.removeEventListener("keydown", priv.keydown_handler);
1138
1150
  priv.keydown_handler = null;
@@ -2542,6 +2554,11 @@ function push_overlay_history(gobj, close, opts) {
2542
2554
  function push_overlay_marker(gobj, entry) {
2543
2555
  let priv = gobj.priv;
2544
2556
  entry.below_hash = window.location.hash;
2557
+ if (window.history.state === null) try {
2558
+ window.history.replaceState({ __yui_below__: entry.id }, "");
2559
+ } catch (e) {
2560
+ log_warning(`C_YUI_SHELL: stamping the entry under an overlay failed: ${e}`);
2561
+ }
2545
2562
  try {
2546
2563
  window.history.pushState({ __yui_overlay__: entry.id }, "");
2547
2564
  } catch (e) {
@@ -2558,6 +2575,35 @@ function drop_expected_pops(gobj) {
2558
2575
  log_warning(`C_YUI_SHELL: ${priv.expected_pops} history.back() of ours did not land on '${priv.expected_pop_hash}' (now '${window.location.hash}'), dropped`);
2559
2576
  priv.expected_pops = 0;
2560
2577
  priv.expected_pop_hash = "";
2578
+ clear_deferred_timer(gobj);
2579
+ if (priv.deferred_route) {
2580
+ log_warning(`C_YUI_SHELL: route '${priv.deferred_route}' waited for that back() and is dropped: the history moved on to '${window.location.hash}'`);
2581
+ priv.deferred_route = "";
2582
+ }
2583
+ }
2584
+ var DEFERRED_ROUTE_WAIT_MS = 1e3;
2585
+ function defer_route(gobj, route) {
2586
+ let priv = gobj.priv;
2587
+ if (priv.deferred_route && priv.deferred_route !== route) log_warning(`C_YUI_SHELL: route '${priv.deferred_route}' waiting for a back() of ours is replaced by '${route}'`);
2588
+ priv.deferred_route = route;
2589
+ if (!priv.deferred_timer) priv.deferred_timer = window.setTimeout(() => {
2590
+ let p = gobj.priv;
2591
+ if (!p) return;
2592
+ p.deferred_timer = null;
2593
+ if (p.expected_pops === 0) return;
2594
+ log_warning(`C_YUI_SHELL: ${p.expected_pops} history.back() of ours did not land in ${DEFERRED_ROUTE_WAIT_MS} ms, given up`);
2595
+ p.expected_pops = 0;
2596
+ p.expected_pop_hash = "";
2597
+ p.restore_hash = "";
2598
+ push_pending_markers(gobj);
2599
+ }, DEFERRED_ROUTE_WAIT_MS);
2600
+ }
2601
+ function clear_deferred_timer(gobj) {
2602
+ let priv = gobj.priv;
2603
+ if (priv.deferred_timer) {
2604
+ window.clearTimeout(priv.deferred_timer);
2605
+ priv.deferred_timer = null;
2606
+ }
2561
2607
  }
2562
2608
  function push_pending_markers(gobj) {
2563
2609
  let priv = gobj.priv;
@@ -2568,6 +2614,12 @@ function push_pending_markers(gobj) {
2568
2614
  entry.hash = window.location.hash;
2569
2615
  push_overlay_marker(gobj, entry);
2570
2616
  }
2617
+ clear_deferred_timer(gobj);
2618
+ if (priv.deferred_route) {
2619
+ let route = priv.deferred_route;
2620
+ priv.deferred_route = "";
2621
+ yui_shell_navigate(gobj, route);
2622
+ }
2571
2623
  }
2572
2624
  function overlay_dismissed(gobj, entry) {
2573
2625
  let priv = gobj.priv;
@@ -2691,6 +2743,10 @@ function ac_nav_clicked(gobj, event, kw, src) {
2691
2743
  }
2692
2744
  route = remembered_position(gobj, route);
2693
2745
  if (gobj_read_attr(gobj, "use_hash") && !route_restores_url(gobj, route)) {
2746
+ if (gobj.priv.expected_pops > 0) {
2747
+ defer_route(gobj, route);
2748
+ return 0;
2749
+ }
2694
2750
  let target_hash = route_to_hash(route);
2695
2751
  if (window.location.hash !== target_hash) window.location.hash = target_hash;
2696
2752
  else navigate_to(gobj, route);
@@ -2930,6 +2986,11 @@ function yui_shell_of(gobj) {
2930
2986
  ************************************************************/
2931
2987
  function yui_shell_navigate(shell_gobj, route, opts) {
2932
2988
  if (!(opts && opts.replace) && gobj_read_attr(shell_gobj, "use_hash")) {
2989
+ let priv = shell_gobj.priv;
2990
+ if (priv && priv.expected_pops > 0) {
2991
+ defer_route(shell_gobj, route);
2992
+ return;
2993
+ }
2933
2994
  let target_hash = route_to_hash(route);
2934
2995
  if (window.location.hash !== target_hash) {
2935
2996
  window.location.hash = target_hash;
@@ -4957,21 +5018,13 @@ function chip_lead(icon) {
4957
5018
  * trace dumps it), so the window travels in it as its FULL NAME,
4958
5019
  * which the trace can print, and the gobj is the event's src --
4959
5020
  * every sender is the window itself. Up to 7.26.9 the kw carried
4960
- * the gobj; that is still taken, with a warning, for this release.
5021
+ * the gobj; since 7.26.14 that is refused.
4961
5022
  ************************************************************/
4962
- var warned_gobj_in_kw = false;
4963
5023
  function window_of(gobj, event, kw, src) {
4964
5024
  let w = kw && kw.window;
4965
5025
  if (is_gobj(w)) {
4966
- if (!warned_gobj_in_kw) {
4967
- warned_gobj_in_kw = true;
4968
- log_warning(`${gobj_short_name(gobj)}: ${event} carries the window gobj in its kw: send {window: gobj_full_name(window)} from the window`);
4969
- }
4970
- if (w !== src) {
4971
- log_error(`${gobj_short_name(gobj)}: ${event}: window '${gobj_full_name(w)}' is not the src of the event (${is_gobj(src) ? gobj_full_name(src) : String(src)})`);
4972
- return null;
4973
- }
4974
- return w;
5026
+ log_error(`${gobj_short_name(gobj)}: ${event} carries the window gobj in its kw: send {window: gobj_full_name(window)} from the window`);
5027
+ return null;
4975
5028
  }
4976
5029
  if (!is_gobj(src) || gobj_full_name(src) !== w) {
4977
5030
  log_error(`${gobj_short_name(gobj)}: ${event}: window '${w}' is not the src of the event (${is_gobj(src) ? gobj_full_name(src) : String(src)})`);
@@ -60641,6 +60694,22 @@ function css_color_or_null(value) {
60641
60694
  * All Rights Reserved.
60642
60695
  ***********************************************************************/
60643
60696
  /***************************************************************
60697
+ * The markup of one toolbar item. Everything that goes into it is
60698
+ * escaped, the read-out branch too: its text, title and value are
60699
+ * values (a zoom figure, a translated title), never markup.
60700
+ ***************************************************************/
60701
+ function toolbar_item_html(item) {
60702
+ if (item.separator) return `<div class="g6-toolbar-sep" aria-hidden="true"></div>`;
60703
+ const extra_class = item.className ? ` ${escapeHtml(String(item.className))}` : "";
60704
+ const title = escapeHtml(String(item.title ?? ""));
60705
+ if (item.readout) return `<div class="g6-toolbar-readout${extra_class}" title="${title}" aria-label="${title}">${escapeHtml(String(item.text ?? ""))}</div>`;
60706
+ const disabled = item.disabled ? " disabled" : "";
60707
+ const is_text = item.text !== void 0;
60708
+ const kind_class = is_text ? " g6-toolbar-item-text" : "";
60709
+ const body = is_text ? `<span class="g6-toolbar-text">${escapeHtml(String(item.text))}</span>` : `<svg aria-hidden="true" focusable="false"><use xlink:href="#${escapeHtml(String(item.id))}"></use></svg>`;
60710
+ return `<div class="g6-toolbar-item${kind_class}${extra_class}" value="${escapeHtml(String(item.value))}" title="${title}" aria-label="${title}"${disabled}>${body}</div>`;
60711
+ }
60712
+ /***************************************************************
60644
60713
  * YuiToolbar — G6 Toolbar subclass that adds per-item className
60645
60714
  * and disabled support, plus three item kinds G6 does not have.
60646
60715
  *
@@ -60666,17 +60735,7 @@ function css_color_or_null(value) {
60666
60735
  ***************************************************************/
60667
60736
  var YuiToolbar = class extends Toolbar {
60668
60737
  async getDOMContent() {
60669
- return (await this.options.getItems()).map((item) => {
60670
- if (item.separator) return `<div class="g6-toolbar-sep" aria-hidden="true"></div>`;
60671
- const extra_class = item.className ? ` ${escapeHtml(String(item.className))}` : "";
60672
- const title = escapeHtml(String(item.title ?? ""));
60673
- if (item.readout) return `<div class="g6-toolbar-readout${extra_class}" title="${title}" aria-label="${title}">${escapeHtml(String(item.text ?? ""))}</div>`;
60674
- const disabled = item.disabled ? " disabled" : "";
60675
- const is_text = item.text !== void 0;
60676
- const kind_class = is_text ? " g6-toolbar-item-text" : "";
60677
- const body = is_text ? `<span class="g6-toolbar-text">${escapeHtml(String(item.text))}</span>` : `<svg aria-hidden="true" focusable="false"><use xlink:href="#${escapeHtml(String(item.id))}"></use></svg>`;
60678
- return `<div class="g6-toolbar-item${kind_class}${extra_class}" value="${escapeHtml(String(item.value))}" title="${title}" aria-label="${title}"${disabled}>${body}</div>`;
60679
- }).join("");
60738
+ return (await this.options.getItems()).map(toolbar_item_html).join("");
60680
60739
  }
60681
60740
  };
60682
60741
  register(ExtensionCategory.PLUGIN, "yui-toolbar", YuiToolbar);
@@ -70871,6 +70930,19 @@ var LEGEND_COUNT_STYLE = "margin-left:.4rem; font-size:.875rem; opacity:.8;";
70871
70930
  var LEGEND_MAIN_NAME_STYLE = LEGEND_NAME_STYLE + " font-weight:700;";
70872
70931
  var LEGEND_STAR_MAIN_STYLE = LEGEND_GLYPH_STYLE + " color:var(--bulma-warning-on-scheme, var(--bulma-warning, #ffdd57));";
70873
70932
  var LEGEND_FOCUSED_STYLE = "box-shadow: inset 0 0 0 2px var(--bulma-text, #2e333d);";
70933
+ /************************************************************
70934
+ * The name of a topic in the legend: schema data, never markup.
70935
+ ************************************************************/
70936
+ function legend_name_item(topic_name, is_main, hidden) {
70937
+ return [
70938
+ "span",
70939
+ {
70940
+ class: "GRAPH_LEGEND_NAME",
70941
+ style: (is_main ? LEGEND_MAIN_NAME_STYLE : LEGEND_NAME_STYLE) + (hidden ? " text-decoration:line-through; opacity:.6;" : "")
70942
+ },
70943
+ text_node(topic_name)
70944
+ ];
70945
+ }
70874
70946
  function refresh_legend(gobj) {
70875
70947
  let priv = gobj.priv;
70876
70948
  let $container = gobj_read_attr(gobj, "$container");
@@ -70893,14 +70965,7 @@ function refresh_legend(gobj) {
70893
70965
  controls.push(["span", {
70894
70966
  class: "GRAPH_LEGEND_SWATCH",
70895
70967
  style: `display:inline-block; width:.8rem; height:.8rem; border-radius:3px; margin-right:.35rem; flex:0 0 auto; background:${entry.color || "#94a3b8"}; border:1px solid rgba(0,0,0,.25);` + (hidden ? "opacity:.35;" : "")
70896
- }], [
70897
- "span",
70898
- {
70899
- class: "GRAPH_LEGEND_NAME",
70900
- style: (is_main ? LEGEND_MAIN_NAME_STYLE : LEGEND_NAME_STYLE) + (hidden ? " text-decoration:line-through; opacity:.6;" : "")
70901
- },
70902
- text_node(topic_name)
70903
- ], [
70968
+ }], legend_name_item(topic_name, is_main, hidden), [
70904
70969
  "span",
70905
70970
  {
70906
70971
  class: "GRAPH_LEGEND_COUNT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.26.13",
3
+ "version": "7.26.15",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -28,6 +28,7 @@
28
28
  "check-markup": "node scripts/check-markup-strings.mjs",
29
29
  "prebuild": "npm run check-markup",
30
30
  "pretest": "npm run check-markup",
31
+ "qa-history": "node scripts/qa-history.mjs",
31
32
  "deploy-round": "node scripts/deploy-round.mjs",
32
33
  "prepublishOnly": "npm run build"
33
34
  },
@@ -94,7 +94,7 @@ function starts_with_markup(s)
94
94
  /* String methods that keep the head of their receiver (a markup head
95
95
  * stays a markup head through them). Not replace()/replaceAll(): they
96
96
  * can take the head away ('<b>x</b>'.replace(/<[^>]+>/g, '') is text),
97
- * so what they give back is not known. */
97
+ * see replaced(). */
98
98
  const HEAD_KEEPING_METHODS = new Set([
99
99
  "trim", "trimStart", "trimEnd", "toString", "valueOf", "normalize",
100
100
  "toLowerCase", "toUpperCase", "padEnd", "concat"
@@ -107,6 +107,39 @@ const PURE_METHODS = new Set([
107
107
  "toLowerCase", "toUpperCase"
108
108
  ]);
109
109
 
110
+ /* replace()/replaceAll() on a receiver that is static and with static
111
+ * arguments is computed, so a tag stripped away is seen as stripped.
112
+ * Anything else keeps the receiver's head and is no longer static: a
113
+ * receiver that carries data stays BUILT markup through them, and so
114
+ * does a static one whose replacement is data
115
+ * ('<b>NAME</b>'.replace('NAME', name)). */
116
+ function replaced(method, head, args)
117
+ {
118
+ if(head.complete && args.length === 2) {
119
+ let pattern = null;
120
+ if(args[0].type === "Literal" && args[0].regex) {
121
+ try {
122
+ pattern = new RegExp(args[0].regex.pattern, args[0].regex.flags);
123
+ } catch(e) {
124
+ pattern = null;
125
+ }
126
+ } else if(is_string_literal(args[0])) {
127
+ pattern = args[0].value;
128
+ }
129
+ let replacement = leading(args[1]);
130
+ if(pattern !== null && replacement && replacement.complete) {
131
+ try {
132
+ return {text: String.prototype[method].call(head.text, pattern, replacement.text),
133
+ complete: true};
134
+ } catch(e) {
135
+ /* replaceAll() with a regex that is not global throws:
136
+ * so does the code, the check need not know what it gives. */
137
+ }
138
+ }
139
+ }
140
+ return {text: head.text, complete: false};
141
+ }
142
+
110
143
  function concat_parts(parts)
111
144
  {
112
145
  /* parts: [{text, complete}] in order. The leading text runs while
@@ -191,6 +224,13 @@ function leading(n)
191
224
  });
192
225
  return concat_parts(parts);
193
226
  }
227
+ if(method === "replace" || method === "replaceAll") {
228
+ let head = leading(receiver);
229
+ if(head === null) {
230
+ return null;
231
+ }
232
+ return replaced(method, head, n.arguments);
233
+ }
194
234
  if(HEAD_KEEPING_METHODS.has(method)) {
195
235
  let head = leading(receiver);
196
236
  if(head === null) {
@@ -179,6 +179,47 @@ import {yui_shell_show_error} from "./shell_modals.js";
179
179
  import {g6_event_kw} from "./g6_event_kw.js";
180
180
  import {css_color_or_null} from "./yui_data_color.js";
181
181
 
182
+ /***************************************************************
183
+ * The markup of one toolbar item. Everything that goes into it is
184
+ * escaped, the read-out branch too: its text, title and value are
185
+ * values (a zoom figure, a translated title), never markup.
186
+ ***************************************************************/
187
+ function toolbar_item_html(item)
188
+ {
189
+ if(item.separator) {
190
+ return `<div class="g6-toolbar-sep" aria-hidden="true"></div>`;
191
+ }
192
+
193
+ const extra_class = item.className ? ` ${escapeHtml(String(item.className))}` : '';
194
+ const title = escapeHtml(String(item.title ?? ''));
195
+
196
+ if(item.readout) {
197
+ return (
198
+ `<div class="g6-toolbar-readout${extra_class}"` +
199
+ ` title="${title}" aria-label="${title}">` +
200
+ `${escapeHtml(String(item.text ?? ''))}` +
201
+ `</div>`
202
+ );
203
+ }
204
+
205
+ const disabled = item.disabled ? ' disabled' : '';
206
+ const is_text = (item.text !== undefined);
207
+ const kind_class = is_text ? ' g6-toolbar-item-text' : '';
208
+ const body = is_text
209
+ ? `<span class="g6-toolbar-text">${escapeHtml(String(item.text))}</span>`
210
+ : `<svg aria-hidden="true" focusable="false">` +
211
+ `<use xlink:href="#${escapeHtml(String(item.id))}"></use>` +
212
+ `</svg>`;
213
+
214
+ return (
215
+ `<div class="g6-toolbar-item${kind_class}${extra_class}"` +
216
+ ` value="${escapeHtml(String(item.value))}" title="${title}"` +
217
+ ` aria-label="${title}"${disabled}>` +
218
+ `${body}` +
219
+ `</div>`
220
+ );
221
+ }
222
+
182
223
  /***************************************************************
183
224
  * YuiToolbar — G6 Toolbar subclass that adds per-item className
184
225
  * and disabled support, plus three item kinds G6 does not have.
@@ -208,43 +249,7 @@ class YuiToolbar extends Toolbar
208
249
  async getDOMContent()
209
250
  {
210
251
  const items = await this.options.getItems();
211
- return items.map((item) => {
212
- if(item.separator) {
213
- return `<div class="g6-toolbar-sep" aria-hidden="true"></div>`;
214
- }
215
-
216
- /* Everything that goes into this markup is escaped, the
217
- * read-out branch too: its text, title and value are values
218
- * (a zoom figure, a translated title), never markup. */
219
- const extra_class = item.className ? ` ${escapeHtml(String(item.className))}` : '';
220
- const title = escapeHtml(String(item.title ?? ''));
221
-
222
- if(item.readout) {
223
- return (
224
- `<div class="g6-toolbar-readout${extra_class}"` +
225
- ` title="${title}" aria-label="${title}">` +
226
- `${escapeHtml(String(item.text ?? ''))}` +
227
- `</div>`
228
- );
229
- }
230
-
231
- const disabled = item.disabled ? ' disabled' : '';
232
- const is_text = (item.text !== undefined);
233
- const kind_class = is_text ? ' g6-toolbar-item-text' : '';
234
- const body = is_text
235
- ? `<span class="g6-toolbar-text">${escapeHtml(String(item.text))}</span>`
236
- : `<svg aria-hidden="true" focusable="false">` +
237
- `<use xlink:href="#${escapeHtml(String(item.id))}"></use>` +
238
- `</svg>`;
239
-
240
- return (
241
- `<div class="g6-toolbar-item${kind_class}${extra_class}"` +
242
- ` value="${escapeHtml(String(item.value))}" title="${title}"` +
243
- ` aria-label="${title}"${disabled}>` +
244
- `${body}` +
245
- `</div>`
246
- );
247
- }).join('');
252
+ return items.map(toolbar_item_html).join('');
248
253
  }
249
254
  }
250
255
  register(ExtensionCategory.PLUGIN, 'yui-toolbar', YuiToolbar);
@@ -12431,4 +12436,7 @@ function register_c_g6_nodes_tree()
12431
12436
  return create_gclass(GCLASS_NAME);
12432
12437
  }
12433
12438
 
12434
- export { register_c_g6_nodes_tree };
12439
+ export {
12440
+ register_c_g6_nodes_tree,
12441
+ toolbar_item_html, // exported for its test
12442
+ };
@@ -4823,5 +4823,9 @@ export {
4823
4823
  register_c_yui_schema_editor,
4824
4824
  /* Exported for its test: the rule that decides whether a topic still
4825
4825
  * owes a version bump, which is asked in two places. */
4826
- topic_is_draft
4826
+ topic_is_draft,
4827
+ /* Exported for their test: the options and the value of a form
4828
+ * control are names from the schema, data, never markup. */
4829
+ select_input,
4830
+ textarea_input,
4827
4831
  };