cx 26.9.1 → 26.9.2

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/dist/widgets.js CHANGED
@@ -18271,7 +18271,7 @@ class Grid extends ContainerBase$1 {
18271
18271
  },
18272
18272
  });
18273
18273
  }
18274
- renderHeader(context, instance, key, fixed, fixedColumns) {
18274
+ renderHeader(context, instance, key, fixed, fixedColumns, repeated) {
18275
18275
  let { data, widget, header } = instance;
18276
18276
  let { CSS, baseClass } = widget;
18277
18277
  let headerRows = [];
@@ -18427,13 +18427,15 @@ class Grid extends ContainerBase$1 {
18427
18427
  }
18428
18428
  });
18429
18429
  if (headerRows.length == 0) return null;
18430
- return jsx(
18431
- "tbody",
18430
+ //headers repeated for each group sit between the data rows, where a second thead
18431
+ //would not be allowed
18432
+ return VDOM$2.createElement(
18433
+ repeated ? "tbody" : "thead",
18432
18434
  {
18435
+ key: "h" + key,
18433
18436
  className: CSS.element(baseClass, "header"),
18434
- children: headerRows,
18435
18437
  },
18436
- "h" + key,
18438
+ headerRows,
18437
18439
  );
18438
18440
  }
18439
18441
  onHeaderMouseMove(e, column, columnInstance, gridInstance, headerLine) {
@@ -18541,6 +18543,7 @@ class Grid extends ContainerBase$1 {
18541
18543
  children: jsx("tr", {
18542
18544
  children: jsx("td", {
18543
18545
  colSpan: 1000,
18546
+ role: "columnheader",
18544
18547
  children: caption,
18545
18548
  }),
18546
18549
  }),
@@ -18605,6 +18608,7 @@ class Grid extends ContainerBase$1 {
18605
18608
  {
18606
18609
  className: cls,
18607
18610
  colSpan: colSpan,
18611
+ role: c.caption ? "columnheader" : undefined,
18608
18612
  style: style,
18609
18613
  children: v,
18610
18614
  },
@@ -18771,9 +18775,9 @@ class Grid extends ContainerBase$1 {
18771
18775
  ),
18772
18776
  );
18773
18777
  if (g.showHeader) {
18774
- record.vdom.push(this.renderHeader(context, instance, record.key + "-header", false, false));
18778
+ record.vdom.push(this.renderHeader(context, instance, record.key + "-header", false, false, true));
18775
18779
  if (hasFixedColumns)
18776
- record.fixedVdom.push(this.renderHeader(context, instance, record.key + "-header", false, true));
18780
+ record.fixedVdom.push(this.renderHeader(context, instance, record.key + "-header", false, true, true));
18777
18781
  }
18778
18782
  }
18779
18783
  if (record.type == "group-footer") {
@@ -19107,6 +19111,29 @@ class GridComponent extends VDOM$2.Component {
19107
19111
  );
19108
19112
  };
19109
19113
  }
19114
+ groupLooseRows(items) {
19115
+ let { CSS, baseClass } = this.props.instance.widget;
19116
+ let result = [];
19117
+ for (let i = 0; i < items.length; i++) {
19118
+ if (!items[i]?.props?.useTrTag) {
19119
+ result.push(items[i]);
19120
+ continue;
19121
+ }
19122
+ let start = i;
19123
+ while (i + 1 < items.length && items[i + 1]?.props?.useTrTag) i++;
19124
+ result.push(
19125
+ jsx(
19126
+ "tbody",
19127
+ {
19128
+ className: CSS.element(baseClass, "row-group"),
19129
+ children: items.slice(start, i + 1),
19130
+ },
19131
+ `rows-${items[start].key}`,
19132
+ ),
19133
+ );
19134
+ }
19135
+ return result;
19136
+ }
19110
19137
  render() {
19111
19138
  let { instance, data, fixedFooter, fixedColumnsFixedFooter } = this.props;
19112
19139
  let { widget, hasFixedColumns } = instance;
@@ -19353,6 +19380,12 @@ class GridComponent extends VDOM$2.Component {
19353
19380
  if (hasFixedColumns) fixedChildren.push(fixedColumnsFixedFooter);
19354
19381
  }
19355
19382
  }
19383
+ //grids with merged cells render rows as tr elements, as rowspan cannot cross row group
19384
+ //boundaries, so consecutive rows have to share a tbody instead of getting one each
19385
+ if (instance.row.hasMergedCells) {
19386
+ children = this.groupLooseRows(children);
19387
+ if (hasFixedColumns) fixedChildren = this.groupLooseRows(fixedChildren);
19388
+ }
19356
19389
  let shouldRenderFixedFooter = widget.scrollable && (fixedFooter || fixedColumnsFixedFooter);
19357
19390
  if (hasFixedColumns) {
19358
19391
  fixedColumnsContent.push(
@@ -20250,16 +20283,18 @@ class GridComponent extends VDOM$2.Component {
20250
20283
  if (this.state.focused && !this.state.cellEdit && wasCellEditing) FocusManager.focus(this.dom.el);
20251
20284
  if (scrollIntoView) {
20252
20285
  let record = this.getRecordAt(index);
20253
- let item = record && this.dom.table.querySelector(`tbody[data-record-key="${record.key}"]`);
20286
+ //rows are tbody elements, except in grids with merged cells, where they are tr
20287
+ let cellsOf = (rowEl) => (rowEl.tagName == "TR" ? rowEl : rowEl.firstChild).children;
20288
+ let item = record && this.dom.table.querySelector(`[data-record-key="${record.key}"]`);
20254
20289
  let hscroll = false;
20255
20290
  if (item) {
20256
20291
  if (widget.cellEditable)
20257
20292
  if (this.state.cursorCellIndex >= this.props.instance.fixedColumnCount) {
20258
20293
  hscroll = true;
20259
- item = item.firstChild.children[this.state.cursorCellIndex - this.props.instance.fixedColumnCount];
20294
+ item = cellsOf(item)[this.state.cursorCellIndex - this.props.instance.fixedColumnCount];
20260
20295
  } else {
20261
- let fixedItem = this.dom.fixedTable.querySelector(`tbody[data-record-key="${record.key}"]`);
20262
- let cell = fixedItem && fixedItem.firstChild.children[this.state.cursorCellIndex];
20296
+ let fixedItem = this.dom.fixedTable.querySelector(`[data-record-key="${record.key}"]`);
20297
+ let cell = fixedItem && cellsOf(fixedItem)[this.state.cursorCellIndex];
20263
20298
  if (cell) scrollElementIntoView(cell, false, true, 10);
20264
20299
  }
20265
20300
  scrollElementIntoView(item, true, hscroll, widget.cellEditable ? 10 : 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "26.9.1",
3
+ "version": "26.9.2",
4
4
  "description": "Advanced JavaScript UI framework for admin and dashboard applications with ready to use grid, form and chart components.",
5
5
  "exports": {
6
6
  "./data": {
@@ -1280,7 +1280,14 @@ export class Grid<T = unknown> extends ContainerBase<GridConfig<T>, GridInstance
1280
1280
  );
1281
1281
  }
1282
1282
 
1283
- renderHeader(context: RenderingContext, instance: GridInstance, key: any, fixed: any, fixedColumns: any) {
1283
+ renderHeader(
1284
+ context: RenderingContext,
1285
+ instance: GridInstance,
1286
+ key: any,
1287
+ fixed: any,
1288
+ fixedColumns: any,
1289
+ repeated?: boolean,
1290
+ ) {
1284
1291
  let { data, widget, header } = instance;
1285
1292
 
1286
1293
  let { CSS, baseClass } = widget;
@@ -1458,10 +1465,12 @@ export class Grid<T = unknown> extends ContainerBase<GridConfig<T>, GridInstance
1458
1465
 
1459
1466
  if (headerRows.length == 0) return null;
1460
1467
 
1461
- return (
1462
- <tbody key={"h" + key} className={CSS.element(baseClass, "header")}>
1463
- {headerRows}
1464
- </tbody>
1468
+ //headers repeated for each group sit between the data rows, where a second thead
1469
+ //would not be allowed
1470
+ return VDOM.createElement(
1471
+ repeated ? "tbody" : "thead",
1472
+ { key: "h" + key, className: CSS.element(baseClass, "header") },
1473
+ headerRows,
1465
1474
  );
1466
1475
  }
1467
1476
 
@@ -1582,7 +1591,9 @@ export class Grid<T = unknown> extends ContainerBase<GridConfig<T>, GridInstance
1582
1591
  data-group-element={`group-caption-${level}`}
1583
1592
  >
1584
1593
  <tr>
1585
- <td colSpan={1000}>{caption}</td>
1594
+ <td colSpan={1000} role="columnheader">
1595
+ {caption}
1596
+ </td>
1586
1597
  </tr>
1587
1598
  </tbody>
1588
1599
  );
@@ -1644,7 +1655,13 @@ export class Grid<T = unknown> extends ContainerBase<GridConfig<T>, GridInstance
1644
1655
  if (pad !== false) cls += (cls ? " " : "") + CSS.state("pad");
1645
1656
 
1646
1657
  return (
1647
- <td key={i} className={cls} colSpan={colSpan} style={style}>
1658
+ <td
1659
+ key={i}
1660
+ className={cls}
1661
+ colSpan={colSpan}
1662
+ role={c.caption ? "columnheader" : undefined}
1663
+ style={style}
1664
+ >
1648
1665
  {v}
1649
1666
  </td>
1650
1667
  );
@@ -1820,9 +1837,11 @@ export class Grid<T = unknown> extends ContainerBase<GridConfig<T>, GridInstance
1820
1837
  );
1821
1838
 
1822
1839
  if (g.showHeader) {
1823
- record.vdom.push(this.renderHeader(context, instance, record.key + "-header", false, false));
1840
+ record.vdom.push(this.renderHeader(context, instance, record.key + "-header", false, false, true));
1824
1841
  if (hasFixedColumns)
1825
- record.fixedVdom.push(this.renderHeader(context, instance, record.key + "-header", false, true));
1842
+ record.fixedVdom.push(
1843
+ this.renderHeader(context, instance, record.key + "-header", false, true, true),
1844
+ );
1826
1845
  }
1827
1846
  }
1828
1847
 
@@ -2242,6 +2261,25 @@ class GridComponent extends VDOM.Component<GridComponentProps, GridComponentStat
2242
2261
  };
2243
2262
  }
2244
2263
 
2264
+ groupLooseRows(items: any[]): any[] {
2265
+ let { CSS, baseClass } = this.props.instance.widget;
2266
+ let result: any[] = [];
2267
+ for (let i = 0; i < items.length; i++) {
2268
+ if (!items[i]?.props?.useTrTag) {
2269
+ result.push(items[i]);
2270
+ continue;
2271
+ }
2272
+ let start = i;
2273
+ while (i + 1 < items.length && items[i + 1]?.props?.useTrTag) i++;
2274
+ result.push(
2275
+ <tbody key={`rows-${items[start].key}`} className={CSS.element(baseClass, "row-group")}>
2276
+ {items.slice(start, i + 1)}
2277
+ </tbody>,
2278
+ );
2279
+ }
2280
+ return result;
2281
+ }
2282
+
2245
2283
  render() {
2246
2284
  let { instance, data, fixedFooter, fixedColumnsFixedFooter } = this.props;
2247
2285
  let { widget, hasFixedColumns } = instance;
@@ -2495,6 +2533,13 @@ class GridComponent extends VDOM.Component<GridComponentProps, GridComponentStat
2495
2533
  }
2496
2534
  }
2497
2535
 
2536
+ //grids with merged cells render rows as tr elements, as rowspan cannot cross row group
2537
+ //boundaries, so consecutive rows have to share a tbody instead of getting one each
2538
+ if (instance.row.hasMergedCells) {
2539
+ children = this.groupLooseRows(children);
2540
+ if (hasFixedColumns) fixedChildren = this.groupLooseRows(fixedChildren);
2541
+ }
2542
+
2498
2543
  let shouldRenderFixedFooter = widget.scrollable && (fixedFooter || fixedColumnsFixedFooter);
2499
2544
 
2500
2545
  if (hasFixedColumns) {
@@ -3526,20 +3571,23 @@ class GridComponent extends VDOM.Component<GridComponentProps, GridComponentStat
3526
3571
  if (scrollIntoView) {
3527
3572
  let record = this.getRecordAt(index)!;
3528
3573
 
3529
- let item = record && this.dom.table!.querySelector(`tbody[data-record-key="${record.key}"]`);
3574
+ //rows are tbody elements, except in grids with merged cells, where they are tr
3575
+ let cellsOf = (rowEl: Element) =>
3576
+ (rowEl.tagName == "TR" ? rowEl : (rowEl.firstChild as HTMLElement)).children;
3577
+
3578
+ let item = record && this.dom.table!.querySelector(`[data-record-key="${record.key}"]`);
3530
3579
 
3531
3580
  let hscroll = false;
3532
3581
  if (item) {
3533
3582
  if (widget.cellEditable)
3534
3583
  if (this.state.cursorCellIndex >= this.props.instance.fixedColumnCount) {
3535
3584
  hscroll = true;
3536
- item = (item.firstChild as HTMLElement)!.children[
3585
+ item = cellsOf(item)[
3537
3586
  this.state.cursorCellIndex - this.props.instance.fixedColumnCount
3538
3587
  ] as Element;
3539
3588
  } else {
3540
- let fixedItem = this.dom.fixedTable!.querySelector(`tbody[data-record-key="${record.key}"]`);
3541
- let cell =
3542
- fixedItem && (fixedItem.firstChild as HTMLElement)!.children[this.state.cursorCellIndex];
3589
+ let fixedItem = this.dom.fixedTable!.querySelector(`[data-record-key="${record.key}"]`);
3590
+ let cell = fixedItem && cellsOf(fixedItem)[this.state.cursorCellIndex];
3543
3591
  if (cell) scrollElementIntoView(cell, false, true, 10);
3544
3592
  }
3545
3593