cx 24.3.5 → 24.3.6

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, {});
@@ -16932,7 +16934,7 @@ var GridComponent = /*#__PURE__*/ (function (_VDOM$Component) {
16932
16934
  index++;
16933
16935
  }
16934
16936
  var count = 0;
16935
- while (count < this.state.dropInsertionIndex) {
16937
+ while (index < children.length && count < this.state.dropInsertionIndex) {
16936
16938
  var _children$index2;
16937
16939
  if (
16938
16940
  ((_children$index2 = children[index]) == null ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "24.3.5",
3
+ "version": "24.3.6",
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) {
@@ -1597,7 +1598,7 @@ class GridComponent extends VDOM.Component {
1597
1598
  while (index < children.length && children[index]?.props?.record?.type != "data") index++;
1598
1599
 
1599
1600
  let count = 0;
1600
- while (count < this.state.dropInsertionIndex) {
1601
+ while (index < children.length && count < this.state.dropInsertionIndex) {
1601
1602
  if (children[index]?.props?.record?.type == "data") count++;
1602
1603
  index++;
1603
1604
  }