@yuneta/gobj-ui 7.23.137 → 7.23.138

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.
@@ -21908,6 +21908,31 @@ function cmd_get_topic_data$1(gobj, cmd, kw, src) {
21908
21908
  ************************************************************/
21909
21909
  function build_ui$6(gobj) {
21910
21910
  let source_url = (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "source_url") || "";
21911
+ let routes = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "card_action_routes");
21912
+ let graph_tpl = (0, _yuneta_gobj_js.is_object)(routes) && typeof routes.graph === "string" ? routes.graph : "";
21913
+ let graph_href = /\/\{topic\}$/.test(graph_tpl) ? graph_tpl.replace(/\/\{topic\}$/, "") : "";
21914
+ let graph_items = [];
21915
+ if (graph_href) graph_items.push([
21916
+ "a",
21917
+ {
21918
+ class: "button TREEDB_GRAPH_BTN",
21919
+ href: graph_href,
21920
+ style: "margin-left:auto;",
21921
+ title: (0, i18next.t)("graph"),
21922
+ "aria-label": (0, i18next.t)("graph"),
21923
+ "data-i18n-title": "graph",
21924
+ "data-i18n-aria-label": "graph"
21925
+ },
21926
+ [[
21927
+ "span",
21928
+ { class: "icon" },
21929
+ [yui_toolbar_icon("yi-hexagon-nodes")]
21930
+ ], [
21931
+ "span",
21932
+ { i18n: "graph" },
21933
+ "graph"
21934
+ ]]
21935
+ ]);
21911
21936
  let $container = (0, _yuneta_gobj_js.createElement2)([
21912
21937
  "div",
21913
21938
  {
@@ -21988,11 +22013,12 @@ function build_ui$6(gobj) {
21988
22013
  source_url
21989
22014
  ]]
21990
22015
  ],
22016
+ ...graph_items,
21991
22017
  [
21992
22018
  "button",
21993
22019
  {
21994
22020
  class: "button TREEDB_JSON_BTN",
21995
- style: "margin-left:auto;",
22021
+ style: graph_href ? "" : "margin-left:auto;",
21996
22022
  title: (0, i18next.t)("raw json"),
21997
22023
  "aria-label": (0, i18next.t)("raw json"),
21998
22024
  "data-i18n-title": "raw json",
@@ -21903,6 +21903,31 @@ function cmd_get_topic_data$1(gobj, cmd, kw, src) {
21903
21903
  ************************************************************/
21904
21904
  function build_ui$6(gobj) {
21905
21905
  let source_url = gobj_read_str_attr(gobj, "source_url") || "";
21906
+ let routes = gobj_read_attr(gobj, "card_action_routes");
21907
+ let graph_tpl = is_object(routes) && typeof routes.graph === "string" ? routes.graph : "";
21908
+ let graph_href = /\/\{topic\}$/.test(graph_tpl) ? graph_tpl.replace(/\/\{topic\}$/, "") : "";
21909
+ let graph_items = [];
21910
+ if (graph_href) graph_items.push([
21911
+ "a",
21912
+ {
21913
+ class: "button TREEDB_GRAPH_BTN",
21914
+ href: graph_href,
21915
+ style: "margin-left:auto;",
21916
+ title: t("graph"),
21917
+ "aria-label": t("graph"),
21918
+ "data-i18n-title": "graph",
21919
+ "data-i18n-aria-label": "graph"
21920
+ },
21921
+ [[
21922
+ "span",
21923
+ { class: "icon" },
21924
+ [yui_toolbar_icon("yi-hexagon-nodes")]
21925
+ ], [
21926
+ "span",
21927
+ { i18n: "graph" },
21928
+ "graph"
21929
+ ]]
21930
+ ]);
21906
21931
  let $container = createElement2([
21907
21932
  "div",
21908
21933
  {
@@ -21983,11 +22008,12 @@ function build_ui$6(gobj) {
21983
22008
  source_url
21984
22009
  ]]
21985
22010
  ],
22011
+ ...graph_items,
21986
22012
  [
21987
22013
  "button",
21988
22014
  {
21989
22015
  class: "button TREEDB_JSON_BTN",
21990
- style: "margin-left:auto;",
22016
+ style: graph_href ? "" : "margin-left:auto;",
21991
22017
  title: t("raw json"),
21992
22018
  "aria-label": t("raw json"),
21993
22019
  "data-i18n-title": "raw json",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.23.137",
3
+ "version": "7.23.138",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -254,6 +254,29 @@ function build_ui(gobj)
254
254
  {
255
255
  let source_url = gobj_read_str_attr(gobj, "source_url") || "";
256
256
 
257
+ /* The whole treedb as a graph, with NO topic focused. A card's graph
258
+ * icon lands on `<graph route>/<topic>`, and that segment is a
259
+ * FOCUS: going through a card was the only way in, and it always
260
+ * arrived with that topic highlighted. The route is the card's
261
+ * template without its `/{topic}`; a host whose template does not
262
+ * end in it, or gives none, gets no button. */
263
+ let routes = gobj_read_attr(gobj, "card_action_routes");
264
+ let graph_tpl = is_object(routes) && typeof routes.graph === "string"? routes.graph : "";
265
+ let graph_href = /\/\{topic\}$/.test(graph_tpl)? graph_tpl.replace(/\/\{topic\}$/, "") : "";
266
+ let graph_items = [];
267
+ if(graph_href) {
268
+ graph_items.push(
269
+ ['a', {class: 'button TREEDB_GRAPH_BTN',
270
+ href: graph_href,
271
+ style: 'margin-left:auto;',
272
+ title: t('graph'), 'aria-label': t('graph'),
273
+ 'data-i18n-title': 'graph', 'data-i18n-aria-label': 'graph'}, [
274
+ ['span', {class: 'icon'}, [yui_toolbar_icon('yi-hexagon-nodes')]],
275
+ ['span', {i18n: 'graph'}, 'graph']
276
+ ]]
277
+ );
278
+ }
279
+
257
280
  /*----------------------------------------------*
258
281
  * Layout Schema
259
282
  *----------------------------------------------*/
@@ -262,12 +285,15 @@ function build_ui(gobj)
262
285
  ['div', {class: 'is-flex-grow-0'}, [
263
286
  ['div', {class: 'is-flex is-align-items-center TREEDB_TOPICS_TOOLBAR',
264
287
  style: 'gap:.25rem; padding:.25rem .25rem;'}, [
265
- /* This toolbar never holds more than TWO buttons at once
266
- * (back|toggle on the left, json on the right), so the
267
- * labels stay on mobile — a deliberate exception to the
268
- * icon-only-on-mobile rule: two bare squares side by side
269
- * read as the same control. The graph's toolbar has many
270
- * more, so it keeps is-hidden-mobile. */
288
+ /* This toolbar never holds more than THREE buttons at once
289
+ * (back|toggle on the left, graph and json on the right),
290
+ * so the labels stay on mobile — a deliberate exception
291
+ * to the icon-only-on-mobile rule: bare squares side by
292
+ * side read as the same control, and the toggle and the
293
+ * graph wear the same icon. They fit at 360px because the
294
+ * source url between them gives way down to its icon. The
295
+ * graph's toolbar has many more, so it keeps
296
+ * is-hidden-mobile. */
271
297
 
272
298
  /* Back to the topic-cards grid (cards-landing mode only);
273
299
  * hidden until a topic is open. */
@@ -309,11 +335,14 @@ function build_ui(gobj)
309
335
  ['span', {class: 'icon'}, [yui_toolbar_icon('yi-cloudversify')]],
310
336
  ['span', {class: 'TREEDB_TOPICS_SOURCE_URL'}, source_url]
311
337
  ]],
338
+ ...graph_items,
312
339
  /* Inspect the treedb's raw tranger json (whole service,
313
- * print-tranger, lazy drill). Last + margin-left:auto:
314
- * flush right, away from the back arrow it sat next to. */
340
+ * print-tranger, lazy drill). Last and flush right, away
341
+ * from the back arrow it sat next to: the `margin-left:
342
+ * auto` goes on the first button of the right group,
343
+ * which is the graph one when there is one. */
315
344
  ['button', {class: 'button TREEDB_JSON_BTN',
316
- style: 'margin-left:auto;',
345
+ style: graph_href? '' : 'margin-left:auto;',
317
346
  title: t('raw json'), 'aria-label': t('raw json'),
318
347
  'data-i18n-title': 'raw json', 'data-i18n-aria-label': 'raw json'}, [
319
348
  ['span', {class: 'icon'}, [yui_toolbar_icon('yi-eye')]],