cx 22.10.0 → 22.10.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/ui.js CHANGED
@@ -2366,7 +2366,11 @@ var InstanceCache = /*#__PURE__*/ (function() {
2366
2366
  this.children[k] = instance;
2367
2367
  }
2368
2368
 
2369
- if (instance.store !== store) instance.setStore(store);
2369
+ if (instance.store !== store) {
2370
+ instance.setStore(store);
2371
+ if (instance.cached) delete instance.cached.rawData; // force prepareData to execute again
2372
+ }
2373
+
2370
2374
  return instance;
2371
2375
  };
2372
2376
 
package/dist/widgets.js CHANGED
@@ -17800,6 +17800,10 @@ var Grid = /*#__PURE__*/ (function(_Widget) {
17800
17800
  if (this.onCreateIsRecordSelectable) {
17801
17801
  instance.isRecordSelectable = instance.invoke("onCreateIsRecordSelectable", null, instance);
17802
17802
  }
17803
+
17804
+ if (this.onTrackMappedRecords) {
17805
+ instance.invoke("onTrackMappedRecords", instance.records, instance);
17806
+ }
17803
17807
  };
17804
17808
 
17805
17809
  _proto.initInstance = function initInstance(context, instance) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "22.10.0",
3
+ "version": "22.10.2",
4
4
  "description": "Advanced JavaScript UI framework for admin and dashboard applications with ready to use grid, form and chart components.",
5
5
  "main": "index.js",
6
6
  "jsnext:main": "src/index.js",
@@ -3,7 +3,7 @@ import { isDefined } from "../util/isDefined";
3
3
  import { defaultCompare } from "./defaultCompare";
4
4
 
5
5
  export function getComparer(sorters, dataAccessor, comparer) {
6
- let data = (sorters || []).map((s) => {
6
+ let resolvedSorters = (sorters || []).map((s) => {
7
7
  let selector = isDefined(s.value) ? getSelector(s.value) : s.field ? (x) => x[s.field] : () => null;
8
8
  return {
9
9
  getter: dataAccessor ? (x) => selector(dataAccessor(x)) : selector,
@@ -14,13 +14,16 @@ export function getComparer(sorters, dataAccessor, comparer) {
14
14
 
15
15
  return function (a, b) {
16
16
  let d, av, bv;
17
- for (let i = 0; i < data.length; i++) {
18
- d = data[i];
17
+ for (let i = 0; i < resolvedSorters.length; i++) {
18
+ d = resolvedSorters[i];
19
19
  av = d.getter(a);
20
20
  bv = d.getter(b);
21
21
 
22
- // show nulls always on the bottom
23
- if (av == null) return bv == null ? 0 : 1;
22
+ // show nulls always on the bottom
23
+ if (av == null) {
24
+ if (bv == null) continue;
25
+ else return 1;
26
+ }
24
27
  if (bv == null) return -1;
25
28
 
26
29
  let r = d.compare(av, bv);
@@ -558,7 +558,10 @@ export class InstanceCache {
558
558
  instance = new Instance(widget, k, this.parent);
559
559
  this.children[k] = instance;
560
560
  }
561
- if (instance.store !== store) instance.setStore(store);
561
+ if (instance.store !== store) {
562
+ instance.setStore(store);
563
+ if (instance.cached) delete instance.cached.rawData; // force prepareData to execute again
564
+ }
562
565
 
563
566
  return instance;
564
567
  }
@@ -354,10 +354,10 @@ interface GridProps extends StyledContainerProps {
354
354
  /** A value used to uniquely identify the record within the hover sync group. */
355
355
  rowHoverId?: StringProp;
356
356
 
357
- /** Set to true or false to explicitly define if grid is allowed to receive focus. */
357
+ /** Set to true or false to explicitly define if grid is allowed to receive focus. */
358
358
  focusable?: boolean;
359
359
 
360
- /** Callback function to retrieve grouping data. */
360
+ /** Callback function to retrieve grouping data. */
361
361
  onGetGrouping?: (params: any, instance: Instance) => GridGroupingConfig[];
362
362
 
363
363
  /** Callback function to dynamically calculate columns. */
@@ -365,6 +365,13 @@ interface GridProps extends StyledContainerProps {
365
365
 
366
366
  /** Allow grid to receive drag and drop operations containing files. */
367
367
  allowsFileDrops?: boolean;
368
+
369
+ /**
370
+ * Callback function to track and retrieve displayed records.
371
+ * Accepts new records as a first argument.
372
+ * If onCreateFilter callback is defined, filtered records can be retrieved using this callback.
373
+ */
374
+ onTrackMappedRecords?: (records: Record[], instance: Instance) => void;
368
375
  }
369
376
 
370
377
  export class Grid extends Widget<GridProps> {}
@@ -349,6 +349,10 @@ export class Grid extends Widget {
349
349
  if (this.onCreateIsRecordSelectable) {
350
350
  instance.isRecordSelectable = instance.invoke("onCreateIsRecordSelectable", null, instance);
351
351
  }
352
+
353
+ if (this.onTrackMappedRecords) {
354
+ instance.invoke("onTrackMappedRecords", instance.records, instance);
355
+ }
352
356
  }
353
357
 
354
358
  initInstance(context, instance) {