@yuneta/gobj-ui 7.23.126 → 7.23.128

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.
@@ -7393,9 +7393,15 @@ function name_form_control($field, conf) {
7393
7393
  let key = conf.label_i18n || conf.label || "";
7394
7394
  if (!key) return;
7395
7395
  let $control = $field.querySelector("input, select, textarea");
7396
- if (!$control || $control.getAttribute("aria-label")) return;
7397
- $control.setAttribute("aria-label", (0, i18next.t)(key));
7398
- $control.setAttribute("data-i18n-aria-label", key);
7396
+ if ($control && !$control.getAttribute("aria-label")) {
7397
+ $control.setAttribute("aria-label", (0, i18next.t)(key));
7398
+ $control.setAttribute("data-i18n-aria-label", key);
7399
+ }
7400
+ let $ts = $field.querySelector(".ts-control input");
7401
+ if ($ts && !$ts.getAttribute("aria-label")) {
7402
+ $ts.setAttribute("aria-label", (0, i18next.t)(key));
7403
+ $ts.setAttribute("data-i18n-aria-label", key);
7404
+ }
7399
7405
  }
7400
7406
  function build_form(gobj) {
7401
7407
  let form_id = (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "form_id");
@@ -8443,7 +8449,7 @@ function create_tabulator$1(gobj, $extend, name, template) {
8443
8449
  tabulator.on("renderComplete", function() {
8444
8450
  yui_tabulator_name_row_selects(tabulator, i18next.t);
8445
8451
  });
8446
- tabulator.on("tableBuilt", function() {
8452
+ tabulator.on("columnsLoaded", function() {
8447
8453
  yui_tabulator_name_row_selects(tabulator, i18next.t);
8448
8454
  });
8449
8455
  tabulator.on("rowClick", function(e, row) {
@@ -25087,12 +25093,15 @@ function create_tabulator(gobj) {
25087
25093
  if (cellClick) colDef.cellClick = cellClick;
25088
25094
  columns.push(colDef);
25089
25095
  }
25096
+ function attr_text(value) {
25097
+ return String(value).replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
25098
+ }
25090
25099
  function operateFormatter(cell, formatterParams, onRendered) {
25091
25100
  return [
25092
- "<button class=\"button without-border px-2 edit\">",
25101
+ `<button class="button without-border px-2 edit" title="${attr_text((0, i18next.t)("edit"))}" aria-label="${attr_text((0, i18next.t)("edit"))}">`,
25093
25102
  "<i style=\"\" class=\"yi-pen has-text-link\"></i>",
25094
25103
  "</button>",
25095
- "<button class=\"button without-border px-2 remove\">",
25104
+ `<button class="button without-border px-2 remove" title="${attr_text((0, i18next.t)("delete"))}" aria-label="${attr_text((0, i18next.t)("delete"))}">`,
25096
25105
  "<i style=\"\" class=\"yi-trash has-text-danger\"></i>",
25097
25106
  "</button>"
25098
25107
  ].join("");
@@ -25218,6 +25227,10 @@ function create_tabulator(gobj) {
25218
25227
  tabulator.element.classList.toggle("yui-single-page", single_page);
25219
25228
  tabulator.element.classList.toggle("yui-no-paginator", no_paginator);
25220
25229
  }
25230
+ tabulator.on("columnsLoaded", function() {
25231
+ yui_tabulator_name_filters(tabulator, i18next.t);
25232
+ yui_tabulator_name_row_selects(tabulator, i18next.t);
25233
+ });
25221
25234
  tabulator._ready = false;
25222
25235
  tabulator.on("tableBuilt", function() {
25223
25236
  yui_tabulator_name_filters(tabulator, i18next.t);
@@ -7388,9 +7388,15 @@ function name_form_control($field, conf) {
7388
7388
  let key = conf.label_i18n || conf.label || "";
7389
7389
  if (!key) return;
7390
7390
  let $control = $field.querySelector("input, select, textarea");
7391
- if (!$control || $control.getAttribute("aria-label")) return;
7392
- $control.setAttribute("aria-label", t(key));
7393
- $control.setAttribute("data-i18n-aria-label", key);
7391
+ if ($control && !$control.getAttribute("aria-label")) {
7392
+ $control.setAttribute("aria-label", t(key));
7393
+ $control.setAttribute("data-i18n-aria-label", key);
7394
+ }
7395
+ let $ts = $field.querySelector(".ts-control input");
7396
+ if ($ts && !$ts.getAttribute("aria-label")) {
7397
+ $ts.setAttribute("aria-label", t(key));
7398
+ $ts.setAttribute("data-i18n-aria-label", key);
7399
+ }
7394
7400
  }
7395
7401
  function build_form(gobj) {
7396
7402
  let form_id = gobj_read_str_attr(gobj, "form_id");
@@ -8438,7 +8444,7 @@ function create_tabulator$1(gobj, $extend, name, template) {
8438
8444
  tabulator.on("renderComplete", function() {
8439
8445
  yui_tabulator_name_row_selects(tabulator, t);
8440
8446
  });
8441
- tabulator.on("tableBuilt", function() {
8447
+ tabulator.on("columnsLoaded", function() {
8442
8448
  yui_tabulator_name_row_selects(tabulator, t);
8443
8449
  });
8444
8450
  tabulator.on("rowClick", function(e, row) {
@@ -25082,12 +25088,15 @@ function create_tabulator(gobj) {
25082
25088
  if (cellClick) colDef.cellClick = cellClick;
25083
25089
  columns.push(colDef);
25084
25090
  }
25091
+ function attr_text(value) {
25092
+ return String(value).replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
25093
+ }
25085
25094
  function operateFormatter(cell, formatterParams, onRendered) {
25086
25095
  return [
25087
- "<button class=\"button without-border px-2 edit\">",
25096
+ `<button class="button without-border px-2 edit" title="${attr_text(t("edit"))}" aria-label="${attr_text(t("edit"))}">`,
25088
25097
  "<i style=\"\" class=\"yi-pen has-text-link\"></i>",
25089
25098
  "</button>",
25090
- "<button class=\"button without-border px-2 remove\">",
25099
+ `<button class="button without-border px-2 remove" title="${attr_text(t("delete"))}" aria-label="${attr_text(t("delete"))}">`,
25091
25100
  "<i style=\"\" class=\"yi-trash has-text-danger\"></i>",
25092
25101
  "</button>"
25093
25102
  ].join("");
@@ -25213,6 +25222,10 @@ function create_tabulator(gobj) {
25213
25222
  tabulator.element.classList.toggle("yui-single-page", single_page);
25214
25223
  tabulator.element.classList.toggle("yui-no-paginator", no_paginator);
25215
25224
  }
25225
+ tabulator.on("columnsLoaded", function() {
25226
+ yui_tabulator_name_filters(tabulator, t);
25227
+ yui_tabulator_name_row_selects(tabulator, t);
25228
+ });
25216
25229
  tabulator._ready = false;
25217
25230
  tabulator.on("tableBuilt", function() {
25218
25231
  yui_tabulator_name_filters(tabulator, t);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.23.126",
3
+ "version": "7.23.128",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
package/src/c_yui_form.js CHANGED
@@ -517,11 +517,22 @@ function name_form_control($field, conf)
517
517
  return; /* a field with no label names nothing */
518
518
  }
519
519
  let $control = $field.querySelector("input, select, textarea");
520
- if(!$control || $control.getAttribute("aria-label")) {
521
- return;
520
+ if($control && !$control.getAttribute("aria-label")) {
521
+ $control.setAttribute("aria-label", t(key));
522
+ $control.setAttribute("data-i18n-aria-label", key);
523
+ }
524
+
525
+ /* Tom Select HIDES the <select> it is given (`ts-hidden-accessible`)
526
+ * and draws its own text box in front of it. Naming the original
527
+ * therefore names the element nobody can reach: the box the reader
528
+ * actually lands on had no name at all. Give it the same one -- it
529
+ * is the same field -- and only when it has none, so a field that
530
+ * named its own box keeps it. */
531
+ let $ts = $field.querySelector(".ts-control input");
532
+ if($ts && !$ts.getAttribute("aria-label")) {
533
+ $ts.setAttribute("aria-label", t(key));
534
+ $ts.setAttribute("data-i18n-aria-label", key);
522
535
  }
523
- $control.setAttribute("aria-label", t(key));
524
- $control.setAttribute("data-i18n-aria-label", key);
525
536
  }
526
537
 
527
538
  function build_form(gobj)
@@ -1842,9 +1853,11 @@ function create_tabulator(gobj, $extend, name, template)
1842
1853
  tabulator.on("renderComplete", function() {
1843
1854
  yui_tabulator_name_row_selects(tabulator, t);
1844
1855
  });
1845
- /* And at build: an EMPTY table renders no body, so `renderComplete`
1846
- * never fires and the header's own box would keep its English name. */
1847
- tabulator.on("tableBuilt", function() {
1856
+ /* And on every rebuild of the COLUMNS: an empty table renders no
1857
+ * body, so `renderComplete` never fires and the header's own box
1858
+ * would keep its English name -- and a `setColumns()` rebuilds the
1859
+ * header, throwing away whatever name was on it. */
1860
+ tabulator.on("columnsLoaded", function() {
1848
1861
  yui_tabulator_name_row_selects(tabulator, t);
1849
1862
  });
1850
1863
  tabulator.on("rowClick", function(e, row) {
@@ -1371,12 +1371,28 @@ function create_tabulator(gobj)
1371
1371
  /*
1372
1372
  * Column with operators: edit, delete
1373
1373
  */
1374
+ /* Two ICON-ONLY buttons with no name of any kind -- and written as an
1375
+ * HTML STRING, where no sweep of `createElement2` specs can see them.
1376
+ * `t()` alone is enough and no `data-i18n-aria-label` is needed: a
1377
+ * language change re-runs `setColumns()`, which re-runs this
1378
+ * formatter. The text goes through an escaper because a translation
1379
+ * is text entering an attribute. */
1380
+ function attr_text(value) {
1381
+ return String(value)
1382
+ .replace(/&/g, "&amp;").replace(/"/g, "&quot;")
1383
+ .replace(/</g, "&lt;").replace(/>/g, "&gt;");
1384
+ }
1385
+
1374
1386
  function operateFormatter(cell, formatterParams, onRendered) {
1375
1387
  return [
1376
- '<button class="button without-border px-2 edit">',
1388
+ `<button class="button without-border px-2 edit" ` +
1389
+ `title="${attr_text(t("edit"))}" ` +
1390
+ `aria-label="${attr_text(t("edit"))}">`,
1377
1391
  '<i style="" class="yi-pen has-text-link"></i>',
1378
1392
  '</button>',
1379
- '<button class="button without-border px-2 remove">',
1393
+ `<button class="button without-border px-2 remove" ` +
1394
+ `title="${attr_text(t("delete"))}" ` +
1395
+ `aria-label="${attr_text(t("delete"))}">`,
1380
1396
  '<i style="" class="yi-trash has-text-danger"></i>',
1381
1397
  '</button>'
1382
1398
  ].join('');
@@ -1652,6 +1668,16 @@ function create_tabulator(gobj)
1652
1668
  tabulator.element.classList.toggle("yui-no-paginator", no_paginator);
1653
1669
  }
1654
1670
 
1671
+ /* `columnsLoaded` and not only `tableBuilt`: EVERY rebuild of the
1672
+ * columns rebuilds the header, and the header carries two things
1673
+ * Tabulator draws without a name -- the per-column filter box and the
1674
+ * select-all checkbox. A language change runs `setColumns()`, so the
1675
+ * names put on at build were thrown away with the old header and the
1676
+ * boxes came back in English. This event fires on both paths. */
1677
+ tabulator.on("columnsLoaded", function() {
1678
+ yui_tabulator_name_filters(tabulator, t);
1679
+ yui_tabulator_name_row_selects(tabulator, t);
1680
+ });
1655
1681
  tabulator._ready = false;
1656
1682
  tabulator.on("tableBuilt", function() {
1657
1683
  /* Tabulator gives its header-filter boxes no name of any kind: