@yuneta/gobj-ui 7.26.10 → 7.26.11

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
@@ -13,12 +13,17 @@ Published as `@yuneta/gobj-ui`. Built on top of [`@yuneta/gobj-js`](https://gith
13
13
  > routing contract (URL = source of truth, push/replace history, the
14
14
  > position/preference/transient litmus).
15
15
  >
16
- > **Peer floors today** (`package.json`): `@yuneta/gobj-js` `^7.22.2`,
16
+ > **Peer floors today** (`package.json`): `@yuneta/gobj-js` `^7.26.3`,
17
17
  > `@antv/g6` `^5.1.0`, `bulma` `^1.0.4`, `i18next` `^26.3.6`, `maplibre-gl`
18
18
  > `^6.11.2`, `tabulator-tables` `^6.5.3`, `tom-select` `^2.6.2`, `uplot`
19
19
  > `^1.6.32`, `vanilla-jsoneditor` `^3.13.0`. The notices below say when and why
20
20
  > each floor moved; the list above is what a consumer must meet now.
21
21
  >
22
+ > **BREAKING (7.26.10):** the peer floor of `@yuneta/gobj-js` rose to
23
+ > `^7.26.3`. The library passes its markup through `html_markup()`, which first
24
+ > ships in that gobj-js. A consumer locked on an older gobj-js gets `ERESOLVE`:
25
+ > raise both in the same change. See the CHANGELOG entry.
26
+ >
22
27
  > **BREAKING (7.23.172):** the peer floor of `@yuneta/gobj-js` rose to
23
28
  > `^7.22.0`. The Developer window turns the runtime's trace bits on and off and
24
29
  > never reads a message to decide what to show; it needs the trace API of that
@@ -3338,14 +3343,23 @@ text is in the yunetas `CLAUDE.md` ("JS GUI conventions"); in short:
3338
3343
  longer run. The test-app runs in that mode. An app turns it on at startup,
3339
3344
  before it builds anything, once its own code is migrated:
3340
3345
 
3341
- 1. Run the static check on the app's sources:
3346
+ 1. Run the static check on the app's sources, from the published package
3347
+ (7.26.11+ ships the script):
3342
3348
  `node node_modules/@yuneta/gobj-ui/scripts/check-markup-strings.mjs src`
3343
- (it needs `acorn`). It lists a markup string literal in a description
3349
+ — usually from the app's `prebuild`. It imports `acorn`, which the APP
3350
+ must declare as a devDependency (npm does not install a dependency's
3351
+ devDependencies). It lists a markup string literal in a description
3344
3352
  (`literal`, wrap it in `html_markup()`), markup built with values
3345
- (`built`, build the element with `createElement2()` and pass the value
3346
- as text) and a markup string in a list of children (`in-list`, which is
3347
- text since gobj-js 7.26.2). It cannot see a variable that holds a
3348
- string.
3353
+ (`built`: a template, a `+` or a `.concat()`; build the element with
3354
+ `createElement2()` and pass the value as text), a markup string in a list
3355
+ of children (`in-list`, which is text since gobj-js 7.26.2) and a list of
3356
+ children whose first item is a markup string (`list-head`: such a list is
3357
+ read as one description). A ternary or `||`/`&&` is checked branch by
3358
+ branch. It CANNOT see: a variable or a function result that holds a
3359
+ string; a description built piece by piece (`push()` into the content
3360
+ list); a computed tag with an attrs slot that is not an object literal;
3361
+ markup given to `innerHTML` or to a widget (Tabulator, G6). Step 3 is
3362
+ the check for those.
3349
3363
  2. Call `set_strings_are_text(true)` before the first `createElement2()`.
3350
3364
  3. Walk the app and read the console: each string that starts with `<` is
3351
3365
  logged once (*"use html_markup() if it is markup"*). A logged string is
@@ -471,6 +471,59 @@ function resolve_route(item_index, route) {
471
471
  };
472
472
  }
473
473
  //#endregion
474
+ //#region src/yui_text.js
475
+ /***********************************************************************
476
+ * yui_text.js
477
+ *
478
+ * DATA as text for createElement2().
479
+ *
480
+ * createElement2() takes a string content that starts with '<' for
481
+ * MARKUP and parses it (that is how a component passes an inline
482
+ * icon). So a value that came from outside -- a backend answer, a
483
+ * treedb node, a name somebody typed, a frame of the traffic -- must
484
+ * never go in as a bare string: "<img src=x onerror=...>" would run.
485
+ * It goes in as a Text node, which is always text.
486
+ *
487
+ * Trimmed like createElement2() trims a string, so the change of
488
+ * form does not change what is shown. A Text node under an
489
+ * `i18n`/`data-i18n` element is still re-translated by
490
+ * refresh_language(), which sets textContent.
491
+ *
492
+ * Copyright (c) 2026, ArtGins.
493
+ * All Rights Reserved.
494
+ ***********************************************************************/
495
+ /************************************************************
496
+ * A Text node with `value` as its text ("" for null/undefined).
497
+ ************************************************************/
498
+ function text_node(value) {
499
+ if (value === null || value === void 0) return document.createTextNode("");
500
+ return document.createTextNode(String(value).trim());
501
+ }
502
+ /************************************************************
503
+ * A Tabulator `titleFormatter` that shows the column title as text.
504
+ *
505
+ * Tabulator puts a STRING title in with innerHTML, so a title taken
506
+ * from a schema (`header`, which the schema editor writes) is markup
507
+ * unless the column carries a formatter that returns a Node.
508
+ ************************************************************/
509
+ function text_title_formatter(cell) {
510
+ return text_node(cell.getValue());
511
+ }
512
+ /************************************************************
513
+ * A Tabulator `itemFormatter` for a `list` editor or header filter
514
+ * that shows each item's label as text.
515
+ *
516
+ * Tabulator appends what an itemFormatter returns only when it is an
517
+ * HTMLElement (a Text node would be innerHTML'd as "[object Text]"),
518
+ * and it puts a bare label in with innerHTML. A label taken from a
519
+ * schema (`enum_list`) is data, so it goes in a span, as text.
520
+ ************************************************************/
521
+ function text_list_item_formatter(label) {
522
+ const span = document.createElement("span");
523
+ span.textContent = label === null || label === void 0 ? "" : String(label);
524
+ return span;
525
+ }
526
+ //#endregion
474
527
  //#region src/route_map_model.js
475
528
  /***********************************************************************
476
529
  * route_map_model.js
@@ -919,6 +972,7 @@ var PRIVATE_DATA$22 = {
919
972
  overlay_stack: [],
920
973
  overlay_seq: 0,
921
974
  expected_pops: 0,
975
+ expected_pop_hash: "",
922
976
  pending_markers: [],
923
977
  popstate_handler: null,
924
978
  avatar_provider: null,
@@ -968,6 +1022,8 @@ function mt_start$20(gobj) {
968
1022
  preinstantiate_eager_views(gobj);
969
1023
  if ((0, _yuneta_gobj_js.gobj_read_attr)(gobj, "use_hash")) {
970
1024
  priv.hash_handler = () => {
1025
+ let p = gobj.priv;
1026
+ if (p && p.expected_pops > 0 && window.location.hash !== p.expected_pop_hash) drop_expected_pops(gobj);
971
1027
  let route = hash_to_route(window.location.hash);
972
1028
  if (!(0, _yuneta_gobj_js.empty_string)(route)) navigate_to(gobj, route);
973
1029
  };
@@ -975,6 +1031,7 @@ function mt_start$20(gobj) {
975
1031
  priv.popstate_handler = (ev) => {
976
1032
  let p = gobj.priv;
977
1033
  if (!p) return;
1034
+ if (p.expected_pops > 0 && window.location.hash !== p.expected_pop_hash) drop_expected_pops(gobj);
978
1035
  if (p.expected_pops > 0) {
979
1036
  p.expected_pops--;
980
1037
  if (p.expected_pops === 0) push_pending_markers(gobj);
@@ -1026,6 +1083,9 @@ function mt_stop$20(gobj) {
1026
1083
  window.removeEventListener("popstate", priv.popstate_handler);
1027
1084
  priv.popstate_handler = null;
1028
1085
  }
1086
+ priv.expected_pops = 0;
1087
+ priv.expected_pop_hash = "";
1088
+ priv.pending_markers = [];
1029
1089
  if (priv.keydown_handler) {
1030
1090
  window.removeEventListener("keydown", priv.keydown_handler);
1031
1091
  priv.keydown_handler = null;
@@ -1829,7 +1889,7 @@ function build_toolbar_action_item(gobj, it) {
1829
1889
  class: "yui-toolbar-item-label",
1830
1890
  i18n: it.name
1831
1891
  },
1832
- it.name
1892
+ text_node(it.name)
1833
1893
  ]);
1834
1894
  let aria_key = it.aria_label || it.name || it.id || "";
1835
1895
  let i18n_aria = it.aria_label || it.name;
@@ -2245,7 +2305,7 @@ function build_dropdown_row(gobj, sub, idx) {
2245
2305
  class: "yui-toolbar-dropdown-label",
2246
2306
  i18n: sub.name
2247
2307
  },
2248
- sub.name
2308
+ text_node(sub.name)
2249
2309
  ]);
2250
2310
  children.push([
2251
2311
  "span",
@@ -2443,6 +2503,14 @@ function push_overlay_marker(gobj, entry) {
2443
2503
  }
2444
2504
  return true;
2445
2505
  }
2506
+ function drop_expected_pops(gobj) {
2507
+ let priv = gobj.priv;
2508
+ if (!priv || priv.expected_pops === 0) return;
2509
+ (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`);
2510
+ priv.expected_pops = 0;
2511
+ priv.expected_pop_hash = "";
2512
+ push_pending_markers(gobj);
2513
+ }
2446
2514
  function push_pending_markers(gobj) {
2447
2515
  let priv = gobj.priv;
2448
2516
  let pending = priv.pending_markers.splice(0);
@@ -2464,6 +2532,7 @@ function overlay_dismissed(gobj, entry) {
2464
2532
  let st = window.history.state;
2465
2533
  if (st && st.__yui_overlay__ === entry.id) {
2466
2534
  priv.expected_pops++;
2535
+ priv.expected_pop_hash = window.location.hash;
2467
2536
  try {
2468
2537
  window.history.back();
2469
2538
  } catch (e) {
@@ -3056,45 +3125,6 @@ function yui_shell_close_dropdown(shell_gobj) {
3056
3125
  close_toolbar_dropdown(shell_gobj);
3057
3126
  }
3058
3127
  //#endregion
3059
- //#region src/yui_text.js
3060
- /***********************************************************************
3061
- * yui_text.js
3062
- *
3063
- * DATA as text for createElement2().
3064
- *
3065
- * createElement2() takes a string content that starts with '<' for
3066
- * MARKUP and parses it (that is how a component passes an inline
3067
- * icon). So a value that came from outside -- a backend answer, a
3068
- * treedb node, a name somebody typed, a frame of the traffic -- must
3069
- * never go in as a bare string: "<img src=x onerror=...>" would run.
3070
- * It goes in as a Text node, which is always text.
3071
- *
3072
- * Trimmed like createElement2() trims a string, so the change of
3073
- * form does not change what is shown. A Text node under an
3074
- * `i18n`/`data-i18n` element is still re-translated by
3075
- * refresh_language(), which sets textContent.
3076
- *
3077
- * Copyright (c) 2026, ArtGins.
3078
- * All Rights Reserved.
3079
- ***********************************************************************/
3080
- /************************************************************
3081
- * A Text node with `value` as its text ("" for null/undefined).
3082
- ************************************************************/
3083
- function text_node(value) {
3084
- if (value === null || value === void 0) return document.createTextNode("");
3085
- return document.createTextNode(String(value).trim());
3086
- }
3087
- /************************************************************
3088
- * A Tabulator `titleFormatter` that shows the column title as text.
3089
- *
3090
- * Tabulator puts a STRING title in with innerHTML, so a title taken
3091
- * from a schema (`header`, which the schema editor writes) is markup
3092
- * unless the column carries a formatter that returns a Node.
3093
- ************************************************************/
3094
- function text_title_formatter(cell) {
3095
- return text_node(cell.getValue());
3096
- }
3097
- //#endregion
3098
3128
  //#region src/shell_modals.js
3099
3129
  /***********************************************************************
3100
3130
  * shell_modals.js
@@ -3860,7 +3890,7 @@ function build_default_header(gobj) {
3860
3890
  if (icon.charAt(0) === "<") items.push([
3861
3891
  "span",
3862
3892
  { class: "icon" },
3863
- icon
3893
+ (0, _yuneta_gobj_js.html_markup)(icon)
3864
3894
  ]);
3865
3895
  else items.push([
3866
3896
  "span",
@@ -4865,7 +4895,7 @@ function chip_lead(icon) {
4865
4895
  if (icon.charAt(0) === "<") return [
4866
4896
  "span",
4867
4897
  { class: "yui-dock-icon" },
4868
- icon
4898
+ (0, _yuneta_gobj_js.html_markup)(icon)
4869
4899
  ];
4870
4900
  return [
4871
4901
  "span",
@@ -4874,9 +4904,6 @@ function chip_lead(icon) {
4874
4904
  ];
4875
4905
  }
4876
4906
  /************************************************************
4877
- * Find a registry entry by its window gobj.
4878
- ************************************************************/
4879
- /************************************************************
4880
4907
  * The window an event is about. A kw is plain json (the machine
4881
4908
  * trace dumps it), so the window travels in it as its FULL NAME,
4882
4909
  * which the trace can print, and the gobj is the event's src --
@@ -4891,6 +4918,10 @@ function window_of(gobj, event, kw, src) {
4891
4918
  warned_gobj_in_kw = true;
4892
4919
  (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`);
4893
4920
  }
4921
+ if (w !== src) {
4922
+ (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)})`);
4923
+ return null;
4924
+ }
4894
4925
  return w;
4895
4926
  }
4896
4927
  if (!(0, _yuneta_gobj_js.is_gobj)(src) || (0, _yuneta_gobj_js.gobj_full_name)(src) !== w) {
@@ -4899,6 +4930,9 @@ function window_of(gobj, event, kw, src) {
4899
4930
  }
4900
4931
  return src;
4901
4932
  }
4933
+ /************************************************************
4934
+ * Find a registry entry by its window gobj.
4935
+ ************************************************************/
4902
4936
  function find_entry(priv, win) {
4903
4937
  for (let e of priv.windows) if (e.gobj === win) return e;
4904
4938
  return null;
@@ -10054,7 +10088,7 @@ function template2columns(gobj, columns, template, sub_elements) {
10054
10088
  break;
10055
10089
  case "enum":
10056
10090
  column.editor = "list";
10057
- column.editorParams = {};
10091
+ column.editorParams = { itemFormatter: text_list_item_formatter };
10058
10092
  switch (field_desc.real_type) {
10059
10093
  case "string":
10060
10094
  case "object":
@@ -15955,7 +15989,7 @@ function push_collapsed_row(ctx, value, segments, depth, key, rows) {
15955
15989
  else if (err) children.push([
15956
15990
  "span",
15957
15991
  { class: "JSON_STUB_ERR has-text-danger is-size-7 ml-2" },
15958
- String(err.error)
15992
+ text_node(err.error)
15959
15993
  ]);
15960
15994
  let attrs = {
15961
15995
  class: "JSON_ROW JSON_COLLAPSED" + (is_pending ? " is-pending" : ""),
@@ -18940,7 +18974,7 @@ function render_raw(gobj) {
18940
18974
  if (dump.error) children.push([
18941
18975
  "div",
18942
18976
  { class: "GCLASS_RAW_ERROR has-text-danger is-size-7 p-2" },
18943
- dump.error
18977
+ text_node(dump.error)
18944
18978
  ]);
18945
18979
  let $body = (0, _yuneta_gobj_js.createElement2)([
18946
18980
  "div",
@@ -19397,7 +19431,7 @@ function build_methods(model) {
19397
19431
  model.methods.map((m) => [
19398
19432
  "span",
19399
19433
  row_attrs(m, { class: "GCLASS_CHIP GCLASS_METHOD" }),
19400
- m
19434
+ text_node(m)
19401
19435
  ])
19402
19436
  ]);
19403
19437
  if (model.internal_methods.length) {
@@ -19415,7 +19449,7 @@ function build_methods(model) {
19415
19449
  model.internal_methods.map((m) => [
19416
19450
  "span",
19417
19451
  row_attrs(m, { class: "GCLASS_CHIP GCLASS_METHOD" }),
19418
- m
19452
+ text_node(m)
19419
19453
  ])
19420
19454
  ]);
19421
19455
  }
@@ -29195,7 +29229,10 @@ function create_tabulator(gobj) {
29195
29229
  break;
29196
29230
  case "enum":
29197
29231
  colDef.editor = "list";
29198
- colDef.editorParams = { values: field_desc.enum_list || [] };
29232
+ colDef.editorParams = {
29233
+ values: field_desc.enum_list || [],
29234
+ itemFormatter: text_list_item_formatter
29235
+ };
29199
29236
  break;
29200
29237
  case "integer":
29201
29238
  case "real":
@@ -29239,7 +29276,8 @@ function create_tabulator(gobj) {
29239
29276
  colDef.headerFilter = "list";
29240
29277
  colDef.headerFilterParams = {
29241
29278
  values: field_desc.enum_list || [],
29242
- clearable: true
29279
+ clearable: true,
29280
+ itemFormatter: text_list_item_formatter
29243
29281
  };
29244
29282
  break;
29245
29283
  case "fkey":
@@ -29649,7 +29687,7 @@ function icon_formatter(cell) {
29649
29687
  class: "ICON_CELL_UNKNOWN is-size-7 yui-text-quiet",
29650
29688
  title: name
29651
29689
  },
29652
- name
29690
+ text_node(name)
29653
29691
  ]);
29654
29692
  return (0, _yuneta_gobj_js.createElement2)(["span", {
29655
29693
  class: `ICON_CELL ${name}`,
@@ -60587,7 +60625,7 @@ var YuiToolbar = class extends _antv_g6.Toolbar {
60587
60625
  const disabled = item.disabled ? " disabled" : "";
60588
60626
  const is_text = item.text !== void 0;
60589
60627
  const kind_class = is_text ? " g6-toolbar-item-text" : "";
60590
- const body = is_text ? `<span class="g6-toolbar-text">${item.text}</span>` : `<svg aria-hidden="true" focusable="false"><use xlink:href="#${item.id}"></use></svg>`;
60628
+ 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="#${item.id}"></use></svg>`;
60591
60629
  return `<div class="g6-toolbar-item${kind_class}${extra_class}" value="${item.value}" title="${title}" aria-label="${title}"${disabled}>${body}</div>`;
60592
60630
  }).join("");
60593
60631
  }
@@ -61817,10 +61855,17 @@ function topic_defaults_of(gobj, topic_name) {
61817
61855
  * It is written into a card's html (see yui_data_color.js): a
61818
61856
  * refused value logs, and the node wears the topic's colour.
61819
61857
  ************************************************************/
61858
+ var refused_colors_logged = /* @__PURE__ */ new Set();
61820
61859
  function data_color(gobj, value) {
61821
61860
  if (value === void 0 || value === null || value === "") return null;
61822
61861
  let color = css_color_or_null(value);
61823
- if (!color) (0, _yuneta_gobj_js.log_warning)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: colour refused, not a css colour: ${JSON.stringify(value)}`);
61862
+ if (!color) {
61863
+ let key = `${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}\u0000${String(value)}`;
61864
+ if (!refused_colors_logged.has(key) && refused_colors_logged.size < 200) {
61865
+ refused_colors_logged.add(key);
61866
+ (0, _yuneta_gobj_js.log_warning)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: colour refused, not a css colour: ${JSON.stringify(value)}`);
61867
+ }
61868
+ }
61824
61869
  return color;
61825
61870
  }
61826
61871
  /************************************************************
@@ -66304,7 +66349,7 @@ function build_context_menu_items(gobj, e) {
66304
66349
  ************************************************************/
66305
66350
  function ctx_item(icon_id, label, value) {
66306
66351
  return {
66307
- name: `<svg style="width:1em;height:1em;vertical-align:-0.125em;margin-right:8px;pointer-events:none;fill:currentColor"><use href="#${icon_id}"></use></svg>${label}`,
66352
+ name: `<svg style="width:1em;height:1em;vertical-align:-0.125em;margin-right:8px;pointer-events:none;fill:currentColor"><use href="#${icon_id}"></use></svg>${(0, _yuneta_gobj_js.escapeHtml)(String(label))}`,
66308
66353
  value
66309
66354
  };
66310
66355
  }
@@ -75767,7 +75812,7 @@ function select_input(name, value, options) {
75767
75812
  value: `${option}`,
75768
75813
  selected: `${option}` === `${value}` ? "selected" : void 0
75769
75814
  }),
75770
- `${option}`
75815
+ text_node(`${option}`)
75771
75816
  ];
75772
75817
  });
75773
75818
  return [
@@ -75789,7 +75834,7 @@ function textarea_input(name, value, rows, placeholder) {
75789
75834
  rows: `${rows || 3}`,
75790
75835
  placeholder: placeholder || ""
75791
75836
  },
75792
- value === void 0 || value === null ? "" : `${value}`
75837
+ text_node(value === void 0 || value === null ? "" : `${value}`)
75793
75838
  ];
75794
75839
  }
75795
75840
  /***************************************************************