@yuneta/gobj-ui 7.23.50 → 7.23.51

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.
@@ -22864,6 +22864,33 @@ function delete_impact(desc, records) {
22864
22864
  * Constants
22865
22865
  ***************************************************************/
22866
22866
  var GCLASS_NAME$5 = "C_YUI_TREEDB_TOPIC_WITH_FORM";
22867
+ var PAGE_SIZE_STORE_PREFIX = "yui_treedb_page_size:";
22868
+ /************************************************************
22869
+ * The size the reader left, or null when there is none.
22870
+ * `true` is Tabulator's "All" and it round-trips as the boolean:
22871
+ * JSON.parse gives it back as one, and a string "true" would be
22872
+ * read by Tabulator as a size of NaN.
22873
+ ************************************************************/
22874
+ function load_page_size(gobj) {
22875
+ try {
22876
+ let raw = window.localStorage.getItem(PAGE_SIZE_STORE_PREFIX + (0, _yuneta_gobj_js.gobj_name)(gobj));
22877
+ if (raw === null) return null;
22878
+ let size = JSON.parse(raw);
22879
+ if (size === true) return true;
22880
+ if (typeof size === "number" && size > 0) return size;
22881
+ return null;
22882
+ } catch (e) {
22883
+ return null;
22884
+ }
22885
+ }
22886
+ /************************************************************
22887
+ *
22888
+ ************************************************************/
22889
+ function save_page_size(gobj, size) {
22890
+ try {
22891
+ window.localStorage.setItem(PAGE_SIZE_STORE_PREFIX + (0, _yuneta_gobj_js.gobj_name)(gobj), JSON.stringify(size));
22892
+ } catch (e) {}
22893
+ }
22867
22894
  /***************************************************************
22868
22895
  * Data
22869
22896
  ***************************************************************/
@@ -22920,6 +22947,7 @@ var PRIVATE_DATA$5 = {
22920
22947
  _pending_pages: null,
22921
22948
  _page_seq: 0,
22922
22949
  _page_total: null,
22950
+ _page_size: null,
22923
22951
  $container: null,
22924
22952
  treedb_name: "",
22925
22953
  topic_name: "",
@@ -23806,6 +23834,9 @@ function create_tabulator(gobj) {
23806
23834
  }
23807
23835
  });
23808
23836
  }
23837
+ let remembered_size = load_page_size(gobj);
23838
+ if (remembered_size !== null && tabulator_settings.pagination) tabulator_settings.paginationSize = remembered_size;
23839
+ gobj.priv._page_size = tabulator_settings.paginationSize;
23809
23840
  Object.assign(tabulator_settings, {
23810
23841
  index: pkey,
23811
23842
  columns,
@@ -23874,6 +23905,9 @@ function create_tabulator(gobj) {
23874
23905
  });
23875
23906
  tabulator.on("dataProcessed", update_rowcount);
23876
23907
  tabulator.on("dataChanged", update_rowcount);
23908
+ tabulator.on("pageSizeChanged", function(size) {
23909
+ (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_PAGE_SIZE_CHANGED", { size }, gobj);
23910
+ });
23877
23911
  tabulator.on("cellEdited", function(cell) {
23878
23912
  let pkey = ((0, _yuneta_gobj_js.gobj_read_attr)(gobj, "desc") || {}).pkey || "id";
23879
23913
  let data = cell.getRow().getData();
@@ -25325,6 +25359,21 @@ function ac_open_columns(gobj, event, kw, src) {
25325
25359
  return 0;
25326
25360
  }
25327
25361
  /************************************************************
25362
+ * The reader picked another page size: remember it, so coming back to
25363
+ * this topic opens where they left it instead of at 200.
25364
+ ************************************************************/
25365
+ function ac_page_size_changed(gobj, event, kw, src) {
25366
+ let size = kw ? kw.size : void 0;
25367
+ if (size !== true && !(typeof size === "number" && size > 0)) {
25368
+ (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: bad page size: ${size}`);
25369
+ return -1;
25370
+ }
25371
+ if (size === gobj.priv._page_size) return 0;
25372
+ gobj.priv._page_size = size;
25373
+ save_page_size(gobj, size);
25374
+ return 0;
25375
+ }
25376
+ /************************************************************
25328
25377
  * Show / hide one column.
25329
25378
  ************************************************************/
25330
25379
  function ac_toggle_column(gobj, event, kw, src) {
@@ -25529,6 +25578,11 @@ function create_gclass$5(gclass_name) {
25529
25578
  ac_open_columns,
25530
25579
  null
25531
25580
  ],
25581
+ [
25582
+ "EV_PAGE_SIZE_CHANGED",
25583
+ ac_page_size_changed,
25584
+ null
25585
+ ],
25532
25586
  [
25533
25587
  "EV_TOGGLE_COLUMN",
25534
25588
  ac_toggle_column,
@@ -25579,6 +25633,7 @@ function create_gclass$5(gclass_name) {
25579
25633
  ["EV_REQUEST_PAGE", _yuneta_gobj_js.event_flag_t.EVF_OUTPUT_EVENT],
25580
25634
  ["EV_SEARCH", 0],
25581
25635
  ["EV_OPEN_COLUMNS", 0],
25636
+ ["EV_PAGE_SIZE_CHANGED", 0],
25582
25637
  ["EV_TOGGLE_COLUMN", 0],
25583
25638
  ["EV_EXPORT_TABLE", 0],
25584
25639
  ["EV_CREATE_RECORD", _yuneta_gobj_js.event_flag_t.EVF_OUTPUT_EVENT],
@@ -22859,6 +22859,33 @@ function delete_impact(desc, records) {
22859
22859
  * Constants
22860
22860
  ***************************************************************/
22861
22861
  var GCLASS_NAME$5 = "C_YUI_TREEDB_TOPIC_WITH_FORM";
22862
+ var PAGE_SIZE_STORE_PREFIX = "yui_treedb_page_size:";
22863
+ /************************************************************
22864
+ * The size the reader left, or null when there is none.
22865
+ * `true` is Tabulator's "All" and it round-trips as the boolean:
22866
+ * JSON.parse gives it back as one, and a string "true" would be
22867
+ * read by Tabulator as a size of NaN.
22868
+ ************************************************************/
22869
+ function load_page_size(gobj) {
22870
+ try {
22871
+ let raw = window.localStorage.getItem(PAGE_SIZE_STORE_PREFIX + gobj_name(gobj));
22872
+ if (raw === null) return null;
22873
+ let size = JSON.parse(raw);
22874
+ if (size === true) return true;
22875
+ if (typeof size === "number" && size > 0) return size;
22876
+ return null;
22877
+ } catch (e) {
22878
+ return null;
22879
+ }
22880
+ }
22881
+ /************************************************************
22882
+ *
22883
+ ************************************************************/
22884
+ function save_page_size(gobj, size) {
22885
+ try {
22886
+ window.localStorage.setItem(PAGE_SIZE_STORE_PREFIX + gobj_name(gobj), JSON.stringify(size));
22887
+ } catch (e) {}
22888
+ }
22862
22889
  /***************************************************************
22863
22890
  * Data
22864
22891
  ***************************************************************/
@@ -22915,6 +22942,7 @@ var PRIVATE_DATA$5 = {
22915
22942
  _pending_pages: null,
22916
22943
  _page_seq: 0,
22917
22944
  _page_total: null,
22945
+ _page_size: null,
22918
22946
  $container: null,
22919
22947
  treedb_name: "",
22920
22948
  topic_name: "",
@@ -23801,6 +23829,9 @@ function create_tabulator(gobj) {
23801
23829
  }
23802
23830
  });
23803
23831
  }
23832
+ let remembered_size = load_page_size(gobj);
23833
+ if (remembered_size !== null && tabulator_settings.pagination) tabulator_settings.paginationSize = remembered_size;
23834
+ gobj.priv._page_size = tabulator_settings.paginationSize;
23804
23835
  Object.assign(tabulator_settings, {
23805
23836
  index: pkey,
23806
23837
  columns,
@@ -23869,6 +23900,9 @@ function create_tabulator(gobj) {
23869
23900
  });
23870
23901
  tabulator.on("dataProcessed", update_rowcount);
23871
23902
  tabulator.on("dataChanged", update_rowcount);
23903
+ tabulator.on("pageSizeChanged", function(size) {
23904
+ gobj_send_event(gobj, "EV_PAGE_SIZE_CHANGED", { size }, gobj);
23905
+ });
23872
23906
  tabulator.on("cellEdited", function(cell) {
23873
23907
  let pkey = (gobj_read_attr(gobj, "desc") || {}).pkey || "id";
23874
23908
  let data = cell.getRow().getData();
@@ -25320,6 +25354,21 @@ function ac_open_columns(gobj, event, kw, src) {
25320
25354
  return 0;
25321
25355
  }
25322
25356
  /************************************************************
25357
+ * The reader picked another page size: remember it, so coming back to
25358
+ * this topic opens where they left it instead of at 200.
25359
+ ************************************************************/
25360
+ function ac_page_size_changed(gobj, event, kw, src) {
25361
+ let size = kw ? kw.size : void 0;
25362
+ if (size !== true && !(typeof size === "number" && size > 0)) {
25363
+ log_error(`${gobj_short_name(gobj)}: bad page size: ${size}`);
25364
+ return -1;
25365
+ }
25366
+ if (size === gobj.priv._page_size) return 0;
25367
+ gobj.priv._page_size = size;
25368
+ save_page_size(gobj, size);
25369
+ return 0;
25370
+ }
25371
+ /************************************************************
25323
25372
  * Show / hide one column.
25324
25373
  ************************************************************/
25325
25374
  function ac_toggle_column(gobj, event, kw, src) {
@@ -25524,6 +25573,11 @@ function create_gclass$5(gclass_name) {
25524
25573
  ac_open_columns,
25525
25574
  null
25526
25575
  ],
25576
+ [
25577
+ "EV_PAGE_SIZE_CHANGED",
25578
+ ac_page_size_changed,
25579
+ null
25580
+ ],
25527
25581
  [
25528
25582
  "EV_TOGGLE_COLUMN",
25529
25583
  ac_toggle_column,
@@ -25574,6 +25628,7 @@ function create_gclass$5(gclass_name) {
25574
25628
  ["EV_REQUEST_PAGE", event_flag_t.EVF_OUTPUT_EVENT],
25575
25629
  ["EV_SEARCH", 0],
25576
25630
  ["EV_OPEN_COLUMNS", 0],
25631
+ ["EV_PAGE_SIZE_CHANGED", 0],
25577
25632
  ["EV_TOGGLE_COLUMN", 0],
25578
25633
  ["EV_EXPORT_TABLE", 0],
25579
25634
  ["EV_CREATE_RECORD", event_flag_t.EVF_OUTPUT_EVENT],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.23.50",
3
+ "version": "7.23.51",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -103,6 +103,67 @@ import { TabulatorFull as Tabulator } from "tabulator-tables";
103
103
  ***************************************************************/
104
104
  const GCLASS_NAME = "C_YUI_TREEDB_TOPIC_WITH_FORM";
105
105
 
106
+ /*
107
+ * Where the reader's page size is remembered.
108
+ *
109
+ * In localStorage and not in a persistent attr: how many rows somebody
110
+ * wants in front of them is a fact about THAT browser, not about the
111
+ * yuno, and a library gclass cannot assume the host app wired the
112
+ * persistence functions. Same reasoning as `C_YUI_GOBJ_TREE_JS` and
113
+ * `C_YUI_JSON`.
114
+ *
115
+ * Keyed by the gobj name, which the host builds as `<view>?<topic>`, so
116
+ * the size is remembered PER TOPIC. That is the useful grain: a topic of
117
+ * 5891 devices and one of 22 do not want the same page.
118
+ */
119
+ const PAGE_SIZE_STORE_PREFIX = "yui_treedb_page_size:";
120
+
121
+ /************************************************************
122
+ * The size the reader left, or null when there is none.
123
+ * `true` is Tabulator's "All" and it round-trips as the boolean:
124
+ * JSON.parse gives it back as one, and a string "true" would be
125
+ * read by Tabulator as a size of NaN.
126
+ ************************************************************/
127
+ function load_page_size(gobj)
128
+ {
129
+ try {
130
+ let raw = window.localStorage.getItem(
131
+ PAGE_SIZE_STORE_PREFIX + gobj_name(gobj)
132
+ );
133
+ if(raw === null) {
134
+ return null;
135
+ }
136
+ let size = JSON.parse(raw);
137
+ if(size === true) {
138
+ return true;
139
+ }
140
+ if(typeof size === "number" && size > 0) {
141
+ return size;
142
+ }
143
+ return null;
144
+ } catch(e) {
145
+ /* localStorage unavailable (private mode) or a value somebody
146
+ * else wrote: the table opens at its default size, which is
147
+ * the same thing that happened before it was remembered. */
148
+ return null;
149
+ }
150
+ }
151
+
152
+ /************************************************************
153
+ *
154
+ ************************************************************/
155
+ function save_page_size(gobj, size)
156
+ {
157
+ try {
158
+ window.localStorage.setItem(
159
+ PAGE_SIZE_STORE_PREFIX + gobj_name(gobj),
160
+ JSON.stringify(size)
161
+ );
162
+ } catch(e) {
163
+ // localStorage unavailable (private mode) — non-fatal
164
+ }
165
+ }
166
+
106
167
  /***************************************************************
107
168
  * Data
108
169
  ***************************************************************/
@@ -168,6 +229,7 @@ let PRIVATE_DATA = {
168
229
  _pending_pages: null, // req_id -> {resolve, reject, timer}
169
230
  _page_seq: 0, // correlation id of a page request
170
231
  _page_total: null, // rows the topic HAS, from the last page answer
232
+ _page_size: null, // rows per page in effect (remembered across visits)
171
233
  $container: null,
172
234
  treedb_name: "",
173
235
  topic_name: "",
@@ -1366,6 +1428,22 @@ function create_tabulator(gobj)
1366
1428
  });
1367
1429
  }
1368
1430
 
1431
+ /* The size the reader picked last time, which outranks both defaults
1432
+ * above. Applied here, once the two paths have set theirs, so it is
1433
+ * written in ONE place -- and applied to `paginationSize` only: the
1434
+ * SELECTOR keeps offering the same sizes, and a remembered value that
1435
+ * is not one of them Tabulator adds to the list itself. */
1436
+ let remembered_size = load_page_size(gobj);
1437
+ if(remembered_size !== null && tabulator_settings.pagination) {
1438
+ tabulator_settings.paginationSize = remembered_size;
1439
+ }
1440
+ /* What the table OPENS at, remembered or default. Tabulator announces
1441
+ * `pageSizeChanged` at build time too, with the size it starts at, and
1442
+ * saving that one would freeze today's default in the reader's browser
1443
+ * for ever: a later change of the default would never reach anybody who
1444
+ * had once opened the table. Only a real change is written. */
1445
+ gobj.priv._page_size = tabulator_settings.paginationSize;
1446
+
1369
1447
  Object.assign(tabulator_settings, {
1370
1448
  index: pkey,
1371
1449
  columns: columns,
@@ -1529,6 +1607,13 @@ function create_tabulator(gobj)
1529
1607
  * box; a filter per column made it a claim you read on every keystroke. */
1530
1608
  tabulator.on("dataProcessed", update_rowcount);
1531
1609
  tabulator.on("dataChanged", update_rowcount);
1610
+ /* The reader changed the page size. The widget has already done the
1611
+ * work -- it re-pages itself -- so what crosses the machine is the
1612
+ * DECISION, which is the half worth remembering and the half that
1613
+ * shows up in the trace. */
1614
+ tabulator.on("pageSizeChanged", function(size) {
1615
+ gobj_send_event(gobj, "EV_PAGE_SIZE_CHANGED", {size: size}, gobj);
1616
+ });
1532
1617
  /* A cell edited in place. Announced as ONE FIELD of one record — not
1533
1618
  * as the row — and that is the whole safety of it: the host writes it
1534
1619
  * with a partial update and no `autolink`, so nothing but that field
@@ -3606,6 +3691,27 @@ function ac_open_columns(gobj, event, kw, src)
3606
3691
  return 0;
3607
3692
  }
3608
3693
 
3694
+ /************************************************************
3695
+ * The reader picked another page size: remember it, so coming back to
3696
+ * this topic opens where they left it instead of at 200.
3697
+ ************************************************************/
3698
+ function ac_page_size_changed(gobj, event, kw, src)
3699
+ {
3700
+ let size = kw? kw.size : undefined;
3701
+ if(size !== true && !(typeof size === "number" && size > 0)) {
3702
+ log_error(`${gobj_short_name(gobj)}: bad page size: ${size}`);
3703
+ return -1;
3704
+ }
3705
+
3706
+ if(size === gobj.priv._page_size) {
3707
+ return 0; /* the build-time announcement, not a decision */
3708
+ }
3709
+ gobj.priv._page_size = size;
3710
+ save_page_size(gobj, size);
3711
+
3712
+ return 0;
3713
+ }
3714
+
3609
3715
  /************************************************************
3610
3716
  * Show / hide one column.
3611
3717
  ************************************************************/
@@ -3744,6 +3850,7 @@ function create_gclass(gclass_name)
3744
3850
  ["EV_PAGE_TIMEOUT", ac_page_timeout, null],
3745
3851
  ["EV_SEARCH", ac_search, null],
3746
3852
  ["EV_OPEN_COLUMNS", ac_open_columns, null],
3853
+ ["EV_PAGE_SIZE_CHANGED", ac_page_size_changed, null],
3747
3854
  ["EV_TOGGLE_COLUMN", ac_toggle_column, null],
3748
3855
  ["EV_EXPORT_TABLE", ac_export_table, null],
3749
3856
  ["EV_SHOW", ac_show, null],
@@ -3784,6 +3891,7 @@ function create_gclass(gclass_name)
3784
3891
  ["EV_REQUEST_PAGE", event_flag_t.EVF_OUTPUT_EVENT],
3785
3892
  ["EV_SEARCH", 0],
3786
3893
  ["EV_OPEN_COLUMNS", 0],
3894
+ ["EV_PAGE_SIZE_CHANGED", 0],
3787
3895
  ["EV_TOGGLE_COLUMN", 0],
3788
3896
  ["EV_EXPORT_TABLE", 0],
3789
3897
 
package/src/tabulator.css CHANGED
@@ -304,6 +304,23 @@
304
304
  color: var(--bulma-link-invert);
305
305
  }
306
306
 
307
+ /* The paginator paints its OWN colour -- tabulator_bulma.css sets
308
+ * `color: hsl(0, 0%, 21%)` on `.tabulator-paginator` itself -- so the
309
+ * footer's colour never reaches the "Rows per page" label: near-black
310
+ * text on the dark footer, legible only if you knew it was there. Say
311
+ * it on the element that sets it, and on the native <select>, which
312
+ * otherwise keeps the browser's light chrome. */
313
+ [data-theme=dark] .tabulator .tabulator-footer .tabulator-paginator,
314
+ [data-theme=dark] .tabulator .tabulator-footer .tabulator-paginator label {
315
+ color: var(--bulma-text);
316
+ }
317
+
318
+ [data-theme=dark] .tabulator .tabulator-footer .tabulator-page-size {
319
+ background-color: var(--bulma-background);
320
+ color: var(--bulma-text);
321
+ border-color: var(--bulma-border);
322
+ }
323
+
307
324
  [data-theme=dark] .tabulator-row .tabulator-cell.tabulator-frozen {
308
325
  background-color: var(--bulma-background) !important;
309
326
  }
@@ -386,5 +403,15 @@
386
403
  background-color: var(--bulma-link);
387
404
  color: var(--bulma-link-invert);
388
405
  }
406
+ /* same paginator-paints-its-own-colour rule as [data-theme=dark] */
407
+ [data-theme=system] .tabulator .tabulator-footer .tabulator-paginator,
408
+ [data-theme=system] .tabulator .tabulator-footer .tabulator-paginator label {
409
+ color: var(--bulma-text);
410
+ }
411
+ [data-theme=system] .tabulator .tabulator-footer .tabulator-page-size {
412
+ background-color: var(--bulma-background);
413
+ color: var(--bulma-text);
414
+ border-color: var(--bulma-border);
415
+ }
389
416
  }
390
417