@yuneta/gobj-ui 7.26.41 → 7.26.42

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.
@@ -1243,8 +1243,9 @@ function build_graph(gobj)
1243
1243
  graph.setTheme(priv.theme);
1244
1244
 
1245
1245
  /* Tab goes from the graph to its own buttons: the main canvas in
1246
- * the Tab order, the other layers out (g6_canvas_tab_order.js). */
1247
- keep_canvas_tab_order(gobj, graph);
1246
+ * the Tab order, named for what it draws, the other layers out
1247
+ * (g6_canvas_tab_order.js). */
1248
+ keep_canvas_tab_order(gobj, graph, "treedb graph");
1248
1249
 
1249
1250
  /* A card is an HTML node, and G6's HTML nodes do not pass the wheel
1250
1251
  * on: over a card the graph neither scrolled nor zoomed. Only a wheel
@@ -430,8 +430,9 @@ function build_graph(gobj)
430
430
  }
431
431
 
432
432
  /* Tab goes from the graph to its own buttons: the main canvas in
433
- * the Tab order, the other layers out (g6_canvas_tab_order.js). */
434
- keep_canvas_tab_order(gobj, priv.graph);
433
+ * the Tab order, named for what it draws, the other layers out
434
+ * (g6_canvas_tab_order.js). */
435
+ keep_canvas_tab_order(gobj, priv.graph, "fsm graph");
435
436
 
436
437
  priv.graph.on('aftertransform', () => {
437
438
  yui_graph_update_zoom(gobj_read_attr(gobj, "$container"), priv.graph);
@@ -1166,8 +1166,9 @@ function build_graph(gobj)
1166
1166
  }
1167
1167
 
1168
1168
  /* Tab goes from the graph to its own buttons: the main canvas in
1169
- * the Tab order, the other layers out (g6_canvas_tab_order.js). */
1170
- keep_canvas_tab_order(gobj, graph);
1169
+ * the Tab order, named for what it draws, the other layers out
1170
+ * (g6_canvas_tab_order.js). */
1171
+ keep_canvas_tab_order(gobj, graph, "gobj tree graph");
1171
1172
 
1172
1173
  /* The readout follows ANY camera change, the wheel included — a
1173
1174
  * wheel notch passes through no action of ours. */
@@ -758,8 +758,9 @@ function build_graph(gobj)
758
758
  }
759
759
 
760
760
  /* Tab goes from the graph to its own buttons: the main canvas in
761
- * the Tab order, the other layers out (g6_canvas_tab_order.js). */
762
- keep_canvas_tab_order(gobj, graph);
761
+ * the Tab order, named for what it draws, the other layers out
762
+ * (g6_canvas_tab_order.js). */
763
+ keep_canvas_tab_order(gobj, graph, "json graph");
763
764
 
764
765
  graph.on(NodeEvent.CLICK, (evt) => {
765
766
  /* An identity, never the G6 event: a kw is plain json, and the
package/src/c_yui_nav.js CHANGED
@@ -463,17 +463,17 @@ function render_tabs(gobj, items)
463
463
  }
464
464
  /* A tab with show_label:false is a bare icon: the label is
465
465
  * its only name (same contract as item_li). */
466
- let label = it.name || "";
466
+ let name_key = it.name || it.aria_label || it.id || "";
467
467
  let a_attrs = {
468
468
  href: it.route ? "#" + it.route : "#",
469
469
  "data-item-id": it.id,
470
470
  "data-route": it.route || "",
471
- "aria-label": label || it.id
471
+ "aria-label": name_key
472
472
  };
473
- if(label) {
474
- a_attrs["data-i18n-aria-label"] = label;
473
+ if(name_key) {
474
+ a_attrs["data-i18n-aria-label"] = name_key;
475
475
  }
476
- let tip = it.tooltip || it.aria_label || label;
476
+ let tip = it.tooltip || it.aria_label || name_key;
477
477
  if(tip) {
478
478
  a_attrs.title = tip;
479
479
  a_attrs["data-i18n-title"] = tip;
@@ -543,19 +543,22 @@ function render_breadcrumb(gobj, items)
543
543
  }
544
544
  /* Named and titled like every other item of the nav: up to
545
545
  * 7.26.34 a crumb had no title, and no name when it had no
546
- * `name` (an icon crumb read as nothing). */
546
+ * `name` (an icon crumb read as nothing), and from 7.26.35 to
547
+ * 7.26.41 it was named by its raw id, with no key: the id is
548
+ * its key, as in item_li. */
549
+ let name_key = it.name || it.aria_label || it.id || "";
547
550
  let a_attrs = {
548
551
  class: "yui-nav-item yui-nav-crumb",
549
552
  href: it.route ? "#" + it.route : "#",
550
553
  "data-item-id": it.id,
551
554
  "data-route": it.route || "",
552
555
  "data-disabled": it.disabled ? "1" : "0",
553
- "aria-label": it.name || it.id
556
+ "aria-label": name_key
554
557
  };
555
- if(it.name) {
556
- a_attrs["data-i18n-aria-label"] = it.name;
558
+ if(name_key) {
559
+ a_attrs["data-i18n-aria-label"] = name_key;
557
560
  }
558
- let tip = it.tooltip || it.aria_label || it.name;
561
+ let tip = it.tooltip || it.aria_label || name_key;
559
562
  if(tip) {
560
563
  a_attrs.title = tip;
561
564
  a_attrs["data-i18n-title"] = tip;
@@ -690,10 +693,17 @@ function render_accordion(gobj, items)
690
693
  let head_badge = item_badge_node(gobj, it, false);
691
694
  if(!empty_string(head_text)) {
692
695
  head_attrs.i18n = head_text;
693
- head_attrs.title = head_text;
694
- head_attrs["data-i18n-title"] = head_text;
695
- head_attrs["aria-label"] = head_text;
696
- head_attrs["data-i18n-aria-label"] = head_text;
696
+ }
697
+ /* Named as every item (item_li): its `name`, else its
698
+ * `aria_label`, else its id, a KEY in every case. Up to 7.26.41
699
+ * a head without a `name` was a button with no name at all. */
700
+ let name_key = it.name || it.aria_label || it.id || "";
701
+ if(!empty_string(name_key)) {
702
+ let tip = it.tooltip || it.aria_label || name_key;
703
+ head_attrs.title = tip;
704
+ head_attrs["data-i18n-title"] = tip;
705
+ head_attrs["aria-label"] = name_key;
706
+ head_attrs["data-i18n-aria-label"] = name_key;
697
707
  /* The count is part of its name: inside a <button> the
698
708
  * badge is no node of its own for a reader (yui_badge.js) */
699
709
  name_control_with_badge(head_attrs, head_badge);
@@ -791,28 +801,32 @@ function item_li(gobj, it, opts)
791
801
  }
792
802
  }
793
803
 
794
- let aria_key = label || it.id;
804
+ /* The name of an item: its `name`, else its `aria_label`, else its
805
+ * id -- a KEY in every case, translated by the pass that translates
806
+ * the labels and reached by a language switch. Up to 7.26.41 an
807
+ * item without a `name` was named by its raw id, with no key and no
808
+ * title, and the `aria_label` it declared went only to the tooltip. */
809
+ let name_key = it.name || it.aria_label || it.id || "";
795
810
  let a_attrs = {
796
811
  class: a_class,
797
812
  href: it.route ? "#" + it.route : "#",
798
813
  "data-item-id": it.id,
799
814
  "data-route": it.route || "",
800
815
  "data-disabled": it.disabled ? "1" : "0",
801
- "aria-label": aria_key
816
+ "aria-label": name_key
802
817
  };
803
818
  /* Mirror the aria-label key in `data-i18n-aria-label` so
804
- * refresh_language() can re-translate it on language switch.
805
- * Only when sourced from a real label (skip the bare-id
806
- * fallback — ids aren't translation keys). */
807
- if(label) {
808
- a_attrs["data-i18n-aria-label"] = label;
819
+ * refresh_language() can re-translate it on language switch. */
820
+ if(name_key) {
821
+ a_attrs["data-i18n-aria-label"] = name_key;
809
822
  }
810
823
  /* Hover tooltip: prefer explicit `tooltip`, fall back to
811
- * `aria_label` (typically equivalent, e.g. "Search (Ctrl+F)").
812
- * Skip when both empty so we don't emit `title=""` noise.
824
+ * `aria_label` (typically equivalent, e.g. "Search (Ctrl+F)"),
825
+ * then the name. Skip when all are empty so we don't emit
826
+ * `title=""` noise.
813
827
  * Mirror the value in `data-i18n-title` so refresh_language()
814
828
  * can re-translate the tooltip on language switch. */
815
- let tip = it.tooltip || it.aria_label || label;
829
+ let tip = it.tooltip || it.aria_label || name_key;
816
830
  if(tip) {
817
831
  a_attrs.title = tip;
818
832
  a_attrs["data-i18n-title"] = tip;
@@ -864,17 +878,18 @@ function item_iconbar(gobj, it, opts)
864
878
  children.push(badge_el);
865
879
  }
866
880
 
881
+ let name_key = it.name || it.aria_label || it.id || "";
867
882
  let a_attrs = {
868
883
  class: "yui-nav-item yui-nav-stacked",
869
884
  href: it.route ? "#" + it.route : "#",
870
885
  "data-item-id": it.id,
871
886
  "data-route": it.route || "",
872
- "aria-label": label || it.id
887
+ "aria-label": name_key
873
888
  };
874
- if(label) {
875
- a_attrs["data-i18n-aria-label"] = label;
889
+ if(name_key) {
890
+ a_attrs["data-i18n-aria-label"] = name_key;
876
891
  }
877
- let tip = it.tooltip || it.aria_label || label;
892
+ let tip = it.tooltip || it.aria_label || name_key;
878
893
  if(tip) {
879
894
  a_attrs.title = tip;
880
895
  a_attrs["data-i18n-title"] = tip;
@@ -58,6 +58,22 @@
58
58
  cursor: pointer;
59
59
  }
60
60
 
61
+ /* The opener of a topic row: a real button -- a key presses it, a
62
+ * reader announces it -- that looks like the name it is. Not
63
+ * `font: inherit`: it would undo the weight of the name. */
64
+ .C_YUI_SCHEMA_EDITOR .SCHEMA_TOPIC_OPEN {
65
+ background: none;
66
+ border: 0;
67
+ margin: 0;
68
+ padding: 0;
69
+ color: inherit;
70
+ font-family: inherit;
71
+ font-size: inherit;
72
+ line-height: inherit;
73
+ text-align: inherit;
74
+ cursor: pointer;
75
+ }
76
+
61
77
  .C_YUI_SCHEMA_EDITOR .SCHEMA_COL_FLAGS .tags {
62
78
  margin-bottom: 0;
63
79
  }
@@ -291,6 +291,10 @@ let PRIVATE_DATA = {
291
291
 
292
292
  let __gclass__ = null;
293
293
 
294
+ /* The ids that tie an opener to what describes it (aria-describedby):
295
+ * the counts of a card, the id of a topic row whose name is not unique. */
296
+ let __described_seq__ = 0;
297
+
294
298
 
295
299
 
296
300
 
@@ -1295,6 +1299,15 @@ function render(gobj)
1295
1299
  * A card that opens something, with its own logical name. The
1296
1300
  * cards grid is the shell's, so a schema card and a nav card
1297
1301
  * look alike on purpose.
1302
+ *
1303
+ * `title` is the card's name: `{i18n: key}`, or `{text: data}` for
1304
+ * a name no locale holds (a treedb's id). The card is a control --
1305
+ * a role=button that Enter and Space press -- and a control is
1306
+ * NAMED: a title and an aria-label, with their keys when the name
1307
+ * is one, and its tags (the counts) as its description, which an
1308
+ * aria-label alone would hide from a reader. Up to 7.26.41 it had
1309
+ * neither, and the orphans card was handed its name translated,
1310
+ * in the language it was drawn in for good.
1298
1311
  ***************************************************************/
1299
1312
  function open_card(gobj, logical, title, icon, tags, event, kw)
1300
1313
  {
@@ -1323,14 +1336,29 @@ function open_card(gobj, logical, title, icon, tags, event, kw)
1323
1336
  : `${tag.text}`];
1324
1337
  });
1325
1338
 
1326
- return ["div", {class: `${logical} yui-nav-card card`, role: "button", tabindex: "0"}, [
1339
+ let tags_id = `yui-schema-described-${++__described_seq__}`;
1340
+ let card_attrs = {class: `${logical} yui-nav-card card`, role: "button", tabindex: "0",
1341
+ "aria-describedby": tags_id};
1342
+ let $name;
1343
+ if(title.i18n) {
1344
+ Object.assign(card_attrs, name_attrs(title.i18n, {}));
1345
+ $name = ["span", {class: `${logical}_NAME has-text-weight-semibold`, i18n: title.i18n},
1346
+ t(title.i18n)];
1347
+ } else {
1348
+ card_attrs.title = String(title.text);
1349
+ card_attrs["aria-label"] = String(title.text);
1350
+ $name = ["span", {class: `${logical}_NAME has-text-weight-semibold`},
1351
+ text_node(title.text)];
1352
+ }
1353
+
1354
+ return ["div", card_attrs, [
1327
1355
  ["div", {class: `${logical}_BODY card-content p-3`}, [
1328
1356
  ["p", {class: `${logical}_TITLE is-flex is-align-items-center`,
1329
1357
  style: "gap:.4rem;"}, [
1330
- ["span", {class: "icon"}, [["i", {class: icon}]]],
1331
- ["span", {class: `${logical}_NAME has-text-weight-semibold`}, text_node(title)]
1358
+ ["span", {class: "icon"}, [["i", {class: icon, "aria-hidden": "true"}]]],
1359
+ $name
1332
1360
  ]],
1333
- ["div", {class: `${logical}_TAGS tags mt-2`, style: "gap:.25rem;"}, $tags]
1361
+ ["div", {class: `${logical}_TAGS tags mt-2`, id: tags_id, style: "gap:.25rem;"}, $tags]
1334
1362
  ]]
1335
1363
  ], {
1336
1364
  click: (evt) => {
@@ -1372,7 +1400,7 @@ function render_treedbs(gobj, $body)
1372
1400
  ? [{i18n: "from c", text: treedb.c_schema_version, style: "is-warning is-light"}]
1373
1401
  : [])
1374
1402
  ];
1375
- $cards.push(open_card(gobj, "SCHEMA_TREEDB_CARD", treedb.id, "yi-database",
1403
+ $cards.push(open_card(gobj, "SCHEMA_TREEDB_CARD", {text: treedb.id}, "yi-database",
1376
1404
  tags, "EV_SELECT_TREEDB", {treedb: treedb.id}));
1377
1405
  }
1378
1406
 
@@ -1380,7 +1408,7 @@ function render_treedbs(gobj, $body)
1380
1408
  /* A leftover of a deletion belongs to no treedb and would be
1381
1409
  * invisible in a screen that only draws the tree. Saying it
1382
1410
  * here is the only place it can be said. */
1383
- $cards.push(open_card(gobj, "SCHEMA_ORPHAN_CARD", t("orphans"), "yi-triangle-exclamation",
1411
+ $cards.push(open_card(gobj, "SCHEMA_ORPHAN_CARD", {i18n: "orphans"}, "yi-triangle-exclamation",
1384
1412
  [{i18n: "topics", text: priv.model.orphan_topics.length},
1385
1413
  {i18n: "columns", text: priv.model.orphan_cols.length}],
1386
1414
  "EV_SHOW_ORPHANS", {}));
@@ -1429,9 +1457,30 @@ function render_topics(gobj, $body)
1429
1457
  "EV_DELETE_TOPIC", {topic: address}));
1430
1458
  }
1431
1459
 
1432
- $rows.push(["tr", {class: "SCHEMA_TOPIC_ROW", role: "button", tabindex: "0"}, [
1460
+ /* The row stays a ROW: a `<tr role=button>` -- what it was up to
1461
+ * 7.26.41 -- is a button to a reader, with no cells, and it had
1462
+ * no name. The opener is a real button in the name cell, named
1463
+ * by the topic: a key presses it with no handler of ours, and a
1464
+ * reader reads the rest of the row as cells of a table. Two
1465
+ * topics of one name are told apart by the id under the name,
1466
+ * which describes the opener. The pointer opens the topic from
1467
+ * anywhere in the row, as before. */
1468
+ let open_attrs = {class: "SCHEMA_TOPIC_OPEN has-text-weight-semibold", type: "button",
1469
+ title: topic.name, "aria-label": topic.name};
1470
+ let id_attrs = {class: "SCHEMA_TOPIC_ID is-size-7 yui-text-quiet"};
1471
+ if(ambiguous) {
1472
+ id_attrs.id = `yui-schema-described-${++__described_seq__}`;
1473
+ open_attrs["aria-describedby"] = id_attrs.id;
1474
+ }
1475
+
1476
+ $rows.push(["tr", {class: "SCHEMA_TOPIC_ROW"}, [
1433
1477
  ["td", {class: "SCHEMA_TOPIC_NAME"}, [
1434
- ["span", {class: "has-text-weight-semibold"}, text_node(topic.name)],
1478
+ ["button", open_attrs, text_node(topic.name), {
1479
+ click: (evt) => {
1480
+ evt.stopPropagation();
1481
+ gobj_send_event(gobj, "EV_SELECT_TOPIC", {topic: address}, gobj);
1482
+ }
1483
+ }],
1435
1484
  topic.system_topic
1436
1485
  ? ["span", {class: "SCHEMA_TOPIC_SYSTEM tag ml-2",
1437
1486
  i18n: "system"}, t("system")]
@@ -1444,8 +1493,7 @@ function render_topics(gobj, $body)
1444
1493
  title: t("main topic"), "data-i18n-title": "main topic"}, "★"]
1445
1494
  : ["span", {}, ""],
1446
1495
  ambiguous
1447
- ? ["div", {class: "SCHEMA_TOPIC_ID is-size-7 yui-text-quiet"},
1448
- [["code", {}, text_node(topic.id)]]]
1496
+ ? ["div", id_attrs, [["code", {}, text_node(topic.id)]]]
1449
1497
  : ["span", {}, ""]
1450
1498
  ]],
1451
1499
  ["td", {class: "SCHEMA_TOPIC_PKEY"}, [["code", {}, text_node(topic.pkey || "id")]]],
@@ -1456,18 +1504,14 @@ function render_topics(gobj, $body)
1456
1504
  ]],
1457
1505
  ["td", {class: "SCHEMA_TOPIC_ACTIONS has-text-right"}, $actions]
1458
1506
  ], {
1507
+ /* The pointer's way in. The keyboard's is the opener: the
1508
+ * row's own keydown also took an Enter meant for a row
1509
+ * action, which then opened the topic instead. */
1459
1510
  click: (evt) => {
1460
1511
  if(evt.target.closest(".SCHEMA_TOPIC_ACTIONS")) {
1461
1512
  return; /* a row action, not the row */
1462
1513
  }
1463
1514
  gobj_send_event(gobj, "EV_SELECT_TOPIC", {topic: address}, gobj);
1464
- },
1465
- keydown: (evt) => {
1466
- if(evt.key !== "Enter" && evt.key !== " ") {
1467
- return;
1468
- }
1469
- evt.preventDefault();
1470
- gobj_send_event(gobj, "EV_SELECT_TOPIC", {topic: address}, gobj);
1471
1515
  }
1472
1516
  }]);
1473
1517
  }