@yuneta/gobj-ui 7.2.4 → 7.2.5

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.
@@ -16954,11 +16954,12 @@ function create_tabulator(gobj) {
16954
16954
  }
16955
16955
  let tabulator = new tabulator_tables.TabulatorFull($table_el, Object.assign({}, tabulator_settings, yui_tabulator_lang(i18next.t), { placeholder: (0, i18next.t)("no data available", { defaultValue: "No data available" }) }));
16956
16956
  if (with_checkbox) $table_el.classList.add("yui-no-row-hover");
16957
- function update_rowcount() {
16957
+ function update_rowcount(explicit_count) {
16958
16958
  let $rc = tabulator.element && tabulator.element.querySelector(".yui-tabulator-rowcount");
16959
16959
  if (!$rc) return;
16960
16960
  let n = 0;
16961
- try {
16961
+ if (typeof explicit_count === "number") n = explicit_count;
16962
+ else try {
16962
16963
  n = tabulator.getDataCount("active");
16963
16964
  } catch (e) {
16964
16965
  n = 0;
@@ -16966,8 +16967,8 @@ function create_tabulator(gobj) {
16966
16967
  $rc.textContent = `${n} ${(0, i18next.t)("rows")}`;
16967
16968
  let single_page = true;
16968
16969
  try {
16969
- let max = tabulator.getPageMax();
16970
- single_page = max === false || max <= 1;
16970
+ let size = tabulator.getPageSize();
16971
+ single_page = !size || n <= size;
16971
16972
  } catch (e) {
16972
16973
  single_page = true;
16973
16974
  }
@@ -16984,7 +16985,9 @@ function create_tabulator(gobj) {
16984
16985
  });
16985
16986
  tabulator.on("dataProcessed", update_rowcount);
16986
16987
  tabulator.on("dataChanged", update_rowcount);
16987
- tabulator.on("dataFiltered", update_rowcount);
16988
+ tabulator.on("dataFiltered", function(filters, rows) {
16989
+ update_rowcount(Array.isArray(rows) ? rows.length : void 0);
16990
+ });
16988
16991
  tabulator.on("rowSelected", function(row) {
16989
16992
  (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_SELECT_ROWS", { rows: [row.getData()] }, gobj);
16990
16993
  });
@@ -16949,11 +16949,12 @@ function create_tabulator(gobj) {
16949
16949
  }
16950
16950
  let tabulator = new TabulatorFull($table_el, Object.assign({}, tabulator_settings, yui_tabulator_lang(t), { placeholder: t("no data available", { defaultValue: "No data available" }) }));
16951
16951
  if (with_checkbox) $table_el.classList.add("yui-no-row-hover");
16952
- function update_rowcount() {
16952
+ function update_rowcount(explicit_count) {
16953
16953
  let $rc = tabulator.element && tabulator.element.querySelector(".yui-tabulator-rowcount");
16954
16954
  if (!$rc) return;
16955
16955
  let n = 0;
16956
- try {
16956
+ if (typeof explicit_count === "number") n = explicit_count;
16957
+ else try {
16957
16958
  n = tabulator.getDataCount("active");
16958
16959
  } catch (e) {
16959
16960
  n = 0;
@@ -16961,8 +16962,8 @@ function create_tabulator(gobj) {
16961
16962
  $rc.textContent = `${n} ${t("rows")}`;
16962
16963
  let single_page = true;
16963
16964
  try {
16964
- let max = tabulator.getPageMax();
16965
- single_page = max === false || max <= 1;
16965
+ let size = tabulator.getPageSize();
16966
+ single_page = !size || n <= size;
16966
16967
  } catch (e) {
16967
16968
  single_page = true;
16968
16969
  }
@@ -16979,7 +16980,9 @@ function create_tabulator(gobj) {
16979
16980
  });
16980
16981
  tabulator.on("dataProcessed", update_rowcount);
16981
16982
  tabulator.on("dataChanged", update_rowcount);
16982
- tabulator.on("dataFiltered", update_rowcount);
16983
+ tabulator.on("dataFiltered", function(filters, rows) {
16984
+ update_rowcount(Array.isArray(rows) ? rows.length : void 0);
16985
+ });
16983
16986
  tabulator.on("rowSelected", function(row) {
16984
16987
  gobj_send_event(gobj, "EV_SELECT_ROWS", { rows: [row.getData()] }, gobj);
16985
16988
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.2.4",
3
+ "version": "7.2.5",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -1082,24 +1082,40 @@ function create_tabulator(gobj)
1082
1082
  /* Keep the footer in sync with the visible (active) row count,
1083
1083
  * and hide the pagination chrome while everything fits in one
1084
1084
  * page (it comes back as soon as a second page exists). */
1085
- function update_rowcount() {
1085
+ /* `explicit_count` is for the ONE caller that cannot ask the table:
1086
+ * `dataFiltered` is dispatched from INSIDE Tabulator's filter(), which
1087
+ * only RETURNS the surviving rows to the pipeline afterwards — so
1088
+ * `getDataCount("active")` still answers the pre-filter set there and
1089
+ * the footer claimed "5 rows" over four. The event hands us the rows
1090
+ * it just kept; that is the number. Every other caller passes nothing
1091
+ * and the table is asked. The `typeof` guard matters because
1092
+ * `dataProcessed` / `dataChanged` are registered directly and hand a
1093
+ * DATA ARRAY as their first argument. */
1094
+ function update_rowcount(explicit_count) {
1086
1095
  let $rc = tabulator.element &&
1087
1096
  tabulator.element.querySelector(".yui-tabulator-rowcount");
1088
1097
  if(!$rc) {
1089
1098
  return;
1090
1099
  }
1091
1100
  let n = 0;
1092
- try {
1093
- n = tabulator.getDataCount("active");
1094
- } catch(e) {
1095
- n = 0;
1101
+ if(typeof explicit_count === "number") {
1102
+ n = explicit_count;
1103
+ } else {
1104
+ try {
1105
+ n = tabulator.getDataCount("active");
1106
+ } catch(e) {
1107
+ n = 0;
1108
+ }
1096
1109
  }
1097
1110
  $rc.textContent = `${n} ${t("rows")}`;
1098
1111
 
1112
+ /* Derived from the count and the page size rather than read from
1113
+ * getPageMax(), which is stale in the filter path for the same
1114
+ * reason. getPageSize() throws with pagination off -> one page. */
1099
1115
  let single_page = true;
1100
1116
  try {
1101
- let max = tabulator.getPageMax(); // false = pagination off
1102
- single_page = (max === false) || max <= 1;
1117
+ let size = tabulator.getPageSize();
1118
+ single_page = !size || n <= size;
1103
1119
  } catch(e) {
1104
1120
  single_page = true;
1105
1121
  }
@@ -1123,7 +1139,9 @@ function create_tabulator(gobj)
1123
1139
  * box; a filter per column made it a claim you read on every keystroke. */
1124
1140
  tabulator.on("dataProcessed", update_rowcount);
1125
1141
  tabulator.on("dataChanged", update_rowcount);
1126
- tabulator.on("dataFiltered", update_rowcount);
1142
+ tabulator.on("dataFiltered", function(filters, rows) {
1143
+ update_rowcount(Array.isArray(rows)? rows.length : undefined);
1144
+ });
1127
1145
  tabulator.on("rowSelected", function(row) {
1128
1146
  gobj_send_event(gobj, "EV_SELECT_ROWS", {rows: [row.getData()]}, gobj);
1129
1147
  });