@motifx-community/ui 0.1.0-beta.17 → 0.1.0-beta.18

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.
Files changed (211) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/components/datagrid/DataGrid.d.ts +2 -1
  3. package/dist/components/datagrid/grid-column.d.ts +6 -0
  4. package/dist/components/datagrid/model/ColumnModel.d.ts +2 -0
  5. package/dist/components/datagrid/model/GridModel.d.ts +4 -0
  6. package/dist/components/datagrid/view/ColumnStyles.d.ts +7 -3
  7. package/dist/components/datagrid/view/GridBody.d.ts +56 -4
  8. package/dist/excel/index.js +1 -1
  9. package/dist/excel/index.js.map +1 -1
  10. package/dist/index.js +370 -24
  11. package/dist/index.js.map +1 -1
  12. package/dist/parts/table/RowHeights.d.ts +23 -0
  13. package/dist/parts/table/ScrollGeometry.d.ts +6 -1
  14. package/dist/parts/table/table-sheet-column.d.ts +2 -0
  15. package/dist/pdf/index.js +1 -1
  16. package/dist/pdf/index.js.map +1 -1
  17. package/dist/pdf/pdf-export-options.d.ts +4 -1
  18. package/dist/styles.css +4 -0
  19. package/docs/accordion.md +1 -1
  20. package/docs/actionsheet.md +1 -1
  21. package/docs/appbar.md +1 -1
  22. package/docs/appmenu-api.md +1 -1
  23. package/docs/appmenu-programmatic.md +1 -1
  24. package/docs/appmenu-search.md +1 -1
  25. package/docs/appmenu.md +1 -1
  26. package/docs/avatar.md +1 -1
  27. package/docs/badge.md +1 -1
  28. package/docs/bar-gauge-angles.md +1 -1
  29. package/docs/bar-gauge-data.md +1 -1
  30. package/docs/bar-gauge-labels.md +1 -1
  31. package/docs/bar-gauge.md +1 -1
  32. package/docs/barcode.md +1 -1
  33. package/docs/bottomnavigation.md +1 -1
  34. package/docs/bottomsheet.md +1 -1
  35. package/docs/breadcrumb.md +1 -1
  36. package/docs/button.md +1 -1
  37. package/docs/buttongroup.md +1 -1
  38. package/docs/buttons.md +1 -1
  39. package/docs/calendar.md +1 -1
  40. package/docs/card.md +1 -1
  41. package/docs/chart-bars.md +1 -1
  42. package/docs/chart-candles.md +1 -1
  43. package/docs/chart-funnel.md +1 -1
  44. package/docs/chart-heatmap.md +1 -1
  45. package/docs/chart-lines.md +1 -1
  46. package/docs/chart-live.md +1 -1
  47. package/docs/chart-pie.md +1 -1
  48. package/docs/chart-radar.md +1 -1
  49. package/docs/chart-ranges.md +1 -1
  50. package/docs/chart-references.md +1 -1
  51. package/docs/chart-scatter.md +1 -1
  52. package/docs/chart-waterfall.md +1 -1
  53. package/docs/chart-zoom.md +1 -1
  54. package/docs/chart.md +1 -1
  55. package/docs/chat.md +1 -1
  56. package/docs/checkbox.md +1 -1
  57. package/docs/chip.md +1 -1
  58. package/docs/choice.md +1 -1
  59. package/docs/colorbox.md +1 -1
  60. package/docs/combobox.md +1 -1
  61. package/docs/commands.md +1 -1
  62. package/docs/control.md +1 -1
  63. package/docs/data.md +1 -1
  64. package/docs/datagrid-api.md +3 -2
  65. package/docs/datagrid-bands.md +1 -1
  66. package/docs/datagrid-drag-select.md +1 -1
  67. package/docs/datagrid-drag.md +1 -1
  68. package/docs/datagrid-editing.md +1 -1
  69. package/docs/datagrid-filtering.md +1 -1
  70. package/docs/datagrid-forms.md +1 -1
  71. package/docs/datagrid-grouping.md +1 -1
  72. package/docs/datagrid-layout.md +1 -1
  73. package/docs/datagrid-lookups.md +1 -1
  74. package/docs/datagrid-master-detail.md +1 -1
  75. package/docs/datagrid-scrolling.md +77 -1
  76. package/docs/datagrid-selection.md +1 -1
  77. package/docs/datagrid.md +1 -1
  78. package/docs/datebox.md +1 -1
  79. package/docs/daterangebox.md +1 -1
  80. package/docs/diagram-api.md +1 -1
  81. package/docs/diagram-commands.md +1 -1
  82. package/docs/diagram-connections.md +1 -1
  83. package/docs/diagram-custom-nodes.md +1 -1
  84. package/docs/diagram-designer.md +1 -1
  85. package/docs/diagram-editing.md +1 -1
  86. package/docs/diagram-flow.md +1 -1
  87. package/docs/diagram-keyboard.md +1 -1
  88. package/docs/diagram-layout.md +1 -1
  89. package/docs/diagram-nodes.md +1 -1
  90. package/docs/diagram-tables.md +1 -1
  91. package/docs/diagram.md +1 -1
  92. package/docs/display.md +1 -1
  93. package/docs/draggable.md +1 -1
  94. package/docs/drawer.md +1 -1
  95. package/docs/dropdown.md +1 -1
  96. package/docs/editors.md +1 -1
  97. package/docs/expressioneditor.md +1 -1
  98. package/docs/expressions.md +1 -1
  99. package/docs/feedback.md +1 -1
  100. package/docs/fileuploader.md +1 -1
  101. package/docs/filterbuilder.md +1 -1
  102. package/docs/formlayout-schema.md +1 -1
  103. package/docs/formlayout.md +1 -1
  104. package/docs/foundations.md +1 -1
  105. package/docs/gallery.md +1 -1
  106. package/docs/gauge-base.md +1 -1
  107. package/docs/gauge-circular.md +1 -1
  108. package/docs/gauge-dashboards.md +1 -1
  109. package/docs/gauge-linear.md +1 -1
  110. package/docs/gauge-markers.md +1 -1
  111. package/docs/gauge-marks.md +1 -1
  112. package/docs/gauge-ranges.md +1 -1
  113. package/docs/gauge-scales.md +1 -1
  114. package/docs/gauge.md +1 -1
  115. package/docs/home.md +1 -1
  116. package/docs/keyboard.md +1 -1
  117. package/docs/language.md +1 -1
  118. package/docs/layout.md +1 -1
  119. package/docs/listbox.md +1 -1
  120. package/docs/loadpanel.md +1 -1
  121. package/docs/lookup.md +1 -1
  122. package/docs/markdown.md +1 -1
  123. package/docs/menus-api.md +1 -1
  124. package/docs/menus-context.md +1 -1
  125. package/docs/menus-customization.md +1 -1
  126. package/docs/menus-merging.md +1 -1
  127. package/docs/menus-programmatic.md +1 -1
  128. package/docs/menus.md +1 -1
  129. package/docs/multiview.md +1 -1
  130. package/docs/navigation.md +1 -1
  131. package/docs/numberbox.md +1 -1
  132. package/docs/otpinput.md +1 -1
  133. package/docs/pagination.md +1 -1
  134. package/docs/pivotgrid-api.md +1 -1
  135. package/docs/pivotgrid-chart.md +1 -1
  136. package/docs/pivotgrid-drilldown.md +1 -1
  137. package/docs/pivotgrid-export.md +1 -1
  138. package/docs/pivotgrid-fields.md +1 -1
  139. package/docs/pivotgrid-keyboard.md +1 -1
  140. package/docs/pivotgrid-layout.md +1 -1
  141. package/docs/pivotgrid-panel.md +1 -1
  142. package/docs/pivotgrid-remote.md +1 -1
  143. package/docs/pivotgrid-sorting.md +1 -1
  144. package/docs/pivotgrid-state.md +1 -1
  145. package/docs/pivotgrid-summaries.md +1 -1
  146. package/docs/pivotgrid.md +1 -1
  147. package/docs/popover.md +1 -1
  148. package/docs/progress.md +1 -1
  149. package/docs/qrcode.md +1 -1
  150. package/docs/radiogroup.md +1 -1
  151. package/docs/rating.md +1 -1
  152. package/docs/resizable.md +1 -1
  153. package/docs/ribbonmenu-api.md +1 -1
  154. package/docs/ribbonmenu-commands.md +1 -1
  155. package/docs/ribbonmenu-customization.md +1 -1
  156. package/docs/ribbonmenu-display.md +1 -1
  157. package/docs/ribbonmenu-layouts.md +1 -1
  158. package/docs/ribbonmenu-programmatic.md +1 -1
  159. package/docs/ribbonmenu.md +1 -1
  160. package/docs/scheduler-agenda.md +1 -1
  161. package/docs/scheduler-big-data.md +1 -1
  162. package/docs/scheduler-editing.md +1 -1
  163. package/docs/scheduler-form.md +1 -1
  164. package/docs/scheduler-icalendar.md +1 -1
  165. package/docs/scheduler-mobile.md +1 -1
  166. package/docs/scheduler-recurrence.md +1 -1
  167. package/docs/scheduler-resources.md +1 -1
  168. package/docs/scheduler-timeline.md +1 -1
  169. package/docs/scheduler.md +1 -1
  170. package/docs/scrollview.md +1 -1
  171. package/docs/shortcuteditor.md +1 -1
  172. package/docs/showcase-flowstudio.md +1 -1
  173. package/docs/showcase-home.md +1 -1
  174. package/docs/showcase-mail.md +1 -1
  175. package/docs/showcase.md +1 -1
  176. package/docs/signature.md +1 -1
  177. package/docs/skeleton.md +1 -1
  178. package/docs/slider.md +1 -1
  179. package/docs/sortable.md +1 -1
  180. package/docs/sparkline.md +1 -1
  181. package/docs/speeddial.md +1 -1
  182. package/docs/splitter.md +1 -1
  183. package/docs/stepper.md +1 -1
  184. package/docs/switch.md +1 -1
  185. package/docs/tabdocs-dock.md +1 -1
  186. package/docs/tabdocs-drag.md +1 -1
  187. package/docs/tabdocs-menus.md +1 -1
  188. package/docs/tabdocs-mobile.md +1 -1
  189. package/docs/tabdocs-tabs.md +1 -1
  190. package/docs/tabdocs-windows.md +1 -1
  191. package/docs/tabdocs-workspace.md +1 -1
  192. package/docs/tabdocs.md +1 -1
  193. package/docs/tabs.md +1 -1
  194. package/docs/tagbox.md +1 -1
  195. package/docs/textarea.md +1 -1
  196. package/docs/textbox.md +1 -1
  197. package/docs/tileview.md +1 -1
  198. package/docs/timeline.md +1 -1
  199. package/docs/toast.md +1 -1
  200. package/docs/tokens.md +1 -1
  201. package/docs/toolbar-api.md +1 -1
  202. package/docs/toolbar-customization.md +1 -1
  203. package/docs/toolbar.md +1 -1
  204. package/docs/tooltip.md +1 -1
  205. package/docs/treeview.md +1 -1
  206. package/docs/validationsummary.md +1 -1
  207. package/docs/window.md +1 -1
  208. package/docs/wizard.md +1 -1
  209. package/llms-full.txt +269 -192
  210. package/llms.txt +1 -1
  211. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -53682,6 +53682,11 @@ var ColumnModel = class {
53682
53682
  const def = this.get(field);
53683
53683
  return def.align ?? (def.type === "number" ? "end" : def.type === "boolean" ? "center" : "start");
53684
53684
  }
53685
+ /** Whether the text of the column's cells wraps onto more lines (`wrap`); the grid's own columns never do. */
53686
+ wraps(field) {
53687
+ this.state.revision;
53688
+ return !this.isInternal(field) && !!readField$1(this.get(field), "wrap");
53689
+ }
53685
53690
  /** Where a band's caption sits: its own, else the `bandAlign` setting. */
53686
53691
  bandAlign(id) {
53687
53692
  return readField$1(this.bands.get(id)?.def, "align") ?? this.settings.get("bandAlign");
@@ -60679,6 +60684,12 @@ var GridModel = class {
60679
60684
  exporting: false,
60680
60685
  acting: false
60681
60686
  }));
60687
+ _defineProperty(
60688
+ this,
60689
+ /** Set when the grid is disposed: a wait for the rows ends with it. */
60690
+ "life",
60691
+ reactive({ over: false })
60692
+ );
60682
60693
  _defineProperty(
60683
60694
  this,
60684
60695
  /** The new-row area, in display order. */
@@ -61162,6 +61173,11 @@ var GridModel = class {
61162
61173
  else if (!this.loadMore()) break;
61163
61174
  return same() && data.total >= Math.min(rows, data.knownCount ?? rows);
61164
61175
  }
61176
+ /** Resolves once the rows the grid waits for have arrived, or failed to: `false` when the grid is disposed first. */
61177
+ async rowsLoaded() {
61178
+ await settled(() => this.life.over || this.state.status !== "loading");
61179
+ return !this.life.over;
61180
+ }
61165
61181
  /** Infinite mode: what the indicator under the rows shows (`loadMoreIndicator`): a part loading, a part that failed, or nothing. Reactive. */
61166
61182
  moreState() {
61167
61183
  if (this.mode !== "infinite" || !this.settings.get("loadMoreIndicator")) return null;
@@ -62364,6 +62380,7 @@ var GridModel = class {
62364
62380
  });
62365
62381
  }
62366
62382
  dispose() {
62383
+ this.life.over = true;
62367
62384
  clearTimeout(this.filterTimer);
62368
62385
  for (const s of this.dataSubscriptions.splice(0)) s.dispose();
62369
62386
  this.events.dispose();
@@ -63991,6 +64008,7 @@ var GridExport = class {
63991
64008
  title: model.columns.title(fields[j]),
63992
64009
  width: options.widthOf(fields[j]),
63993
64010
  align: model.columns.align(fields[j]),
64011
+ wrap: model.columns.wraps(fields[j]) || void 0,
63994
64012
  numberFormat: column.type === "number" && !column.lookup ? formatter.numberOptions(column) : void 0,
63995
64013
  dateFormat: (column.type === "date" || column.type === "datetime") && !column.lookup ? formatter.dateOptions(column) : void 0
63996
64014
  })),
@@ -65217,8 +65235,9 @@ var ColumnMenu = class {
65217
65235
  //#endregion
65218
65236
  //#region src/components/datagrid/view/ColumnStyles.ts
65219
65237
  var escapeAttr = (v) => v.replace(/["\\]/g, "\\$&");
65238
+ var NO_WRAP = /* @__PURE__ */ new Set();
65220
65239
  /**
65221
- * Per-column CSS of one grid: columns not shown, the tracks of the columns pinned to the end, alignment and sticky offsets, written as rules keyed
65240
+ * Per-column CSS of one grid: columns not shown, the tracks of the columns pinned to the end, alignment, wrapping and sticky offsets, written as rules keyed
65222
65241
  * by `data-field` (a pinned band's header by `data-band`, at the offset of its columns). Changing a width or pinning a column rewrites this sheet only; no cell gets a
65223
65242
  * binding of its own and no row is touched. A rule finds the rows through the parts that hold them (the head, the body,
65224
65243
  * the foot, the copy of a dragged row), which carry the grid's id, and goes on by child combinators only: the rows of a
@@ -65244,11 +65263,20 @@ var ColumnStyles = class {
65244
65263
  this.columns = columns;
65245
65264
  this.gridId = gridId;
65246
65265
  }
65247
- /** `placed`: every column's cells get their track by number, so a row may leave out the cells of columns not drawn (virtual columns). */
65248
- update(visible, offsets, align, bands = [], placed = false) {
65266
+ /**
65267
+ * `placed`: every column's cells get their track by number, so a row may leave out the cells of columns not drawn (virtual
65268
+ * columns). `wrap`: the columns whose cells wrap their text; with any, a data row (in the body, and its copy while it is
65269
+ * dragged) is as tall as its tallest cell.
65270
+ */
65271
+ update(visible, offsets, align, bands = [], placed = false, wrap = NO_WRAP) {
65249
65272
  const rows = `[data-grid-id="${this.gridId}"] > .mx-data-grid__row`;
65250
65273
  const rules = [];
65251
65274
  const shown = new Set(visible);
65275
+ if (wrap.size) {
65276
+ const dataRows = `[data-grid-id="${this.gridId}"]:is(.mx-data-grid__body, .mx-data-grid__ghost-rows) > .mx-data-grid__row:not(.mx-data-grid__group-row, .mx-data-grid__group-footer)`;
65277
+ rules.push(`${dataRows}{block-size:auto;min-block-size:var(--_row-height)}`);
65278
+ rules.push(`${dataRows} > .mx-data-grid__cell{contain:size}`);
65279
+ }
65252
65280
  for (const field of this.columns.state.order) {
65253
65281
  const sel = `${rows} > [data-field="${escapeAttr(field)}"]`;
65254
65282
  if (!shown.has(field)) {
@@ -65263,6 +65291,7 @@ var ColumnStyles = class {
65263
65291
  rules.push(`${sel}.mx-data-grid__cell{text-align:${a}}`);
65264
65292
  rules.push(`${sel} > .mx-data-grid__title{text-align:${a}}`);
65265
65293
  }
65294
+ if (wrap.has(field)) rules.push(`${sel}.mx-data-grid__cell:not(.mx-data-grid__summary-cell){contain:inline-size;white-space:pre-line;overflow-wrap:anywhere;text-overflow:clip;line-height:var(--_wrap-line);padding-block:var(--_wrap-space)}`);
65266
65295
  if (sticky) {
65267
65296
  rules.push(`${sel}{position:sticky;inset-inline-${sticky.side}:${sticky.offset}px;z-index:var(--_z-sticky)}`);
65268
65297
  if (sticky.edge) rules.push(`${sel}{box-shadow:var(--_sticky-${sticky.side})}`);
@@ -66028,6 +66057,57 @@ var ExtraHeights = class {
66028
66057
  }
66029
66058
  };
66030
66059
  //#endregion
66060
+ //#region src/parts/table/RowHeights.ts
66061
+ /**
66062
+ * How much taller than the others some rows are (a column that wraps its text), by position among the rows laid out. A
66063
+ * row not measured yet counts as tall as every row. The sums before a position are kept in a Fenwick tree, so a row's
66064
+ * offset is found in a few steps however many rows there are, and a new measurement changes one entry only.
66065
+ */
66066
+ var RowHeights = class {
66067
+ constructor(size) {
66068
+ _defineProperty(this, "size", void 0);
66069
+ _defineProperty(this, "added", void 0);
66070
+ _defineProperty(this, "summed", void 0);
66071
+ _defineProperty(this, "taller", 0);
66072
+ _defineProperty(this, "sum", 0);
66073
+ this.size = size;
66074
+ this.added = new Float64Array(size);
66075
+ this.summed = new Float64Array(size + 1);
66076
+ }
66077
+ /** Whether any row is taller than the others. */
66078
+ get any() {
66079
+ return this.taller > 0;
66080
+ }
66081
+ /** What every row adds, together. */
66082
+ get total() {
66083
+ return this.sum;
66084
+ }
66085
+ /** Gives a position what it adds to the height every row has (0: as tall as the others). Returns whether it changed. */
66086
+ set(position, added) {
66087
+ if (position < 0 || position >= this.size) return false;
66088
+ const value = added > 0 ? added : 0;
66089
+ const before = this.added[position];
66090
+ if (value === before) return false;
66091
+ this.added[position] = value;
66092
+ if (before === 0) this.taller++;
66093
+ else if (value === 0) this.taller--;
66094
+ const diff = value - before;
66095
+ this.sum += diff;
66096
+ for (let i = position + 1; i <= this.size; i += i & -i) this.summed[i] += diff;
66097
+ return true;
66098
+ }
66099
+ /** What a position adds (0 out of range). */
66100
+ addedAt(position) {
66101
+ return position >= 0 && position < this.size ? this.added[position] : 0;
66102
+ }
66103
+ /** What the positions before `position` add. */
66104
+ before(position) {
66105
+ let sum = 0;
66106
+ for (let i = Math.min(Math.max(0, position), this.size); i > 0; i -= i & -i) sum += this.summed[i];
66107
+ return sum;
66108
+ }
66109
+ };
66110
+ //#endregion
66031
66111
  //#region src/parts/table/ScrollGeometry.ts
66032
66112
  var clamp$2 = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
66033
66113
  /**
@@ -66037,7 +66117,7 @@ var clamp$2 = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
66037
66117
  * placed relative to the scroll position, so the wheel and the keyboard still move row by row.
66038
66118
  */
66039
66119
  var ScrollGeometry = class ScrollGeometry {
66040
- constructor(total, rowHeight, viewport, max = ScrollGeometry.MAX_HEIGHT, tall = null, details = null, adaptive = null, tail = 0) {
66120
+ constructor(total, rowHeight, viewport, max = ScrollGeometry.MAX_HEIGHT, tall = null, details = null, adaptive = null, tail = 0, rows = null) {
66041
66121
  _defineProperty(this, "total", void 0);
66042
66122
  _defineProperty(this, "rowHeight", void 0);
66043
66123
  _defineProperty(this, "viewport", void 0);
@@ -66046,6 +66126,7 @@ var ScrollGeometry = class ScrollGeometry {
66046
66126
  _defineProperty(this, "details", void 0);
66047
66127
  _defineProperty(this, "adaptive", void 0);
66048
66128
  _defineProperty(this, "tail", void 0);
66129
+ _defineProperty(this, "rows", void 0);
66049
66130
  this.total = total;
66050
66131
  this.rowHeight = rowHeight;
66051
66132
  this.viewport = viewport;
@@ -66054,19 +66135,20 @@ var ScrollGeometry = class ScrollGeometry {
66054
66135
  this.details = details;
66055
66136
  this.adaptive = adaptive;
66056
66137
  this.tail = tail;
66138
+ this.rows = rows;
66057
66139
  }
66058
66140
  /** Height of all rows, and the room after them. */
66059
66141
  get contentHeight() {
66060
- return this.total * this.rowHeight + this.extraHeight + this.adaptiveBefore(this.total) + (this.details ? this.details.before(this.total) : 0) + this.tail;
66142
+ return this.total * this.rowHeight + this.extraHeight + this.adaptiveBefore(this.total) + (this.details ? this.details.before(this.total) : 0) + (this.rows ? this.rows.before(this.total) : 0) + this.tail;
66061
66143
  }
66062
66144
  /** Top of row `index` in the full content. */
66063
66145
  offsetOf(index) {
66064
66146
  const tall = this.tall;
66065
- return index * this.rowHeight + (tall && index > tall.at ? tall.extra : 0) + this.adaptiveBefore(index) + (this.details ? this.details.before(index) : 0);
66147
+ return index * this.rowHeight + (tall && index > tall.at ? tall.extra : 0) + this.adaptiveBefore(index) + (this.details ? this.details.before(index) : 0) + (this.rows ? this.rows.before(index) : 0);
66066
66148
  }
66067
66149
  /** Height of row `index` itself (the edit form when it stands for the row), without its details. */
66068
66150
  rowHeightOf(index) {
66069
- return this.rowHeight + (this.tall?.at === index ? this.tall.extra : 0);
66151
+ return this.rowHeight + (this.tall?.at === index ? this.tall.extra : 0) + (this.rows ? this.rows.addedAt(index) : 0);
66070
66152
  }
66071
66153
  /** Height of the adaptive detail under row `index` (0 when it has none open). */
66072
66154
  adaptiveAt(index) {
@@ -66079,7 +66161,7 @@ var ScrollGeometry = class ScrollGeometry {
66079
66161
  /** The row at an offset in the full content (a row's details count as the row). */
66080
66162
  indexAt(offset) {
66081
66163
  const tall = this.tall;
66082
- if (this.details?.size || this.adaptive) return this.search(offset);
66164
+ if (this.details?.size || this.adaptive || this.rows?.any) return this.search(offset);
66083
66165
  if (!tall || offset < (tall.at + 1) * this.rowHeight) return Math.floor(offset / this.rowHeight);
66084
66166
  if (offset < (tall.at + 1) * this.rowHeight + tall.extra) return tall.at;
66085
66167
  return Math.floor((offset - tall.extra) / this.rowHeight);
@@ -67686,7 +67768,11 @@ var grids = /* @__PURE__ */ new Set();
67686
67768
  * detail of the one row that has it open (the columns the width hides) is a detail row too, right
67687
67769
  * under its row and before its details. The viewport is read with the measuring layer: a layout asked for
67688
67770
  * runs at once with the viewport as last read (and as the body scrolled it), and again with the next round
67689
- * if the viewport turns out to be elsewhere; the sizes of details and of the edit form are watched.
67771
+ * if the viewport turns out to be elsewhere; the sizes of details and of the edit form are watched. While a
67772
+ * column wraps its text, a data row is as tall as its cells: the rows drawn are measured in the round after
67773
+ * they are laid out, before the screen is drawn, and again when one changes size; what they add over the
67774
+ * rows' height is kept by position (`RowHeights`), and the first row in view stays where it stood when the
67775
+ * rows above it come out taller or shorter.
67690
67776
  */
67691
67777
  var GridBody = class extends Component {
67692
67778
  constructor(grid, viewport, widths, host) {
@@ -67842,6 +67928,74 @@ var GridBody = class extends Component {
67842
67928
  "dropRow",
67843
67929
  null
67844
67930
  );
67931
+ _defineProperty(
67932
+ this,
67933
+ /** Whether a column wraps its text: data rows are as tall as their cells, measured as they are drawn. */
67934
+ "wrapping",
67935
+ false
67936
+ );
67937
+ _defineProperty(
67938
+ this,
67939
+ /** The columns and widths the rows were measured for. */
67940
+ "wrapFor",
67941
+ ""
67942
+ );
67943
+ _defineProperty(
67944
+ this,
67945
+ /** What the rows laid out add over the rows' height, and the rows and height that was found for. */
67946
+ "heights",
67947
+ null
67948
+ );
67949
+ _defineProperty(this, "heightsFor", "");
67950
+ _defineProperty(
67951
+ this,
67952
+ /** The size watches of the pooled rows, while rows are measured. */
67953
+ "rowWatches",
67954
+ /* @__PURE__ */ new Map()
67955
+ );
67956
+ _defineProperty(
67957
+ this,
67958
+ /**
67959
+ * The row kept in place after the last layout, the first in view or the one `reveal` brought in: its position, its id,
67960
+ * how far below the top of the view its top (or its bottom, `edge`) stood, and the scroll then.
67961
+ */
67962
+ "anchor",
67963
+ null
67964
+ );
67965
+ _defineProperty(
67966
+ this,
67967
+ /** The row `reveal` brought into view, at the edge it was brought to: kept there while rows are measured, until the view is scrolled. */
67968
+ "pinned",
67969
+ null
67970
+ );
67971
+ _defineProperty(
67972
+ this,
67973
+ /** The heights of the data rows drawn, read after they were laid out. */
67974
+ "readHeights",
67975
+ () => {
67976
+ const out = [];
67977
+ for (const row of this.byIndex.values()) if (row.row !== void 0) out.push([row, boxOf(row.part).offsetHeight]);
67978
+ return out;
67979
+ }
67980
+ );
67981
+ _defineProperty(
67982
+ this,
67983
+ /** Rows that came out another height: the rows are laid out again, the first row in view where it stood. */
67984
+ "writeHeights",
67985
+ (read) => {
67986
+ const heights = this.wrapping ? this.rowHeights() : null;
67987
+ if (!heights || !this.isBuilt) return;
67988
+ const grid = this.grid;
67989
+ const base = grid.state.rowHeight;
67990
+ let changed = false;
67991
+ for (const [row, height] of read) {
67992
+ if (height <= 0 || row.index < 0 || row.row === void 0) continue;
67993
+ const l = grid.mode !== "paged" ? row.index : grid.localOf(row.index);
67994
+ if (heights.set(l, height - base)) changed = true;
67995
+ }
67996
+ if (changed) this.layoutSoon();
67997
+ }
67998
+ );
67845
67999
  _defineProperty(this, "readView", () => {
67846
68000
  const vp = this.scroller();
67847
68001
  if (!vp) return null;
@@ -67887,8 +68041,10 @@ var GridBody = class extends Component {
67887
68041
  if (scrollTop === null || !wanted || !vp) return;
67888
68042
  const local = this.grid.localOf(wanted.index);
67889
68043
  if (local < 0) return;
67890
- const top = this.geometry().revealRow(scrollTop, local, wanted.align);
68044
+ const g = this.geometry();
68045
+ const top = g.revealRow(scrollTop, local, wanted.align);
67891
68046
  if (top === scrollTop) return;
68047
+ this.pin(g, local, top);
67892
68048
  scrollTo(vp, { top });
67893
68049
  this.lastView = {
67894
68050
  ...this.lastView,
@@ -67933,15 +68089,19 @@ var GridBody = class extends Component {
67933
68089
  });
67934
68090
  this.motif.setDisposable(() => resolved.dispose());
67935
68091
  }
67936
- /** Geometry of the rows the body lays out (all rows, or one page); the edit form's row is as tall as the form, open details and the adaptive detail add their height. */
68092
+ /**
68093
+ * Geometry of the rows the body lays out (all rows, or one page); the edit form's row is as tall as the form, open details
68094
+ * and the adaptive detail add their height, and so do rows taller than the others while a column wraps.
68095
+ */
67937
68096
  geometry() {
67938
68097
  const grid = this.grid;
67939
68098
  const rowHeight = grid.state.rowHeight;
68099
+ const heights = this.rowHeights();
67940
68100
  const at = this.formIndex();
67941
68101
  const local = at < 0 ? -1 : grid.mode !== "paged" ? at : grid.localOf(at);
67942
68102
  const tall = local >= 0 && this.form ? {
67943
68103
  at: local,
67944
- extra: Math.max(0, this.form.height - rowHeight)
68104
+ extra: Math.max(0, this.form.height - rowHeight) - (heights ? heights.addedAt(local) : 0)
67945
68105
  } : null;
67946
68106
  const a = this.adaptiveLocal();
67947
68107
  const adaptive = a >= 0 ? {
@@ -67949,7 +68109,163 @@ var GridBody = class extends Component {
67949
68109
  height: this.adaptive?.id === grid.adaptive.state.rowId ? this.adaptive.height : 0
67950
68110
  } : null;
67951
68111
  const tail = grid.moreState() ? rowHeight : 0;
67952
- return new ScrollGeometry(grid.reachable(), rowHeight, Math.max(rowHeight, grid.state.viewport), ScrollGeometry.MAX_HEIGHT, tall, this.openExtras(), adaptive, tail);
68112
+ return new ScrollGeometry(grid.reachable(), rowHeight, Math.max(rowHeight, grid.state.viewport), ScrollGeometry.MAX_HEIGHT, tall, this.openExtras(), adaptive, tail, heights);
68113
+ }
68114
+ /**
68115
+ * Whether a column wraps its text, and the columns and widths that is for (`key`): with one, rows are measured as they
68116
+ * are drawn and when they change size; another key has the rows drawn measured again.
68117
+ */
68118
+ setWrap(on, key) {
68119
+ if (on === this.wrapping && key === this.wrapFor) return;
68120
+ const was = this.wrapping;
68121
+ this.wrapFor = key;
68122
+ if (!on && !was) return;
68123
+ this.wrapping = on;
68124
+ if (on) for (const row of this.pool) this.watchRow(row);
68125
+ else {
68126
+ for (const stop of this.rowWatches.values()) stop();
68127
+ this.rowWatches.clear();
68128
+ const anchor = this.anchor;
68129
+ this.heights = null;
68130
+ this.heightsFor = "";
68131
+ this.anchor = null;
68132
+ this.pinned = null;
68133
+ if (was && anchor) this.scrollToAnchor(anchor);
68134
+ }
68135
+ this.layoutSoon(true);
68136
+ }
68137
+ /** Scrolls so that a row noted in the view (`anchor`) stands where it stood, in the rows as they are now. */
68138
+ scrollToAnchor(anchor) {
68139
+ const vp = this.scroller();
68140
+ const g = this.geometry();
68141
+ if (!vp || anchor.local >= g.total) return;
68142
+ const edge = anchor.edge === "bottom" ? g.offsetOf(anchor.local) + g.rowHeightOf(anchor.local) : g.offsetOf(anchor.local);
68143
+ const want = Math.max(0, Math.min(g.maxVirtualTop, edge - anchor.screen));
68144
+ this.sizeSpacer(g);
68145
+ if (this.grid.mode !== "paged") {
68146
+ this.setVirtualTop(vp, g, want, true);
68147
+ return;
68148
+ }
68149
+ scrollTo(vp, { top: want });
68150
+ this.lastView = {
68151
+ ...this.lastView,
68152
+ top: want
68153
+ };
68154
+ if (this.seenScroll) this.seenScroll = {
68155
+ ...this.seenScroll,
68156
+ top: want
68157
+ };
68158
+ }
68159
+ /** What the rows laid out add over the rows' height while a column wraps; found again for other rows or another height. */
68160
+ rowHeights() {
68161
+ if (!this.wrapping) return null;
68162
+ return untracked(() => {
68163
+ const grid = this.grid;
68164
+ const st = grid.state;
68165
+ const n = grid.reachable();
68166
+ const same = `${st.version}|${st.connection}|${st.added}|${st.page}|${st.rowHeight}|${grid.mode}`;
68167
+ const key = `${same}|${n}`;
68168
+ if (this.heights && key === this.heightsFor) return this.heights;
68169
+ const was = this.heights;
68170
+ const kept = was !== null && this.heightsFor.startsWith(`${same}|`);
68171
+ this.heightsFor = key;
68172
+ this.heights = new RowHeights(n);
68173
+ if (kept) {
68174
+ for (let l = 0, end = Math.min(n, was.size); l < end; l++) if (was.addedAt(l)) this.heights.set(l, was.addedAt(l));
68175
+ }
68176
+ return this.heights;
68177
+ });
68178
+ }
68179
+ /** Watches a pooled row's size while rows are measured: a row that changes size (its content drawn again) is measured again. */
68180
+ watchRow(row) {
68181
+ if (this.rowWatches.has(row)) return;
68182
+ this.rowWatches.set(row, onLayout(row.part, "size", (size) => this.rowResized(row, size), { owner: this }));
68183
+ }
68184
+ /** A row drawn came out another size than it was measured at: the rows after it move, with the next round. */
68185
+ rowResized(row, size) {
68186
+ const heights = this.wrapping ? this.rowHeights() : null;
68187
+ const height = Math.round(size.height);
68188
+ if (!heights || this.isDisposed || height <= 0 || row.index < 0 || row.row === void 0) return;
68189
+ const l = this.grid.mode !== "paged" ? row.index : this.grid.localOf(row.index);
68190
+ if (heights.set(l, height - this.grid.state.rowHeight)) this.layoutSoon();
68191
+ }
68192
+ /**
68193
+ * While rows are measured, the first row in view stays where it stood when what the rows above it add changed (they were
68194
+ * measured, or found again), unless the view was scrolled since: returns the scroll the rows are laid out for.
68195
+ */
68196
+ keepAnchor(g, scrollTop) {
68197
+ const a = this.anchor;
68198
+ const vp = this.scroller();
68199
+ if (!a || !vp || scrollTop !== a.scrollTop) {
68200
+ if (a) this.pinned = null;
68201
+ return scrollTop;
68202
+ }
68203
+ const grid = this.grid;
68204
+ const paged = grid.mode === "paged";
68205
+ let l = a.local;
68206
+ if (a.rowId !== void 0 && grid.rowIdAt(paged ? grid.viewAt(l) : l) !== a.rowId) {
68207
+ const i = grid.indexOfKey(a.rowId);
68208
+ const found = i < 0 ? -1 : paged ? grid.localOf(i) : i;
68209
+ if (found >= 0) l = found;
68210
+ }
68211
+ if (l < 0 || l >= g.total) return scrollTop;
68212
+ if (this.pinned) this.pinned = {
68213
+ ...this.pinned,
68214
+ local: l
68215
+ };
68216
+ const edge = a.edge === "bottom" ? g.offsetOf(l) + g.rowHeightOf(l) : g.offsetOf(l);
68217
+ const want = Math.max(0, Math.min(g.maxVirtualTop, edge - a.screen));
68218
+ const now = paged ? scrollTop : this.virtualTop;
68219
+ if (Math.abs(want - now) < 1) return scrollTop;
68220
+ let top = want;
68221
+ if (!paged) {
68222
+ this.virtualTop = want;
68223
+ top = g.scrollFromVirtual(want);
68224
+ }
68225
+ scrollTo(vp, { top });
68226
+ this.lastView = {
68227
+ ...this.lastView,
68228
+ top
68229
+ };
68230
+ if (this.seenScroll) this.seenScroll = {
68231
+ ...this.seenScroll,
68232
+ top
68233
+ };
68234
+ return top;
68235
+ }
68236
+ /** Notes the row to keep where it stands (`keepAnchor`): the one `reveal` brought in, else the first that starts in view. */
68237
+ noteAnchor(g, scrollTop) {
68238
+ const grid = this.grid;
68239
+ const paged = grid.mode === "paged";
68240
+ const vt = paged ? scrollTop : this.virtualTop;
68241
+ const p = this.pinned && this.pinned.local < g.total ? this.pinned : null;
68242
+ let l = p ? p.local : g.total > 0 ? g.indexAt(vt) : -1;
68243
+ if (!p && l >= 0 && l < g.total - 1 && g.offsetOf(l) < vt) l++;
68244
+ if (l < 0) {
68245
+ this.anchor = null;
68246
+ return;
68247
+ }
68248
+ const edge = p?.edge ?? "top";
68249
+ const at = edge === "bottom" ? g.offsetOf(l) + g.rowHeightOf(l) : g.offsetOf(l);
68250
+ this.anchor = {
68251
+ local: l,
68252
+ rowId: grid.rowIdAt(paged ? grid.viewAt(l) : l),
68253
+ edge,
68254
+ screen: at - vt,
68255
+ scrollTop
68256
+ };
68257
+ }
68258
+ /** While rows are measured, a row `reveal` scrolled to stays at the edge it came to (`v`: the view's new top). */
68259
+ pin(g, local, v) {
68260
+ if (!this.wrapping) return;
68261
+ this.pinned = Math.abs(v - g.offsetOf(local)) < 1 ? {
68262
+ local,
68263
+ edge: "top"
68264
+ } : {
68265
+ local,
68266
+ edge: "bottom"
68267
+ };
68268
+ this.anchor = null;
67953
68269
  }
67954
68270
  /** The details drawn now, the adaptive detail among them, in grid order (a row's adaptive detail before its details). */
67955
68271
  drawnDetails() {
@@ -68225,7 +68541,9 @@ var GridBody = class extends Component {
68225
68541
  }
68226
68542
  const g = this.geometry();
68227
68543
  this.sizeSpacer(g);
68228
- this.setVirtualTop(vp, g, g.revealRow(this.virtualTop, index, align), true);
68544
+ const v = g.revealRow(this.virtualTop, index, align);
68545
+ if (v !== this.virtualTop) this.pin(g, index, v);
68546
+ this.setVirtualTop(vp, g, v, true);
68229
68547
  }
68230
68548
  /** Back to the first row (after a sort change); the rows follow with the next round. */
68231
68549
  toStart() {
@@ -68245,10 +68563,25 @@ var GridBody = class extends Component {
68245
68563
  };
68246
68564
  this.layoutSoon();
68247
68565
  }
68248
- /** Rows the viewport shows fully, for PageUp/PageDown. */
68249
- pageRows() {
68566
+ /**
68567
+ * Rows the viewport shows fully, for PageUp/PageDown: a screen of rows down (`down`) or up from grid row `from`, counted
68568
+ * by their heights while some are taller than the others.
68569
+ */
68570
+ pageRows(from = -1, down = true) {
68250
68571
  const g = this.geometry();
68251
- return Math.max(1, Math.floor(g.viewport / g.rowHeight) - 1);
68572
+ const even = Math.max(1, Math.floor(g.viewport / g.rowHeight) - 1);
68573
+ const grid = this.grid;
68574
+ const start = !g.rows?.any || from < 0 ? -1 : grid.mode !== "paged" ? from : grid.localOf(from);
68575
+ if (start < 0) return even;
68576
+ const step = down ? 1 : -1;
68577
+ let room = g.viewport - g.heightOf(start);
68578
+ let n = 0;
68579
+ for (let l = start + step; l >= 0 && l < g.total; l += step) {
68580
+ room -= g.heightOf(l);
68581
+ if (room < 0) break;
68582
+ n++;
68583
+ }
68584
+ return Math.max(1, n);
68252
68585
  }
68253
68586
  /** The pooled row that shows grid row `index`, if it is drawn. */
68254
68587
  rowAt(index) {
@@ -68483,7 +68816,7 @@ var GridBody = class extends Component {
68483
68816
  const data = grid.data;
68484
68817
  const g = this.geometry();
68485
68818
  const loading = grid.state.status === "loading";
68486
- const scrollTop = view.top;
68819
+ let scrollTop = view.top;
68487
68820
  let start;
68488
68821
  let end;
68489
68822
  let top;
@@ -68492,6 +68825,7 @@ var GridBody = class extends Component {
68492
68825
  if (this.expectedScrollTop < 0 || Math.abs(scrollTop - this.expectedScrollTop) > 1) this.virtualTop = g.virtualFromScroll(scrollTop);
68493
68826
  this.expectedScrollTop = -1;
68494
68827
  this.virtualTop = Math.max(0, Math.min(g.maxVirtualTop, this.virtualTop));
68828
+ if (this.wrapping) scrollTop = this.keepAnchor(g, scrollTop);
68495
68829
  const vis = g.visibleRange(this.virtualTop);
68496
68830
  const extra = Math.max(0, Math.floor(grid.settings.get("extraRows")));
68497
68831
  start = Math.max(0, vis.first - extra);
@@ -68506,6 +68840,7 @@ var GridBody = class extends Component {
68506
68840
  else if (end > start && dataOf(end) > dataOf(start)) data.ensure(Math.max(0, dataOf(start) - pre), dataOf(end) + pre, immediate);
68507
68841
  if (grid.mode === "infinite" && !loading && data.total - dataOf(vis.end) <= Math.max(0, grid.settings.get("loadMoreDistance")) + pre) grid.loadMore();
68508
68842
  } else {
68843
+ if (this.wrapping) scrollTop = this.keepAnchor(g, scrollTop);
68509
68844
  start = 0;
68510
68845
  end = g.total;
68511
68846
  top = (local) => g.offsetOf(local);
@@ -68596,6 +68931,10 @@ var GridBody = class extends Component {
68596
68931
  const under = i - row === .5 && drawn && adaptiveAt === row ? 2 : 1;
68597
68932
  put(part, "aria-rowindex", String(Number.isInteger(i) ? this.ariaRowIndex(i) : this.ariaRowIndex(row) + under));
68598
68933
  }
68934
+ if (this.wrapping) {
68935
+ this.noteAnchor(g, scrollTop);
68936
+ measure(this, this.readHeights, this.writeHeights);
68937
+ }
68599
68938
  }
68600
68939
  /**
68601
68940
  * Details under the rows that show theirs (made the first time); the others are parked, and those
@@ -68806,6 +69145,7 @@ var GridBody = class extends Component {
68806
69145
  this.controls.add(row.part);
68807
69146
  row.arrange(this.visible);
68808
69147
  this.pool.push(row);
69148
+ if (this.wrapping) this.watchRow(row);
68809
69149
  return row;
68810
69150
  }
68811
69151
  /** Gives a row's element an id of its own. */
@@ -72464,6 +72804,7 @@ var hasKeys = (o) => Object.keys(o).length > 0;
72464
72804
  var COLUMN_LOOK = [
72465
72805
  "title",
72466
72806
  "hidingPriority",
72807
+ "wrap",
72467
72808
  "resizeMode",
72468
72809
  "columnRenderingMode",
72469
72810
  "headerFilterInterval",
@@ -73312,10 +73653,12 @@ var DataGrid = class extends Control {
73312
73653
  * Opens a new row, as the "New row" button does: at the bottom (the grid moves to the end, and a
73313
73654
  * virtual list loads only the last block) or at the top, with the first cell a new row can fill in
73314
73655
  * edit mode. The row being edited is left first, and no row is added if it cannot be left. `values`
73315
- * fill the new row as if typed.
73656
+ * fill the new row as if typed. While the rows load (before the first of them arrive, or after the
73657
+ * sort changes), it waits for them; `false` if the grid is disposed first.
73316
73658
  */
73317
73659
  addRow(values) {
73318
73660
  const { model } = this;
73661
+ if (model.state.status === "loading") return model.rowsLoaded().then((ok) => ok ? this.addRow(values) : false);
73319
73662
  if (model.state.busy) return Promise.resolve(false);
73320
73663
  if (this.formEdit && !this.cancelForm(false)) return Promise.resolve(false);
73321
73664
  const pending = this.pendingInvalid;
@@ -75210,6 +75553,7 @@ var DataGrid = class extends Control {
75210
75553
  cols.template(visible),
75211
75554
  [...cols.stickyOffsets(visible)],
75212
75555
  visible.map((f) => cols.align(f)),
75556
+ visible.map((f) => cols.wraps(f)),
75213
75557
  cols.hasBands ? cols.shownBands(visible) : [],
75214
75558
  cols.anyVirtual(visible)
75215
75559
  ])];
@@ -75218,8 +75562,10 @@ var DataGrid = class extends Control {
75218
75562
  const visible = cols.visible();
75219
75563
  const align = /* @__PURE__ */ new Map();
75220
75564
  for (const f of visible) align.set(f, cols.align(f));
75565
+ const wrap = new Set(visible.filter((f) => cols.wraps(f)));
75221
75566
  if (this.shell) css(this.shell.vp, "--_columns", cols.template(visible));
75222
- this.styles.update(visible, cols.stickyOffsets(visible), align, cols.hasBands ? cols.shownBands(visible) : [], cols.anyVirtual(visible));
75567
+ this.styles.update(visible, cols.stickyOffsets(visible), align, cols.hasBands ? cols.shownBands(visible) : [], cols.anyVirtual(visible), wrap);
75568
+ this.body.setWrap(wrap.size > 0, `${visible.join("\n")}|${cols.template(visible)}|${[...wrap].join("\n")}`);
75223
75569
  });
75224
75570
  this.whenChanged(() => [model.columns.fitWidth(model.state.width).join("\n")], () => {
75225
75571
  const hidden = model.columns.fitWidth(model.state.width);
@@ -77514,7 +77860,7 @@ var DataGrid = class extends Control {
77514
77860
  return;
77515
77861
  }
77516
77862
  if (down ? !hasRows : row < 0) break;
77517
- row = down ? row < 0 ? first : model.stepRow(row, this.body.pageRows()) : model.stepRow(row, -this.body.pageRows());
77863
+ row = down ? row < 0 ? first : model.stepRow(row, this.body.pageRows(row, true)) : model.stepRow(row, -this.body.pageRows(row, false));
77518
77864
  break;
77519
77865
  }
77520
77866
  case "Enter":
@@ -77822,9 +78168,9 @@ var DataGrid = class extends Control {
77822
78168
  model.loadMore();
77823
78169
  break;
77824
78170
  case "pageDown":
77825
- row = model.stepRow(row, this.body.pageRows());
78171
+ row = model.stepRow(row, this.body.pageRows(row, true));
77826
78172
  break;
77827
- case "pageUp": row = model.stepRow(row, -this.body.pageRows());
78173
+ case "pageUp": row = model.stepRow(row, -this.body.pageRows(row, false));
77828
78174
  }
77829
78175
  e.preventDefault();
77830
78176
  if (row < 0) return true;
@@ -77842,7 +78188,7 @@ var DataGrid = class extends Control {
77842
78188
  const move = Object.keys(keys).find((name) => isChord(keys[name] ?? [], e));
77843
78189
  if (!move) return false;
77844
78190
  e.preventDefault();
77845
- const page = this.body.pageRows();
78191
+ const page = move === "pageDown" || move === "pageUp" ? this.body.pageRows(row, move === "pageDown") : 1;
77846
78192
  const to = model.stepRow(row, move === "down" ? 1 : move === "up" ? -1 : move === "pageDown" ? page : -page);
77847
78193
  if (to < 0) return true;
77848
78194
  this.extendSelection(row, to);