@gramlot/gramlot 0.3.31 → 0.3.32

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gramlot/gramlot",
3
- "version": "0.3.31",
3
+ "version": "0.3.32",
4
4
  "description": "Declarative HTML/SVG interfaces with live data binding, authored in JavaScript or Python.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -72,10 +72,17 @@ export class GridSelection {
72
72
  this.#apply(selected, visible.has(this.#current) ? this.#current : null, visible.has(this.#anchor) ? this.#anchor : null);
73
73
  }
74
74
 
75
+ /**
76
+ * `.selectionLength` is relative to the datapath context of the grid (legacy genro_grid.js). A grid
77
+ * with no `datapath` on itself or on an ancestor has no relative Data place, so it does not write it.
78
+ */
79
+ get #writesLength() { return this.source.attributeOwnerNode('datapath') !== null; }
80
+
75
81
  /** The absolute Data paths this grid publishes the selection to. */
76
82
  paths() {
77
83
  const names = Object.keys(this.source.getAttr()).filter(name => PUBLISHED.includes(name) || name.startsWith('selected_'));
78
- return [this.source.absDatapath('.selectionLength'), ...names.map(name => this.source.absDatapath(this.source.getAttr(name)))];
84
+ const paths = names.map(name => this.source.absDatapath(this.source.getAttr(name)));
85
+ return this.#writesLength ? [this.source.absDatapath('.selectionLength'), ...paths] : paths;
79
86
  }
80
87
 
81
88
  #apply(selected, current, anchor) {
@@ -83,7 +90,7 @@ export class GridSelection {
83
90
  this.publish();
84
91
  }
85
92
 
86
- /** Publish the selection to the declared Data paths, `.selectionLength` and `onSelectedRow`. */
93
+ /** Publish the selection to the declared Data paths, `.selectionLength` (with a datapath context) and `onSelectedRow`. */
87
94
  publish() {
88
95
  const store = this.#host.store(), view = this.#host.view(), nodes = this.nodes, current = this.#current;
89
96
  const idx = current === null ? -1 : view.getRows().indexOf(current);
@@ -112,7 +119,7 @@ export class GridSelection {
112
119
  const field = name.slice('selected_'.length);
113
120
  this.#context.writeParameter(name, [...new Set(nodes.map(node => store.value(node, field)))].join(','));
114
121
  }
115
- if (this.source.getRelativeData('.selectionLength') !== nodes.length) this.source.setRelativeData('.selectionLength', nodes.length);
122
+ if (this.#writesLength && this.source.getRelativeData('.selectionLength') !== nodes.length) this.source.setRelativeData('.selectionLength', nodes.length);
116
123
  this.#context.publish('onSelectedRow', {idx, selectedId, selectedPkeys});
117
124
  }
118
125
  }
@@ -477,4 +477,6 @@
477
477
 
478
478
  /* FrameGrid owns its single command/search toolbar. */
479
479
  .gramlot-grid-toolbar { padding:2px 6px; min-height:40px; background:var(--gramlot-surface-subtle); }
480
+ /* A toolbar with no tools and no authored items takes no space (it may hold an empty text node). */
481
+ .gramlot-grid-toolbar:not(:has(> *)) { display:none; }
480
482
  .gramlot-grid-toolbar > .gramlot-grid-search { margin-inline-start:auto; }