@yuneta/gobj-ui 7.23.135 → 7.23.136

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.
@@ -61339,13 +61339,13 @@ function ac_descs(gobj, event, kw, src) {
61339
61339
  gobj.priv;
61340
61340
  let descs = kw;
61341
61341
  (0, _yuneta_gobj_js.gobj_write_attr)(gobj, "descs", descs);
61342
- let idx = 0;
61343
- for (const [topic_name, desc] of Object.entries(descs)) {
61344
- calculate_hooks_fkeys_counter(desc);
61345
- if (topic_name.substring(0, 2) === "__") continue;
61346
- desc.color = node_colors[idx % node_colors.length];
61347
- idx++;
61348
- }
61342
+ for (const desc of Object.values(descs)) calculate_hooks_fkeys_counter(desc);
61343
+ let names = Object.keys(descs).filter((topic_name) => {
61344
+ return topic_name.substring(0, 2) !== "__";
61345
+ }).sort((a, b) => {
61346
+ return a.localeCompare(b);
61347
+ });
61348
+ for (let idx = 0; idx < names.length; idx++) descs[names[idx]].color = node_colors[idx % node_colors.length];
61349
61349
  return 0;
61350
61350
  }
61351
61351
  /************************************************************
@@ -65162,17 +65162,21 @@ function schema_to_graph(gobj) {
65162
65162
  nodes,
65163
65163
  edges: []
65164
65164
  };
65165
- let idx = 0;
65165
+ let rank = {};
65166
+ Object.keys(descs).filter((topic) => {
65167
+ return topic.substring(0, 2) !== "__";
65168
+ }).sort((a, b) => {
65169
+ return a.localeCompare(b);
65170
+ }).forEach((topic, i) => {
65171
+ rank[topic] = i;
65172
+ });
65166
65173
  for (let topic of Object.keys(descs)) {
65167
65174
  let is_system = topic.substring(0, 2) === "__";
65168
65175
  if (!system && is_system) continue;
65169
65176
  let rows = schema_rows(descs[topic]);
65170
65177
  let color;
65171
65178
  if (is_system) color = SYSTEM_TOPIC_COLOR;
65172
- else {
65173
- color = topic_colors[idx % topic_colors.length];
65174
- idx++;
65175
- }
65179
+ else color = topic_colors[rank[topic] % topic_colors.length];
65176
65180
  cards[topic] = {
65177
65181
  rows,
65178
65182
  size: card_size(rows),
@@ -61334,13 +61334,13 @@ function ac_descs(gobj, event, kw, src) {
61334
61334
  gobj.priv;
61335
61335
  let descs = kw;
61336
61336
  gobj_write_attr(gobj, "descs", descs);
61337
- let idx = 0;
61338
- for (const [topic_name, desc] of Object.entries(descs)) {
61339
- calculate_hooks_fkeys_counter(desc);
61340
- if (topic_name.substring(0, 2) === "__") continue;
61341
- desc.color = node_colors[idx % node_colors.length];
61342
- idx++;
61343
- }
61337
+ for (const desc of Object.values(descs)) calculate_hooks_fkeys_counter(desc);
61338
+ let names = Object.keys(descs).filter((topic_name) => {
61339
+ return topic_name.substring(0, 2) !== "__";
61340
+ }).sort((a, b) => {
61341
+ return a.localeCompare(b);
61342
+ });
61343
+ for (let idx = 0; idx < names.length; idx++) descs[names[idx]].color = node_colors[idx % node_colors.length];
61344
61344
  return 0;
61345
61345
  }
61346
61346
  /************************************************************
@@ -65157,17 +65157,21 @@ function schema_to_graph(gobj) {
65157
65157
  nodes,
65158
65158
  edges: []
65159
65159
  };
65160
- let idx = 0;
65160
+ let rank = {};
65161
+ Object.keys(descs).filter((topic) => {
65162
+ return topic.substring(0, 2) !== "__";
65163
+ }).sort((a, b) => {
65164
+ return a.localeCompare(b);
65165
+ }).forEach((topic, i) => {
65166
+ rank[topic] = i;
65167
+ });
65161
65168
  for (let topic of Object.keys(descs)) {
65162
65169
  let is_system = topic.substring(0, 2) === "__";
65163
65170
  if (!system && is_system) continue;
65164
65171
  let rows = schema_rows(descs[topic]);
65165
65172
  let color;
65166
65173
  if (is_system) color = SYSTEM_TOPIC_COLOR;
65167
- else {
65168
- color = topic_colors[idx % topic_colors.length];
65169
- idx++;
65170
- }
65174
+ else color = topic_colors[rank[topic] % topic_colors.length];
65171
65175
  cards[topic] = {
65172
65176
  rows,
65173
65177
  size: card_size(rows),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.23.135",
3
+ "version": "7.23.136",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -9825,15 +9825,23 @@ function ac_descs(gobj, event, kw, src)
9825
9825
  /*
9826
9826
  * Assign colors and calculate counters
9827
9827
  * descs is a dict: { __snaps__: {…}, roles: {…}, users: {…} }
9828
+ *
9829
+ * The palette goes by ALPHABETICAL order of the topic names, not
9830
+ * by the order the backend lists them in: that one is not the same
9831
+ * from one load to the next, and two topics swapped colours with
9832
+ * it. The legend is alphabetical too, so the strip reads as the
9833
+ * palette in order.
9828
9834
  */
9829
- let idx = 0;
9830
- for(const [topic_name, desc] of Object.entries(descs)) {
9835
+ for(const desc of Object.values(descs)) {
9831
9836
  calculate_hooks_fkeys_counter(desc);
9832
- if(topic_name.substring(0, 2) === "__") {
9833
- continue;
9834
- }
9835
- desc.color = node_colors[idx % node_colors.length];
9836
- idx++;
9837
+ }
9838
+ let names = Object.keys(descs).filter((topic_name) => {
9839
+ return topic_name.substring(0, 2) !== "__";
9840
+ }).sort((a, b) => {
9841
+ return a.localeCompare(b);
9842
+ });
9843
+ for(let idx = 0; idx < names.length; idx++) {
9844
+ descs[names[idx]].color = node_colors[idx % node_colors.length];
9837
9845
  }
9838
9846
 
9839
9847
  return 0;
@@ -406,7 +406,19 @@ function schema_to_graph(gobj)
406
406
  return {nodes: nodes, edges: []};
407
407
  }
408
408
 
409
- let idx = 0;
409
+ /* The palette by ALPHABETICAL rank, as the treedb graph does it:
410
+ * the backend's order is not the same from one load to the next,
411
+ * and a topic's colour must not change with it. The cards keep
412
+ * the backend's order; only the colour is ranked. */
413
+ let rank = {};
414
+ Object.keys(descs).filter((topic) => {
415
+ return topic.substring(0, 2) !== "__";
416
+ }).sort((a, b) => {
417
+ return a.localeCompare(b);
418
+ }).forEach((topic, i) => {
419
+ rank[topic] = i;
420
+ });
421
+
410
422
  for(let topic of Object.keys(descs)) {
411
423
  let is_system = (topic.substring(0, 2) === "__");
412
424
  if(!system && is_system) {
@@ -417,8 +429,7 @@ function schema_to_graph(gobj)
417
429
  if(is_system) {
418
430
  color = SYSTEM_TOPIC_COLOR;
419
431
  } else {
420
- color = topic_colors[idx % topic_colors.length];
421
- idx++;
432
+ color = topic_colors[rank[topic] % topic_colors.length];
422
433
  }
423
434
  cards[topic] = {rows: rows, size: card_size(rows), color: color};
424
435
  }