cx 23.6.0 → 23.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.
package/dist/ui.js CHANGED
@@ -1123,6 +1123,9 @@ var Repeater = /*#__PURE__*/ (function (_Container) {
1123
1123
  };
1124
1124
  this.dataAdapter.setFilter(filter);
1125
1125
  instance.mappedRecords = this.dataAdapter.getRecords(context, instance, data.records, instance.store);
1126
+ if (this.onTrackMappedRecords) {
1127
+ instance.invoke("onTrackMappedRecords", instance.mappedRecords, instance);
1128
+ }
1126
1129
  _Container.prototype.prepareData.call(this, context, instance);
1127
1130
  };
1128
1131
  _proto.explore = function explore(context, instance, data) {
package/dist/widgets.js CHANGED
@@ -8874,7 +8874,7 @@ function getOptionKey(bindings, data) {
8874
8874
  }
8875
8875
  function areKeysEqual(key1, key2) {
8876
8876
  if (!key1 || !key2 || key1.length != key2.length) return false;
8877
- for (var i = 0; i < key1.length; i++) if (key1[i] != key2[i]) return false;
8877
+ for (var i = 0; i < key1.length; i++) if (key1[i] !== key2[i]) return false;
8878
8878
  return true;
8879
8879
  }
8880
8880
  function convertOption(bindings, data) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "23.6.0",
3
+ "version": "23.7.0",
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",
@@ -1,3 +1,6 @@
1
- import { BoundedObjectProps } from "../svg/BoundedObject";
1
+ import { Widget } from "cx/src/core";
2
+ import { BoundedObject, BoundedObjectProps } from "../svg/BoundedObject";
2
3
 
3
- export class PieLabelsContainer extends BoundedObjectProps {}
4
+ interface PieLabelsContainerProps extends BoundedObjectProps {}
5
+
6
+ export class PieLabelsContainer extends Widget<PieLabelsContainerProps> {}
@@ -39,6 +39,13 @@ interface RepeaterProps extends PureContainerProps {
39
39
  /** Callback to create a filter function for given filter params. */
40
40
  onCreateFilter?: (filterParams: any, instance: Instance) => (record: Record) => boolean;
41
41
 
42
+ /**
43
+ * Callback function to track and retrieve displayed records.
44
+ * Accepts new records as a first argument.
45
+ * If onCreateFilter callback is defined, filtered records can be retrieved using this callback.
46
+ */
47
+ onTrackMappedRecords?: string | ((records: Record[], instance: Instance) => void);
48
+
42
49
  /** Options for data sorting. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator */
43
50
  sortOptions?: CollatorOptions;
44
51
 
@@ -1,33 +1,32 @@
1
- import {Widget} from './Widget';
2
- import {PureContainer} from './PureContainer';
3
- import {Container} from './Container';
4
- import {ArrayAdapter} from './adapter/ArrayAdapter';
5
- import {UseParentLayout} from "./layout/UseParentLayout";
6
- import {getAccessor} from "../data/getAccessor";
1
+ import { Widget } from "./Widget";
2
+ import { PureContainer } from "./PureContainer";
3
+ import { Container } from "./Container";
4
+ import { ArrayAdapter } from "./adapter/ArrayAdapter";
5
+ import { UseParentLayout } from "./layout/UseParentLayout";
6
+ import { getAccessor } from "../data/getAccessor";
7
7
 
8
8
  export class Repeater extends Container {
9
-
10
9
  declareData() {
11
- super.declareData({
12
- records: undefined,
13
- sorters: undefined,
14
- sortField: undefined,
15
- sortDirection: undefined,
16
- filterParams: {
17
- structured: true
18
- }
19
- }, ...arguments);
10
+ super.declareData(
11
+ {
12
+ records: undefined,
13
+ sorters: undefined,
14
+ sortField: undefined,
15
+ sortDirection: undefined,
16
+ filterParams: {
17
+ structured: true,
18
+ },
19
+ },
20
+ ...arguments
21
+ );
20
22
  }
21
23
 
22
24
  init() {
23
-
24
25
  this.recordsAccessor = getAccessor(this.records);
25
26
 
26
- if (this.recordAlias)
27
- this.recordName = this.recordAlias;
27
+ if (this.recordAlias) this.recordName = this.recordAlias;
28
28
 
29
- if (this.indexAlias)
30
- this.indexName = this.indexAlias;
29
+ if (this.indexAlias) this.indexName = this.indexAlias;
31
30
 
32
31
  this.dataAdapter = ArrayAdapter.create({
33
32
  ...this.dataAdapter,
@@ -37,12 +36,12 @@ export class Repeater extends Container {
37
36
  immutable: this.immutable,
38
37
  sealed: this.sealed,
39
38
  recordsAccessor: this.recordsAccessor,
40
- sortOptions: this.sortOptions
39
+ sortOptions: this.sortOptions,
41
40
  });
42
41
 
43
42
  this.item = PureContainer.create({
44
43
  children: this.items || this.children,
45
- layout: UseParentLayout
44
+ layout: UseParentLayout,
46
45
  });
47
46
 
48
47
  delete this.children;
@@ -56,20 +55,25 @@ export class Repeater extends Container {
56
55
  }
57
56
 
58
57
  prepareData(context, instance) {
59
- let {data} = instance;
58
+ let { data } = instance;
60
59
  if (data.sortField)
61
- data.sorters = [{
62
- field: data.sortField,
63
- direction: data.sortDirection || "ASC"
64
- }];
60
+ data.sorters = [
61
+ {
62
+ field: data.sortField,
63
+ direction: data.sortDirection || "ASC",
64
+ },
65
+ ];
65
66
  this.dataAdapter.sort(data.sorters);
66
67
  let filter = null;
67
- if (this.onCreateFilter)
68
- filter = instance.invoke("onCreateFilter", data.filterParams, instance);
69
- else if (this.filter)
70
- filter = item => this.filter(item, data.filterParams);
68
+ if (this.onCreateFilter) filter = instance.invoke("onCreateFilter", data.filterParams, instance);
69
+ else if (this.filter) filter = (item) => this.filter(item, data.filterParams);
71
70
  this.dataAdapter.setFilter(filter);
72
71
  instance.mappedRecords = this.dataAdapter.getRecords(context, instance, data.records, instance.store);
72
+
73
+ if (this.onTrackMappedRecords) {
74
+ instance.invoke("onTrackMappedRecords", instance.mappedRecords, instance);
75
+ }
76
+
73
77
  super.prepareData(context, instance);
74
78
  }
75
79
 
@@ -77,23 +81,22 @@ export class Repeater extends Container {
77
81
  let instances = [];
78
82
  instance.mappedRecords.forEach((record) => {
79
83
  let subInstance = instance.getChild(context, this.item, record.key, record.store);
80
- let changed = subInstance.cache('recordData', record.data) || subInstance.cache('key', record.key);
84
+ let changed = subInstance.cache("recordData", record.data) || subInstance.cache("key", record.key);
81
85
  subInstance.record = record;
82
86
  if (this.cached && !changed && subInstance.visible && !subInstance.childStateDirty) {
83
87
  instances.push(subInstance);
84
88
  subInstance.shouldUpdate = false;
85
- } else if (subInstance.scheduleExploreIfVisible(context))
86
- instances.push(subInstance);
89
+ } else if (subInstance.scheduleExploreIfVisible(context)) instances.push(subInstance);
87
90
  });
88
91
  instance.children = instances;
89
92
  }
90
93
  }
91
94
 
92
- Repeater.prototype.recordName = '$record';
93
- Repeater.prototype.indexName = '$index';
95
+ Repeater.prototype.recordName = "$record";
96
+ Repeater.prototype.indexName = "$index";
94
97
  Repeater.prototype.cached = false;
95
98
  Repeater.prototype.immutable = false;
96
99
  Repeater.prototype.sealed = false;
97
100
  Repeater.prototype.isPureContainer = true;
98
101
 
99
- Widget.alias('repeater', Repeater);
102
+ Widget.alias("repeater", Repeater);
@@ -33,13 +33,13 @@ interface DragSourceProps extends Cx.StyledContainerProps {
33
33
  cloneStyle?: Cx.StyleProp;
34
34
 
35
35
  /** CSS styles to be applied to the element being dragged. */
36
- draggedStyle: Cx.StyleProp;
36
+ draggedStyle?: Cx.StyleProp;
37
37
 
38
38
  /** Additional CSS class to be applied to the clone of the element being dragged. */
39
- cloneClass: Cx.ClassProp;
39
+ cloneClass?: Cx.ClassProp;
40
40
 
41
41
  /** Additional CSS class to be applied to the element being dragged. */
42
- draggedClass: Cx.ClassProp;
42
+ draggedClass?: Cx.ClassProp;
43
43
  }
44
44
 
45
45
  export class DragSource extends Cx.Widget<DragSourceProps> {}
@@ -266,7 +266,7 @@ function getOptionKey(bindings, data) {
266
266
  function areKeysEqual(key1, key2) {
267
267
  if (!key1 || !key2 || key1.length != key2.length) return false;
268
268
 
269
- for (let i = 0; i < key1.length; i++) if (key1[i] != key2[i]) return false;
269
+ for (let i = 0; i < key1.length; i++) if (key1[i] !== key2[i]) return false;
270
270
 
271
271
  return true;
272
272
  }