cx 24.3.5 → 24.3.7

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
@@ -6348,6 +6348,7 @@ var Label = /*#__PURE__*/ (function (_HtmlElement) {
6348
6348
  required: undefined,
6349
6349
  disabled: undefined,
6350
6350
  htmlFor: undefined,
6351
+ asterisk: undefined,
6351
6352
  },
6352
6353
  ]),
6353
6354
  );
@@ -6368,7 +6369,7 @@ var Label = /*#__PURE__*/ (function (_HtmlElement) {
6368
6369
  data._disabled,
6369
6370
  context.parentDisabled,
6370
6371
  );
6371
- data.asterisk = context.parentAsterisk || this.asterisk;
6372
+ data.asterisk = context.parentAsterisk || data.asterisk;
6372
6373
  if (instance.cache("disabled", data.disabled) || instance.cache("asterisk", data.asterisk)) {
6373
6374
  instance.markShouldUpdate(context);
6374
6375
  this.prepareCSS(context, instance);
@@ -16636,6 +16637,7 @@ var GridComponent = /*#__PURE__*/ (function (_VDOM$Component) {
16636
16637
  dragged: isDragged,
16637
16638
  cursor: widget.selectable && index == cursor,
16638
16639
  over: dropTarget == "row" && dropInsertionIndex === index,
16640
+ alternate: index % 2 == 1,
16639
16641
  };
16640
16642
  if (isRecordSelectable) {
16641
16643
  var selectable = isRecordSelectable(record.data, {});
@@ -16919,44 +16921,32 @@ var GridComponent = /*#__PURE__*/ (function (_VDOM$Component) {
16919
16921
  },
16920
16922
  "dropzone",
16921
16923
  );
16924
+ var isDataRecord = widget.buffered
16925
+ ? function (item) {
16926
+ var _item$props;
16927
+ return (
16928
+ ((_item$props = item.props) == null ||
16929
+ (_item$props = _item$props.instance) == null ||
16930
+ (_item$props = _item$props.data) == null
16931
+ ? void 0
16932
+ : _item$props["class"]) == "cxe-grid-data"
16933
+ );
16934
+ }
16935
+ : function (item) {
16936
+ var _item$props2;
16937
+ return (_item$props2 = item.props) == null || (_item$props2 = _item$props2.record) == null
16938
+ ? void 0
16939
+ : _item$props2.type;
16940
+ };
16922
16941
  var index = 0;
16923
- while (
16924
- index < children.length &&
16925
- ((_children$index = children[index]) == null ||
16926
- (_children$index = _children$index.props) == null ||
16927
- (_children$index = _children$index.record) == null
16928
- ? void 0
16929
- : _children$index.type) != "data"
16930
- ) {
16931
- var _children$index;
16932
- index++;
16933
- }
16942
+ while (index < children.length && !isDataRecord(children[index])) index++;
16934
16943
  var count = 0;
16935
- while (count < this.state.dropInsertionIndex) {
16936
- var _children$index2;
16937
- if (
16938
- ((_children$index2 = children[index]) == null ||
16939
- (_children$index2 = _children$index2.props) == null ||
16940
- (_children$index2 = _children$index2.record) == null
16941
- ? void 0
16942
- : _children$index2.type) == "data"
16943
- )
16944
- count++;
16944
+ while (index < children.length && count < this.state.dropInsertionIndex) {
16945
+ if (isDataRecord(children[index])) count++;
16945
16946
  index++;
16946
16947
  }
16947
16948
  var savedIndexPos = index;
16948
- if (!this.state.dropNextToTheRowAbove)
16949
- while (
16950
- index < children.length &&
16951
- ((_children$index3 = children[index]) == null ||
16952
- (_children$index3 = _children$index3.props) == null ||
16953
- (_children$index3 = _children$index3.record) == null
16954
- ? void 0
16955
- : _children$index3.type) != "data"
16956
- ) {
16957
- var _children$index3;
16958
- index++;
16959
- }
16949
+ if (!this.state.dropNextToTheRowAbove) while (index < children.length && !isDataRecord(children[index])) index++;
16960
16950
 
16961
16951
  // do not allow insertion after the last group footer
16962
16952
  if (savedIndexPos < index && index == children.length) index = savedIndexPos;
@@ -17351,15 +17341,15 @@ var GridComponent = /*#__PURE__*/ (function (_VDOM$Component) {
17351
17341
  if (dropTarget == "grid" && widget.onDrop && dropInsertionIndex != null) {
17352
17342
  e.target = {
17353
17343
  insertionIndex: start + dropInsertionIndex,
17354
- recordBefore: this.getRecordAt(start + dropInsertionIndex - 1),
17355
- recordAfter: this.getRecordAt(start + dropInsertionIndex),
17344
+ recordBefore: this.getDataRecordAt(start + dropInsertionIndex - 1),
17345
+ recordAfter: this.getDataRecordAt(start + dropInsertionIndex),
17356
17346
  dropNextToTheRowAbove: dropNextToTheRowAbove,
17357
17347
  };
17358
17348
  instance.invoke("onDrop", e, instance);
17359
17349
  } else if (dropTarget == "row") {
17360
17350
  e.target = {
17361
17351
  index: start + dropInsertionIndex,
17362
- record: this.getRecordAt(start + dropInsertionIndex),
17352
+ record: this.getDataRecordAt(start + dropInsertionIndex),
17363
17353
  };
17364
17354
  instance.invoke("onRowDrop", e, instance);
17365
17355
  } else if (dropTarget == "column" && widget.onColumnDrop) {
@@ -18032,6 +18022,14 @@ var GridComponent = /*#__PURE__*/ (function (_VDOM$Component) {
18032
18022
  }
18033
18023
  widget.selection.selectMultiple(instance.store, selection, indexes, options);
18034
18024
  };
18025
+ _proto2.getDataRecordAt = function getDataRecordAt(index) {
18026
+ var records = this.props.instance.records;
18027
+ if (!records) return this.getRecordAt(index);
18028
+ var dataRecords = records.filter(function (r) {
18029
+ return r.type == "data";
18030
+ });
18031
+ return dataRecords[index];
18032
+ };
18035
18033
  _proto2.getRecordAt = function getRecordAt(cursor) {
18036
18034
  var _this$props7 = this.props,
18037
18035
  instance = _this$props7.instance,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "24.3.5",
3
+ "version": "24.3.7",
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",
@@ -20,19 +20,19 @@ interface SwimlanesProps extends BoundedObjectProps {
20
20
  baseClass?: string;
21
21
 
22
22
  /** Represents a swimlane size. */
23
- size?: number;
23
+ size?: Cx.NumberProp;
24
24
 
25
25
  /**
26
26
  * Represents a swimlane step. Define a step on which a swimlane will be rendered. (eg. step 2 will render
27
27
  * every second swimlane in the chart.)
28
28
  */
29
- step?: number;
29
+ step?: Cx.NumberProp;
30
30
 
31
31
  /** Switch to vertical swimlanes. */
32
32
  vertical?: boolean;
33
33
 
34
34
  /**The laneOffset property adjusts the positioning of lane elements, enhancing their alignment and readability. */
35
- laneOffset?: number;
35
+ laneOffset?: Cx.NumberProp;
36
36
 
37
37
  /** Style object applied to the swimlanes. */
38
38
  laneStyle?: StyleProp;
@@ -33,6 +33,8 @@ export class Swimlanes extends BoundedObject {
33
33
  let { bounds } = data;
34
34
  let { CSS, baseClass } = this;
35
35
 
36
+ if (data.step <= 0 || data.size <= 0) return;
37
+
36
38
  let axis = this.vertical ? xAxis : yAxis;
37
39
 
38
40
  if (!axis) return null;
package/src/core.d.ts CHANGED
@@ -72,6 +72,7 @@ declare namespace Cx {
72
72
  type ClassProp = Prop<string> | StructuredProp;
73
73
  type RecordsProp = Prop<Record[]>;
74
74
  type SortersProp = Prop<Sorter[]>;
75
+ type UnknownProp = Prop<unknown>;
75
76
 
76
77
  type RecordAlias = string | { toString(): string };
77
78
 
@@ -59,7 +59,7 @@ export interface FieldProps extends Cx.StyledContainerProps {
59
59
  requiredText?: string;
60
60
 
61
61
  /** Append asterisk to the label to indicate a required field. */
62
- asterisk?: boolean;
62
+ asterisk?: Cx.BooleanProp;
63
63
 
64
64
  /** Text displayed to the user to indicate that server-side validation is in progress. */
65
65
  validatingText?: string;
@@ -1,25 +1,23 @@
1
- import * as Cx from '../../core';
1
+ import * as Cx from "../../core";
2
2
 
3
3
  interface LabelProps extends Cx.HtmlElementProps {
4
-
5
4
  /** Used in combination with `asterisk` to indicate required fields. */
6
- required?: Cx.BooleanProp,
5
+ required?: Cx.BooleanProp;
7
6
 
8
7
  /** Set to true to disable the label. */
9
- disabled?: Cx.BooleanProp,
8
+ disabled?: Cx.BooleanProp;
10
9
 
11
10
  /** Id of the field. */
12
- htmlFor?: Cx.StringProp,
13
-
11
+ htmlFor?: Cx.StringProp;
12
+
14
13
  /** Base CSS class to be applied to the element. No class is applied by default. */
15
- baseClass?: string,
14
+ baseClass?: string;
16
15
 
17
16
  /** Set to `true` to add red asterisk for required fields. */
18
- asterisk?: boolean,
17
+ asterisk?: Cx.BooleanProp;
19
18
 
20
19
  /** Name of the HTML element to be rendered. Default is `div`. */
21
- tag?: string
22
-
20
+ tag?: string;
23
21
  }
24
22
 
25
23
  export class Label extends Cx.Widget<LabelProps> {}
@@ -1,88 +1,89 @@
1
- import { Widget, VDOM } from "../../ui/Widget";
2
- import { HtmlElement } from "../HtmlElement";
3
- import { FocusManager } from "../../ui/FocusManager";
4
- import { isArray } from "../../util/isArray";
5
- import { coalesce } from "../../util/coalesce";
6
-
7
- export class Label extends HtmlElement {
8
- declareData() {
9
- super.declareData(...arguments, {
10
- required: undefined,
11
- disabled: undefined,
12
- htmlFor: undefined,
13
- });
14
- }
15
-
16
- prepareData(context, instance) {
17
- let { data } = instance;
18
- data.stateMods = {
19
- ...data.stateMods,
20
- disabled: data.disabled,
21
- };
22
- data._disabled = data.disabled;
23
- super.prepareData(context, instance);
24
- }
25
-
26
- explore(context, instance) {
27
- let { data } = instance;
28
-
29
- if (!data.htmlFor) data.htmlFor = context.lastFieldId;
30
-
31
- data.disabled = data.stateMods.disabled = coalesce(
32
- context.parentStrict ? context.parentDisabled : null,
33
- data._disabled,
34
- context.parentDisabled
35
- );
36
-
37
- data.asterisk = context.parentAsterisk || this.asterisk;
38
-
39
- if (instance.cache("disabled", data.disabled) || instance.cache("asterisk", data.asterisk)) {
40
- instance.markShouldUpdate(context);
41
- this.prepareCSS(context, instance);
42
- }
43
-
44
- super.explore(context, instance);
45
- }
46
-
47
- isValidHtmlAttribute(attrName) {
48
- switch (attrName) {
49
- case "asterisk":
50
- case "required":
51
- return false;
52
- }
53
- return super.isValidHtmlAttribute(attrName);
54
- }
55
-
56
- attachProps(context, instance, props) {
57
- super.attachProps(context, instance, props);
58
-
59
- let { data } = instance;
60
-
61
- if (data.htmlFor) {
62
- props.htmlFor = data.htmlFor;
63
-
64
- if (!props.onClick)
65
- props.onClick = () => {
66
- //additional focus for LookupFields which are not input based
67
- let el = document.getElementById(instance.data.htmlFor);
68
- if (el) FocusManager.focusFirst(el);
69
- };
70
- }
71
-
72
- if (!props.id && data.htmlFor) props.id = `${data.htmlFor}-label`;
73
-
74
- if (data.required && data.asterisk) {
75
- if (!isArray(props.children)) props.children = [props.children];
76
- props.children.push(" ");
77
- props.children.push(
78
- <span key="asterisk" className={this.CSS.element(this.baseClass, "asterisk")}>
79
- *
80
- </span>
81
- );
82
- }
83
- }
84
- }
85
-
86
- Label.prototype.baseClass = "label";
87
- Label.prototype.tag = "label";
88
- Label.prototype.asterisk = false;
1
+ import { Widget, VDOM } from "../../ui/Widget";
2
+ import { HtmlElement } from "../HtmlElement";
3
+ import { FocusManager } from "../../ui/FocusManager";
4
+ import { isArray } from "../../util/isArray";
5
+ import { coalesce } from "../../util/coalesce";
6
+
7
+ export class Label extends HtmlElement {
8
+ declareData() {
9
+ super.declareData(...arguments, {
10
+ required: undefined,
11
+ disabled: undefined,
12
+ htmlFor: undefined,
13
+ asterisk: undefined,
14
+ });
15
+ }
16
+
17
+ prepareData(context, instance) {
18
+ let { data } = instance;
19
+ data.stateMods = {
20
+ ...data.stateMods,
21
+ disabled: data.disabled,
22
+ };
23
+ data._disabled = data.disabled;
24
+ super.prepareData(context, instance);
25
+ }
26
+
27
+ explore(context, instance) {
28
+ let { data } = instance;
29
+
30
+ if (!data.htmlFor) data.htmlFor = context.lastFieldId;
31
+
32
+ data.disabled = data.stateMods.disabled = coalesce(
33
+ context.parentStrict ? context.parentDisabled : null,
34
+ data._disabled,
35
+ context.parentDisabled
36
+ );
37
+
38
+ data.asterisk = context.parentAsterisk || data.asterisk;
39
+
40
+ if (instance.cache("disabled", data.disabled) || instance.cache("asterisk", data.asterisk)) {
41
+ instance.markShouldUpdate(context);
42
+ this.prepareCSS(context, instance);
43
+ }
44
+
45
+ super.explore(context, instance);
46
+ }
47
+
48
+ isValidHtmlAttribute(attrName) {
49
+ switch (attrName) {
50
+ case "asterisk":
51
+ case "required":
52
+ return false;
53
+ }
54
+ return super.isValidHtmlAttribute(attrName);
55
+ }
56
+
57
+ attachProps(context, instance, props) {
58
+ super.attachProps(context, instance, props);
59
+
60
+ let { data } = instance;
61
+
62
+ if (data.htmlFor) {
63
+ props.htmlFor = data.htmlFor;
64
+
65
+ if (!props.onClick)
66
+ props.onClick = () => {
67
+ //additional focus for LookupFields which are not input based
68
+ let el = document.getElementById(instance.data.htmlFor);
69
+ if (el) FocusManager.focusFirst(el);
70
+ };
71
+ }
72
+
73
+ if (!props.id && data.htmlFor) props.id = `${data.htmlFor}-label`;
74
+
75
+ if (data.required && data.asterisk) {
76
+ if (!isArray(props.children)) props.children = [props.children];
77
+ props.children.push(" ");
78
+ props.children.push(
79
+ <span key="asterisk" className={this.CSS.element(this.baseClass, "asterisk")}>
80
+ *
81
+ </span>
82
+ );
83
+ }
84
+ }
85
+ }
86
+
87
+ Label.prototype.baseClass = "label";
88
+ Label.prototype.tag = "label";
89
+ Label.prototype.asterisk = false;
@@ -1,17 +1,9 @@
1
- import * as Cx from '../../core';
2
- import { FieldGroupProps } from './FieldGroup';
1
+ import * as Cx from "../../core";
2
+ import { FieldGroupProps } from "./FieldGroup";
3
3
 
4
4
  interface LabeledContainerProps extends FieldGroupProps {
5
-
6
5
  /** The label. */
7
- label?: Cx.StringProp | Cx.Config,
8
-
9
- /** Set to true to disable all fields inside the container. */
10
- disabled?: boolean,
11
-
12
- /** Apply asterisk to the label. */
13
- asterisk?: boolean
14
-
6
+ label?: Cx.StringProp | Cx.Config;
15
7
  }
16
8
 
17
9
  export class LabeledContainer extends Cx.Widget<LabeledContainerProps> {}
@@ -35,7 +35,7 @@ export interface ValidationGroupProps extends Cx.PureContainerProps {
35
35
  strict?: Cx.BooleanProp;
36
36
 
37
37
  /** Set to `true` to add red asterisk for all required fields inside the group. */
38
- asterisk?: boolean;
38
+ asterisk?: Cx.BooleanProp;
39
39
  }
40
40
 
41
41
  export class ValidationGroup extends Cx.Widget<ValidationGroupProps> {}
@@ -17,6 +17,7 @@ import {
17
17
  StructuredProp,
18
18
  StyledContainerProps,
19
19
  StyleProp,
20
+ UnknownProp,
20
21
  Widget,
21
22
  } from "../../core";
22
23
  import { DataAdapterRecord } from "../../ui/adapter/DataAdapter";
@@ -108,6 +109,7 @@ interface GridColumnConfig {
108
109
  aggregate?: "min" | "max" | "count" | "sum" | "distinct" | "avg";
109
110
  aggregateAlias?: string;
110
111
  aggregateField?: string;
112
+ aggregateValue?: UnknownProp;
111
113
  caption?: StringProp;
112
114
  class?: ClassProp;
113
115
  className?: ClassProp;
@@ -319,7 +321,7 @@ interface GridProps<T = unknown> extends StyledContainerProps {
319
321
  sortField?: string;
320
322
  sortDirection?: string;
321
323
  },
322
- instance?: Instance,
324
+ instance?: Instance
323
325
  ) => FetchRecordsResult | Promise<FetchRecordsResult>;
324
326
 
325
327
  /** Callback function to be executed when a row is double-clicked. */
@@ -352,7 +354,7 @@ interface GridProps<T = unknown> extends StyledContainerProps {
352
354
  /** Callback to create a function that can be used to check whether a record is selectable. */
353
355
  onCreateIsRecordSelectable?: (
354
356
  params: any,
355
- instance: Instance,
357
+ instance: Instance
356
358
  ) => (record: T, options?: { range?: boolean; toggle?: boolean }) => boolean;
357
359
 
358
360
  /** Parameters whose change will cause scroll to be reset. */
@@ -1324,6 +1324,7 @@ class GridComponent extends VDOM.Component {
1324
1324
  dragged: isDragged,
1325
1325
  cursor: widget.selectable && index == cursor,
1326
1326
  over: dropTarget == "row" && dropInsertionIndex === index,
1327
+ alternate: index % 2 == 1,
1327
1328
  };
1328
1329
 
1329
1330
  if (isRecordSelectable) {
@@ -1593,19 +1594,23 @@ class GridComponent extends VDOM.Component {
1593
1594
  </tbody>
1594
1595
  );
1595
1596
 
1597
+ let isDataRecord = widget.buffered
1598
+ ? (item) => item.props?.instance?.data?.class == "cxe-grid-data"
1599
+ : (item) => item.props?.record?.type;
1600
+
1596
1601
  let index = 0;
1597
- while (index < children.length && children[index]?.props?.record?.type != "data") index++;
1602
+ while (index < children.length && !isDataRecord(children[index])) index++;
1598
1603
 
1599
1604
  let count = 0;
1600
- while (count < this.state.dropInsertionIndex) {
1601
- if (children[index]?.props?.record?.type == "data") count++;
1605
+ while (index < children.length && count < this.state.dropInsertionIndex) {
1606
+ if (isDataRecord(children[index])) count++;
1602
1607
  index++;
1603
1608
  }
1604
1609
 
1605
1610
  let savedIndexPos = index;
1606
1611
 
1607
1612
  if (!this.state.dropNextToTheRowAbove)
1608
- while (index < children.length && children[index]?.props?.record?.type != "data") index++;
1613
+ while (index < children.length && !isDataRecord(children[index])) index++;
1609
1614
 
1610
1615
  // do not allow insertion after the last group footer
1611
1616
  if (savedIndexPos < index && index == children.length) index = savedIndexPos;
@@ -2001,15 +2006,15 @@ class GridComponent extends VDOM.Component {
2001
2006
  if (dropTarget == "grid" && widget.onDrop && dropInsertionIndex != null) {
2002
2007
  e.target = {
2003
2008
  insertionIndex: start + dropInsertionIndex,
2004
- recordBefore: this.getRecordAt(start + dropInsertionIndex - 1),
2005
- recordAfter: this.getRecordAt(start + dropInsertionIndex),
2009
+ recordBefore: this.getDataRecordAt(start + dropInsertionIndex - 1),
2010
+ recordAfter: this.getDataRecordAt(start + dropInsertionIndex),
2006
2011
  dropNextToTheRowAbove,
2007
2012
  };
2008
2013
  instance.invoke("onDrop", e, instance);
2009
2014
  } else if (dropTarget == "row") {
2010
2015
  e.target = {
2011
2016
  index: start + dropInsertionIndex,
2012
- record: this.getRecordAt(start + dropInsertionIndex),
2017
+ record: this.getDataRecordAt(start + dropInsertionIndex),
2013
2018
  };
2014
2019
  instance.invoke("onRowDrop", e, instance);
2015
2020
  } else if (dropTarget == "column" && widget.onColumnDrop) {
@@ -2729,6 +2734,13 @@ class GridComponent extends VDOM.Component {
2729
2734
  widget.selection.selectMultiple(instance.store, selection, indexes, options);
2730
2735
  }
2731
2736
 
2737
+ getDataRecordAt(index) {
2738
+ let { records } = this.props.instance;
2739
+ if (!records) return this.getRecordAt(index);
2740
+ let dataRecords = records.filter((r) => r.type == "data");
2741
+ return dataRecords[index];
2742
+ }
2743
+
2732
2744
  getRecordAt(cursor) {
2733
2745
  let { instance, data } = this.props;
2734
2746
  let { records, widget } = instance;