cx 26.5.1 → 26.7.0

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 (64) hide show
  1. package/build/data/ExposedValueView.js +1 -1
  2. package/build/data/comparer.d.ts +6 -8
  3. package/build/data/comparer.d.ts.map +1 -1
  4. package/build/locale/de-de.js +1 -0
  5. package/build/locale/en-us.js +1 -0
  6. package/build/locale/es-es.js +1 -0
  7. package/build/locale/fr-fr.js +1 -0
  8. package/build/locale/nl-nl.js +1 -0
  9. package/build/locale/pt-pt.js +1 -0
  10. package/build/locale/sr-latn-ba.js +1 -0
  11. package/build/ui/Prop.d.ts +1 -1
  12. package/build/ui/Prop.d.ts.map +1 -1
  13. package/build/ui/adapter/ArrayAdapter.d.ts +4 -6
  14. package/build/ui/adapter/ArrayAdapter.d.ts.map +1 -1
  15. package/build/ui/adapter/GroupAdapter.d.ts +22 -2
  16. package/build/ui/adapter/GroupAdapter.d.ts.map +1 -1
  17. package/build/ui/adapter/GroupAdapter.js +80 -5
  18. package/build/widgets/drag-drop/DragSource.d.ts +3 -2
  19. package/build/widgets/drag-drop/DragSource.d.ts.map +1 -1
  20. package/build/widgets/drag-drop/DropZone.d.ts +4 -4
  21. package/build/widgets/drag-drop/DropZone.d.ts.map +1 -1
  22. package/build/widgets/drag-drop/ops.d.ts +13 -2
  23. package/build/widgets/drag-drop/ops.d.ts.map +1 -1
  24. package/build/widgets/drag-drop/ops.js +36 -9
  25. package/build/widgets/form/LookupField.d.ts +6 -0
  26. package/build/widgets/form/LookupField.d.ts.map +1 -1
  27. package/build/widgets/form/LookupField.js +12 -0
  28. package/build/widgets/form/NumberField.js +1 -0
  29. package/build/widgets/grid/Grid.d.ts +24 -3
  30. package/build/widgets/grid/Grid.d.ts.map +1 -1
  31. package/build/widgets/grid/Grid.js +5 -2
  32. package/build/widgets/overlay/captureMouse.d.ts +4 -4
  33. package/build/widgets/overlay/captureMouse.d.ts.map +1 -1
  34. package/build/widgets/overlay/captureMouse.js +8 -3
  35. package/dist/data.js +1 -1
  36. package/dist/manifest.js +857 -857
  37. package/dist/ui.js +94 -9
  38. package/dist/widgets.css +8 -0
  39. package/dist/widgets.js +60 -12
  40. package/package.json +1 -1
  41. package/src/data/ExposedValueView.spec.ts +57 -0
  42. package/src/data/ExposedValueView.ts +1 -1
  43. package/src/data/comparer.ts +6 -7
  44. package/src/locale/de-de.ts +1 -0
  45. package/src/locale/en-us.ts +1 -0
  46. package/src/locale/es-es.ts +1 -0
  47. package/src/locale/fr-fr.ts +1 -0
  48. package/src/locale/nl-nl.ts +1 -0
  49. package/src/locale/pt-pt.ts +1 -0
  50. package/src/locale/sr-latn-ba.ts +1 -0
  51. package/src/ui/Prop.ts +1 -1
  52. package/src/ui/adapter/ArrayAdapter.ts +6 -8
  53. package/src/ui/adapter/GroupAdapter.spec.ts +75 -0
  54. package/src/ui/adapter/GroupAdapter.ts +103 -10
  55. package/src/widgets/drag-drop/DragSource.tsx +3 -3
  56. package/src/widgets/drag-drop/DropZone.tsx +5 -5
  57. package/src/widgets/drag-drop/ops.tsx +54 -12
  58. package/src/widgets/form/LookupField.spec.tsx +149 -0
  59. package/src/widgets/form/LookupField.tsx +27 -0
  60. package/src/widgets/form/NumberField.scss +4 -0
  61. package/src/widgets/form/NumberField.tsx +1 -0
  62. package/src/widgets/grid/Grid.scss +6 -0
  63. package/src/widgets/grid/Grid.tsx +31 -4
  64. package/src/widgets/overlay/captureMouse.ts +14 -7
@@ -23,6 +23,7 @@ import {
23
23
  NumberProp,
24
24
  Prop,
25
25
  RecordAlias,
26
+ Sorter,
26
27
  SortDirection,
27
28
  SortersProp,
28
29
  StringProp,
@@ -62,6 +63,7 @@ import {
62
63
  ddMouseDown,
63
64
  DragDropOperationContext,
64
65
  DragEvent,
66
+ DragEndEvent,
65
67
  initiateDragDrop,
66
68
  registerDropZone,
67
69
  } from "../drag-drop/ops";
@@ -156,10 +158,24 @@ export interface GridGroupingConfig<T> {
156
158
  showCaption?: boolean;
157
159
  showFooter?: boolean;
158
160
  showHeader?: boolean;
161
+ /**
162
+ * Restart automatic row numbers (`cxe-grid-row-number`) from 1 at the beginning of each group
163
+ * at this grouping level instead of counting continuously across the whole grid. Defaults to `false`.
164
+ */
165
+ resetRowNumbers?: boolean;
159
166
  caption?: StringProp;
160
167
  name?: StringProp;
161
168
  text?: StringProp;
162
169
  comparer?: (a: GroupingResult<T>, b: GroupingResult<T>) => number;
170
+ /**
171
+ * Sort groups by a single field resolved against the group's key, aggregates and name.
172
+ * Use an aggregate alias to sort by an aggregate, or a key field to sort by key.
173
+ */
174
+ sortField?: string;
175
+ /** Sort direction used together with `sortField`. Defaults to `"ASC"`. */
176
+ sortDirection?: SortDirection;
177
+ /** Multi-field group sorting. Each sorter's `field` is resolved against the group's key, aggregates and name. */
178
+ sorters?: Sorter[];
163
179
  }
164
180
 
165
181
  export interface GridColumnHeaderConfig {
@@ -385,7 +401,7 @@ export interface GridConfig<T = any> extends StyledContainerConfig {
385
401
  onDrop?: string | ((e: GridDragEvent<T>, instance: Instance) => void);
386
402
  onDropTest?: string | ((e: DragEvent, instance: Instance) => boolean);
387
403
  onDragStart?: string | ((e: DragEvent, instance: Instance) => void);
388
- onDragEnd?: string | ((e: DragEvent, instance: Instance) => void);
404
+ onDragEnd?: string | ((e: DragEndEvent, instance: Instance) => void);
389
405
  onDragOver?: string | ((e: GridDragEvent<T>, instance: Instance) => void | boolean);
390
406
 
391
407
  onRowDropTest?: string | ((e: DragEvent, instance: Instance) => boolean);
@@ -497,6 +513,13 @@ export interface GridConfig<T = any> extends StyledContainerConfig {
497
513
 
498
514
  /** When enabled, groups are shown in the same order as the source records. */
499
515
  preserveGroupOrder?: boolean;
516
+
517
+ /**
518
+ * When enabled, sorting by a column header also reorders groups. The active sort field is resolved
519
+ * against each group's key fields, aggregates and name, so it works for both grouping columns and
520
+ * aggregate columns. Ignored when `preserveGroupOrder` is set.
521
+ */
522
+ sortGroups?: boolean;
500
523
  }
501
524
 
502
525
  export interface GridCellInfo {
@@ -630,6 +653,7 @@ export class Grid<T = unknown> extends ContainerBase<GridConfig<T>, GridInstance
630
653
  declare onCreateIsRecordDraggable?: any;
631
654
  declare onRef?: any;
632
655
  declare preserveGroupOrder: boolean;
656
+ declare sortGroups: boolean;
633
657
  declare styled: boolean;
634
658
  declare selectable?: boolean;
635
659
  declare recordsAccessor: any;
@@ -839,6 +863,7 @@ export class Grid<T = unknown> extends ContainerBase<GridConfig<T>, GridInstance
839
863
  sortOptions: this.sortOptions,
840
864
  groupings: grouping,
841
865
  preserveOrder: this.preserveGroupOrder,
866
+ sortGroupsBySorters: this.sortGroups,
842
867
  },
843
868
  this.dataAdapter,
844
869
  );
@@ -1510,12 +1535,13 @@ export class Grid<T = unknown> extends ContainerBase<GridConfig<T>, GridInstance
1510
1535
  ) {
1511
1536
  let { CSS, baseClass } = this;
1512
1537
  let data = store.getData();
1538
+ let resetRowNumbers = g.resetRowNumbers ? "reset-row-numbers" : null;
1513
1539
  if (g.caption) {
1514
1540
  let caption = g.caption(data);
1515
1541
  return (
1516
1542
  <tbody
1517
1543
  key={`g-${level}-${group.$key}`}
1518
- className={CSS.element(baseClass, "group-caption", ["level-" + level])}
1544
+ className={CSS.element(baseClass, "group-caption", ["level-" + level, resetRowNumbers])}
1519
1545
  data-group-key={group.$key}
1520
1546
  data-group-element={`group-caption-${level}`}
1521
1547
  >
@@ -1598,7 +1624,7 @@ export class Grid<T = unknown> extends ContainerBase<GridConfig<T>, GridInstance
1598
1624
  return (
1599
1625
  <tbody
1600
1626
  key={"c" + group.$key}
1601
- className={CSS.element(baseClass, "group-caption", ["level-" + level])}
1627
+ className={CSS.element(baseClass, "group-caption", ["level-" + level, resetRowNumbers])}
1602
1628
  data-group-key={group.$key}
1603
1629
  data-group-element={`group-caption-${level}`}
1604
1630
  >
@@ -1897,6 +1923,7 @@ Grid.prototype.hoverChannel = "default";
1897
1923
  Grid.prototype.focusable = null; // automatically resolved
1898
1924
  Grid.prototype.allowsFileDrops = false;
1899
1925
  Grid.prototype.preserveGroupOrder = false;
1926
+ Grid.prototype.sortGroups = false;
1900
1927
 
1901
1928
  Widget.alias("grid", Grid);
1902
1929
  Localization.registerPrototype("cx/widgets/Grid", Grid);
@@ -2845,7 +2872,7 @@ class GridComponent extends VDOM.Component<GridComponentProps, GridComponentStat
2845
2872
  return (grid || row || column) && { grid, row, column };
2846
2873
  }
2847
2874
 
2848
- onDragEnd(e: DragEvent) {
2875
+ onDragEnd(e: DragEndEvent) {
2849
2876
  this.setState({
2850
2877
  dropTarget: null,
2851
2878
  dropInsertionIndex: null,
@@ -31,7 +31,7 @@ interface CaptureMouseOptions {
31
31
  export function captureMouse2(
32
32
  e: React.MouseEvent | React.TouchEvent | MouseEvent | TouchEvent,
33
33
  options: CaptureMouseOptions,
34
- ): void {
34
+ ): () => void {
35
35
  let surface = document.createElement("div");
36
36
  surface.className = "cxb-mousecapture";
37
37
  surface.style.cursor = options.cursor || getComputedStyle(e.currentTarget as Element).cursor;
@@ -67,6 +67,8 @@ export function captureMouse2(
67
67
 
68
68
  e.stopPropagation();
69
69
 
70
+ return tear;
71
+
70
72
  function move(e: Event) {
71
73
  if (!active) {
72
74
  tear();
@@ -110,7 +112,7 @@ export function captureMouse2(
110
112
  export function captureMouseOrTouch2(
111
113
  e: React.MouseEvent | React.TouchEvent | MouseEvent | TouchEvent,
112
114
  options: CaptureMouseOptions,
113
- ): void {
115
+ ): () => void {
114
116
  if (e.type.indexOf("touch") == 0) {
115
117
  let el = e.currentTarget as HTMLElement;
116
118
 
@@ -136,7 +138,12 @@ export function captureMouseOrTouch2(
136
138
  el.addEventListener("touchend", end);
137
139
 
138
140
  e.stopPropagation();
139
- } else captureMouse2(e, options);
141
+
142
+ return () => {
143
+ el.removeEventListener("touchmove", move);
144
+ el.removeEventListener("touchend", end);
145
+ };
146
+ } else return captureMouse2(e, options);
140
147
  }
141
148
 
142
149
  /**
@@ -153,8 +160,8 @@ export function captureMouse(
153
160
  onMouseUp?: (e: MouseEvent | TouchEvent, captureData?: any) => void,
154
161
  captureData?: any,
155
162
  cursor?: string,
156
- ): void {
157
- captureMouse2(e, {
163
+ ): () => void {
164
+ return captureMouse2(e, {
158
165
  onMouseMove,
159
166
  onMouseUp,
160
167
  captureData,
@@ -176,8 +183,8 @@ export function captureMouseOrTouch(
176
183
  onMouseUp?: (e: MouseEvent, captureData?: any) => void,
177
184
  captureData?: any,
178
185
  cursor?: string,
179
- ): void {
180
- captureMouseOrTouch2(e, { onMouseMove, onMouseUp, captureData, cursor });
186
+ ): () => void {
187
+ return captureMouseOrTouch2(e, { onMouseMove, onMouseUp, captureData, cursor });
181
188
  }
182
189
 
183
190
  /**